Crocoddyl
 
Loading...
Searching...
No Matches
CostModelNumDiffTpl< _Scalar > Class Template Reference

This class computes the numerical differentiation of a cost model. More...

#include <cost.hpp>

Inheritance diagram for CostModelNumDiffTpl< _Scalar >:
CostModelAbstractTpl< _Scalar >

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 ()
 Initialize the numdiff cost model.
 
virtual void calc (const std::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
virtual void calc (const std::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the cost value and its residual vector.
 
virtual void calcDiff (const std::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
virtual void calcDiff (const std::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the Jacobian and Hessian of cost and its residual vector.
 
virtual std::shared_ptr< CostDataAbstractcreateData (DataCollectorAbstract *const data)
 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)
 
 CostModelAbstractTpl (std::shared_ptr< StateAbstract > state, const std::size_t nr, const std::size_t nu)
 
 CostModelAbstractTpl (std::shared_ptr< StateAbstract > state, std::shared_ptr< ActivationModelAbstract > activation)
 
 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)
 
virtual void calc (const std::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 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)=0
 Compute the cost value and its residual vector.
 
virtual void calcDiff (const std::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 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)=0
 Compute the Jacobian and Hessian of cost and its residual vector.
 
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< ActivationModelAbstractactivation_
 Activation model.
 
std::size_t nu_
 Control dimension.
 
std::shared_ptr< StateAbstractstate_
 State description.
 
VectorXs unone_
 No control vector.
 
- Protected Attributes inherited from CostModelAbstractTpl< _Scalar >
std::shared_ptr< ActivationModelAbstractactivation_
 Activation model.
 
std::size_t nu_
 Control dimension.
 
std::shared_ptr< ResidualModelAbstractresidual_
 Residual model.
 
std::shared_ptr< StateAbstractstate_
 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.
 

Detailed Description

template<typename _Scalar>
class crocoddyl::CostModelNumDiffTpl< _Scalar >

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., \(\mathbf{\ell_x}\), \(\mathbf{\ell_u}\), \(\mathbf{\ell_{xx}}\), \(\mathbf{\ell_{uu}}\), and \(\mathbf{\ell_{xu}}\) which denote the Jacobians and Hessians of the cost function, respectively.

See also
CostModelAbstractTpl(), calcDiff()

Definition at line 34 of file cost.hpp.

Member Typedef Documentation

◆ CostDataAbstract

template<typename _Scalar >
typedef CostDataAbstractTpl<Scalar> CostDataAbstract

Definition at line 39 of file cost.hpp.

◆ Base

template<typename _Scalar >
typedef CostModelAbstractTpl<Scalar> Base

Definition at line 40 of file cost.hpp.

◆ Data

template<typename _Scalar >
typedef CostDataNumDiffTpl<Scalar> Data

Definition at line 41 of file cost.hpp.

◆ DataCollectorAbstract

template<typename _Scalar >
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract

Definition at line 42 of file cost.hpp.

◆ MathBase

template<typename _Scalar >
typedef MathBaseTpl<Scalar> MathBase

Definition at line 43 of file cost.hpp.

◆ VectorXs

template<typename _Scalar >
typedef MathBaseTpl<Scalar>::VectorXs VectorXs

Definition at line 44 of file cost.hpp.

◆ MatrixXs

template<typename _Scalar >
typedef MathBaseTpl<Scalar>::MatrixXs MatrixXs

Definition at line 45 of file cost.hpp.

◆ ReevaluationFunction

template<typename _Scalar >
typedef boost::function<void(const VectorXs&, const VectorXs&)> ReevaluationFunction

Definition at line 47 of file cost.hpp.

Constructor & Destructor Documentation

◆ CostModelNumDiffTpl()

template<typename _Scalar >
CostModelNumDiffTpl ( const std::shared_ptr< Base > &  model)
explicit

Initialize the numdiff cost model.

Parameters
modelCost model that we want to apply the numerical differentiation

Member Function Documentation

◆ calc() [1/2]

template<typename _Scalar >
virtual void calc ( const std::shared_ptr< CostDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x,
const Eigen::Ref< const VectorXs > &  u 
)
virtual

Compute the cost value and its residual vector.

Parameters
[in]dataCost data
[in]xState point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
[in]uControl input \(\mathbf{u}\in\mathbb{R}^{nu}\)

◆ calc() [2/2]

template<typename _Scalar >
virtual void calc ( const std::shared_ptr< CostDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x 
)
virtual

◆ calcDiff() [1/2]

template<typename _Scalar >
virtual void calcDiff ( const std::shared_ptr< CostDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x,
const Eigen::Ref< const VectorXs > &  u 
)
virtual

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.

Parameters
[in]dataCost data
[in]xState point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
[in]uControl input \(\mathbf{u}\in\mathbb{R}^{nu}\)

◆ calcDiff() [2/2]

template<typename _Scalar >
virtual void calcDiff ( const std::shared_ptr< CostDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x 
)
virtual

◆ createData()

template<typename _Scalar >
virtual std::shared_ptr< CostDataAbstract > createData ( DataCollectorAbstract *const  data)
virtual

Create a numdiff cost data.

Parameters
dataData collector used by the original model
Returns
the numdiff cost data

Reimplemented from CostModelAbstractTpl< _Scalar >.

◆ get_with_gauss_approx()

template<typename _Scalar >
bool get_with_gauss_approx ( )

Identify if the Gauss approximation is going to be used or not.

Returns
true
false

◆ set_reevals()

template<typename _Scalar >
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.

Parameters
reevalsare the registered functions.

Member Data Documentation

◆ Scalar

template<typename _Scalar >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Definition at line 38 of file cost.hpp.

◆ activation_

template<typename _Scalar >
std::shared_ptr<ActivationModelAbstract> activation_
protected

Activation model.

Definition at line 271 of file cost-base.hpp.

◆ nu_

template<typename _Scalar >
std::size_t nu_
protected

Control dimension.

Definition at line 273 of file cost-base.hpp.

◆ state_

template<typename _Scalar >
std::shared_ptr<StateAbstract> state_
protected

State description.

Definition at line 270 of file cost-base.hpp.

◆ unone_

template<typename _Scalar >
VectorXs unone_
protected

No control vector.

Definition at line 274 of file cost-base.hpp.


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