- 3.0.2 optimal control module.
ct::optcon::tpl::OptVector< SCALAR > Class Template Reference

Class containing and managing all the optimization variables used for in the NLP solver IPOPT and SNOPT. More...

#include <OptVector.h>

Inheritance diagram for ct::optcon::tpl::OptVector< SCALAR >:
ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >

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 VectorXsgetOptimizationVars () 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_
 

Detailed Description

template<typename SCALAR>
class ct::optcon::tpl::OptVector< SCALAR >

Class containing and managing all the optimization variables used for in the NLP solver IPOPT and SNOPT.

Member Typedef Documentation

◆ VectorXs

template<typename SCALAR >
using ct::optcon::tpl::OptVector< SCALAR >::VectorXs = Eigen::Matrix<SCALAR, Eigen::Dynamic, 1>

◆ VectorXi

template<typename SCALAR >
using ct::optcon::tpl::OptVector< SCALAR >::VectorXi = Eigen::Matrix<int, Eigen::Dynamic, 1>

◆ MapVecXs

template<typename SCALAR >
using ct::optcon::tpl::OptVector< SCALAR >::MapVecXs = Eigen::Map<VectorXs>

◆ MapVecXi

template<typename SCALAR >
using ct::optcon::tpl::OptVector< SCALAR >::MapVecXi = Eigen::Map<VectorXi>

◆ MapConstVecXs

template<typename SCALAR >
using ct::optcon::tpl::OptVector< SCALAR >::MapConstVecXs = Eigen::Map<const VectorXs>

Constructor & Destructor Documentation

◆ OptVector() [1/2]

template<typename SCALAR >
ct::optcon::tpl::OptVector< SCALAR >::OptVector ( )
delete

◆ OptVector() [2/2]

◆ ~OptVector()

template<typename SCALAR >
virtual ct::optcon::tpl::OptVector< SCALAR >::~OptVector ( )
virtualdefault

Member Function Documentation

◆ resizeConstraintVars()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::resizeConstraintVars ( size_t  m)
inline

Resizes the vectors of the constraint variables to the correct size.

Parameters
[in]mThe number of constraints

References ct::optcon::tpl::OptVector< SCALAR >::zMul_, and ct::optcon::tpl::OptVector< SCALAR >::zState_.

◆ reset()

◆ resizeOptimizationVars()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::resizeOptimizationVars ( const size_t  size)
inline

◆ setZero()

◆ setRandomInitialGuess()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::setRandomInitialGuess ( )
inline

◆ setInitialGuess()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::setInitialGuess ( const VectorXs xinit)
inline

◆ checkOptimizationVarDimension()

template<typename SCALAR >
bool ct::optcon::tpl::OptVector< SCALAR >::checkOptimizationVarDimension ( const unsigned int  n)
inline

Checks if the optimization variables have to correct size.

Parameters
[in]nThe number of optimization variables
Returns
returns true of the dimensions match

References ct::optcon::tpl::OptVector< SCALAR >::x_, ct::optcon::tpl::OptVector< SCALAR >::xLb_, and ct::optcon::tpl::OptVector< SCALAR >::xUb_.

◆ setBounds()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::setBounds ( const VectorXs xLb,
const VectorXs xUb 
)
inline

Sets the optimization variable bounds.

Parameters
[in]xLbThe lower optimization variable bound
[in]xUbThe upper optimization variable bound

References ct::optcon::tpl::OptVector< SCALAR >::xLb_, and ct::optcon::tpl::OptVector< SCALAR >::xUb_.

◆ getLowerBounds()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::getLowerBounds ( MapVecXs x) const
inline

Gets the lower bounds of the optimization variables.

Parameters
[out]xLower bound

References ct::optcon::tpl::OptVector< SCALAR >::xLb_.

◆ getUpperBounds()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::getUpperBounds ( MapVecXs x) const
inline

Gets the upper bounds of the optimization variables.

Parameters
[out]xThe upper bound

References ct::optcon::tpl::OptVector< SCALAR >::xUb_.

◆ getOptimizationMultState()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::getOptimizationMultState ( const size_t  n,
MapVecXs xMul,
MapVecXi xState 
) const
inline

Return the state and the multiplier of the optimization variables, used in the NLP solver SNOPT.

Parameters
[in]n{ The number of optimization variables }
[out]xMulThe optimization variables multiplier
[out]xStateThe optimization variables state

References ct::optcon::tpl::OptVector< SCALAR >::xMul_, and ct::optcon::tpl::OptVector< SCALAR >::xState_.

◆ getConstraintsMultState()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::getConstraintsMultState ( const size_t  m,
MapVecXs zMul,
MapVecXi zState 
) const
inline

Gets the constraint multiplier and state, used in the NLP solver SNOPT.

Parameters
[in]m{ The number of constraints }
[out]zMulThe constraint variable multiplier
[out]zStateThe constraint variable state

References ct::optcon::tpl::OptVector< SCALAR >::zMul_, and ct::optcon::tpl::OptVector< SCALAR >::zState_.

◆ size()

template<typename SCALAR >
size_t ct::optcon::tpl::OptVector< SCALAR >::size ( ) const
inline

Returns the number of optimization variables.

Returns
the number of optimization variables

References ct::optcon::tpl::OptVector< SCALAR >::x_.

◆ getBoundMultipliers()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::getBoundMultipliers ( size_t  n,
MapVecXs low,
MapVecXs up 
) const
inline

Gets the bound multipliers used in the NLP solver IPOPT.

Parameters
[in]n{ The number of optimization variables }
[out]lowThe value for the lower bound multiplier
[out]upThe value for the upper bound multiplier

References ct::optcon::tpl::OptVector< SCALAR >::zLow_, and ct::optcon::tpl::OptVector< SCALAR >::zUpper_.

◆ getLambdaVars()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::getLambdaVars ( size_t  m,
MapVecXs x 
) const
inline

Gets the values of the constraint multipliers.

Parameters
[in]m{ The number of constraints }
[out]xThe values of the constraint multipliers

References ct::optcon::tpl::OptVector< SCALAR >::lambda_.

◆ getOptimizationVars() [1/2]

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::getOptimizationVars ( size_t  n,
MapVecXs x 
) const
inline

Gets the optimization variables.

Parameters
[in]n{ The number of optimization variables }
[out]xThe optimization variables

References ct::optcon::tpl::OptVector< SCALAR >::x_.

◆ getOptimizationVars() [2/2]

template<typename SCALAR >
const VectorXs& ct::optcon::tpl::OptVector< SCALAR >::getOptimizationVars ( ) const
inline

◆ getInitialGuess()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::getInitialGuess ( size_t  n,
MapVecXs x 
) const
inline

◆ setNewIpoptSolution()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::setNewIpoptSolution ( const MapConstVecXs x,
const MapConstVecXs zL,
const MapConstVecXs zU,
const MapConstVecXs lambda 
)
inline

Extracts the solution from ipopt and stores them into class variables.

Parameters
[in]xThe optimization variables
[in]zLThe lower bound multiplier
[in]zUThe upper bound multiplier
[in]lambdaThe 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_.

◆ setNewSnoptSolution()

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::setNewSnoptSolution ( const MapVecXs x,
const MapVecXs xMul,
const MapVecXi xState,
const MapVecXs fMul,
const MapVecXi fState 
)
inline

Extracts the solution from snopt and stores it into class variables.

Parameters
[in]xThe optimization variables
[in]xMulThe optimization variables multiplier
[in]xStateThe optimization variables state
[in]fMulThe constraints multiplier
[in]fStateThe 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_.

◆ setOptimizationVars() [1/2]

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::setOptimizationVars ( const MapConstVecXs x)
inline

Sets the updates optimization variables from the NLP solver and updates the counter.

Parameters
[in]xThe updates primal variables

References ct::optcon::tpl::OptVector< SCALAR >::updateCount_, x, and ct::optcon::tpl::OptVector< SCALAR >::x_.

◆ setOptimizationVars() [2/2]

template<typename SCALAR >
void ct::optcon::tpl::OptVector< SCALAR >::setOptimizationVars ( const VectorXs x)
inline

◆ getUpdateCount()

template<typename SCALAR >
size_t ct::optcon::tpl::OptVector< SCALAR >::getUpdateCount ( ) const
inline

Returns the update counter.

Returns
The update counter

References ct::optcon::tpl::OptVector< SCALAR >::updateCount_.

Member Data Documentation

◆ x_

◆ xInit_

◆ xLb_

◆ xUb_

◆ zUpper_

◆ zLow_

◆ lambda_

◆ xMul_

◆ xState_

◆ zMul_

◆ zState_

◆ updateCount_

template<typename SCALAR >
size_t ct::optcon::tpl::OptVector< SCALAR >::updateCount_
protected

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