dart
|
ModularFunction uses C++11 std::function to allow you to easily swap out the cost function, gradient function, and Hessian function during runtime for an optimization::Function instance. More...
#include <Function.hpp>
Public Member Functions | |
ModularFunction (const std::string &_name="modular_function") | |
Constructor. | |
~ModularFunction () override | |
Destructor. | |
double | eval (const Eigen::VectorXd &_x) override |
eval() will now call whatever CostFunction you set using setCostFunction() | |
void | evalGradient (const Eigen::VectorXd &_x, Eigen::Map< Eigen::VectorXd > _grad) override |
evalGradient() will now call whatever GradientFunction you set using setGradientFunction() | |
void | evalHessian (const Eigen::VectorXd &_x, Eigen::Map< Eigen::VectorXd, Eigen::RowMajor > _Hess) override |
evalHessian() will now call whatever HessianFunction you set using setHessianFunction() | |
void | setCostFunction (CostFunction _cost) |
Set the function that gets called by eval() | |
void | clearCostFunction (bool _printWarning=true) |
Replace the cost function with a constant-zero function. More... | |
void | setGradientFunction (GradientFunction _gradient) |
Set the function that gets called by evalGradient() | |
void | clearGradientFunction () |
Replace the gradient function with the default evalGradient() of the base Function class. More... | |
void | setHessianFunction (HessianFunction _hessian) |
Set the function that gets called by evalHessian() | |
void | clearHessianFunction () |
Replace the Hessian function with the default evalHessian() of the base Function class. More... | |
![]() | |
Function (const std::string &_name="function") | |
Constructor. | |
virtual | ~Function () |
Destructor. | |
virtual void | setName (const std::string &newName) |
Sets the name of this Function. | |
const std::string & | getName () const |
Returns the name of this Function. | |
void | evalGradient (const Eigen::VectorXd &_x, Eigen::VectorXd &_grad) |
Evaluates and return the objective function at the point x. More... | |
Protected Attributes | |
CostFunction | mCostFunction |
Storage for the cost function. | |
GradientFunction | mGradientFunction |
Storage for the gradient function. | |
HessianFunction | mHessianFunction |
Storage for the Hessian function. | |
![]() | |
std::string | mName |
Name of this function. | |
ModularFunction uses C++11 std::function to allow you to easily swap out the cost function, gradient function, and Hessian function during runtime for an optimization::Function instance.
void dart::optimization::ModularFunction::clearCostFunction | ( | bool | _printWarning = true | ) |
Replace the cost function with a constant-zero function.
Passing in true will cause a warning to be printed out whenever eval() is called.
void dart::optimization::ModularFunction::clearGradientFunction | ( | ) |
Replace the gradient function with the default evalGradient() of the base Function class.
A warning will be printed whenever evalGradient() gets called.
void dart::optimization::ModularFunction::clearHessianFunction | ( | ) |
Replace the Hessian function with the default evalHessian() of the base Function class.
A warning will be printed whenever evalHessian() gets called.