Template Class ConstraintModelManagerTpl
Defined in File constraint-manager.hpp
Class Documentation
-
template<typename _Scalar>
class ConstraintModelManagerTpl Manage the individual constraint models.
This class serves to manage a set of added constraint models. The constraint functions might active or inactive, with this approach we avoid dynamic allocation of memory. Each constraint model is added through
addConstraint, where its status can be defined.The main computations are carring out in
calcandcalcDiffroutines.calccomputes the constraint residuals andcalcDiffcomputes the Jacobians of the constraint functions. Concretely speaking,calcDiffbuilds a linear approximation of the total constraint function (both inequality and equality) with the form: \(\mathbf{g_u}\in\mathbb{R}^{ng\times nu}\), \(\mathbf{h_x}\in\mathbb{R}^{nh\times ndx}\) \(\mathbf{h_u}\in\mathbb{R}^{nh\times nu}\).See also
Public Types
-
typedef MathBaseTpl<Scalar> MathBase
-
typedef ConstraintDataManagerTpl<Scalar> ConstraintDataManager
-
typedef StateAbstractTpl<Scalar> StateAbstract
-
typedef ConstraintModelAbstractTpl<Scalar> ConstraintModelAbstract
-
typedef ConstraintDataAbstractTpl<Scalar> ConstraintDataAbstract
-
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract
-
typedef ConstraintItemTpl<Scalar> ConstraintItem
-
typedef std::map<std::string, std::shared_ptr<ConstraintItem>> ConstraintModelContainer
-
typedef std::map<std::string, std::shared_ptr<ConstraintDataAbstract>> ConstraintDataContainer
Public Functions
Initialize the constraint-manager model.
- Parameters:
state – [in] State of the multibody system
nu – [in] Dimension of control vector
Initialize the constraint-manager model.
The default
nuvalue is obtained fromStateAbstractTpl::get_nv().- Parameters:
state – [in] State of the multibody system
-
~ConstraintModelManagerTpl()
Add a constraint item.
- Parameters:
name – [in] Constraint name
constraint – [in] Constraint model
weight – [in] Constraint weight
active – [in] True if the constraint is activated (default true)
-
void removeConstraint(const std::string &name)
Remove a constraint item.
- Parameters:
name – [in] Constraint name
-
void changeConstraintStatus(const std::string &name, bool active)
Change the constraint status.
- Parameters:
name – [in] Constraint name
active – [in] Constraint status (true for active and false for inactive)
Compute the total constraint value.
- Parameters:
data – [in] Constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
u – [in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)
Compute the total constraint value for nodes that depends only on the state.
It updates the constraint based on the state only. This function is commonly used in the terminal nodes of an optimal control problem.
- Parameters:
data – [in] Constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
Compute the Jacobian of the total constraint.
- Parameters:
data – [in] Constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
u – [in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)
Compute the Jacobian of the total constraint with respect to the state only.
It computes the Jacobian of the constraint function based on the state only. This function is commonly used in the terminal nodes of an optimal control problem.
- Parameters:
data – [in] Constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
-
std::shared_ptr<ConstraintDataManager> createData(DataCollectorAbstract *const data)
Create the constraint data.
The default data contains objects to store the values of the constraint and their derivatives (i.e. Jacobians). However, it is possible to specialize this function is we need to create additional data, for instance, to avoid dynamic memory allocation.
- Parameters:
data – Data collector
- Returns:
the constraint data
-
template<typename NewScalar>
ConstraintModelManagerTpl<NewScalar> cast() const Cast the constraint-manager 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:
ConstraintModelManagerTpl<NewScalar> A constraint-manager model with the new scalar type.
-
const std::shared_ptr<StateAbstract> &get_state() const
Return the state.
-
const ConstraintModelContainer &get_constraints() const
Return the stack of constraint models.
-
std::size_t get_nu() const
Return the dimension of the control input.
-
std::size_t get_ng() const
Return the number of active inequality constraints.
-
std::size_t get_nh() const
Return the number of active equality constraints.
-
std::size_t get_ng_T() const
Return the number of active inequality terminal constraints.
-
std::size_t get_nh_T() const
Return the number of active equality terminal constraints.
-
const std::set<std::string> &get_active_set() const
Return the names of the set of active constraints.
-
const std::set<std::string> &get_inactive_set() const
Return the names of the set of inactive constraints.
-
bool getConstraintStatus(const std::string &name) const
Return the status of a given constraint name.
- Parameters:
name – [in] Constraint name
Public Members
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
Friends
-
template<class Scalar>
friend std::ostream &operator<<(std::ostream &os, const ConstraintModelManagerTpl<Scalar> &model) Print information on the stack of constraints.
-
typedef MathBaseTpl<Scalar> MathBase