Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Evolution Strategy with Covariance Matrix Adaptation

Synopsis

#include <boost/math/optimization/cma_es.hpp>

namespace boost::math::optimization {

template <typename ArgumentContainer> struct cma_es_parameters {
    using Real = typename ArgumentContainer::value_type;
    ArgumentContainer lower_bounds;
    ArgumentContainer upper_bounds;
    size_t max_generations = 1000;
    ArgumentContainer const * initial_guess = nullptr;
    // If zero, choose the default from the reference.
    size_t population_size = 0;
    Real learning_rate = 1;
};

template <typename ArgumentContainer, class Func, class URBG>
ArgumentContainer cma_es(const Func cost_function,
                         cma_es_parameters<ArgumentContainer> const &params,
                         URBG &gen,
                         std::invoke_result_t<Func, ArgumentContainer> value_to_reach
                           = std::numeric_limits<std::invoke_result_t<Func, ArgumentContainer>>::quiet_NaN(),
                         std::atomic<bool> *cancellation = nullptr,
                         std::atomic<std::invoke_result_t<Func, ArgumentContainer>> *current_minimum_cost = nullptr,
                         std::vector<std::pair<ArgumentContainer, std::invoke_result_t<Func, ArgumentContainer>>> *queries = nullptr);

} // namespaces

The cma_es optimizer searches for a global minimum of a function. Our implementation attempts to follow "The CMA evolution strategy: A tutorial" exactly.

Parameters

The function

template <typename ArgumentContainer, class Func, class URBG>
ArgumentContainer cma_es(const Func cost_function,
                         cma_es_parameters<ArgumentContainer> const &params,
                         URBG &gen,
                         std::invoke_result_t<Func, ArgumentContainer> value_to_reach
                            = std::numeric_limits<std::invoke_result_t<Func, ArgumentContainer>>::quiet_NaN(),
                         std::atomic<bool> *cancellation = nullptr,
                         std::atomic<std::invoke_result_t<Func, ArgumentContainer>> *current_minimum_cost = nullptr,
                         std::vector<std::pair<ArgumentContainer, std::invoke_result_t<Func, ArgumentContainer>>> *queries = nullptr)

Parameters:

Returns:

The ArgumentContainer corresponding to the minimum cost found by the optimization.

Examples

An example exhibiting graceful cancellation and progress observability can be studied in cma_es_example.cpp.

References

Hansen, N. (2016). The CMA evolution strategy: A tutorial. arXiv preprint arXiv:1604.00772.


PrevUpHomeNext