DMP_BBO library
Public Member Functions | List of all members
DemoTaskApproximateQuadraticFunction Class Reference

The task is to choose the parameters a and c such that the function $ y = a*x^2 + c $ best matches a set of target values y_target for a set of input values x. More...

Inheritance diagram for DemoTaskApproximateQuadraticFunction:
Inheritance graph
[legend]
Collaboration diagram for DemoTaskApproximateQuadraticFunction:
Collaboration graph
[legend]

Public Member Functions

 DemoTaskApproximateQuadraticFunction (double a, double c, const VectorXd &inputs, double regularization_weight)
 Constructor. More...
 
void evaluateRollout (const MatrixXd &cost_vars, const VectorXd &sample, const VectorXd &task_parameters, VectorXd &cost) const
 Cost function. More...
 
unsigned int getNumberOfCostComponents (void) const
 Get the number of individual cost components that constitute the final total cost. More...
 
string toString (void) const
 Returns a string representation of the object. More...
 
- Public Member Functions inherited from Task
virtual void evaluateRollout (const Eigen::MatrixXd &cost_vars, const Eigen::VectorXd &sample, Eigen::VectorXd &costs) const
 The cost function which defines the task. More...
 
virtual void evaluateRollout (const Eigen::MatrixXd &cost_vars, const Eigen::VectorXd &sample, const Eigen::VectorXd &task_parameters, Eigen::VectorXd &cost) const =0
 The cost function which defines the task. More...
 
virtual bool savePlotRolloutScript (std::string directory) const
 Save a python script that is able to visualize the rollouts, given the cost-relevant variables stored in a file. More...
 

Detailed Description

The task is to choose the parameters a and c such that the function $ y = a*x^2 + c $ best matches a set of target values y_target for a set of input values x.

Definition at line 61 of file demoOptimizationTask.cpp.

Constructor & Destructor Documentation

DemoTaskApproximateQuadraticFunction ( double  a,
double  c,
const VectorXd &  inputs,
double  regularization_weight 
)
inline

Constructor.

Parameters
[in]aa in $ y = a*x^2 + c $
[in]cc in $ y = a*x^2 + c $
[in]inputsx in $ y = a*x^2 + c $
[in]regularization_weightRegularization penalty on the parameter vector.

Definition at line 70 of file demoOptimizationTask.cpp.

71  {
72  inputs_ = inputs;
73  targetFunction(a,c,inputs_,targets_);
74  regularization_weight_ = regularization_weight;
75  }
void targetFunction(double a, double c, const VectorXd &inputs, VectorXd &outputs)
Target function .

Here is the call graph for this function:

Member Function Documentation

void evaluateRollout ( const MatrixXd &  cost_vars,
const VectorXd &  sample,
const VectorXd &  task_parameters,
VectorXd &  cost 
) const
inline

Cost function.

Parameters
[in]cost_varsy in $ y = a*x^2 + c $
[in]sampleThe sample from which cost_vars was generated. Required for regularization.
[in]task_parametersIgnored
[out]costCost of the rollout.

Definition at line 83 of file demoOptimizationTask.cpp.

84  {
85  VectorXd diff_square = (cost_vars.array()-targets_.array()).square();
86  cost.resize(3);
87  cost[1] = diff_square.mean();
88  cost[2] = regularization_weight_*sqrt(sample.array().pow(2).sum());
89  cost[0] = cost[1] + cost[2];
90  }
unsigned int getNumberOfCostComponents ( void  ) const
inlinevirtual

Get the number of individual cost components that constitute the final total cost.

Returns
The number of cost components.

Implements Task.

Definition at line 92 of file demoOptimizationTask.cpp.

93  {
94  return 2;
95  };
string toString ( void  ) const
inlinevirtual

Returns a string representation of the object.

Returns
A string representation of the object.

Implements Task.

Definition at line 100 of file demoOptimizationTask.cpp.

101  {
102  string str = "TaskApproximateQuadraticFunctionSolver";
103  return str;
104  }

The documentation for this class was generated from the following file: