libcmaes
A C++11 library for stochastic optimization with CMA-ES
 All Classes Namespaces Functions Variables Typedefs
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno > Class Template Reference

This is an implementation of CMA-ES. It uses the reference algorithm and termination criteria of the following paper: Hansen, N. (2009). Benchmarking a BI-Population CMA-ES on the BBOB-2009 Function Testbed. Workshop Proceedings of the GECCO Genetic and Evolutionary Computation Conference, ACM, pp. 2389-2395 See https://www.lri.fr/~hansen/publications.html for more information. More...

#include <cmastrategy.h>

Inheritance diagram for libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >:
libcmaes::ESOStrategy< CMAParameters< TGenoPheno >, CMASolutions, CMAStopCriteria< TGenoPheno > > libcmaes::IPOPCMAStrategy< TCovarianceUpdate, TGenoPheno > libcmaes::OptHopStrategy< TCovarianceUpdate, TGenoPheno > libcmaes::SurrogateStrategy< CMAStrategy, TCovarianceUpdate, TGenoPheno > libcmaes::BIPOPCMAStrategy< TCovarianceUpdate, TGenoPheno > libcmaes::SimpleSurrogateStrategy< CMAStrategy, TCovarianceUpdate, TGenoPheno > RSVMSimpleSurrogateStrategy< TCovarianceUpdate, TGenoPheno >

Public Member Functions

 CMAStrategy ()
 dummy constructor
 
 CMAStrategy (FitFunc &func, CMAParameters< TGenoPheno > &parameters)
 constructor. More...
 
 CMAStrategy (FitFunc &func, CMAParameters< TGenoPheno > &parameters, const CMASolutions &cmasols)
 constructor for starting from an existing solution. More...
 
dMat ask ()
 generates nsols new candidate solutions, sampled from a multivariate normal distribution. return A matrix whose rows contain the candidate points.
 
void tell ()
 Updates the covariance matrix and prepares for the next iteration.
 
bool stop ()
 Stops search on a set of termination criterias, see reference paper. More...
 
int optimize (const EvalFunc &evalf, const AskFunc &askf, const TellFunc &tellf)
 Finds the minimum of the objective function. It makes alternate calls to ask(), tell() and stop() until one of the termination criteria triggers. More...
 
int optimize ()
 Finds the minimum of the objective function. It makes alternate calls to ask(), tell() and stop() until one of the termination criteria triggers. More...
 
void plot ()
 Stream the internal state of the search into an output file, as defined in the _parameters object.
 
- Public Member Functions inherited from libcmaes::ESOStrategy< CMAParameters< TGenoPheno >, CMASolutions, CMAStopCriteria< TGenoPheno > >
 ESOStrategy ()
 dummy constructor.
 
 ESOStrategy (FitFunc &func, CMAParameters< TGenoPheno > &parameters)
 constructor More...
 
 ESOStrategy (FitFunc &func, CMAParameters< TGenoPheno > &parameters, const CMASolutions &solutions)
 constructor for starting from an existing solution. More...
 
dMat ask ()
 Generates a set of candidate points. More...
 
void eval (const dMat &candidates, const dMat &phenocandidates=dMat(0, 0))
 Evaluates a set of candidates against the objective function. The procedure is multithreaded and stores both the candidates and their f-value into the _solutions object that bears the current set of potential solutions to the optimization problem. More...
 
void tell ()
 Updates the state of the stochastic search, and prepares for the next iteration.
 
bool stop ()
 Decides whether to stop the search for solutions. More...
 
int optimize (const EvalFunc &evalf, const AskFunc &askf, const TellFunc &tellf)
 Finds the minimum of the objective function. It makes alternative calls to ask(), tell() and stop() until one of the termination criteria triggers. More...
 
void inc_iter ()
 increment iteration count.
 
void update_fevals (const int &evals)
 updates the consumed budget of objective function evaluations. More...
 
void set_gradient_func (GradFunc &gfunc)
 sets the gradient function, if available. More...
 
void set_progress_func (ProgressFunc< CMAParameters< TGenoPheno >, CMASolutions > &pfunc)
 Sets the possibly custom progress function, that is called in between every search step, and gives an outside user a simple way to witness progress of the algorithm, as well as to add custom termination criteria. More...
 
void start_from_solution (const CMASolutions &sol)
 starts optimization from a given solution object. More...
 
void set_plot_func (PlotFunc< CMAParameters< TGenoPheno >, CMASolutions > &pffunc)
 Sets the possibly custom plot to file function, that is useful for storing into file various possibly custom variable values for each step until termination. More...
 
dVec gradf (const dVec &x)
 returns numerical gradient of objective function at x. More...
 
dVec gradgp (const dVec &x) const
 returns the numerical gradient of the objective function in phenotype space More...
 
double edm ()
 computes expected distance to minimum (EDM). More...
 
CMASolutionsget_solutions ()
 returns reference to current solution object More...
 
CMAParameters< TGenoPheno > & get_parameters ()
 returns reference to current optimization parameters object More...
 
double fitfunc (const double *x, const int N)
 execute objective function More...
 
void uncertainty_handling ()
 uncertainty handling scheme that computes and uncertainty level based on a dual candidate ranking.
 
void tpa_update ()
 updates the two-point adaptation average rank difference for the step-size adaptation mechanism
 
Candidate best_solution () const
 
void set_initial_elitist (const bool &e)
 

Static Public Attributes

static ProgressFunc
< CMAParameters< TGenoPheno >
, CMASolutions
_defaultPFunc = &pfuncdef_impl<TCovarianceUpdate,TGenoPheno>
 
static PlotFunc< CMAParameters
< TGenoPheno >, CMASolutions
_defaultFPFunc = &fpfuncdef_impl<TCovarianceUpdate,TGenoPheno>
 

Protected Attributes

Eigen::EigenMultivariateNormal
< double > 
_esolver
 
CMAStopCriteria< TGenoPheno > _stopcriteria
 
std::ofstream * _fplotstream = nullptr
 
- Protected Attributes inherited from libcmaes::ESOStrategy< CMAParameters< TGenoPheno >, CMASolutions, CMAStopCriteria< TGenoPheno > >
FitFunc _func
 
int _nevals
 
int _niter
 
CMASolutions _solutions
 
CMAParameters< TGenoPheno > _parameters
 
ProgressFunc< CMAParameters
< TGenoPheno >, CMASolutions
_pfunc
 
GradFunc _gfunc
 
PlotFunc< CMAParameters
< TGenoPheno >, CMASolutions
_pffunc
 
FitFunc _funcaux
 
bool _initial_elitist
 

Detailed Description

template<class TCovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
class libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >

This is an implementation of CMA-ES. It uses the reference algorithm and termination criteria of the following paper: Hansen, N. (2009). Benchmarking a BI-Population CMA-ES on the BBOB-2009 Function Testbed. Workshop Proceedings of the GECCO Genetic and Evolutionary Computation Conference, ACM, pp. 2389-2395 See https://www.lri.fr/~hansen/publications.html for more information.

Constructor & Destructor Documentation

template<class TCovarianceUpdate , class TGenoPheno >
libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >::CMAStrategy ( FitFunc &  func,
CMAParameters< TGenoPheno > &  parameters 
)

constructor.

Parameters
funcobjective function to minimize
parametersstochastic search parameters
template<class TCovarianceUpdate , class TGenoPheno >
libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >::CMAStrategy ( FitFunc &  func,
CMAParameters< TGenoPheno > &  parameters,
const CMASolutions cmasols 
)

constructor for starting from an existing solution.

Parameters
funcobjective function to minimize
parametersstochastic search parameters
cmasolssolution object to start from

Member Function Documentation

template<class TCovarianceUpdate , class TGenoPheno >
int libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >::optimize ( const EvalFunc &  evalf,
const AskFunc &  askf,
const TellFunc &  tellf 
)

Finds the minimum of the objective function. It makes alternate calls to ask(), tell() and stop() until one of the termination criteria triggers.

Parameters
evalfcustom eval function
askfcustom ask function
tellfcustom tell function
Returns
success or error code, as defined in opti_err.h Note: the termination criteria code is held by _solutions._run_status
template<class TCovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
int libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >::optimize ( )
inline

Finds the minimum of the objective function. It makes alternate calls to ask(), tell() and stop() until one of the termination criteria triggers.

Returns
success or error code, as defined in opti_err.h Note: the termination criteria code is held by _solutions._run_status
template<class TCovarianceUpdate , class TGenoPheno >
bool libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >::stop ( )

Stops search on a set of termination criterias, see reference paper.

Returns
true if search must stop, false otherwise.

Member Data Documentation

template<class TCovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
PlotFunc< CMAParameters< TGenoPheno >, CMASolutions > libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >::_defaultFPFunc = &fpfuncdef_impl<TCovarianceUpdate,TGenoPheno>
static

the default plot to file function.

template<class TCovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
ProgressFunc< CMAParameters< TGenoPheno >, CMASolutions > libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >::_defaultPFunc = &pfuncdef_impl<TCovarianceUpdate,TGenoPheno>
static

the default progress function.

template<class TCovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
Eigen::EigenMultivariateNormal<double> libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >::_esolver
protected

multivariate normal distribution sampler, and eigendecomposition solver.

template<class TCovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
std::ofstream* libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >::_fplotstream = nullptr
protected

plotting file stream, not in parameters because of copy-constructor hell.

template<class TCovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
CMAStopCriteria<TGenoPheno> libcmaes::CMAStrategy< TCovarianceUpdate, TGenoPheno >::_stopcriteria
protected

holds the set of termination criteria, see reference paper.


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