robotoc
robotoc - efficient ROBOT Optimal Control solvers
|
Stack of the cost function. Composed by cost function components that inherits CostFunctionComponentBase. More...
#include <cost_function.hpp>
Public Types | |
using | CostFunctionComponentBasePtr = std::shared_ptr< CostFunctionComponentBase > |
Public Member Functions | |
CostFunction (const double discount_factor, const double discount_time_step) | |
Constructor with discount factor. More... | |
CostFunction () | |
Default constructor. More... | |
~CostFunction ()=default | |
Destructor. More... | |
CostFunction (const CostFunction &)=default | |
Default copy constructor. More... | |
CostFunction & | operator= (const CostFunction &)=default |
Default copy operator. More... | |
CostFunction (CostFunction &&) noexcept=default | |
Default move constructor. More... | |
CostFunction & | operator= (CostFunction &&) noexcept=default |
Default move assign operator. More... | |
void | setDiscountFactor (const double discount_factor, const double discount_time_step) |
Sets the discount facor. More... | |
double | discountFactor () const |
Gets the discount facor. More... | |
double | discountTimeStep () const |
Gets the discount time step. More... | |
bool | exist (const std::string &name) const |
Checks if thsi has a cost function component of the specified name. More... | |
void | add (const std::string &name, const CostFunctionComponentBasePtr &cost) |
Adds a cost function component. If a component of the same name exists, throws an exeption. More... | |
void | erase (const std::string &name) |
Erases a cost function component. If a component of the specified name does not exist, throws an exeption. More... | |
CostFunctionComponentBasePtr | get (const std::string &name) const |
Gets a cost function component. If a component of the specified name does not exist, throws an exeption. More... | |
void | clear () |
Clear cost function by removing all components. More... | |
CostFunctionData | createCostFunctionData (const Robot &robot) const |
Creates CostFunctionData according to robot model and cost function components. More... | |
double | evalStageCost (Robot &robot, const ContactStatus &contact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s) const |
Computes the stage cost. More... | |
double | linearizeStageCost (Robot &robot, const ContactStatus &contact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTResidual &kkt_residual) const |
Computes the stage cost and its first-order partial derivatives. More... | |
double | quadratizeStageCost (Robot &robot, const ContactStatus &contact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTResidual &kkt_residual, SplitKKTMatrix &kkt_matrix) const |
Computes the stage cost, its first-order partial derivatives, and its Hessian, i.e., its second-order partial derivatives. More... | |
double | evalTerminalCost (Robot &robot, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s) const |
Computes the terminal cost. More... | |
double | linearizeTerminalCost (Robot &robot, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTResidual &kkt_residual) const |
Computes the terminal cost and its first-order partial derivatives. More... | |
double | quadratizeTerminalCost (Robot &robot, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTResidual &kkt_residual, SplitKKTMatrix &kkt_matrix) const |
Computes the terminal cost, its first-order partial derivatives, and its Hessian, i.e., its second-order partial derivatives. More... | |
double | evalImpactCost (Robot &robot, const ImpactStatus &impact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s) const |
Computes the impact cost. More... | |
double | linearizeImpactCost (Robot &robot, const ImpactStatus &impact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTResidual &kkt_residual) const |
Computes the impact cost and its first-order partial derivatives. More... | |
double | quadratizeImpactCost (Robot &robot, const ImpactStatus &impact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTResidual &kkt_residual, SplitKKTMatrix &kkt_matrix) const |
Computes the impact cost, its first-order partial derivatives, and its Hessian, i.e., its second-order partial derivatives. More... | |
std::vector< std::string > | getCostComponentList () const |
Gets a list of the cost components. More... | |
void | disp (std::ostream &os) const |
Displays the cost function onto a ostream. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const CostFunction &cost_function) |
std::ostream & | operator<< (std::ostream &os, const std::shared_ptr< CostFunction > &cost_function) |
Stack of the cost function. Composed by cost function components that inherits CostFunctionComponentBase.
using robotoc::CostFunction::CostFunctionComponentBasePtr = std::shared_ptr<CostFunctionComponentBase> |
robotoc::CostFunction::CostFunction | ( | const double | discount_factor, |
const double | discount_time_step | ||
) |
Constructor with discount factor.
[in] | discount_factor | Discount factor. Must be positive and smaller than 1.0. |
[in] | discount_time_step | The cost is reduced by discount_factor as the time proceeds to this value. Must be positive. |
robotoc::CostFunction::CostFunction | ( | ) |
Default constructor.
|
default |
Destructor.
|
default |
Default copy constructor.
|
defaultnoexcept |
Default move constructor.
void robotoc::CostFunction::add | ( | const std::string & | name, |
const CostFunctionComponentBasePtr & | cost | ||
) |
Adds a cost function component. If a component of the same name exists, throws an exeption.
[in] | name | Name of the cost function component. |
[in] | cost | shared pointer to the cost function component. |
void robotoc::CostFunction::clear | ( | ) |
Clear cost function by removing all components.
CostFunctionData robotoc::CostFunction::createCostFunctionData | ( | const Robot & | robot | ) | const |
Creates CostFunctionData according to robot model and cost function components.
[in] | robot | robot model. |
double robotoc::CostFunction::discountFactor | ( | ) | const |
Gets the discount facor.
double robotoc::CostFunction::discountTimeStep | ( | ) | const |
Gets the discount time step.
void robotoc::CostFunction::disp | ( | std::ostream & | os | ) | const |
Displays the cost function onto a ostream.
void robotoc::CostFunction::erase | ( | const std::string & | name | ) |
Erases a cost function component. If a component of the specified name does not exist, throws an exeption.
[in] | name | Name of the cost function component. |
double robotoc::CostFunction::evalImpactCost | ( | Robot & | robot, |
const ImpactStatus & | impact_status, | ||
CostFunctionData & | data, | ||
const GridInfo & | grid_info, | ||
const SplitSolution & | s | ||
) | const |
Computes the impact cost.
[in] | robot | Robot model. |
[in] | impact_status | Impact status. |
[in] | data | Cost function data. |
[in] | grid_info | Grid info. |
[in] | s | Split solution. |
double robotoc::CostFunction::evalStageCost | ( | Robot & | robot, |
const ContactStatus & | contact_status, | ||
CostFunctionData & | data, | ||
const GridInfo & | grid_info, | ||
const SplitSolution & | s | ||
) | const |
Computes the stage cost.
[in] | robot | Robot model. |
[in] | contact_status | Contact status. |
[in] | data | Cost function data. |
[in] | grid_info | Grid info. |
[in] | s | Split solution. |
double robotoc::CostFunction::evalTerminalCost | ( | Robot & | robot, |
CostFunctionData & | data, | ||
const GridInfo & | grid_info, | ||
const SplitSolution & | s | ||
) | const |
Computes the terminal cost.
[in] | robot | Robot model. |
[in] | data | Cost function data. |
[in] | grid_info | Grid info. |
[in] | s | Split solution. |
bool robotoc::CostFunction::exist | ( | const std::string & | name | ) | const |
Checks if thsi has a cost function component of the specified name.
[in] | name | Name of the cost function component. |
CostFunctionComponentBasePtr robotoc::CostFunction::get | ( | const std::string & | name | ) | const |
Gets a cost function component. If a component of the specified name does not exist, throws an exeption.
[in] | name | Name of the cost function component. |
std::vector< std::string > robotoc::CostFunction::getCostComponentList | ( | ) | const |
Gets a list of the cost components.
double robotoc::CostFunction::linearizeImpactCost | ( | Robot & | robot, |
const ImpactStatus & | impact_status, | ||
CostFunctionData & | data, | ||
const GridInfo & | grid_info, | ||
const SplitSolution & | s, | ||
SplitKKTResidual & | kkt_residual | ||
) | const |
Computes the impact cost and its first-order partial derivatives.
[in] | robot | Robot model. |
[in] | impact_status | Impact status. |
[in] | data | Cost function data. |
[in] | grid_info | Grid info. |
[in] | s | Split solution. |
[in,out] | kkt_residual | Split KKT residual. The partial derivatives are added to this object. |
double robotoc::CostFunction::linearizeStageCost | ( | Robot & | robot, |
const ContactStatus & | contact_status, | ||
CostFunctionData & | data, | ||
const GridInfo & | grid_info, | ||
const SplitSolution & | s, | ||
SplitKKTResidual & | kkt_residual | ||
) | const |
Computes the stage cost and its first-order partial derivatives.
[in] | robot | Robot model. |
[in] | contact_status | Contact status. |
[in] | data | Cost function data. |
[in] | grid_info | Grid info. |
[in] | s | Split solution. |
[in,out] | kkt_residual | Split KKT residual. The partial derivatives are added to this object. |
double robotoc::CostFunction::linearizeTerminalCost | ( | Robot & | robot, |
CostFunctionData & | data, | ||
const GridInfo & | grid_info, | ||
const SplitSolution & | s, | ||
SplitKKTResidual & | kkt_residual | ||
) | const |
Computes the terminal cost and its first-order partial derivatives.
[in] | robot | Robot model. |
[in] | data | Cost function data. |
[in] | grid_info | Grid info. |
[in] | s | Split solution. |
[in,out] | kkt_residual | Split KKT residual. The partial derivatives are added to this object. |
|
default |
Default copy operator.
|
defaultnoexcept |
Default move assign operator.
double robotoc::CostFunction::quadratizeImpactCost | ( | Robot & | robot, |
const ImpactStatus & | impact_status, | ||
CostFunctionData & | data, | ||
const GridInfo & | grid_info, | ||
const SplitSolution & | s, | ||
SplitKKTResidual & | kkt_residual, | ||
SplitKKTMatrix & | kkt_matrix | ||
) | const |
Computes the impact cost, its first-order partial derivatives, and its Hessian, i.e., its second-order partial derivatives.
[in] | robot | Robot model. |
[in] | impact_status | Impact status. |
[in] | data | Cost function data. |
[in] | grid_info | Grid info. |
[in] | s | Split solution. |
[in,out] | kkt_residual | Split KKT residual. The partial derivatives are added to this object. |
[in,out] | kkt_matrix | Split KKT matrix. The Hessians are added to this object. |
double robotoc::CostFunction::quadratizeStageCost | ( | Robot & | robot, |
const ContactStatus & | contact_status, | ||
CostFunctionData & | data, | ||
const GridInfo & | grid_info, | ||
const SplitSolution & | s, | ||
SplitKKTResidual & | kkt_residual, | ||
SplitKKTMatrix & | kkt_matrix | ||
) | const |
Computes the stage cost, its first-order partial derivatives, and its Hessian, i.e., its second-order partial derivatives.
[in] | robot | Robot model. |
[in] | contact_status | Contact status. |
[in] | data | Cost function data. |
[in] | grid_info | Grid info. |
[in] | s | Split solution. |
[in,out] | kkt_residual | Split KKT residual. The partial derivatives are added to this object. |
[in,out] | kkt_matrix | Split KKT matrix. The Hessians are added to this object. |
double robotoc::CostFunction::quadratizeTerminalCost | ( | Robot & | robot, |
CostFunctionData & | data, | ||
const GridInfo & | grid_info, | ||
const SplitSolution & | s, | ||
SplitKKTResidual & | kkt_residual, | ||
SplitKKTMatrix & | kkt_matrix | ||
) | const |
Computes the terminal cost, its first-order partial derivatives, and its Hessian, i.e., its second-order partial derivatives.
[in] | robot | Robot model. |
[in] | data | Cost function data. |
[in] | grid_info | Grid info. |
[in] | s | Split solution. |
[in,out] | kkt_residual | Split KKT residual. The partial derivatives are added to this object. |
[in,out] | kkt_matrix | Split KKT matrix. The Hessians are added to this object. |
void robotoc::CostFunction::setDiscountFactor | ( | const double | discount_factor, |
const double | discount_time_step | ||
) |
Sets the discount facor.
[in] | discount_factor | Discount factor. Must be positive and smaller than 1.0. Otherwise, the discounted cost is disabled. |
[in] | discount_time_step | The cost is reduced by discount_factor as the time proceeds to this value. Must be positive. Otherwise, the discounted cost is disabled. |
|
friend |
|
friend |