Drake
OptimizationProblem Class Reference

#include <drake/solvers/Optimization.h>

Classes

struct  SolverData
 

Public Types

enum  { INITIAL_VARIABLE_ALLOCATION_NUM = 100 }
 

Public Member Functions

 OptimizationProblem ()
 
const DecisionVariableView AddContinuousVariables (std::size_t num_new_vars, std::string name="x")
 
void AddCost (std::shared_ptr< Constraint > const &obj, VariableList const &vars)
 
void AddCost (std::shared_ptr< Constraint > const &obj)
 
template<typename F >
std::enable_if< !std::is_convertible< F, std::shared_ptr< Constraint > >::value, std::shared_ptr< Constraint > >::type AddCost (F &&f, VariableList const &vars)
 
template<typename F >
std::enable_if< !std::is_convertible< F, std::shared_ptr< Constraint > >::value, std::shared_ptr< Constraint > >::type AddCost (F &&f)
 
template<typename F >
std::shared_ptr< ConstraintAddCost (std::unique_ptr< F > &&f, VariableList const &vars)
 
template<typename F >
std::shared_ptr< ConstraintAddCost (std::unique_ptr< F > &&f)
 
template<typename DerivedQ , typename Derivedb >
std::shared_ptr< QuadraticConstraintAddQuadraticErrorCost (const Eigen::MatrixBase< DerivedQ > &Q, const Eigen::MatrixBase< Derivedb > &x_desired, const VariableList &vars)
 AddQuadraticErrorCost. More...
 
template<typename DerivedQ , typename Derivedb >
std::shared_ptr< QuadraticConstraintAddQuadraticErrorCost (const Eigen::MatrixBase< DerivedQ > &Q, const Eigen::MatrixBase< Derivedb > &x_desired)
 AddQuadraticErrorCost. More...
 
void AddQuadraticCost (std::shared_ptr< QuadraticConstraint > const &obj, VariableList const &vars)
 AddQuadraticCost. More...
 
void AddQuadraticCost (std::shared_ptr< QuadraticConstraint > const &obj)
 AddQuadraticCost. More...
 
template<typename DerivedQ , typename Derivedb >
std::shared_ptr< QuadraticConstraintAddQuadraticCost (const Eigen::MatrixBase< DerivedQ > &Q, const Eigen::MatrixBase< Derivedb > &b, const VariableList &vars)
 AddQuadraticCost. More...
 
template<typename DerivedQ , typename Derivedb >
std::shared_ptr< QuadraticConstraintAddQuadraticCost (const Eigen::MatrixBase< DerivedQ > &Q, const Eigen::MatrixBase< Derivedb > &b)
 AddQuadraticCost. More...
 
void AddGenericConstraint (std::shared_ptr< Constraint > con, VariableList const &vars)
 AddGenericConstraint. More...
 
void AddGenericConstraint (std::shared_ptr< Constraint > con)
 
void AddLinearConstraint (std::shared_ptr< LinearConstraint > con, VariableList const &vars)
 AddLinearConstraint. More...
 
void AddLinearConstraint (std::shared_ptr< LinearConstraint > con)
 AddLinearConstraint. More...
 
template<typename DerivedA , typename DerivedLB , typename DerivedUB >
std::shared_ptr< LinearConstraintAddLinearConstraint (const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedLB > &lb, const Eigen::MatrixBase< DerivedUB > &ub, const VariableList &vars)
 AddLinearConstraint. More...
 
template<typename DerivedA , typename DerivedLB , typename DerivedUB >
std::shared_ptr< LinearConstraintAddLinearConstraint (const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedLB > &lb, const Eigen::MatrixBase< DerivedUB > &ub)
 AddLinearConstraint. More...
 
void AddLinearEqualityConstraint (std::shared_ptr< LinearEqualityConstraint > con, VariableList const &vars)
 AddLinearEqualityConstraint. More...
 
void AddLinearEqualityConstraint (std::shared_ptr< LinearEqualityConstraint > con)
 AddLinearEqualityConstraint. More...
 
template<typename DerivedA , typename DerivedB >
std::shared_ptr< LinearEqualityConstraintAddLinearEqualityConstraint (const Eigen::MatrixBase< DerivedA > &Aeq, const Eigen::MatrixBase< DerivedB > &beq, const VariableList &vars)
 AddLinearEqualityConstraint. More...
 
template<typename DerivedA , typename DerivedB >
std::shared_ptr< LinearEqualityConstraintAddLinearEqualityConstraint (const Eigen::MatrixBase< DerivedA > &Aeq, const Eigen::MatrixBase< DerivedB > &beq)
 AddLinearEqualityConstraint. More...
 
void AddBoundingBoxConstraint (std::shared_ptr< BoundingBoxConstraint > con, VariableList const &vars)
 AddBoundingBoxConstraint. More...
 
void AddBoundingBoxConstraint (std::shared_ptr< BoundingBoxConstraint > con)
 AddBoundingBoxConstraint. More...
 
template<typename DerivedLB , typename DerivedUB >
std::shared_ptr< BoundingBoxConstraintAddBoundingBoxConstraint (const Eigen::MatrixBase< DerivedLB > &lb, const Eigen::MatrixBase< DerivedUB > &ub, const VariableList &vars)
 AddBoundingBoxConstraint. More...
 
template<typename DerivedLB , typename DerivedUB >
std::shared_ptr< BoundingBoxConstraintAddBoundingBoxConstraint (const Eigen::MatrixBase< DerivedLB > &lb, const Eigen::MatrixBase< DerivedUB > &ub)
 AddBoundingBoxConstraint. More...
 
template<typename DerivedM , typename Derivedq >
std::shared_ptr< LinearComplementarityConstraintAddLinearComplementarityConstraint (const Eigen::MatrixBase< DerivedM > &M, const Eigen::MatrixBase< Derivedq > &q, const VariableList &vars)
 AddLinearComplementarityConstraint. More...
 
template<typename DerivedM , typename Derivedq >
std::shared_ptr< LinearComplementarityConstraintAddLinearComplementarityConstraint (const Eigen::MatrixBase< DerivedM > &M, const Eigen::MatrixBase< Derivedq > &q)
 AddLinearComplementarityConstraint. More...
 
std::shared_ptr< ConstraintAddPolynomialConstraint (const VectorXPoly &polynomials, const std::vector< Polynomiald::VarType > &poly_vars, const Eigen::VectorXd &lb, const Eigen::VectorXd &ub, const VariableList &vars)
 AddPolynomialConstraint. More...
 
std::shared_ptr< ConstraintAddPolynomialConstraint (const VectorXPoly &polynomials, const std::vector< Polynomiald::VarType > &poly_vars, const Eigen::VectorXd &lb, const Eigen::VectorXd &ub)
 AddPolynomialConstraint. More...
 
template<typename Derived >
void SetInitialGuess (const DecisionVariableView &var, const Eigen::MatrixBase< Derived > &x0)
 
SolutionResult Solve ()
 Solve the OptimizationProblem. More...
 
void PrintSolution ()
 
template<typename Derived >
void SetDecisionVariableValues (const Eigen::MatrixBase< Derived > &x)
 
void SetSolverOption (const std::string &solver_name, const std::string &solver_option, double option_value)
 Set an option for a particular solver. More...
 
void SetSolverOption (const std::string &solver_name, const std::string &solver_option, int option_value)
 
void SetSolverOption (const std::string &solver_name, const std::string &solver_option, const std::string &option_value)
 
const std::map< std::string, double > & GetSolverOptionsDouble (const std::string &solver_name)
 
const std::map< std::string, int > & GetSolverOptionsInt (const std::string &solver_name)
 
const std::map< std::string, std::string > & GetSolverOptionsStr (const std::string &solver_name)
 
void GetSolverResult (std::string *solver_name, int *solver_result) const
 Get the name and result code of the particular solver which was used to solve this OptimizationProblem. More...
 
void SetSolverResult (const std::string &solver_name, int solver_result)
 
const std::list< Binding< Constraint > > & generic_costs () const
 
const std::list< Binding< Constraint > > & generic_constraints () const
 
const std::list< Binding< LinearEqualityConstraint > > & linear_equality_constraints () const
 
const std::list< Binding< QuadraticConstraint > > & quadratic_costs () const
 Getter for quadratic costs. More...
 
const std::list< Binding< LinearConstraint > > & linear_constraints () const
 
std::list< Binding< Constraint > > GetAllCosts () const
 GetAllCosts. More...
 
std::list< Binding< LinearConstraint > > GetAllLinearConstraints () const
 
const std::list< Binding< BoundingBoxConstraint > > & bounding_box_constraints () const
 
const std::list< Binding< LinearComplementarityConstraint > > & linear_complementarity_constraints () const
 
template<typename T >
std::shared_ptr< T > GetSolverData ()
 
size_t num_vars () const
 
const Eigen::VectorXd & initial_guess () const
 

Member Enumeration Documentation

anonymous enum
Enumerator
INITIAL_VARIABLE_ALLOCATION_NUM 

Constructor & Destructor Documentation

OptimizationProblem ( )
inline

Member Function Documentation

void AddBoundingBoxConstraint ( std::shared_ptr< BoundingBoxConstraint con,
VariableList const &  vars 
)
inline

AddBoundingBoxConstraint.

Adds bounding box constraints referencing potentially a subset of the decision variables.

void AddBoundingBoxConstraint ( std::shared_ptr< BoundingBoxConstraint con)
inline

AddBoundingBoxConstraint.

Adds bounding box constraints to the program for all (currently existing) variables.

std::shared_ptr<BoundingBoxConstraint> AddBoundingBoxConstraint ( const Eigen::MatrixBase< DerivedLB > &  lb,
const Eigen::MatrixBase< DerivedUB > &  ub,
const VariableList vars 
)
inline

AddBoundingBoxConstraint.

Adds bounding box constraints referencing potentially a subset of the decision variables (defined in the vars parameter).

std::shared_ptr<BoundingBoxConstraint> AddBoundingBoxConstraint ( const Eigen::MatrixBase< DerivedLB > &  lb,
const Eigen::MatrixBase< DerivedUB > &  ub 
)
inline

AddBoundingBoxConstraint.

Adds bounding box constraints to the program for all (currently existing) variables.

const DecisionVariableView AddContinuousVariables ( std::size_t  num_new_vars,
std::string  name = "x" 
)
inline

Here is the call graph for this function:

Here is the caller graph for this function:

void AddCost ( std::shared_ptr< Constraint > const &  obj,
VariableList const &  vars 
)
inline
void AddCost ( std::shared_ptr< Constraint > const &  obj)
inline

Here is the call graph for this function:

std::enable_if< !std::is_convertible<F, std::shared_ptr<Constraint> >::value, std::shared_ptr<Constraint> >::type AddCost ( F &&  f,
VariableList const &  vars 
)
inline

Here is the call graph for this function:

std::enable_if< !std::is_convertible<F, std::shared_ptr<Constraint> >::value, std::shared_ptr<Constraint> >::type AddCost ( F &&  f)
inline
std::shared_ptr<Constraint> AddCost ( std::unique_ptr< F > &&  f,
VariableList const &  vars 
)
inline
std::shared_ptr<Constraint> AddCost ( std::unique_ptr< F > &&  f)
inline
void AddGenericConstraint ( std::shared_ptr< Constraint con,
VariableList const &  vars 
)
inline

AddGenericConstraint.

Adds a generic constraint to the program. This should only be used if a more specific type of constraint is not available, as it may require the use of a significantly more expensive solver.

Here is the caller graph for this function:

void AddGenericConstraint ( std::shared_ptr< Constraint con)
inline
std::shared_ptr<LinearComplementarityConstraint> AddLinearComplementarityConstraint ( const Eigen::MatrixBase< DerivedM > &  M,
const Eigen::MatrixBase< Derivedq > &  q,
const VariableList vars 
)
inline

AddLinearComplementarityConstraint.

Adds a linear complementarity constraints referencing a subset of the decision variables.

std::shared_ptr<LinearComplementarityConstraint> AddLinearComplementarityConstraint ( const Eigen::MatrixBase< DerivedM > &  M,
const Eigen::MatrixBase< Derivedq > &  q 
)
inline

AddLinearComplementarityConstraint.

Adds a linear complementarity constraint to the program for all (currently existing) variables.

void AddLinearConstraint ( std::shared_ptr< LinearConstraint con,
VariableList const &  vars 
)
inline

AddLinearConstraint.

Adds linear constraints referencing potentially a subset of the decision variables (defined in the vars parameter).

void AddLinearConstraint ( std::shared_ptr< LinearConstraint con)
inline

AddLinearConstraint.

Adds linear constraints to the program for all (currently existing) variables.

std::shared_ptr<LinearConstraint> AddLinearConstraint ( const Eigen::MatrixBase< DerivedA > &  A,
const Eigen::MatrixBase< DerivedLB > &  lb,
const Eigen::MatrixBase< DerivedUB > &  ub,
const VariableList vars 
)
inline

AddLinearConstraint.

Adds linear constraints referencing potentially a subset of the decision variables (defined in the vars parameter).

std::shared_ptr<LinearConstraint> AddLinearConstraint ( const Eigen::MatrixBase< DerivedA > &  A,
const Eigen::MatrixBase< DerivedLB > &  lb,
const Eigen::MatrixBase< DerivedUB > &  ub 
)
inline

AddLinearConstraint.

Adds linear constraints to the program for all (currently existing) variables.

void AddLinearEqualityConstraint ( std::shared_ptr< LinearEqualityConstraint con,
VariableList const &  vars 
)
inline

AddLinearEqualityConstraint.

Adds linear equality constraints referencing potentially a subset of the decision variables (defined in the vars parameter).

Here is the caller graph for this function:

void AddLinearEqualityConstraint ( std::shared_ptr< LinearEqualityConstraint con)
inline

AddLinearEqualityConstraint.

Adds linear equality constraints to the program for all (currently existing) variables.

std::shared_ptr<LinearEqualityConstraint> AddLinearEqualityConstraint ( const Eigen::MatrixBase< DerivedA > &  Aeq,
const Eigen::MatrixBase< DerivedB > &  beq,
const VariableList vars 
)
inline

AddLinearEqualityConstraint.

Adds linear equality constraints referencing potentially a subset of the decision variables. Example: to add and equality constraint which only depends on two of the elements of x, you could use auto x = prog.AddContinuousDecisionVariable(6,"myvar"); prog.AddLinearEqualityConstraint(Aeq, beq,{x.row(2), x.row(5)}); where Aeq has exactly two columns.

std::shared_ptr<LinearEqualityConstraint> AddLinearEqualityConstraint ( const Eigen::MatrixBase< DerivedA > &  Aeq,
const Eigen::MatrixBase< DerivedB > &  beq 
)
inline

AddLinearEqualityConstraint.

Adds linear equality constraints to the program for all (currently existing) variables.

std::shared_ptr<Constraint> AddPolynomialConstraint ( const VectorXPoly polynomials,
const std::vector< Polynomiald::VarType > &  poly_vars,
const Eigen::VectorXd &  lb,
const Eigen::VectorXd &  ub,
const VariableList vars 
)
inline

AddPolynomialConstraint.

Adds a polynomial constraint to the program referencing a subset of the decision variables (defined in the vars parameter).

Here is the caller graph for this function:

std::shared_ptr<Constraint> AddPolynomialConstraint ( const VectorXPoly polynomials,
const std::vector< Polynomiald::VarType > &  poly_vars,
const Eigen::VectorXd &  lb,
const Eigen::VectorXd &  ub 
)
inline

AddPolynomialConstraint.

Adds a polynomial constraint to the program referencing all of the decision variables.

void AddQuadraticCost ( std::shared_ptr< QuadraticConstraint > const &  obj,
VariableList const &  vars 
)
inline

AddQuadraticCost.

Adds a cost term of the form 0.5*x'*Q*x + b'x Applied to subset of the variables and pushes onto the quadratic cost data structure.

Here is the caller graph for this function:

void AddQuadraticCost ( std::shared_ptr< QuadraticConstraint > const &  obj)
inline

AddQuadraticCost.

Adds a cost term of the form 0.5*x'*Q*x + b'x Applied to all (currently existing) variables.

std::shared_ptr<QuadraticConstraint> AddQuadraticCost ( const Eigen::MatrixBase< DerivedQ > &  Q,
const Eigen::MatrixBase< Derivedb > &  b,
const VariableList vars 
)
inline

AddQuadraticCost.

Adds a cost term of the form 0.5*x'*Q*x + b'x Applied to subset of the variables

std::shared_ptr<QuadraticConstraint> AddQuadraticCost ( const Eigen::MatrixBase< DerivedQ > &  Q,
const Eigen::MatrixBase< Derivedb > &  b 
)
inline

AddQuadraticCost.

Adds a cost term of the form 0.5*x'*Q*x + b'x Applies to all (currently existing) variables.

std::shared_ptr<QuadraticConstraint> AddQuadraticErrorCost ( const Eigen::MatrixBase< DerivedQ > &  Q,
const Eigen::MatrixBase< Derivedb > &  x_desired,
const VariableList vars 
)
inline

AddQuadraticErrorCost.

Adds a cost term of the form (x-x_desired)'Q(x-x_desired).

std::shared_ptr<QuadraticConstraint> AddQuadraticErrorCost ( const Eigen::MatrixBase< DerivedQ > &  Q,
const Eigen::MatrixBase< Derivedb > &  x_desired 
)
inline

AddQuadraticErrorCost.

Adds a cost term of the form (x-x_desired)'Q(x-x_desired). Applied to all (currently existing) variables.

const std::list<Binding<BoundingBoxConstraint> >& bounding_box_constraints ( ) const
inline

Here is the caller graph for this function:

const std::list<Binding<Constraint> >& generic_constraints ( ) const
inline

Here is the caller graph for this function:

const std::list<Binding<Constraint> >& generic_costs ( ) const
inline

Here is the caller graph for this function:

std::list<Binding<Constraint> > GetAllCosts ( ) const
inline

GetAllCosts.

Getter returning all costs (for now quadratic costs appended to generic costs).

std::list<Binding<LinearConstraint> > GetAllLinearConstraints ( ) const
inline

Here is the caller graph for this function:

std::shared_ptr<T> GetSolverData ( )
inline
const std::map<std::string, double>& GetSolverOptionsDouble ( const std::string &  solver_name)
inline

Here is the caller graph for this function:

const std::map<std::string, int>& GetSolverOptionsInt ( const std::string &  solver_name)
inline

Here is the caller graph for this function:

const std::map<std::string, std::string>& GetSolverOptionsStr ( const std::string &  solver_name)
inline

Here is the caller graph for this function:

void GetSolverResult ( std::string *  solver_name,
int *  solver_result 
) const
inline

Get the name and result code of the particular solver which was used to solve this OptimizationProblem.

The solver names and results are not documented here as this function is only intended for debugging, testing, and support of certain legacy APIs.

const Eigen::VectorXd& initial_guess ( ) const
inline

Here is the caller graph for this function:

const std::list<Binding<LinearComplementarityConstraint> >& linear_complementarity_constraints ( ) const
inline

Here is the caller graph for this function:

const std::list<Binding<LinearConstraint> >& linear_constraints ( ) const
inline

Here is the caller graph for this function:

const std::list<Binding<LinearEqualityConstraint> >& linear_equality_constraints ( ) const
inline

Here is the caller graph for this function:

size_t num_vars ( ) const
inline

Here is the caller graph for this function:

void PrintSolution ( )
inline
const std::list<Binding<QuadraticConstraint> >& quadratic_costs ( ) const
inline

Getter for quadratic costs.

Here is the caller graph for this function:

void SetDecisionVariableValues ( const Eigen::MatrixBase< Derived > &  x)
inline

Here is the call graph for this function:

Here is the caller graph for this function:

void SetInitialGuess ( const DecisionVariableView var,
const Eigen::MatrixBase< Derived > &  x0 
)
inline

Here is the call graph for this function:

void SetSolverOption ( const std::string &  solver_name,
const std::string &  solver_option,
double  option_value 
)
inline

Set an option for a particular solver.

This interface does not do any verification of solver parameters beyond what an individual solver does for itself. It does not even verify that the specifed solver exists. Use this only when you have particular knowledge of what solver is being invoked, and exactly what tuning is required.

Supported solver names/options:

"SNOPT" – Paramater names and values as specified in SNOPT User's Guide section 7.7 "Description ofthe optional parameters", used as described in section 7.5 for snSet().

"IPOPT" – Paramater names and values as specified in IPOPT users guide section "Options Reference" http://www.coin-or.org/Ipopt/documentation/node40.html

void SetSolverOption ( const std::string &  solver_name,
const std::string &  solver_option,
int  option_value 
)
inline
void SetSolverOption ( const std::string &  solver_name,
const std::string &  solver_option,
const std::string &  option_value 
)
inline
void SetSolverResult ( const std::string &  solver_name,
int  solver_result 
)
inline

Here is the caller graph for this function:

SolutionResult Solve ( )
inline

Solve the OptimizationProblem.

Returns
SolutionResult indicating if the solution was successful.

Here is the caller graph for this function:


The documentation for this class was generated from the following file: