- 3.0.2 optimal control module.
ExampleCostEvaluator< SCALAR > Class Template Referencefinal

This class implements the cost function and its gradient. More...

Inheritance diagram for ExampleCostEvaluator< SCALAR >:
ct::optcon::tpl::DiscreteCostEvaluatorBase< SCALAR > ct::optcon::tpl::DiscreteCostEvaluatorBase< SCALAR >

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW ExampleCostEvaluator (std::shared_ptr< tpl::OptVector< SCALAR >> optVector)
 
 ~ExampleCostEvaluator () override=default
 
SCALAR eval () override
 Evaluates the cost function. More...
 
void evalGradient (size_t grad_length, Eigen::Map< Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 >> &grad) override
 Evaluates the cost gradient. More...
 
void getSparsityPatternHessian (Eigen::VectorXi &iRow, Eigen::VectorXi &jCol) override
 
void sparseHessianValues (const Eigen::VectorXd &optVec, const Eigen::VectorXd &lambda, Eigen::VectorXd &hes) override
 Evaluates the cost hessian. More...
 
 ExampleCostEvaluator (std::shared_ptr< tpl::OptVector< SCALAR >> optVector)
 number non-zero elements in the hessian (triangular view) More...
 
 ~ExampleCostEvaluator () override=default
 
SCALAR eval () override
 Evaluates the cost function. More...
 
void evalGradient (size_t grad_length, Eigen::Map< Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 >> &grad) override
 Evaluates the cost gradient. More...
 
void getSparsityPatternHessian (Eigen::VectorXi &iRow, Eigen::VectorXi &jCol) override
 
void sparseHessianValues (const Eigen::VectorXd &optVec, const Eigen::VectorXd &lambda, Eigen::VectorXd &hes) override
 
- Public Member Functions inherited from ct::optcon::tpl::DiscreteCostEvaluatorBase< SCALAR >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DiscreteCostEvaluatorBase ()=default
 Default constructor. More...
 
virtual ~DiscreteCostEvaluatorBase ()=default
 Destructor. More...
 

Static Public Attributes

static EIGEN_MAKE_ALIGNED_OPERATOR_NEW const size_t nnz_hessian = 2
 

Detailed Description

template<typename SCALAR>
class ExampleCostEvaluator< SCALAR >

This class implements the cost function and its gradient.

Template Parameters
SCALARScalar type

Constructor & Destructor Documentation

◆ ExampleCostEvaluator() [1/2]

template<typename SCALAR >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ExampleCostEvaluator< SCALAR >::ExampleCostEvaluator ( std::shared_ptr< tpl::OptVector< SCALAR >>  optVector)
inline

◆ ~ExampleCostEvaluator() [1/2]

template<typename SCALAR >
ExampleCostEvaluator< SCALAR >::~ExampleCostEvaluator ( )
overridedefault

◆ ExampleCostEvaluator() [2/2]

template<typename SCALAR >
ExampleCostEvaluator< SCALAR >::ExampleCostEvaluator ( std::shared_ptr< tpl::OptVector< SCALAR >>  optVector)
inline

number non-zero elements in the hessian (triangular view)

◆ ~ExampleCostEvaluator() [2/2]

template<typename SCALAR >
ExampleCostEvaluator< SCALAR >::~ExampleCostEvaluator ( )
overridedefault

Member Function Documentation

◆ eval() [1/2]

template<typename SCALAR >
SCALAR ExampleCostEvaluator< SCALAR >::eval ( )
inlineoverridevirtual

Evaluates the cost function.

Returns
The evaluates cost function

Implements ct::optcon::tpl::DiscreteCostEvaluatorBase< SCALAR >.

◆ evalGradient() [1/2]

template<typename SCALAR >
void ExampleCostEvaluator< SCALAR >::evalGradient ( size_t  grad_length,
Eigen::Map< Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 >> &  grad 
)
inlineoverridevirtual

Evaluates the cost gradient.

Parameters
[in]grad_lengthThe size of the gradient vector
[out]gradThe values of the gradient

Implements ct::optcon::tpl::DiscreteCostEvaluatorBase< SCALAR >.

◆ getSparsityPatternHessian() [1/2]

template<typename SCALAR >
void ExampleCostEvaluator< SCALAR >::getSparsityPatternHessian ( Eigen::VectorXi &  iRow,
Eigen::VectorXi &  jCol 
)
inlineoverridevirtual

◆ sparseHessianValues() [1/2]

template<typename SCALAR >
void ExampleCostEvaluator< SCALAR >::sparseHessianValues ( const Eigen::VectorXd &  optVec,
const Eigen::VectorXd &  lambda,
Eigen::VectorXd &  hes 
)
inlineoverridevirtual

Evaluates the cost hessian.

Parameters
[in]optVecThe optimization variables
[in]lambdamultipliers for hessian matrix
[out]hesThe cost hessian matrix coeff

Reimplemented from ct::optcon::tpl::DiscreteCostEvaluatorBase< SCALAR >.

◆ eval() [2/2]

template<typename SCALAR >
SCALAR ExampleCostEvaluator< SCALAR >::eval ( )
inlineoverridevirtual

Evaluates the cost function.

Returns
The evaluates cost function

Implements ct::optcon::tpl::DiscreteCostEvaluatorBase< SCALAR >.

◆ evalGradient() [2/2]

template<typename SCALAR >
void ExampleCostEvaluator< SCALAR >::evalGradient ( size_t  grad_length,
Eigen::Map< Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 >> &  grad 
)
inlineoverridevirtual

Evaluates the cost gradient.

Parameters
[in]grad_lengthThe size of the gradient vector
[out]gradThe values of the gradient

Implements ct::optcon::tpl::DiscreteCostEvaluatorBase< SCALAR >.

◆ getSparsityPatternHessian() [2/2]

template<typename SCALAR >
void ExampleCostEvaluator< SCALAR >::getSparsityPatternHessian ( Eigen::VectorXi &  iRow,
Eigen::VectorXi &  jCol 
)
inlineoverridevirtual
Note
this function implementation is only required for the exact-Hessian solver case
we only implement the lower-triangular part of the sparsity pattern

Reimplemented from ct::optcon::tpl::DiscreteCostEvaluatorBase< SCALAR >.

◆ sparseHessianValues() [2/2]

template<typename SCALAR >
void ExampleCostEvaluator< SCALAR >::sparseHessianValues ( const Eigen::VectorXd &  optVec,
const Eigen::VectorXd &  lambda,
Eigen::VectorXd &  hes 
)
inlineoverridevirtual
Note
this function implementation is only required for the exact-Hessian solver case

Reimplemented from ct::optcon::tpl::DiscreteCostEvaluatorBase< SCALAR >.

Member Data Documentation

◆ nnz_hessian

template<typename SCALAR >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW const size_t ExampleCostEvaluator< SCALAR >::nnz_hessian = 2
static

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