- 3.0.2 optimal control module.
ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR > Class Template Reference

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>

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

Public Types

typedef tpl::OptVector< SCALARBase
 
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_tgetOptimizedStates ()
 Returns the optimized state for all shots. More...
 
const control_vector_array_tgetOptimizedInputs ()
 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 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...
 

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef DmsDimensions< STATE_DIM, CONTROL_DIM, SCALARDIMENSIONS
 

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_
 

Detailed Description

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
class ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >

This class is a wrapper around the NLP Optvector. It wraps the Vectors from the NLP solvers into state, control and time trajectories.

Template Parameters
STATE_DIMThe state dimension
CONTROL_DIMThe control dimension

Member Typedef Documentation

◆ Base

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef tpl::OptVector<SCALAR> ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::Base

◆ state_vector_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef DIMENSIONS::state_vector_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::state_vector_t

◆ control_vector_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef DIMENSIONS::control_vector_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::control_vector_t

◆ state_vector_array_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef DIMENSIONS::state_vector_array_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::state_vector_array_t

◆ control_vector_array_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef DIMENSIONS::control_vector_array_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::control_vector_array_t

◆ control_matrix_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef DIMENSIONS::control_matrix_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::control_matrix_t

◆ time_array_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef DIMENSIONS::time_array_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::time_array_t

Constructor & Destructor Documentation

◆ OptVectorDms() [1/2]

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::OptVectorDms ( size_t  n,
const DmsSettings settings 
)

Custom constructor.

Parameters
[in]nThe number of optimization variables
[in]settingsThe dms settings

References i.

◆ OptVectorDms() [2/2]

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::OptVectorDms ( const OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR > &  arg)
delete

◆ ~OptVectorDms()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::~OptVectorDms ( )
overridedefault

Destructor.

Member Function Documentation

◆ getOptimizedState()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
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.

Parameters
[in]pairNumThe shot number
Returns
The optimized state

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().

◆ getOptimizedControl()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
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.

Parameters
[in]pairNumThe shot number
Returns
The optimized control input

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().

◆ getOptimizedStates()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
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.

Returns
The optimized states.

References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedState(), and i.

Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::printoutSolution().

◆ getOptimizedInputs()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
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.

Returns
The optimized control inputs.

References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedControl(), and i.

Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::printoutSolution().

◆ getStateIndex()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
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.

Parameters
[in]pairNumThe shot number
Returns
The state index.

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().

◆ getControlIndex()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
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.

Parameters
[in]pairNumThe shot number
Returns
The state index.

Referenced by ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getOptimizedControl(), and ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::setInitGuess().

◆ setInitGuess() [1/2]

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
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.

Parameters
[in]x0The initial state
[in]x_fThe final state
[in]u0The 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_.

◆ setInitGuess() [2/2]

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
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.

Parameters
[in]x_initInitial guess for the state trajectory
[in]u_initInitial 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_.

◆ changeInitialState()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
void ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::changeInitialState ( const state_vector_t x0)

Updates the initial state.

Parameters
[in]x0The new initial state

References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::getStateIndex(), x0, and ct::optcon::tpl::OptVector< SCALAR >::x_.

◆ changeDesiredState()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
void ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::changeDesiredState ( const state_vector_t xF)

Updates the final state.

Parameters
[in]xFThe new final state

References ct::optcon::DmsSettings::N_, and ct::optcon::tpl::OptVector< SCALAR >::x_.

◆ numPairs()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
size_t ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::numPairs ( )
inline

Returns the number of pairs.

Returns
Number of pairs

References ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::printoutSolution().

◆ printoutSolution()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR >
void ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::printoutSolution ( )

Member Data Documentation

◆ DIMENSIONS

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef DmsDimensions<STATE_DIM, CONTROL_DIM, SCALAR> ct::optcon::OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >::DIMENSIONS

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