- 3.0.2 optimal control module.
ExampleProblem< SCALAR > Class Template Referencefinal

Sets up the nlp to be solved by an nlpsolver. More...

Inheritance diagram for ExampleProblem< SCALAR >:
ct::optcon::tpl::Nlp< SCALAR > ct::optcon::tpl::Nlp< SCALAR >

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW ExampleProblem ()
 
 ~ExampleProblem () override=default
 
void updateProblem () override
 { This method gets called at each update of the Optimization variables. This can be used to distribute or rearrange the optimization variables appropriately } More...
 
Eigen::VectorXd getSolution ()
 
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ExampleProblem ()
 
 ~ExampleProblem () override=default
 
void updateProblem () override
 { This method gets called at each update of the Optimization variables. This can be used to distribute or rearrange the optimization variables appropriately } More...
 
Eigen::VectorXd getSolution ()
 
- Public Member Functions inherited from ct::optcon::tpl::Nlp< SCALAR >
 Nlp ()=default
 Default constructor. More...
 
virtual ~Nlp ()=default
 Destructor. More...
 
SCALAR evaluateCostFun ()
 { Evaluates the costfunction at the current nlp iteration } More...
 
void evaluateCostGradient (const size_t n, MapVecXs &grad)
 { Evaluates the gradient of the costfunction} More...
 
void evaluateConstraints (MapVecXs &values)
 { Evaluates the constraints } More...
 
void evaluateConstraintJacobian (const int nele_jac, MapVecXs &jac)
 { Evaluates the constraint jacobian } More...
 
void evaluateHessian (const int nele_hes, MapVecXs &hes, const SCALAR obj_fac, MapConstVecXs &lambda)
 Evaluates the hessian of the lagrangian. More...
 
void getSparsityPatternJacobian (const int nele_jac, MapVecXi &iRow, MapVecXi &jCol) const
 Gets the sparsity pattern. More...
 
void getSparsityPatternHessian (const int nele_hes, MapVecXi &iRow, MapVecXi &jCol) const
 Gets the sparsity pattern of the Hessian of the Lagrangian. More...
 
size_t getConstraintsCount () const
 Returns the number of constraints in the NLP. More...
 
size_t getNonZeroJacobianCount () const
 Returns the number of the non zero elements of the constraint jacobian. More...
 
size_t getNonZeroHessianCount ()
 Returns the number of non zeros in the Hessian. More...
 
void getConstraintBounds (MapVecXs &lowerBound, MapVecXs &upperBound, const size_t m) const
 Reads the bounds of the constraints. More...
 
size_t getVarCount () const
 Returns the number of Optimization optimization variables. More...
 
void getVariableBounds (MapVecXs &lowerBound, MapVecXs &upperBound, const size_t n) const
 Reads the bounds on the Optimization optimization variables. More...
 
void extractOptimizationVars (const MapConstVecXs &x, bool isNew)
 {Extracts the Optimization optimization variables from the nlp solvers between nlp iterations} More...
 
void getInitialGuess (const size_t n, MapVecXs &x) const
 Gets the Optimization variables. More...
 
void getOptimizationMultState (const size_t n, MapVecXs &xMul, MapVecXi &xState) const
 Gets the variable multiplier and the variable state, used in the NLP solver SNOPT. See the snopt documentation for further explanations. More...
 
void getConstraintsMultState (const size_t m, MapVecXs &zMul, MapVecXi &zState) const
 Gets the constraint multiplier and state, used in the NLP solver SNOPT. More...
 
void getBoundMultipliers (size_t n, MapVecXs &zLow, MapVecXs &zUp) const
 Gets the bound multipliers used in the NLP solver IPOPT. More...
 
void getLambdaVars (size_t m, MapVecXs &lambda) const
 Gets the values of the constraint multipliers. More...
 
void extractIpoptSolution (const MapConstVecXs &x, const MapConstVecXs &zL, const MapConstVecXs &zU, const MapConstVecXs &lambda)
 { Extracts the solution values from IPOPT } More...
 
void extractSnoptSolution (const MapVecXs &x, const MapVecXs &xMul, const MapVecXi &xState, const MapVecXs &fMul, const MapVecXi &fState)
 { Extracts the solution values from SNOPT } More...
 

Additional Inherited Members

- Public Types inherited from ct::optcon::tpl::Nlp< SCALAR >
using VectorXs = Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 >
 
using VectorXi = Eigen::Matrix< int, Eigen::Dynamic, 1 >
 
using MapVecXs = Eigen::Map< VectorXs >
 
using MapVecXi = Eigen::Map< VectorXi >
 
using MapConstVecXs = Eigen::Map< const VectorXs >
 
- Protected Attributes inherited from ct::optcon::tpl::Nlp< SCALAR >
std::shared_ptr< DiscreteCostEvaluatorBase< SCALAR > > costEvaluator_
 Ptr to cost evaluator, which approximates the cost evaluation for the discrete problem. More...
 
std::shared_ptr< OptVector< SCALAR > > optVariables_
 Ptr to optimization variable container, which holds the optimization variables used in the NLP solvers. More...
 
std::shared_ptr< DiscreteConstraintContainerBase< SCALAR > > constraints_
 Ptr to constraint container, which contains the discretized constraints for the problem. More...
 
Eigen::VectorXi iRowHessianCost_
 helper containers for calculating the sparsity patterns More...
 
Eigen::VectorXi iRowHessianConstraints_
 
Eigen::VectorXi jColHessianCost_
 
Eigen::VectorXi jColHessianConstraints_
 
Eigen::VectorXi iRowHessian_
 combined Hessian sparsity pattern gets stored here More...
 
Eigen::VectorXi jColHessian_
 

Detailed Description

template<typename SCALAR>
class ExampleProblem< SCALAR >

Sets up the nlp to be solved by an nlpsolver.

Template Parameters
SCALARScalar type

Constructor & Destructor Documentation

◆ ExampleProblem() [1/2]

template<typename SCALAR >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ExampleProblem< SCALAR >::ExampleProblem ( )
inline

◆ ~ExampleProblem() [1/2]

template<typename SCALAR >
ExampleProblem< SCALAR >::~ExampleProblem ( )
overridedefault

◆ ExampleProblem() [2/2]

template<typename SCALAR >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ExampleProblem< SCALAR >::ExampleProblem ( )
inline

◆ ~ExampleProblem() [2/2]

template<typename SCALAR >
ExampleProblem< SCALAR >::~ExampleProblem ( )
overridedefault

Member Function Documentation

◆ updateProblem() [1/2]

template<typename SCALAR >
void ExampleProblem< SCALAR >::updateProblem ( )
inlineoverridevirtual

{ This method gets called at each update of the Optimization variables. This can be used to distribute or rearrange the optimization variables appropriately }

Implements ct::optcon::tpl::Nlp< SCALAR >.

◆ getSolution() [1/2]

template<typename SCALAR >
Eigen::VectorXd ExampleProblem< SCALAR >::getSolution ( )
inline

◆ updateProblem() [2/2]

template<typename SCALAR >
void ExampleProblem< SCALAR >::updateProblem ( )
inlineoverridevirtual

{ This method gets called at each update of the Optimization variables. This can be used to distribute or rearrange the optimization variables appropriately }

Implements ct::optcon::tpl::Nlp< SCALAR >.

◆ getSolution() [2/2]

template<typename SCALAR >
Eigen::VectorXd ExampleProblem< SCALAR >::getSolution ( )
inline

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