- 3.0.2 optimal control module.
|
This class is a wrapper around the NLP Optvector. It wraps the Vectors from the NLP solvers into state, control and time trajectories. More...
#include <OptVectorDms.h>
Public Types | |
typedef tpl::OptVector< SCALAR > | Base |
typedef DIMENSIONS::state_vector_t | state_vector_t |
typedef DIMENSIONS::control_vector_t | control_vector_t |
typedef DIMENSIONS::state_vector_array_t | state_vector_array_t |
typedef DIMENSIONS::control_vector_array_t | control_vector_array_t |
typedef DIMENSIONS::control_matrix_t | control_matrix_t |
typedef DIMENSIONS::time_array_t | time_array_t |
Public Types inherited from ct::optcon::tpl::OptVector< 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 > |
Public Member Functions | |
OptVectorDms (size_t n, const DmsSettings &settings) | |
Custom constructor. More... | |
OptVectorDms (const OptVectorDms &arg)=delete | |
~OptVectorDms () override=default | |
Destructor. More... | |
state_vector_t | getOptimizedState (const size_t pairNum) const |
Returns the optimized state for a specific shot. More... | |
control_vector_t | getOptimizedControl (const size_t pairNum) const |
Returns the optimized control input for a specific shot. More... | |
const state_vector_array_t & | getOptimizedStates () |
Returns the optimized state for all shots. More... | |
const control_vector_array_t & | getOptimizedInputs () |
Returns the optimized control inputs for all shots. More... | |
size_t | getStateIndex (const size_t pairNum) const |
Returns the starting index for the state at shot pairNum inside the optimization vector. More... | |
size_t | getControlIndex (const size_t pairNum) const |
Returns the starting index for the control input at shot pairNum inside the optimization vector. More... | |
void | setInitGuess (const state_vector_t &x0, const state_vector_t &x_f, const control_vector_t &u0) |
Sets an initial guess for the optimal solution. The optimal solution is set as a linear interpolation between inital state x0 and final state xf. The initial guess for the control input is assumed to be constant and equal to u0. More... | |
void | setInitGuess (const state_vector_array_t &x_init, const control_vector_array_t &u_init) |
Sets an initial guess for the optimal solution. More... | |
void | changeInitialState (const state_vector_t &x0) |
Updates the initial state. More... | |
void | changeDesiredState (const state_vector_t &xF) |
Updates the final state. More... | |
size_t | numPairs () |
Returns the number of pairs. More... | |
void | printoutSolution () |
Prints out the solution trajectories. More... | |
Public Member Functions inherited from ct::optcon::tpl::OptVector< SCALAR > | |
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... | |
Public Attributes | |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef DmsDimensions< STATE_DIM, CONTROL_DIM, SCALAR > | DIMENSIONS |
Additional Inherited Members | |
Protected Attributes inherited from ct::optcon::tpl::OptVector< SCALAR > | |
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_ |
This class is a wrapper around the NLP Optvector. It wraps the Vectors from the NLP solvers into state, control and time trajectories.
STATE_DIM | The state dimension |
CONTROL_DIM | The control dimension |
typedef tpl::OptVector<SCALAR> ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::Base |
typedef DIMENSIONS::state_vector_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::state_vector_t |
typedef DIMENSIONS::control_vector_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::control_vector_t |
typedef DIMENSIONS::state_vector_array_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::state_vector_array_t |
typedef DIMENSIONS::control_vector_array_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::control_vector_array_t |
typedef DIMENSIONS::control_matrix_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::control_matrix_t |
typedef DIMENSIONS::time_array_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::time_array_t |
ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::OptVectorDms | ( | size_t | n, |
const DmsSettings & | settings | ||
) |
Custom constructor.
[in] | n | The number of optimization variables |
[in] | settings | The dms settings |
References i.
|
delete |
|
overridedefault |
Destructor.
DmsDimensions< STATE_DIM, CONTROL_DIM, SCALAR >::state_vector_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedState | ( | const size_t | pairNum | ) | const |
Returns the optimized state for a specific shot.
[in] | pairNum | The shot number |
References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getStateIndex(), and ct::optcon::tpl::OptVector< SCALAR >::x_.
Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedStates().
DmsDimensions< STATE_DIM, CONTROL_DIM, SCALAR >::control_vector_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedControl | ( | const size_t | pairNum | ) | const |
Returns the optimized control input for a specific shot.
[in] | pairNum | The shot number |
References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getControlIndex(), and ct::optcon::tpl::OptVector< SCALAR >::x_.
Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedInputs().
const DmsDimensions< STATE_DIM, CONTROL_DIM, SCALAR >::state_vector_array_t & ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedStates | ( | ) |
Returns the optimized state for all shots.
References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedState(), and i.
Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::printoutSolution().
const DmsDimensions< STATE_DIM, CONTROL_DIM, SCALAR >::control_vector_array_t & ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedInputs | ( | ) |
Returns the optimized control inputs for all shots.
References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedControl(), and i.
Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::printoutSolution().
size_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getStateIndex | ( | const size_t | pairNum | ) | const |
Returns the starting index for the state at shot pairNum inside the optimization vector.
[in] | pairNum | The shot number |
Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::changeInitialState(), ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedState(), and ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::setInitGuess().
size_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getControlIndex | ( | const size_t | pairNum | ) | const |
Returns the starting index for the control input at shot pairNum inside the optimization vector.
[in] | pairNum | The shot number |
Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedControl(), and ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::setInitGuess().
void ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::setInitGuess | ( | const state_vector_t & | x0, |
const state_vector_t & | x_f, | ||
const control_vector_t & | u0 | ||
) |
Sets an initial guess for the optimal solution. The optimal solution is set as a linear interpolation between inital state x0 and final state xf. The initial guess for the control input is assumed to be constant and equal to u0.
[in] | x0 | The initial state |
[in] | x_f | The final state |
[in] | u0 | The control input |
References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getControlIndex(), ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getStateIndex(), i, x0, and ct::optcon::tpl::OptVector< SCALAR >::xInit_.
void ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::setInitGuess | ( | const state_vector_array_t & | x_init, |
const control_vector_array_t & | u_init | ||
) |
Sets an initial guess for the optimal solution.
[in] | x_init | Initial guess for the state trajectory |
[in] | u_init | Initial guess for the control trajectory |
References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getControlIndex(), ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getStateIndex(), i, and ct::optcon::tpl::OptVector< SCALAR >::xInit_.
void ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::changeInitialState | ( | const state_vector_t & | x0 | ) |
Updates the initial state.
[in] | x0 | The new initial state |
References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getStateIndex(), x0, and ct::optcon::tpl::OptVector< SCALAR >::x_.
void ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::changeDesiredState | ( | const state_vector_t & | xF | ) |
Updates the final state.
[in] | xF | The new final state |
References ct::optcon::DmsSettings::N_, and ct::optcon::tpl::OptVector< SCALAR >::x_.
|
inline |
Returns the number of pairs.
References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::printoutSolution().
void ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::printoutSolution | ( | ) |
Prints out the solution trajectories.
References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedInputs(), ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedStates(), and i.
Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::numPairs().
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef DmsDimensions<STATE_DIM, CONTROL_DIM, SCALAR> ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::DIMENSIONS |