iDynTree::optimalcontrol::Cost class

The Cost virtual class definition.

Publicly inherit from this class to specify a Cost to be used in a optimal control problem.

Derived classes

class L2NormCost
class QuadraticLikeCost

Constructors, destructors, conversion operators

Cost(const std::string& costName)
Cost constructor.
~Cost() virtual

Public functions

auto name() const -> const std::string&
Get the name of the cost.
auto costEvaluation(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, double& costValue) -> bool pure virtual
Evaluate the cost function.
auto costFirstPartialDerivativeWRTState(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, iDynTree::VectorDynSize& partialDerivative) -> bool virtual
Evaluate cost first partial derivative wrt the state.
auto costFirstPartialDerivativeWRTControl(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, iDynTree::VectorDynSize& partialDerivative) -> bool virtual
Evaluate cost first partial derivative wrt the control variables.
auto costSecondPartialDerivativeWRTState(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, iDynTree::MatrixDynSize& partialDerivative) -> bool virtual
Evaluate cost second partial derivative wrt the state variables.
auto costSecondPartialDerivativeWRTControl(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, iDynTree::MatrixDynSize& partialDerivative) -> bool virtual
Evaluate cost second partial derivative wrt the control.
auto costSecondPartialDerivativeWRTStateControl(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, iDynTree::MatrixDynSize& partialDerivative) -> bool virtual
Evaluate cost second partial derivative wrt the state and control.
auto costSecondPartialDerivativeWRTStateSparsity(iDynTree::optimalcontrol::SparsityStructure& stateSparsity) -> bool virtual
Returns the set of nonzeros elements in terms of row and colun index, in the state hessian.
auto costSecondPartialDerivativeWRTStateControlSparsity(iDynTree::optimalcontrol::SparsityStructure& stateControlSparsity) -> bool virtual
Returns the set of nonzeros elements in terms of row and colun index, in the mixed hessian.
auto costSecondPartialDerivativeWRTControlSparsity(iDynTree::optimalcontrol::SparsityStructure& controlSparsity) -> bool virtual
Returns the set of nonzeros elements in terms of row and colun index, in the control hessian.

Function documentation

iDynTree::optimalcontrol::Cost::Cost(const std::string& costName)

Cost constructor.

Parameters
costName in Univocal name of the cost.

const std::string& iDynTree::optimalcontrol::Cost::name() const

Get the name of the cost.

Returns The name of the cost

bool iDynTree::optimalcontrol::Cost::costEvaluation(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, double& costValue) pure virtual

Evaluate the cost function.

Parameters
time in The time at which the cost is evaluated.
state in The state value with which the cost has to be evaluated.
control in The control value with which the cost has to be evaluated.
costValue out The cost value given the above inputs.
Returns True if successfull, false otherwise.

bool iDynTree::optimalcontrol::Cost::costFirstPartialDerivativeWRTState(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, iDynTree::VectorDynSize& partialDerivative) virtual

Evaluate cost first partial derivative wrt the state.

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.
partialDerivative out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

It is the result of $\frac{\partial g(t, x, u)}{\partial x}$

bool iDynTree::optimalcontrol::Cost::costFirstPartialDerivativeWRTControl(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, iDynTree::VectorDynSize& partialDerivative) virtual

Evaluate cost first partial derivative wrt the control 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.
partialDerivative out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

It is the result of $\frac{\partial g(t, x, u)}{\partial u}$

bool iDynTree::optimalcontrol::Cost::costSecondPartialDerivativeWRTState(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, iDynTree::MatrixDynSize& partialDerivative) virtual

Evaluate cost 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.
partialDerivative out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

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

bool iDynTree::optimalcontrol::Cost::costSecondPartialDerivativeWRTControl(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, iDynTree::MatrixDynSize& partialDerivative) virtual

Evaluate cost 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.
partialDerivative out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

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

bool iDynTree::optimalcontrol::Cost::costSecondPartialDerivativeWRTStateControl(double time, const iDynTree::VectorDynSize& state, const iDynTree::VectorDynSize& control, iDynTree::MatrixDynSize& partialDerivative) virtual

Evaluate cost 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.
partialDerivative out The output partial derivative.
Returns True if successfull, false otherwise (or if not implemented).

It is the result of $\frac{\partial^2 g(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::Cost::costSecondPartialDerivativeWRTStateSparsity(iDynTree::optimalcontrol::SparsityStructure& stateSparsity) virtual

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

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

bool iDynTree::optimalcontrol::Cost::costSecondPartialDerivativeWRTStateControlSparsity(iDynTree::optimalcontrol::SparsityStructure& stateControlSparsity) virtual

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

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

bool iDynTree::optimalcontrol::Cost::costSecondPartialDerivativeWRTControlSparsity(iDynTree::optimalcontrol::SparsityStructure& controlSparsity) virtual

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

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