|
libcmaes
A C++11 library for stochastic optimization with CMA-ES
|
Main class describing an evolutionary optimization strategy. Every algorithm in libcmaes descends from this class, and bring its functionalities to an ESOptimizer object. More...
#include <esostrategy.h>
Public Member Functions | |
| ESOStrategy () | |
| dummy constructor. | |
| ESOStrategy (FitFunc &func, TParameters ¶meters) | |
| constructor More... | |
| ESOStrategy (FitFunc &func, TParameters ¶meters, const TSolutions &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< TParameters, TSolutions > &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 TSolutions &sol) |
| starts optimization from a given solution object. More... | |
| void | set_plot_func (PlotFunc< TParameters, TSolutions > &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... | |
| TSolutions & | get_solutions () |
| returns reference to current solution object More... | |
| TParameters & | 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) |
Protected Attributes | |
| FitFunc | _func |
| int | _nevals |
| int | _niter |
| TSolutions | _solutions |
| TParameters | _parameters |
| ProgressFunc< TParameters, TSolutions > | _pfunc |
| GradFunc | _gfunc = nullptr |
| PlotFunc< TParameters, TSolutions > | _pffunc |
| FitFunc | _funcaux |
| bool | _initial_elitist = false |
Main class describing an evolutionary optimization strategy. Every algorithm in libcmaes descends from this class, and bring its functionalities to an ESOptimizer object.
| libcmaes::ESOStrategy< TParameters, TSolutions, TStopCriteria >::ESOStrategy | ( | FitFunc & | func, |
| TParameters & | parameters | ||
| ) |
constructor
| func | function to minimize |
| parameters | optimization parameters |
| libcmaes::ESOStrategy< TParameters, TSolutions, TStopCriteria >::ESOStrategy | ( | FitFunc & | func, |
| TParameters & | parameters, | ||
| const TSolutions & | solutions | ||
| ) |
constructor for starting from an existing solution.
| func | objective function to minimize |
| parameters | stochastic search parameters |
| solution | solution object to start from |
| dMat libcmaes::ESOStrategy< TParameters, TSolutions, TStopCriteria >::ask | ( | ) |
Generates a set of candidate points.
| double libcmaes::ESOStrategy< TParameters, TSolutions, TStopCriteria >::edm | ( | ) |
computes expected distance to minimum (EDM).
| void libcmaes::ESOStrategy< TParameters, TSolutions, TStopCriteria >::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.
| candidates | A matrix whose rows contain the candidates. |
| phenocandidates | The candidates transformed into phenotype, leave empty if no pheno transform. |
|
inline |
execute objective function
| x | point at which to execute the function |
| N | dimension of array x |
|
inline |
returns reference to current optimization parameters object
|
inline |
returns reference to current solution object
| dVec libcmaes::ESOStrategy< TParameters, TSolutions, TStopCriteria >::gradf | ( | const dVec & | x | ) |
returns numerical gradient of objective function at x.
| x | point at which to compute the gradient |
| dVec libcmaes::ESOStrategy< TParameters, TSolutions, TStopCriteria >::gradgp | ( | const dVec & | x | ) | const |
returns the numerical gradient of the objective function in phenotype space
| x | point in genotype coordinates at which to compute the gradient |
| int libcmaes::ESOStrategy< TParameters, TSolutions, TStopCriteria >::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.
| evalf | custom eval function |
| askf | custom ask function |
| tellf | custom tell function |
|
inline |
sets the gradient function, if available.
| gfunc | gradient function |
|
inline |
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.
| pffunc | a stream to file output function |
|
inline |
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.
| pfunc | a progress function |
|
inline |
starts optimization from a given solution object.
| sol | the solution object to start search from. |
| bool libcmaes::ESOStrategy< TParameters, TSolutions, TStopCriteria >::stop | ( | ) |
Decides whether to stop the search for solutions.
| void libcmaes::ESOStrategy< TParameters, TSolutions, TStopCriteria >::update_fevals | ( | const int & | evals | ) |
updates the consumed budget of objective function evaluations.
| evals | increment to the current consumed budget |
|
protected |
the objective function.
|
protected |
gradient function, when available.
|
protected |
restarts from and re-injects best seen solution if not the final one.
|
protected |
number of function evaluations.
|
protected |
number of iterations.
|
protected |
the optimizer's set of static parameters, from inputs or internal.
|
protected |
possibly custom stream data to file function.
|
protected |
possibly custom progress function.
|
protected |
holder of the current set of solutions and the dynamic elemenst of the search state in general.
1.8.8