This class computes the numerical differentiation of a constraint model. More...
#include <constraint.hpp>
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 std::shared_ptr< Base > &model) | |
| Initialize the numdiff constraint model. | |
| virtual | ~ConstraintModelNumDiffTpl ()=default |
| Initialize the numdiff constraint model. | |
| virtual void | calc (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) override |
| virtual void | calc (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) override |
| Compute the constraint value. | |
| virtual void | calcDiff (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) override |
| virtual void | calcDiff (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) override |
| Compute the Jacobian of the constraint. | |
| template<typename NewScalar > | |
| ConstraintModelNumDiffTpl< NewScalar > | cast () const |
| Cast the constraint numdiff model to a different scalar type. | |
| virtual std::shared_ptr< ConstraintDataAbstract > | createData (DataCollectorAbstract *const data) override |
| Create the constraint 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 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. | |
Public Member Functions inherited from ConstraintModelAbstractTpl< _Scalar > | |
| ConstraintModelAbstractTpl (std::shared_ptr< StateAbstract > state, const std::size_t ng, const std::size_t nh, const bool T_const=true) | |
| ConstraintModelAbstractTpl (std::shared_ptr< StateAbstract > state, const std::size_t nu, const std::size_t ng, const std::size_t nh, const bool T_const=true) | |
| the constraint model | |
| ConstraintModelAbstractTpl (std::shared_ptr< StateAbstract > state, std::shared_ptr< ResidualModelAbstract > residual, const std::size_t ng, const std::size_t nh) | |
| Initialize the constraint model. | |
| virtual void | calc (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) |
| Compute the constraint value for nodes that depends only on the state. | |
| virtual void | calc (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0 |
| Compute the constraint value. | |
| virtual void | calcDiff (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) |
| Compute the Jacobian of the constraint with respect to the state only. | |
| virtual void | calcDiff (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0 |
| Compute the Jacobian of the constraint. | |
| 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 std::shared_ptr< ResidualModelAbstract > & | get_residual () const |
| Return the residual model. | |
| const std::shared_ptr< StateAbstract > & | get_state () const |
| Return the state. | |
| bool | get_T_constraint () const |
| Return true if the constraint is imposed in terminal nodes as well. | |
| 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. | |
| 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. | |
| std::shared_ptr< StateAbstract > | state_ |
| 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. | |
| std::shared_ptr< ResidualModelAbstract > | residual_ |
| Residual model. | |
| std::shared_ptr< StateAbstract > | state_ |
| State description. | |
| bool | T_constraint_ |
| ConstraintType | type_ |
| Type of constraint: inequality=0, equality=1, both=2. | |
| VectorXs | ub_ |
| Upper bound of the constraint. | |
| VectorXs | unone_ |
| No control vector. | |
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.
ConstraintModelAbstractTpl(), calcDiff() Definition at line 30 of file constraint.hpp.
| typedef ConstraintDataAbstractTpl<Scalar> ConstraintDataAbstract |
Definition at line 36 of file constraint.hpp.
| typedef ConstraintModelAbstractTpl<Scalar> Base |
Definition at line 37 of file constraint.hpp.
| typedef ConstraintDataNumDiffTpl<Scalar> Data |
Definition at line 38 of file constraint.hpp.
| typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract |
Definition at line 39 of file constraint.hpp.
| typedef MathBaseTpl<Scalar> MathBase |
Definition at line 40 of file constraint.hpp.
| typedef MathBaseTpl<Scalar>::VectorXs VectorXs |
Definition at line 41 of file constraint.hpp.
| typedef boost::function<void(const VectorXs&, const VectorXs&)> ReevaluationFunction |
Definition at line 43 of file constraint.hpp.
|
explicit |
Initialize the numdiff constraint model.
| model |
|
overridevirtual |
Compute the constraint value.
| [in] | data | Constraint data |
| [in] | x | State point \(\mathbf{x}\in\mathbb{R}^{ndx}\) |
| [in] | u | Control input \(\mathbf{u}\in\mathbb{R}^{nu}\) |
|
overridevirtual |
|
overridevirtual |
Compute the Jacobian of the constraint.
It computes the Jacobian of the constraint function. It assumes that calc() has been run first.
| [in] | data | Constraint data |
| [in] | x | State point \(\mathbf{x}\in\mathbb{R}^{ndx}\) |
| [in] | u | Control input \(\mathbf{u}\in\mathbb{R}^{nu}\) |
|
overridevirtual |
|
overridevirtual |
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.
| data | Data collector |
Reimplemented from ConstraintModelAbstractTpl< _Scalar >.
| ConstraintModelNumDiffTpl< NewScalar > cast | ( | ) | const |
Cast the constraint 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. |
| 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 |
Definition at line 35 of file constraint.hpp.
|
protected |
Control dimension.
Definition at line 258 of file constraint-base.hpp.
|
protected |
State description.
Definition at line 252 of file constraint-base.hpp.
|
protected |
No control vector.
Definition at line 263 of file constraint-base.hpp.