iDynTree::optimalcontrol::LinearConstraint class

Base classes

class Constraint
The Constraint virtual class definition.

Constructors, destructors, conversion operators

LinearConstraint(size_t size, const std::string name)
LinearConstraint(size_t size, const std::string name, const SparsityStructure& stateSparsity, const SparsityStructure& controlSparsity)
~LinearConstraint() override

Public functions

auto setStateConstraintMatrix(const MatrixDynSize& constraintMatrix) -> bool
auto setControlConstraintMatrix(const MatrixDynSize& constraintMatrix) -> bool
auto setStateConstraintMatrix(std::shared_ptr<TimeVaryingMatrix> constraintMatrix) -> bool
auto setControlConstraintMatrix(std::shared_ptr<TimeVaryingMatrix> constraintMatrix) -> bool
auto evaluateConstraint(double time, const VectorDynSize& state, const VectorDynSize& control, VectorDynSize& constraint) -> bool final
Evaluate the constraint.
auto constraintJacobianWRTState(double time, const VectorDynSize& state, const VectorDynSize& control, MatrixDynSize& jacobian) -> bool final
Evaluate the constraint jacobian with respect to the state variables This methods evaluates the partial derivative of the constraint wrt to the state.
auto constraintJacobianWRTControl(double time, const VectorDynSize& state, const VectorDynSize& control, MatrixDynSize& jacobian) -> bool final
Evaluate the constraint jacobian with respect to the control variables This methods evaluates the partial derivative of the constraint wrt to the control.
auto constraintJacobianWRTStateSparsity(iDynTree::optimalcontrol::SparsityStructure& stateSparsity) -> bool final
Returns the set of nonzeros elements in terms of row and colun index, in the state jacobian.
auto constraintJacobianWRTControlSparsity(iDynTree::optimalcontrol::SparsityStructure& controlSparsity) -> bool final
Returns the set of nonzeros elements in terms of row and colun index, in the control jacobian.
auto constraintSecondPartialDerivativeWRTState(double time, const VectorDynSize& state, const VectorDynSize& control, const VectorDynSize& lambda, MatrixDynSize& hessian) -> bool final
Evaluate constraint second partial derivative wrt the state variables.
auto constraintSecondPartialDerivativeWRTControl(double time, const VectorDynSize& state, const VectorDynSize& control, const VectorDynSize& lambda, MatrixDynSize& hessian) -> bool final
Evaluate constraint second partial derivative wrt the control.
auto constraintSecondPartialDerivativeWRTStateControl(double time, const VectorDynSize& state, const VectorDynSize& control, const VectorDynSize& lambda, MatrixDynSize& hessian) -> bool final
Evaluate constraint second partial derivative wrt the state and control.
auto constraintSecondPartialDerivativeWRTStateSparsity(iDynTree::optimalcontrol::SparsityStructure& stateSparsity) -> bool final
Returns the set of nonzeros elements in terms of row and colun index, in the state hessian.
auto constraintSecondPartialDerivativeWRTStateControlSparsity(iDynTree::optimalcontrol::SparsityStructure& stateControlSparsity) -> bool final
Returns the set of nonzeros elements in terms of row and colun index, in the mixed hessian.
auto constraintSecondPartialDerivativeWRTControlSparsity(iDynTree::optimalcontrol::SparsityStructure& controlSparsity) -> bool final
Returns the set of nonzeros elements in terms of row and colun index, in the control hessian.

Function documentation

bool iDynTree::optimalcontrol::LinearConstraint::evaluateConstraint(double time, const VectorDynSize& state, const VectorDynSize& control, VectorDynSize& constraint) final

Evaluate the constraint.

Parameters
time in The time at which the constraint is evaluated.
state in The state at which the constraint is evaluated.
control in The control at which the constraint is evaluated
constraint out The constraint right hand value.
Returns True if successfull, false otherwise.

This method has to be overriden when defining the constraint.

bool iDynTree::optimalcontrol::LinearConstraint::constraintJacobianWRTState(double time, const VectorDynSize& state, const VectorDynSize& control, MatrixDynSize& jacobian) final

Evaluate the constraint jacobian with respect to the state variables This methods evaluates the partial derivative of the constraint wrt to the state.

Parameters
time in The time at which the constraint jacobian is evaluated.
state in The state at which the constraint jacobian is evaluated.
control in The control at which the constraint jacobian is evaluated
jacobian out The jacobian right hand side value.
Returns True if successful. False otherwise (or by default).

By default, the implementation return false. The user needs to override this method if the constraint will be used, for example, within an optimal control problem that will be solved using an optimizer that needs this information (i.e. Ipopt).

bool iDynTree::optimalcontrol::LinearConstraint::constraintJacobianWRTControl(double time, const VectorDynSize& state, const VectorDynSize& control, MatrixDynSize& jacobian) final

Evaluate the constraint jacobian with respect to the control variables This methods evaluates the partial derivative of the constraint wrt to the control.

Parameters
time in The time at which the constraint jacobian is evaluated.
state in The state at which the constraint jacobian is evaluated.
control in The control at which the constraint jacobian is evaluated
jacobian out The jacobian right hand side value.
Returns True if successful. False otherwise (or by default).

By default, the implementation return false. The user needs to override this method if the constraint will be used, for example, within an optimal control problem that will be solved using an optimizer that needs this information (i.e. Ipopt).

bool iDynTree::optimalcontrol::LinearConstraint::constraintJacobianWRTStateSparsity(iDynTree::optimalcontrol::SparsityStructure& stateSparsity) final

Returns the set of nonzeros elements in terms of row and colun index, in the state jacobian.

Parameters
stateSparsity Sparsity structure of the partial derivative of the constraint wrt state variables.
Returns true if the sparsity is available. False otherwise.

bool iDynTree::optimalcontrol::LinearConstraint::constraintJacobianWRTControlSparsity(iDynTree::optimalcontrol::SparsityStructure& controlSparsity) final

Returns the set of nonzeros elements in terms of row and colun index, in the control jacobian.

Parameters
controlSparsity Sparsity structure of the partial derivative of the constraint wrt control variables.
Returns true if the sparsity is available. False otherwise.

bool iDynTree::optimalcontrol::LinearConstraint::constraintSecondPartialDerivativeWRTState(double time, const VectorDynSize& state, const VectorDynSize& control, const VectorDynSize& lambda, MatrixDynSize& hessian) final

Evaluate constraint second partial derivative wrt the state variables.

Parameters
time in The time at which the partial derivative is computed.
state in The state value at which the partial derivative is computed.
control in The control value at which the partial derivative is computed..
lambda in The lagrange multipliers
hessian out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

It is the result of $\sum \lambda_i \frac{\partial^2 c(t, x, u)}{\partial x^2}$

bool iDynTree::optimalcontrol::LinearConstraint::constraintSecondPartialDerivativeWRTControl(double time, const VectorDynSize& state, const VectorDynSize& control, const VectorDynSize& lambda, MatrixDynSize& hessian) final

Evaluate constraint second partial derivative wrt the control.

Parameters
time in The time at which the partial derivative is computed.
state in The state value at which the partial derivative is computed.
control in The control value at which the partial derivative is computed.
lambda in The lagrange multipliers
hessian out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

It is the result of $\sum \lambda_i \frac{\partial^2 c(t, x, u)}{\partial u^2}$

bool iDynTree::optimalcontrol::LinearConstraint::constraintSecondPartialDerivativeWRTStateControl(double time, const VectorDynSize& state, const VectorDynSize& control, const VectorDynSize& lambda, MatrixDynSize& hessian) final

Evaluate constraint second partial derivative wrt the state and control.

Parameters
time in The time at which the partial derivative is computed.
state in The state value at which the partial derivative is computed.
control in The control value at which the partial derivative is computed.
lambda in The lagrange multipliers
hessian out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

It is the result of $\sum \lambda_i \frac{\partial^2 c(t, x, u)}{\partial x \partial u}$ , thus it has number of rows equals to the number of states and number of cols equal to the number of control inputs.

bool iDynTree::optimalcontrol::LinearConstraint::constraintSecondPartialDerivativeWRTStateSparsity(iDynTree::optimalcontrol::SparsityStructure& stateSparsity) final

Returns the set of nonzeros elements in terms of row and colun index, in the state hessian.

Parameters
stateSparsity Sparsity structure of the partial derivative of the jacobian wrt state variables.
Returns true if the sparsity is available. False otherwise.

bool iDynTree::optimalcontrol::LinearConstraint::constraintSecondPartialDerivativeWRTStateControlSparsity(iDynTree::optimalcontrol::SparsityStructure& stateControlSparsity) final

Returns the set of nonzeros elements in terms of row and colun index, in the mixed hessian.

Parameters
stateControlSparsity Sparsity structure of the partial derivative of the jacobian wrt state and control variables.
Returns true if the sparsity is available. False otherwise.

bool iDynTree::optimalcontrol::LinearConstraint::constraintSecondPartialDerivativeWRTControlSparsity(iDynTree::optimalcontrol::SparsityStructure& controlSparsity) final

Returns the set of nonzeros elements in terms of row and colun index, in the control hessian.

Parameters
controlSparsity Sparsity structure of the partial derivative of the jacobian wrt control variables.
Returns true if the sparsity is available. False otherwise.