Template Class CostModelNumDiffTpl
Defined in File cost.hpp
Inheritance Relationships
Base Type
public crocoddyl::CostModelAbstractTpl< _Scalar >(Template Class CostModelAbstractTpl)
Class Documentation
-
template<typename _Scalar>
class CostModelNumDiffTpl : public crocoddyl::CostModelAbstractTpl<_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
Public Types
-
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
Public Functions
Initialize the numdiff cost model.
- Parameters:
model – Cost model that we want to apply the numerical differentiation
-
virtual ~CostModelNumDiffTpl() = default
Initialize the numdiff cost model.
Compute the cost value and its residual vector.
- Parameters:
data – [in] Cost data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
u – [in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)
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.
- Parameters:
data – [in] Cost data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
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:
data – [in] Cost data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
u – [in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)
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.
- Parameters:
data – [in] Cost data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
-
virtual std::shared_ptr<CostDataAbstract> createData(DataCollectorAbstract *const data) override
Create a numdiff cost data.
- Parameters:
data – Data collector used by the original model
- Returns:
the numdiff cost data
-
template<typename NewScalar>
CostModelNumDiffTpl<NewScalar> cast() const Cast the cost numdiff model to a different scalar type.
It is useful for operations requiring different precision or scalar types.
- Template Parameters:
NewScalar – The new scalar type to cast to.
- Returns:
CostModelNumDiffTpl<NewScalar> A cost model with the new scalar type.
-
const Scalar get_disturbance() const
Return the disturbance constant used by the numerical differentiation routine.
-
void set_disturbance(const Scalar disturbance)
Modify the disturbance constant used by the numerical differentiation routine.
-
bool get_with_gauss_approx()
Identify if the Gauss approximation is going to be used or not.
- Returns:
true
- Returns:
false
-
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:
reevals – are the registered functions.
Public Members
- 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.
-
typedef CostDataAbstractTpl<Scalar> CostDataAbstract