- 3.0.2 optimal control module.
|
Class containing and managing all the optimization variables used for in the NLP solver IPOPT and SNOPT. More...
#include <OptVector.h>
Public Types | |
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 > |
Public Member Functions | |
OptVector ()=delete | |
OptVector (const size_t n) | |
{ Constructor resizing the vectors of the optimization variables to the correct size } More... | |
void | resizeConstraintVars (size_t m) |
Resizes the vectors of the constraint variables to the correct size. More... | |
void | reset () |
virtual | ~OptVector ()=default |
Destructor. More... | |
void | resizeOptimizationVars (const size_t size) |
Resizes the vectors of the optimization variables. More... | |
void | setZero () |
Resets the optimization variables. More... | |
void | setRandomInitialGuess () |
void | setInitialGuess (const VectorXs &xinit) |
bool | checkOptimizationVarDimension (const unsigned int n) |
Checks if the optimization variables have to correct size. More... | |
void | setBounds (const VectorXs &xLb, const VectorXs &xUb) |
Sets the optimization variable bounds. More... | |
void | getLowerBounds (MapVecXs &x) const |
Gets the lower bounds of the optimization variables. More... | |
void | getUpperBounds (MapVecXs &x) const |
Gets the upper bounds of the optimization variables. More... | |
void | getOptimizationMultState (const size_t n, MapVecXs &xMul, MapVecXi &xState) const |
Return the state and the multiplier of the optimization variables, used in the NLP solver SNOPT. 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... | |
size_t | size () const |
Returns the number of optimization variables. More... | |
void | getBoundMultipliers (size_t n, MapVecXs &low, MapVecXs &up) const |
Gets the bound multipliers used in the NLP solver IPOPT. More... | |
void | getLambdaVars (size_t m, MapVecXs &x) const |
Gets the values of the constraint multipliers. More... | |
void | getOptimizationVars (size_t n, MapVecXs &x) const |
Gets the optimization variables. More... | |
const VectorXs & | getOptimizationVars () const |
void | getInitialGuess (size_t n, MapVecXs &x) const |
void | setNewIpoptSolution (const MapConstVecXs &x, const MapConstVecXs &zL, const MapConstVecXs &zU, const MapConstVecXs &lambda) |
Extracts the solution from ipopt and stores them into class variables. More... | |
void | setNewSnoptSolution (const MapVecXs &x, const MapVecXs &xMul, const MapVecXi &xState, const MapVecXs &fMul, const MapVecXi &fState) |
Extracts the solution from snopt and stores it into class variables. More... | |
void | setOptimizationVars (const MapConstVecXs &x) |
Sets the updates optimization variables from the NLP solver and updates the counter. More... | |
void | setOptimizationVars (const VectorXs &x) |
size_t | getUpdateCount () const |
Returns the update counter. More... | |
Protected Attributes | |
VectorXs | x_ |
VectorXs | xInit_ |
VectorXs | xLb_ |
VectorXs | xUb_ |
VectorXs | zUpper_ |
VectorXs | zLow_ |
VectorXs | lambda_ |
VectorXs | xMul_ |
VectorXi | xState_ |
VectorXs | zMul_ |
VectorXi | zState_ |
size_t | updateCount_ |
Class containing and managing all the optimization variables used for in the NLP solver IPOPT and SNOPT.
using ct::optcon::tpl::OptVector< SCALAR >::VectorXs = Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> |
using ct::optcon::tpl::OptVector< SCALAR >::VectorXi = Eigen::Matrix<int, Eigen::Dynamic, 1> |
using ct::optcon::tpl::OptVector< SCALAR >::MapVecXs = Eigen::Map<VectorXs> |
using ct::optcon::tpl::OptVector< SCALAR >::MapVecXi = Eigen::Map<VectorXi> |
using ct::optcon::tpl::OptVector< SCALAR >::MapConstVecXs = Eigen::Map<const VectorXs> |
|
delete |
|
inline |
{ Constructor resizing the vectors of the optimization variables to the correct size }
[in] | n | The number of the optimization variables |
References ct::optcon::tpl::OptVector< SCALAR >::x_, ct::optcon::tpl::OptVector< SCALAR >::xInit_, ct::optcon::tpl::OptVector< SCALAR >::xLb_, ct::optcon::tpl::OptVector< SCALAR >::xMul_, ct::optcon::tpl::OptVector< SCALAR >::xState_, ct::optcon::tpl::OptVector< SCALAR >::xUb_, ct::optcon::tpl::OptVector< SCALAR >::zLow_, and ct::optcon::tpl::OptVector< SCALAR >::zUpper_.
|
virtualdefault |
Destructor.
Referenced by ct::optcon::tpl::OptVector< SCALAR >::reset().
|
inline |
Resizes the vectors of the constraint variables to the correct size.
[in] | m | The number of constraints |
References ct::optcon::tpl::OptVector< SCALAR >::zMul_, and ct::optcon::tpl::OptVector< SCALAR >::zState_.
|
inline |
|
inline |
Resizes the vectors of the optimization variables.
[in] | size | The size of the new optimization variables |
References ct::optcon::tpl::OptVector< SCALAR >::lambda_, ct::optcon::tpl::OptVector< SCALAR >::x_, ct::optcon::tpl::OptVector< SCALAR >::xInit_, ct::optcon::tpl::OptVector< SCALAR >::xLb_, ct::optcon::tpl::OptVector< SCALAR >::xUb_, ct::optcon::tpl::OptVector< SCALAR >::zLow_, and ct::optcon::tpl::OptVector< SCALAR >::zUpper_.
|
inline |
Resets the optimization variables.
References ct::optcon::tpl::OptVector< SCALAR >::lambda_, ct::optcon::tpl::OptVector< SCALAR >::x_, ct::optcon::tpl::OptVector< SCALAR >::xInit_, ct::optcon::tpl::OptVector< SCALAR >::zLow_, and ct::optcon::tpl::OptVector< SCALAR >::zUpper_.
|
inline |
|
inline |
|
inline |
Checks if the optimization variables have to correct size.
[in] | n | The number of optimization variables |
References ct::optcon::tpl::OptVector< SCALAR >::x_, ct::optcon::tpl::OptVector< SCALAR >::xLb_, and ct::optcon::tpl::OptVector< SCALAR >::xUb_.
|
inline |
Sets the optimization variable bounds.
[in] | xLb | The lower optimization variable bound |
[in] | xUb | The upper optimization variable bound |
References ct::optcon::tpl::OptVector< SCALAR >::xLb_, and ct::optcon::tpl::OptVector< SCALAR >::xUb_.
|
inline |
Gets the lower bounds of the optimization variables.
[out] | x | Lower bound |
References ct::optcon::tpl::OptVector< SCALAR >::xLb_.
|
inline |
Gets the upper bounds of the optimization variables.
[out] | x | The upper bound |
References ct::optcon::tpl::OptVector< SCALAR >::xUb_.
|
inline |
Return the state and the multiplier of the optimization variables, used in the NLP solver SNOPT.
[in] | n | { The number of optimization variables } |
[out] | xMul | The optimization variables multiplier |
[out] | xState | The optimization variables state |
References ct::optcon::tpl::OptVector< SCALAR >::xMul_, and ct::optcon::tpl::OptVector< SCALAR >::xState_.
|
inline |
Gets the constraint multiplier and state, used in the NLP solver SNOPT.
[in] | m | { The number of constraints } |
[out] | zMul | The constraint variable multiplier |
[out] | zState | The constraint variable state |
References ct::optcon::tpl::OptVector< SCALAR >::zMul_, and ct::optcon::tpl::OptVector< SCALAR >::zState_.
|
inline |
Returns the number of optimization variables.
References ct::optcon::tpl::OptVector< SCALAR >::x_.
|
inline |
Gets the bound multipliers used in the NLP solver IPOPT.
[in] | n | { The number of optimization variables } |
[out] | low | The value for the lower bound multiplier |
[out] | up | The value for the upper bound multiplier |
References ct::optcon::tpl::OptVector< SCALAR >::zLow_, and ct::optcon::tpl::OptVector< SCALAR >::zUpper_.
|
inline |
Gets the values of the constraint multipliers.
[in] | m | { The number of constraints } |
[out] | x | The values of the constraint multipliers |
References ct::optcon::tpl::OptVector< SCALAR >::lambda_.
|
inline |
Gets the optimization variables.
[in] | n | { The number of optimization variables } |
[out] | x | The optimization variables |
References ct::optcon::tpl::OptVector< SCALAR >::x_.
|
inline |
References ct::optcon::tpl::OptVector< SCALAR >::x_.
|
inline |
References ct::optcon::tpl::OptVector< SCALAR >::xInit_.
|
inline |
Extracts the solution from ipopt and stores them into class variables.
[in] | x | The optimization variables |
[in] | zL | The lower bound multiplier |
[in] | zU | The upper bound multiplier |
[in] | lambda | The constraint multiplier |
References ct::optcon::tpl::OptVector< SCALAR >::lambda_, x, ct::optcon::tpl::OptVector< SCALAR >::x_, ct::optcon::tpl::OptVector< SCALAR >::zLow_, and ct::optcon::tpl::OptVector< SCALAR >::zUpper_.
|
inline |
Extracts the solution from snopt and stores it into class variables.
[in] | x | The optimization variables |
[in] | xMul | The optimization variables multiplier |
[in] | xState | The optimization variables state |
[in] | fMul | The constraints multiplier |
[in] | fState | The constraints state |
References x, ct::optcon::tpl::OptVector< SCALAR >::x_, ct::optcon::tpl::OptVector< SCALAR >::xMul_, ct::optcon::tpl::OptVector< SCALAR >::xState_, ct::optcon::tpl::OptVector< SCALAR >::zMul_, and ct::optcon::tpl::OptVector< SCALAR >::zState_.
|
inline |
Sets the updates optimization variables from the NLP solver and updates the counter.
[in] | x | The updates primal variables |
References ct::optcon::tpl::OptVector< SCALAR >::updateCount_, x, and ct::optcon::tpl::OptVector< SCALAR >::x_.
|
inline |
|
inline |
Returns the update counter.
References ct::optcon::tpl::OptVector< SCALAR >::updateCount_.
|
protected |
The optimization variables
Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::changeDesiredState(), ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::changeInitialState(), ct::optcon::tpl::OptVector< SCALAR >::checkOptimizationVarDimension(), ct::optcon::tpl::OptVector< SCALAR >::getOptimizationVars(), ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedControl(), ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedState(), ct::optcon::tpl::OptVector< SCALAR >::OptVector(), ct::optcon::tpl::OptVector< SCALAR >::resizeOptimizationVars(), ct::optcon::tpl::OptVector< SCALAR >::setInitialGuess(), ct::optcon::tpl::OptVector< SCALAR >::setNewIpoptSolution(), ct::optcon::tpl::OptVector< SCALAR >::setNewSnoptSolution(), ct::optcon::tpl::OptVector< SCALAR >::setOptimizationVars(), ct::optcon::tpl::OptVector< SCALAR >::setRandomInitialGuess(), ct::optcon::tpl::OptVector< SCALAR >::setZero(), and ct::optcon::tpl::OptVector< SCALAR >::size().
|
protected |
Referenced by ct::optcon::tpl::OptVector< SCALAR >::getInitialGuess(), ct::optcon::tpl::OptVector< SCALAR >::OptVector(), ct::optcon::tpl::OptVector< SCALAR >::resizeOptimizationVars(), ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::setInitGuess(), ct::optcon::tpl::OptVector< SCALAR >::setInitialGuess(), ct::optcon::tpl::OptVector< SCALAR >::setRandomInitialGuess(), and ct::optcon::tpl::OptVector< SCALAR >::setZero().
|
protected |
lower bound on optimization vector
Referenced by ct::optcon::tpl::OptVector< SCALAR >::checkOptimizationVarDimension(), ct::optcon::tpl::OptVector< SCALAR >::getLowerBounds(), ct::optcon::tpl::OptVector< SCALAR >::OptVector(), ct::optcon::tpl::OptVector< SCALAR >::resizeOptimizationVars(), and ct::optcon::tpl::OptVector< SCALAR >::setBounds().
|
protected |
upper bound on optimization vector
Referenced by ct::optcon::tpl::OptVector< SCALAR >::checkOptimizationVarDimension(), ct::optcon::tpl::OptVector< SCALAR >::getUpperBounds(), ct::optcon::tpl::OptVector< SCALAR >::OptVector(), ct::optcon::tpl::OptVector< SCALAR >::resizeOptimizationVars(), and ct::optcon::tpl::OptVector< SCALAR >::setBounds().
|
protected |
The upper bound multiplier, used in IPOPT
Referenced by ct::optcon::tpl::OptVector< SCALAR >::getBoundMultipliers(), ct::optcon::tpl::OptVector< SCALAR >::OptVector(), ct::optcon::tpl::OptVector< SCALAR >::resizeOptimizationVars(), ct::optcon::tpl::OptVector< SCALAR >::setNewIpoptSolution(), and ct::optcon::tpl::OptVector< SCALAR >::setZero().
|
protected |
The lower bound multiplier, used in IPOPT
Referenced by ct::optcon::tpl::OptVector< SCALAR >::getBoundMultipliers(), ct::optcon::tpl::OptVector< SCALAR >::OptVector(), ct::optcon::tpl::OptVector< SCALAR >::resizeOptimizationVars(), ct::optcon::tpl::OptVector< SCALAR >::setNewIpoptSolution(), and ct::optcon::tpl::OptVector< SCALAR >::setZero().
|
protected |
The constraint multiplier, used in IPOPT
Referenced by ct::optcon::tpl::OptVector< SCALAR >::getLambdaVars(), ct::optcon::tpl::OptVector< SCALAR >::resizeOptimizationVars(), ct::optcon::tpl::OptVector< SCALAR >::setNewIpoptSolution(), and ct::optcon::tpl::OptVector< SCALAR >::setZero().
|
protected |
The optimization variable multiplier, used in SNOPT
Referenced by ct::optcon::tpl::OptVector< SCALAR >::getOptimizationMultState(), ct::optcon::tpl::OptVector< SCALAR >::OptVector(), and ct::optcon::tpl::OptVector< SCALAR >::setNewSnoptSolution().
|
protected |
The optimization variable state, used in SNOPT
Referenced by ct::optcon::tpl::OptVector< SCALAR >::getOptimizationMultState(), ct::optcon::tpl::OptVector< SCALAR >::OptVector(), and ct::optcon::tpl::OptVector< SCALAR >::setNewSnoptSolution().
|
protected |
The constraint multiplier, used in SNOPT
Referenced by ct::optcon::tpl::OptVector< SCALAR >::getConstraintsMultState(), ct::optcon::tpl::OptVector< SCALAR >::resizeConstraintVars(), and ct::optcon::tpl::OptVector< SCALAR >::setNewSnoptSolution().
|
protected |
The constraint state, used in SNOPT
Referenced by ct::optcon::tpl::OptVector< SCALAR >::getConstraintsMultState(), ct::optcon::tpl::OptVector< SCALAR >::resizeConstraintVars(), and ct::optcon::tpl::OptVector< SCALAR >::setNewSnoptSolution().
|
protected |
The number of optimization variable updates
Referenced by ct::optcon::tpl::OptVector< SCALAR >::getUpdateCount(), ct::optcon::tpl::OptVector< SCALAR >::reset(), and ct::optcon::tpl::OptVector< SCALAR >::setOptimizationVars().