Skip to content
Snippets Groups Projects
Commit d04cb601 authored by Erik Strand's avatar Erik Strand
Browse files

Add CMA-ES method that uses with a single std dev

parent 764be714
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,13 @@ public: ...@@ -30,6 +30,13 @@ public:
uint32_t pop_size() const { return pop_size_; } uint32_t pop_size() const { return pop_size_; }
uint32_t& pop_size() { return pop_size_; } uint32_t& pop_size() { return pop_size_; }
template <typename Objective>
VectorXs optimize(
Objective& objective,
VectorXs const& initial_point,
Scalar initial_std_dev = 0.3
);
template <typename Objective> template <typename Objective>
VectorXs optimize( VectorXs optimize(
Objective& objective, Objective& objective,
...@@ -49,6 +56,19 @@ private: ...@@ -49,6 +56,19 @@ private:
uint32_t n_iterations_; uint32_t n_iterations_;
}; };
//..................................................................................................
template <typename Objective>
VectorXs CmaEs::optimize(
Objective& objective,
VectorXs const& initial_point,
Scalar initial_std_dev
) {
VectorXs std_dev_vector;
std_dev_vector.resize(initial_point.size());
std_dev_vector.fill(initial_std_dev);
return optimize(objective, initial_point, std_dev_vector);
}
//.................................................................................................. //..................................................................................................
template <typename Objective> template <typename Objective>
VectorXs CmaEs::optimize( VectorXs CmaEs::optimize(
......
...@@ -35,7 +35,7 @@ int main(int const argc, char const** argv) { ...@@ -35,7 +35,7 @@ int main(int const argc, char const** argv) {
clara::Opt(pop_size, "pop_size")["-p"]["--pop-size"]("Population size") | clara::Opt(pop_size, "pop_size")["-p"]["--pop-size"]("Population size") |
clara::Opt(seed, "seed")["-s"]["--seed"]("Seed for CMA-ES random number generator") | clara::Opt(seed, "seed")["-s"]["--seed"]("Seed for CMA-ES random number generator") |
clara::Opt(max_evaluations, "max_evaluations")["-n"]["--max-evaluations"]("Max number of function evaluations") | clara::Opt(max_evaluations, "max_evaluations")["-n"]["--max-evaluations"]("Max number of function evaluations") |
clara::Opt(max_iterations, "max_iterations")["-n"]["--max-iterations"]("Max number of generations") | clara::Opt(max_iterations, "max_iterations")["-i"]["--max-iterations"]("Max number of generations") |
clara::Opt(rel_y_tol, "rel_y_tol")["-t"]["--rel-y-tol"]("Termination condition") | clara::Opt(rel_y_tol, "rel_y_tol")["-t"]["--rel-y-tol"]("Termination condition") |
clara::Opt(x0, "x0")["-x"]["--x0"]("X coordinate of initial point") | clara::Opt(x0, "x0")["-x"]["--x0"]("X coordinate of initial point") |
clara::Opt(y0, "y0")["-y"]["--y0"]("Y coordinate of initial point"); clara::Opt(y0, "y0")["-y"]["--y0"]("Y coordinate of initial point");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment