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

Implements an abstract base class from which all the discrete custom NLP constraints should derive. More...

#include <DiscreteConstraintBase.h>

Inheritance diagram for ct::optcon::tpl::DiscreteConstraintBase< SCALAR >:
ct::optcon::ConstraintDiscretizer< STATE_DIM, CONTROL_DIM, SCALAR > ct::optcon::ContinuityConstraint< STATE_DIM, CONTROL_DIM, SCALAR > ct::optcon::InitStateConstraint< STATE_DIM, CONTROL_DIM, SCALAR > ExampleConstraints< SCALAR > ExampleConstraints< SCALAR >

Public Types

using VectorXs = Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 >
 

Public Member Functions

 DiscreteConstraintBase ()=default
 Default constructor. More...
 
virtual ~DiscreteConstraintBase ()=default
 Destructor. More...
 
virtual VectorXs eval ()=0
 Evaluates the constraint violation. More...
 
virtual VectorXs evalSparseJacobian ()=0
 Returns the non zero elements of the eval method with respect to the optimization variables. More...
 
virtual size_t getConstraintSize ()=0
 Returns size of the constraint vector. More...
 
virtual size_t getNumNonZerosJacobian ()=0
 Returns the number of non zero elements of the jacobian. More...
 
virtual void genSparsityPattern (Eigen::VectorXi &iRow_vec, Eigen::VectorXi &jCol_vec)=0
 Returns the sparsity structure of the constraint jacobian. More...
 
virtual void genSparsityPatternHessian (Eigen::VectorXi &iRow_vec, Eigen::VectorXi &jCol_vec)
 Returns the sparsity structure of the constraint hessian. More...
 
virtual void sparseHessianValues (const Eigen::VectorXd &optVec, const Eigen::VectorXd &lambda, Eigen::VectorXd &sparseHes)
 Returns the non zero elements (values) of the Hessian matrix of this constraint. More...
 
virtual VectorXs getLowerBound ()=0
 Returns the lower bound of the constraint. More...
 
virtual VectorXs getUpperBound ()=0
 Returns the upper bound of the constraint. More...
 
Eigen::VectorXi & iRowHessian ()
 
Eigen::VectorXi & jColHessian ()
 

Protected Member Functions

size_t genDiagonalIndices (const size_t col_start, const size_t num_elements, Eigen::VectorXi &iRow_vec, Eigen::VectorXi &jCol_vec, const size_t indexNumber)
 This method generates Row and Column vectors which indicate the sparsity pattern of the constraint jacobian for a quadratic matrix block containing diagonal entries only. More...
 
size_t genBlockIndices (const size_t col_start, const size_t num_rows, const size_t num_cols, Eigen::VectorXi &iRow_vec, Eigen::VectorXi &jCol_vec, const size_t indexNumber)
 This method generates Row and Column vectors which indicate the sparsity pattern of the constraint jacobian for an arbitrary dense matrix block. More...
 

Protected Attributes

Eigen::VectorXi iRowHessian_
 
Eigen::VectorXi jColHessian_
 

Detailed Description

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

Implements an abstract base class from which all the discrete custom NLP constraints should derive.

Member Typedef Documentation

◆ VectorXs

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

Constructor & Destructor Documentation

◆ DiscreteConstraintBase()

template<typename SCALAR >
ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::DiscreteConstraintBase ( )
default

Default constructor.

◆ ~DiscreteConstraintBase()

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

Destructor.

Member Function Documentation

◆ eval()

◆ evalSparseJacobian()

template<typename SCALAR >
virtual VectorXs ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::evalSparseJacobian ( )
pure virtual

Returns the non zero elements of the eval method with respect to the optimization variables.

Returns
A vector of the non zero elements of the constraint jacobian

Implemented in ct::optcon::ConstraintDiscretizer< STATE_DIM, CONTROL_DIM, SCALAR >, ct::optcon::ContinuityConstraint< STATE_DIM, CONTROL_DIM, SCALAR >, ExampleConstraints< SCALAR >, ExampleConstraints< SCALAR >, and ct::optcon::InitStateConstraint< STATE_DIM, CONTROL_DIM, SCALAR >.

◆ getConstraintSize()

template<typename SCALAR >
virtual size_t ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::getConstraintSize ( )
pure virtual

Returns size of the constraint vector.

Returns
The size of the constraint vector (should be equal to the size of the return value of the eval method)

Implemented in ct::optcon::ConstraintDiscretizer< STATE_DIM, CONTROL_DIM, SCALAR >, ct::optcon::ContinuityConstraint< STATE_DIM, CONTROL_DIM, SCALAR >, ExampleConstraints< SCALAR >, ExampleConstraints< SCALAR >, and ct::optcon::InitStateConstraint< STATE_DIM, CONTROL_DIM, SCALAR >.

◆ getNumNonZerosJacobian()

template<typename SCALAR >
virtual size_t ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::getNumNonZerosJacobian ( )
pure virtual

Returns the number of non zero elements of the jacobian.

Returns
The number of non zero elements of the jacobian (which should be equal to the return value of evalSparseJacobian)

Implemented in ct::optcon::ConstraintDiscretizer< STATE_DIM, CONTROL_DIM, SCALAR >, ct::optcon::ContinuityConstraint< STATE_DIM, CONTROL_DIM, SCALAR >, ExampleConstraints< SCALAR >, ExampleConstraints< SCALAR >, and ct::optcon::InitStateConstraint< STATE_DIM, CONTROL_DIM, SCALAR >.

◆ genSparsityPattern()

template<typename SCALAR >
virtual void ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::genSparsityPattern ( Eigen::VectorXi &  iRow_vec,
Eigen::VectorXi &  jCol_vec 
)
pure virtual

Returns the sparsity structure of the constraint jacobian.

Parameters
[out]iRow_vecA vector containing the row indices of the non zero elements of the constraint jacobian
[out]jCol_vecA vector containing the column indices of the non zero elements of the constraint jacobian

Implemented in ct::optcon::ConstraintDiscretizer< STATE_DIM, CONTROL_DIM, SCALAR >, ct::optcon::ContinuityConstraint< STATE_DIM, CONTROL_DIM, SCALAR >, ExampleConstraints< SCALAR >, ExampleConstraints< SCALAR >, and ct::optcon::InitStateConstraint< STATE_DIM, CONTROL_DIM, SCALAR >.

◆ genSparsityPatternHessian()

template<typename SCALAR >
virtual void ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::genSparsityPatternHessian ( Eigen::VectorXi &  iRow_vec,
Eigen::VectorXi &  jCol_vec 
)
inlinevirtual

Returns the sparsity structure of the constraint hessian.

Parameters
[out]iRow_vecA vector containing the row indices of the non zero elements of the constraint hessian
[out]jCol_vecA vector containing the column indices of the non zero elements of the constraint hessian

Reimplemented in ExampleConstraints< SCALAR >, and ExampleConstraints< SCALAR >.

◆ sparseHessianValues()

template<typename SCALAR >
virtual void ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::sparseHessianValues ( const Eigen::VectorXd &  optVec,
const Eigen::VectorXd &  lambda,
Eigen::VectorXd &  sparseHes 
)
inlinevirtual

Returns the non zero elements (values) of the Hessian matrix of this constraint.

Parameters
[in]optVecA vector holding the current optimization variable vector
[in]lambdaA vector holding the current constraint multipliers (one scalar for each row of constraints)
[out]sparseHesThe sparse hessian values

Reimplemented in ExampleConstraints< SCALAR >, and ExampleConstraints< SCALAR >.

References ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::getLowerBound(), and ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::getUpperBound().

◆ getLowerBound()

◆ getUpperBound()

◆ iRowHessian()

template<typename SCALAR >
Eigen::VectorXi& ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::iRowHessian ( )
inline

◆ jColHessian()

◆ genDiagonalIndices()

template<typename SCALAR >
size_t DiscreteConstraintBase::genDiagonalIndices ( const size_t  col_start,
const size_t  num_elements,
Eigen::VectorXi &  iRow_vec,
Eigen::VectorXi &  jCol_vec,
const size_t  indexNumber 
)
inlineprotected

This method generates Row and Column vectors which indicate the sparsity pattern of the constraint jacobian for a quadratic matrix block containing diagonal entries only.

Parameters
[in]col_startThe starting column of the jCol vec
[in]num_elementsThe size of the matrix block
[out]iRow_vecThe resulting row vector
[out]jCol_vecThe resuling column vector
[in]indexNumberThe starting inserting index for iRow and jCol
Returns
indexnumber plus num_elements

References i.

Referenced by ct::optcon::InitStateConstraint< STATE_DIM, CONTROL_DIM, SCALAR >::genSparsityPattern(), and ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::jColHessian().

◆ genBlockIndices()

template<typename SCALAR >
size_t DiscreteConstraintBase::genBlockIndices ( const size_t  col_start,
const size_t  num_rows,
const size_t  num_cols,
Eigen::VectorXi &  iRow_vec,
Eigen::VectorXi &  jCol_vec,
const size_t  indexNumber 
)
inlineprotected

This method generates Row and Column vectors which indicate the sparsity pattern of the constraint jacobian for an arbitrary dense matrix block.

Parameters
[in]col_startThe starting column of the jCol vec
[in]num_rowsThe number of rows of the matrix block
[in]num_colsThe number of columns of the matrix block
[out]iRow_vecThe resulting row vector
[out]jCol_vecThe resuling column vector
[in]indexNumberThe starting inserting index for iRow and jCol
Returns
The indexnumber plus the number of elements contained in the matrix block

Referenced by ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::jColHessian().

Member Data Documentation

◆ iRowHessian_

template<typename SCALAR >
Eigen::VectorXi ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::iRowHessian_
protected

◆ jColHessian_

template<typename SCALAR >
Eigen::VectorXi ct::optcon::tpl::DiscreteConstraintBase< SCALAR >::jColHessian_
protected

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