This class is a factory class to generate SystemConstraintWrapper.
Namely this class helps to convert a SystemConstraint to a solvers::Constraint. Internally this class will convert a System<double> to System<AutoDiffXd> (and System<symbolic::Expression> if possible), and store these systems (of different scalar types) inside this class. Using this class with a system that cannot be converted to System<AutoDiffXd> will cause a runtime error.
#include <drake/systems/optimization/system_constraint_adapter.h>
◆ SystemConstraintAdapter() [1/3]
◆ SystemConstraintAdapter() [2/3]
◆ SystemConstraintAdapter() [3/3]
◆ Create()
template<typename UpdateContextFromDecisionVariablesGenericFunction>
This method creates a solvers::Constraint from a SystemConstraint.
The newly created constraint represents lower <= system_constraint.Calc(UpdateContextFromDecisionVariablesGeneric(x)) <= upper, where lower and upper are obtained from SystemConstraint::lower_bound() and SystemConstraint::upper_bound().
- Parameters
-
| index | The index of the constraint stored inside system in the class constructor. |
| context | SystemConstraint::Calc function requires a context as the input. On the other hand, the generated constraint might be imposed on a partial subset of variables (state, time, input and parameters) inside the context. Hence we use UpdateContextFromDecisionVariablesGeneric to select the decision variables inside context. The unselected variables will remain to its values stored in context. |
◆ MaybeCreateConstraintSymbolically()
Given a SystemConstraint and the Context to evaluate this SystemConstraint, parse the constraint in the symbolic forms.
Currently we support parsing the following forms:
- bounding box ( lower <= x <= upper )
- linear equality ( aᵀx = b )
- linear inequality ( lower <= aᵀx <= upper )
If the SystemConstraint cannot be parsed to the forms above, then returns nullopt; otherwise returns a vector containing the parsed constraint.
- Parameters
-
| index | The index of the constraint in the System object. |
| context | The context used to evaluate the SystemConstraint. |
- Return values
-
| constraints | If the SystemConstraint can be parsed to the constraint in the above forms, then constraints.value()[i] is the i'th row of the SystemConstraint evaluation result; if the SystemConstraint cannot be parsed in the above forms (either due to the System is not instantiated with symbolic::Expression, or the constraint is not linear), then constraints.has_value() = false. |
◆ MaybeCreateGenericConstraintSymbolically()
Given a SystemConstraint and the Context to evaluate this SystemConstraint, parses the constraint to a generic nonlinear constraint lower <= SystemConstraint.Calc(context) <= upper.
If the SystemConstraint cannot be parsed to the form above, then returns empty; otherwise returns a parsed constraint, together with the bound variables. We currently only support systems without abstract state or abstract parameters.
- Parameters
-
| index | The index of the constraint in the System object. |
| context | The context used to evaluate the SystemConstraint. |
- Note
- each expression in
context (like state, parameter, etc) should be either a single symbolic variable, or a constant. Currently we do not support complicated symbolic expressions.
- Return values
-
- Exceptions
-
| std::exception | if the system contains abstract state or abstract parameters. |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ system_autodiff()
Getters for the system instantiated with AutoDiffXd.
◆ system_symbolic()
Returns the symbolic system.
Throws a runtime error if the system cannot be instantiated with symbolic::Expression.
The documentation for this class was generated from the following file: