- 3.0.2 optimal control module.
ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR > Class Template Referenceabstract

An abstract base class which serves as a container for all the discrete constraints used in the NLP. More...

#include <DiscreteConstraintContainerBase.h>

Inheritance diagram for ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >:
ct::optcon::ConstraintsContainerDms< STATE_DIM, CONTROL_DIM, SCALAR > ExampleConstraintsContainer< SCALAR > ExampleConstraintsContainer< 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 >
 

Public Member Functions

 DiscreteConstraintContainerBase ()=default
 Default constructor. More...
 
virtual ~DiscreteConstraintContainerBase ()=default
 Destructor. More...
 
virtual void prepareEvaluation ()=0
 Gets called before the constraint evaluation. This method should contain all the calculations needed to evaluate the constraints. More...
 
virtual void prepareJacobianEvaluation ()=0
 Gets called before the constraint jacobian evaluation. This method should contain all the calculations needed to evaluate the constraint jacobian. More...
 
void evalConstraints (MapVecXs &c_nlp)
 Writes the constraint evaluations into the large constraint optimization vector. More...
 
void evalConstraints (VectorXs &c_nlp)
 
void evalSparseJacobian (MapVecXs &jac_nlp, const int nzz_jac_g)
 Evaluates the jacobian of the constraints and writes them into the nlp vector. More...
 
void getSparsityPattern (Eigen::Map< Eigen::VectorXi > &iRow_nlp, Eigen::Map< Eigen::VectorXi > &jCol_nlp, const int nnz_jac_g)
 Retrieves the sparsity pattern of the constraint Jacobian and writes them into the nlp vectors. More...
 
size_t getConstraintsCount () const
 Returns the number of constraints in the NLP. More...
 
size_t getNonZerosJacobianCount () const
 Returns the number of non zeros in the constraint jacobian. More...
 
void getSparsityPatternHessian (Eigen::VectorXi &iRow, Eigen::VectorXi &jCol, size_t numOptVar)
 creates the combined hessian sparsity pattern from a number of constraint terms More...
 
Eigen::VectorXd sparseHessianValues (const Eigen::VectorXd &optVec, const Eigen::VectorXd &lambda)
 Evaluates the constraint Hessian. More...
 
void getBounds (MapVecXs &lowerBound, MapVecXs &upperBound)
 Retrieves the constraint bounds and writes them into the vectors used in the NLP. More...
 

Protected Attributes

std::vector< std::shared_ptr< DiscreteConstraintBase< SCALAR > > > constraints_
 Container which holds all the constraints of the NLP. More...
 
std::vector< int > iRowHessianStdVec_
 
std::vector< int > jColHessianStdVec_
 

Detailed Description

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

An abstract base class which serves as a container for all the discrete constraints used in the NLP.

Member Typedef Documentation

◆ VectorXs

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

◆ VectorXi

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

◆ MapVecXs

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

◆ MapVecXi

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

Constructor & Destructor Documentation

◆ DiscreteConstraintContainerBase()

Default constructor.

◆ ~DiscreteConstraintContainerBase()

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

Destructor.

Member Function Documentation

◆ prepareEvaluation()

template<typename SCALAR >
virtual void ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::prepareEvaluation ( )
pure virtual

Gets called before the constraint evaluation. This method should contain all the calculations needed to evaluate the constraints.

Implemented in ExampleConstraintsContainer< SCALAR >, ExampleConstraintsContainer< SCALAR >, and ct::optcon::ConstraintsContainerDms< STATE_DIM, CONTROL_DIM, SCALAR >.

Referenced by ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::evalConstraints().

◆ prepareJacobianEvaluation()

template<typename SCALAR >
virtual void ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::prepareJacobianEvaluation ( )
pure virtual

Gets called before the constraint jacobian evaluation. This method should contain all the calculations needed to evaluate the constraint jacobian.

Implemented in ExampleConstraintsContainer< SCALAR >, ExampleConstraintsContainer< SCALAR >, and ct::optcon::ConstraintsContainerDms< STATE_DIM, CONTROL_DIM, SCALAR >.

Referenced by ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::evalSparseJacobian().

◆ evalConstraints() [1/2]

template<typename SCALAR >
void ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::evalConstraints ( MapVecXs c_nlp)
inline

Writes the constraint evaluations into the large constraint optimization vector.

Parameters
[out]c_nlpThe constraint vector used in the NLP

References ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::constraints_, and ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::prepareEvaluation().

◆ evalConstraints() [2/2]

◆ evalSparseJacobian()

template<typename SCALAR >
void ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::evalSparseJacobian ( MapVecXs jac_nlp,
const int  nzz_jac_g 
)
inline

Evaluates the jacobian of the constraints and writes them into the nlp vector.

Parameters
[out]jac_nlpThe constraint jacobian vector used in NLP
[in]nzz_jac_gThe number of non zero elements in the jacobian

References ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::constraints_, and ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::prepareJacobianEvaluation().

◆ getSparsityPattern()

template<typename SCALAR >
void ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::getSparsityPattern ( Eigen::Map< Eigen::VectorXi > &  iRow_nlp,
Eigen::Map< Eigen::VectorXi > &  jCol_nlp,
const int  nnz_jac_g 
)
inline

Retrieves the sparsity pattern of the constraint Jacobian and writes them into the nlp vectors.

Parameters
[out]iRow_nlpThe vector containing the row indices of the non zero entries of the constraint jacobian
[out]jCol_nlpThe vector containing the column indices of the non zero entries of the constraint jacobian
[in]nnz_jac_gThe number of non zero elements in the constraint jacobian

References ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::constraints_.

◆ getConstraintsCount()

template<typename SCALAR >
size_t ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::getConstraintsCount ( ) const
inline

Returns the number of constraints in the NLP.

Returns
The number of constraint in the NLP

References ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::constraints_.

◆ getNonZerosJacobianCount()

template<typename SCALAR >
size_t ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::getNonZerosJacobianCount ( ) const
inline

Returns the number of non zeros in the constraint jacobian.

Returns
The number of non zeros in the constraint jacobian

References ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::constraints_.

◆ getSparsityPatternHessian()

template<typename SCALAR >
void ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::getSparsityPatternHessian ( Eigen::VectorXi &  iRow,
Eigen::VectorXi &  jCol,
size_t  numOptVar 
)
inline

creates the combined hessian sparsity pattern from a number of constraint terms

Returns
The number of non zeros in the constraint jacobian

References ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::constraints_, i, ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::iRowHessianStdVec_, and ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::jColHessianStdVec_.

◆ sparseHessianValues()

template<typename SCALAR >
Eigen::VectorXd ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::sparseHessianValues ( const Eigen::VectorXd &  optVec,
const Eigen::VectorXd &  lambda 
)
inline

Evaluates the constraint Hessian.

Parameters
[in]optVecThe optimization variables
[in]lambdamultipliers for Hessian matrix
[out]hesThe cost Hessian matrix coefficients

References ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::constraints_, i, and ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::jColHessianStdVec_.

◆ getBounds()

template<typename SCALAR >
void ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::getBounds ( MapVecXs lowerBound,
MapVecXs upperBound 
)
inline

Retrieves the constraint bounds and writes them into the vectors used in the NLP.

Parameters
[out]lowerBoundThe lower constraint bound
[out]upperBoundThe lower constraint bound

References ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::constraints_.

Member Data Documentation

◆ constraints_

◆ iRowHessianStdVec_

template<typename SCALAR >
std::vector<int> ct::optcon::tpl::DiscreteConstraintContainerBase< SCALAR >::iRowHessianStdVec_
protected

◆ jColHessianStdVec_


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