Crocoddyl
ConstraintModelNumDiffTpl< _Scalar > Class Template Reference

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

#include <constraint.hpp>

Inheritance diagram for ConstraintModelNumDiffTpl< _Scalar >:
ConstraintModelAbstractTpl< _Scalar >

Public Types

typedef ConstraintModelAbstractTpl< Scalar > Base
 
typedef ConstraintDataAbstractTpl< Scalar > ConstraintDataAbstract
 
typedef ConstraintDataNumDiffTpl< Scalar > Data
 
typedef DataCollectorAbstractTpl< Scalar > DataCollectorAbstract
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef boost::function< void(const VectorXs &, const VectorXs &)> ReevaluationFunction
 
typedef MathBaseTpl< Scalar >::VectorXs VectorXs
 
- Public Types inherited from ConstraintModelAbstractTpl< _Scalar >
typedef ConstraintDataAbstractTpl< Scalar > ConstraintDataAbstract
 
typedef DataCollectorAbstractTpl< Scalar > DataCollectorAbstract
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef ResidualModelAbstractTpl< Scalar > ResidualModelAbstract
 
typedef StateAbstractTpl< Scalar > StateAbstract
 
typedef MathBase::VectorXs VectorXs
 

Public Member Functions

 ConstraintModelNumDiffTpl (const boost::shared_ptr< Base > &model)
 Initialize the numdiff constraint model. More...
 
virtual ~ConstraintModelNumDiffTpl ()
 Initialize the numdiff constraint model.
 
virtual void calc (const boost::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
virtual void calc (const boost::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the constraint value. More...
 
virtual void calcDiff (const boost::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
virtual void calcDiff (const boost::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the Jacobian of the constraint. More...
 
virtual boost::shared_ptr< ConstraintDataAbstractcreateData (DataCollectorAbstract *const data)
 Create the constraint data. More...
 
const Scalar get_disturbance () const
 Return the disturbance constant used by the numerical differentiation routine.
 
const boost::shared_ptr< Base > & get_model () const
 Return the original constraint model.
 
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. More...
 
- Public Member Functions inherited from ConstraintModelAbstractTpl< _Scalar >
 ConstraintModelAbstractTpl (boost::shared_ptr< StateAbstract > state, boost::shared_ptr< ResidualModelAbstract > residual, const std::size_t ng, const std::size_t nh)
 Initialize the constraint model. More...
 
 ConstraintModelAbstractTpl (boost::shared_ptr< StateAbstract > state, const std::size_t ng, const std::size_t nh)
 Initialize the constraint model. More...
 
 ConstraintModelAbstractTpl (boost::shared_ptr< StateAbstract > state, const std::size_t nu, const std::size_t ng, const std::size_t nh)
 the constraint model More...
 
const VectorXs & get_lb () const
 Return the lower bound of the constraint.
 
std::size_t get_ng () const
 Return the number of inequality constraints.
 
std::size_t get_nh () const
 Return the number of equality constraints.
 
std::size_t get_nu () const
 Return the dimension of the control input.
 
const boost::shared_ptr< ResidualModelAbstract > & get_residual () const
 Return the residual model.
 
const boost::shared_ptr< StateAbstract > & get_state () const
 Return the state.
 
ConstraintType get_type () const
 Return the type of constraint.
 
const VectorXs & get_ub () const
 Return the upper bound of the constraint.
 
virtual void print (std::ostream &os) const
 Print relevant information of the constraint model. More...
 
void remove_bounds ()
 Remove the bounds of the constraint.
 
void update_bounds (const VectorXs &lower, const VectorXs &upper)
 Update the lower and upper bounds the upper bound of constraint.
 

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
 
- Public Attributes inherited from ConstraintModelAbstractTpl< _Scalar >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
 

Protected Attributes

std::size_t nu_
 Control dimension.
 
boost::shared_ptr< StateAbstractstate_
 State description.
 
VectorXs unone_
 No control vector.
 
- Protected Attributes inherited from ConstraintModelAbstractTpl< _Scalar >
VectorXs lb_
 Lower bound of the constraint.
 
std::size_t ng_
 Number of inequality constraints.
 
std::size_t nh_
 Number of equality constraints.
 
std::size_t nu_
 Control dimension.
 
boost::shared_ptr< ResidualModelAbstractresidual_
 Residual model.
 
boost::shared_ptr< StateAbstractstate_
 State description.
 
ConstraintType type_
 Type of constraint: inequality=0, equality=1, both=2.
 
VectorXs ub_
 Upper bound of the constraint.
 
VectorXs unone_
 No control vector.
 

Detailed Description

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

This class computes the numerical differentiation of a constraint model.

It computes the Jacobian of the constraint model via numerical differentiation, i.e., \(\mathbf{g_x}\), \(\mathbf{g_u}\) and \(\mathbf{h_x}\), \(\mathbf{h_u}\), which denote the Jacobians of the inequality and equality constraints, respectively.

See also
ConstraintModelAbstractTpl(), calcDiff()

Definition at line 30 of file constraint.hpp.

Constructor & Destructor Documentation

◆ ConstraintModelNumDiffTpl()

ConstraintModelNumDiffTpl ( const boost::shared_ptr< Base > &  model)
explicit

Initialize the numdiff constraint model.

Parameters
model

Member Function Documentation

◆ calc() [1/2]

virtual void calc ( const boost::shared_ptr< ConstraintDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x,
const Eigen::Ref< const VectorXs > &  u 
)
virtual

Compute the constraint value.

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

Implements ConstraintModelAbstractTpl< _Scalar >.

◆ calc() [2/2]

virtual void calc ( const boost::shared_ptr< ConstraintDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x 
)
virtual

◆ calcDiff() [1/2]

virtual void calcDiff ( const boost::shared_ptr< ConstraintDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x,
const Eigen::Ref< const VectorXs > &  u 
)
virtual

Compute the Jacobian of the constraint.

It computes the Jacobian of the constraint function. It assumes that calc() has been run first.

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

Implements ConstraintModelAbstractTpl< _Scalar >.

◆ calcDiff() [2/2]

virtual void calcDiff ( const boost::shared_ptr< ConstraintDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x 
)
virtual

◆ createData()

virtual boost::shared_ptr<ConstraintDataAbstract> createData ( DataCollectorAbstract *const  data)
virtual

Create the constraint data.

The default data contains objects to store the values of the constraint, residual vector and their first derivatives. However, it is possible to specialize this function is we need to create additional data, for instance, to avoid dynamic memory allocation.

Parameters
dataData collector
Returns
the constraint data

Reimplemented from ConstraintModelAbstractTpl< _Scalar >.

◆ set_reevals()

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.

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