This class computes the numerical differentiation of a cost model. More...
#include <cost.hpp>
Public Types | |
| typedef CostModelAbstractTpl< Scalar > | Base |
| typedef CostDataAbstractTpl< Scalar > | CostDataAbstract |
| typedef CostDataNumDiffTpl< Scalar > | Data |
| typedef DataCollectorAbstractTpl< Scalar > | DataCollectorAbstract |
| typedef MathBaseTpl< Scalar > | MathBase |
| typedef MathBaseTpl< Scalar >::MatrixXs | MatrixXs |
| typedef boost::function< void(const VectorXs &, const VectorXs &)> | ReevaluationFunction |
| typedef MathBaseTpl< Scalar >::VectorXs | VectorXs |
| Public Types inherited from CostModelAbstractTpl< _Scalar > | |
| typedef ActivationModelAbstractTpl< Scalar > | ActivationModelAbstract |
| typedef ActivationModelQuadTpl< Scalar > | ActivationModelQuad |
| typedef CostDataAbstractTpl< Scalar > | CostDataAbstract |
| typedef DataCollectorAbstractTpl< Scalar > | DataCollectorAbstract |
| typedef MathBaseTpl< Scalar > | MathBase |
| typedef MathBase::MatrixXs | MatrixXs |
| typedef ResidualModelAbstractTpl< Scalar > | ResidualModelAbstract |
| typedef StateAbstractTpl< Scalar > | StateAbstract |
| typedef MathBase::VectorXs | VectorXs |
Public Member Functions | |
| CostModelNumDiffTpl (const std::shared_ptr< Base > &model) | |
| Initialize the numdiff cost model. | |
| virtual | ~CostModelNumDiffTpl ()=default |
| Initialize the numdiff cost model. | |
| virtual void | calc (const std::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) override |
| Compute the total cost value for nodes that depends only on the state. | |
| virtual void | calc (const std::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) override |
| Compute the cost value and its residual vector. | |
| virtual void | calcDiff (const std::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) override |
| Compute the Jacobian and Hessian of the cost functions with respect to the state only. | |
| virtual void | calcDiff (const std::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) override |
| Compute the Jacobian and Hessian of cost and its residual vector. | |
| template<typename NewScalar> | |
| CostModelNumDiffTpl< NewScalar > | cast () const |
| Cast the cost numdiff model to a different scalar type. | |
| virtual std::shared_ptr< CostDataAbstract > | createData (DataCollectorAbstract *const data) override |
| Create a numdiff cost data. | |
| const Scalar | get_disturbance () const |
| Return the disturbance constant used by the numerical differentiation routine. | |
| const std::shared_ptr< Base > & | get_model () const |
| Return the original cost model. | |
| bool | get_with_gauss_approx () |
| Identify if the Gauss approximation is going to be used or not. | |
| void | set_disturbance (const Scalar disturbance) |
| Modify the disturbance constant used by the numerical differentiation routine. | |
| void | set_reevals (const std::vector< ReevaluationFunction > &reevals) |
| Register functions that updates the shared data computed for a system rollout The updated data is used to evaluate of the gradient and Hessian. | |
| Public Member Functions inherited from CostModelAbstractTpl< _Scalar > | |
| CostModelAbstractTpl (std::shared_ptr< StateAbstract > state, const std::size_t nr) | |
| Initialize the cost model. | |
| CostModelAbstractTpl (std::shared_ptr< StateAbstract > state, const std::size_t nr, const std::size_t nu) | |
| Initialize the cost model. | |
| CostModelAbstractTpl (std::shared_ptr< StateAbstract > state, std::shared_ptr< ActivationModelAbstract > activation) | |
| Initialize the cost model. | |
| CostModelAbstractTpl (std::shared_ptr< StateAbstract > state, std::shared_ptr< ActivationModelAbstract > activation, const std::size_t nu) | |
| Initialize the cost model. | |
| CostModelAbstractTpl (std::shared_ptr< StateAbstract > state, std::shared_ptr< ActivationModelAbstract > activation, std::shared_ptr< ResidualModelAbstract > residual) | |
| Initialize the cost model. | |
| CostModelAbstractTpl (std::shared_ptr< StateAbstract > state, std::shared_ptr< ResidualModelAbstract > residual) | |
| Initialize the cost model. | |
| const std::shared_ptr< ActivationModelAbstract > & | get_activation () const |
| Return the activation model. | |
| std::size_t | get_nu () const |
| Return the dimension of the control input. | |
| template<class ReferenceType> | |
| ReferenceType | get_reference () |
| Return the cost reference. | |
| const std::shared_ptr< ResidualModelAbstract > & | get_residual () const |
| Return the residual model. | |
| const std::shared_ptr< StateAbstract > & | get_state () const |
| Return the state. | |
| virtual void | print (std::ostream &os) const |
| Print relevant information of the cost model. | |
| template<class ReferenceType> | |
| void | set_reference (ReferenceType ref) |
| Modify the cost reference. | |
Public Attributes | |
| EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar | Scalar |
| Public Attributes inherited from CostModelAbstractTpl< _Scalar > | |
| EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar | Scalar |
Protected Attributes | |
| std::shared_ptr< ActivationModelAbstract > | activation_ |
| Activation model. | |
| std::size_t | nu_ |
| Control dimension. | |
| std::shared_ptr< StateAbstract > | state_ |
| State description. | |
| VectorXs | unone_ |
| No control vector. | |
| Protected Attributes inherited from CostModelAbstractTpl< _Scalar > | |
| std::shared_ptr< ActivationModelAbstract > | activation_ |
| Activation model. | |
| std::size_t | nu_ |
| Control dimension. | |
| std::shared_ptr< ResidualModelAbstract > | residual_ |
| Residual model. | |
| std::shared_ptr< StateAbstract > | state_ |
| State description. | |
| VectorXs | unone_ |
| No control vector. | |
Additional Inherited Members | |
| Protected Member Functions inherited from CostModelAbstractTpl< _Scalar > | |
| virtual void | get_referenceImpl (const std::type_info &, void *) |
| Return the cost reference. | |
| virtual void | set_referenceImpl (const std::type_info &, const void *) |
| Modify the cost reference. | |
This class computes the numerical differentiation of a cost model.
It computes the Jacobian and Hessian of the cost model via numerical differentiation, i.e., 




| typedef CostDataAbstractTpl<Scalar> CostDataAbstract |
| typedef CostModelAbstractTpl<Scalar> Base |
| typedef CostDataNumDiffTpl<Scalar> Data |
| typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract |
| typedef MathBaseTpl<Scalar> MathBase |
| typedef MathBaseTpl<Scalar>::VectorXs VectorXs |
| typedef MathBaseTpl<Scalar>::MatrixXs MatrixXs |
| typedef boost::function<void(const VectorXs&, const VectorXs&)> ReevaluationFunction |
| explicit |
Initialize the numdiff cost model.
| model | Cost model that we want to apply the numerical differentiation |
| overridevirtual |
Compute the cost value and its residual vector.
| [in] | data | Cost data |
| [in] | x | State point ![]() |
| [in] | u | Control input ![]() |
Implements CostModelAbstractTpl< _Scalar >.
| overridevirtual |
Compute the total cost value for nodes that depends only on the state.
It updates the total cost based on the state only. This function is used in the terminal nodes of an optimal control problem.
| [in] | data | Cost data |
| [in] | x | State point ![]() |
Reimplemented from CostModelAbstractTpl< _Scalar >.
| overridevirtual |
Compute the Jacobian and Hessian of cost and its residual vector.
It computes the Jacobian and Hessian of the cost function. It assumes that calc() has been run first.
| [in] | data | Cost data |
| [in] | x | State point ![]() |
| [in] | u | Control input ![]() |
Implements CostModelAbstractTpl< _Scalar >.
| overridevirtual |
Compute the Jacobian and Hessian of the cost functions with respect to the state only.
It updates the Jacobian and Hessian of the cost function based on the state only. This function is used in the terminal nodes of an optimal control problem.
| [in] | data | Cost data |
| [in] | x | State point ![]() |
Reimplemented from CostModelAbstractTpl< _Scalar >.
| overridevirtual |
Create a numdiff cost data.
| data | Data collector used by the original model |
Reimplemented from CostModelAbstractTpl< _Scalar >.
Cast the cost numdiff model to a different scalar type.
It is useful for operations requiring different precision or scalar types.
| NewScalar | The new scalar type to cast to. |
| bool get_with_gauss_approx | ( | ) |
Identify if the Gauss approximation is going to be used or not.
| void set_reevals | ( | const std::vector< ReevaluationFunction > & | reevals | ) |
Register functions that updates the shared data computed for a system rollout The updated data is used to evaluate of the gradient and Hessian.
| reevals | are the registered functions. |
| EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar |
| protected |
Activation model.
Definition at line 276 of file cost-base.hpp.
| protected |
Control dimension.
Definition at line 278 of file cost-base.hpp.
| protected |
State description.
Definition at line 275 of file cost-base.hpp.
| protected |
No control vector.
Definition at line 279 of file cost-base.hpp.