27 #ifndef EXAMPLES_SIMPLE_OPTIMIZATION_TASK_H_ 28 #define EXAMPLES_SIMPLE_OPTIMIZATION_TASK_H_ 47 const std::vector<double>& bias_thresholds,
48 const std::vector<double>& std_dev):
55 int num_timesteps = parameters_bias.cols();
56 stomp_core::generateSmoothingMatrix(num_timesteps,1.0,
smoothing_M_);
74 std::size_t start_timestep,
75 std::size_t num_timesteps,
78 Eigen::MatrixXd& parameters_noise,
79 Eigen::MatrixXd& noise)
override 82 for(std::size_t
d = 0;
d < parameters.rows();
d++)
84 for(std::size_t t = 0; t < parameters.cols(); t++)
86 rand_noise =
static_cast<double>(rand()%RAND_MAX)/static_cast<double>(RAND_MAX - 1);
87 rand_noise = 2*(0.5 - rand_noise);
92 parameters_noise = parameters + noise;
108 std::size_t start_timestep,
109 std::size_t num_timesteps,
110 int iteration_number,
111 Eigen::VectorXd& costs,
112 bool& validity)
override 114 return computeNoisyCosts(parameters,start_timestep,num_timesteps,iteration_number,-1,costs,validity);
129 std::size_t start_timestep,
130 std::size_t num_timesteps,
131 int iteration_number,
133 Eigen::VectorXd& costs,
134 bool& validity)
override 136 costs.setZero(num_timesteps);
141 for(std::size_t t = 0u; t < num_timesteps; t++)
144 for(std::size_t
d = 0u;
d < parameters.rows() ;
d++)
173 std::size_t num_timesteps,
174 int iteration_number,
175 const Eigen::MatrixXd& parameters,
176 Eigen::MatrixXd& updates)
override 193 std::size_t num_timesteps,
194 int iteration_number,
195 Eigen::MatrixXd& updates)
198 for(
auto d = 0u;
d < updates.rows();
d++)
200 updates.row(
d).transpose() =
smoothing_M_*(updates.row(
d).transpose());
std::vector< double > bias_thresholds_
bool smoothParameterUpdates(std::size_t start_timestep, std::size_t num_timesteps, int iteration_number, Eigen::MatrixXd &updates)
Perform a smooth update given a noisy update.
SimpleOptimizationTask(const Eigen::MatrixXd ¶meters_bias, const std::vector< double > &bias_thresholds, const std::vector< double > &std_dev)
A simple task for demonstrating how to use Stomp.
bool generateNoisyParameters(const Eigen::MatrixXd ¶meters, std::size_t start_timestep, std::size_t num_timesteps, int iteration_number, int rollout_number, Eigen::MatrixXd ¶meters_noise, Eigen::MatrixXd &noise) override
[SimpleOptimizationTask Inherit]
std::vector< double > std_dev_
bool computeCosts(const Eigen::MatrixXd ¶meters, std::size_t start_timestep, std::size_t num_timesteps, int iteration_number, Eigen::VectorXd &costs, bool &validity) override
computes the state costs as a function of the distance from the bias parameters
bool filterParameterUpdates(std::size_t start_timestep, std::size_t num_timesteps, int iteration_number, const Eigen::MatrixXd ¶meters, Eigen::MatrixXd &updates) override
Filters the given parameters which is applied after the update. It could be used for clipping of join...
Eigen::MatrixXd smoothing_M_
bool computeNoisyCosts(const Eigen::MatrixXd ¶meters, std::size_t start_timestep, std::size_t num_timesteps, int iteration_number, int rollout_number, Eigen::VectorXd &costs, bool &validity) override
computes the state costs as a function of the distance from the bias parameters
This defines the stomp task.
Eigen::MatrixXd parameters_bias_
[SimpleOptimizationTask Inherit]
Defines the STOMP improvement policy.