libcmaes 0.10.2
A C++11 library for stochastic optimization with CMA-ES
|
Parameters for various flavors of the CMA-ES algorithm. More...
#include <libcmaes/cmaparameters.h>
Public Member Functions | |
CMAParameters (const int &dim, const double *x0, const double &sigma, const int &lambda=-1, const uint64_t &seed=0, const TGenoPheno &gp=TGenoPheno()) | |
Constructor. | |
CMAParameters (const std::vector< double > &x0, const double &sigma, const int &lambda=-1, const uint64_t &seed=0, const TGenoPheno &gp=TGenoPheno()) | |
Constructor. | |
CMAParameters (const std::vector< double > &x0, const std::vector< double > &sigma, const int &lambda=-1, const std::vector< double > &lbounds=std::vector< double >(), const std::vector< double > &ubounds=std::vector< double >(), const uint64_t &seed=0) | |
Constructor. | |
void | initialize_parameters () |
initialize required parameters based on dim, lambda, x0 and sigma. | |
void | reset_as_fixed (const int &k) |
void | set_noisy () |
adapt parameters for noisy objective function. | |
void | set_algo (const int &algo) |
sets the optimization algorithm. Note: overrides Parameters::set_algo | |
void | set_str_algo (const std::string &algo) |
sets the optimization algorithm. | |
double | get_sigma_init () const |
returns initial sigma value | |
void | set_gradient (const bool &gradient) |
activates the gradient injection scheme. If no gradient function is defined, injects a numerical gradient solution instead Note: overrides Parameters::set_gradient | |
void | set_sep () |
fix parameters for sep-CMA-ES, using only the diagonal of covariance matrix. | |
bool | is_sep () const |
whether algorithm leverages separability. | |
void | set_vd () |
activates VD decomposition. | |
bool | is_vd () const |
whether algorithm uses vd update. | |
void | set_fixed_p (const int &index, const double &value) |
freezes a parameter to a given value in genotype during optimization. Adapts some generic parameters as well. | |
void | unset_fixed_p (const int &index) |
unfreezes a parameter. | |
void | set_restarts (const int &nrestarts) |
sets the maximum number of restarts (applies to IPOP and BIPOP). | |
int | get_restarts () const |
get the number of restarts (applies to IPOP and BIPOP). | |
void | set_lazy_update (const bool &lz) |
sets the lazy update (i.e. updates the eigenvalues every few steps). | |
bool | get_lazy_update () |
get lazy update status. | |
void | set_elitism (const int &e) |
sets elitism: 0 -> no elitism 1 -> elitism: reinjects the best-ever seen solution 2 -> initial elitism: reinject x0 as long as it is not improved upon 3 -> initial elitism on restart: restart if best encountered solution is not the the final solution and reinjects the best solution until the population has better fitness, in its majority | |
void | set_stopping_criteria (const int &criteria, const bool &active) |
all stopping criteria are active by default, this allows to control them | |
void | set_tpa (const int &b) |
activates / deactivates two-point adaptation step-size mechanism. Overrides parameters::set_tpa by automatically setting dsigma value. | |
void | set_tpa_dsigma (const double &d) |
sets dsigma value, use with care. | |
![]() | |
Parameters () | |
empty constructor. | |
Parameters (const int &dim, const double *x0, const int &lambda=-1, const uint64_t &seed=0, const TGenoPheno &gp=GenoPheno< NoBoundStrategy >()) | |
constructor | |
void | set_x0 (const double &x0) |
sets initial objective function parameter values to x0 across all dimensions | |
void | set_x0 (const double *x0) |
sets initial objective function parameter values to array x0 | |
void | set_x0 (const dVec &x0) |
sets initial objective function parameter values from Eigen vector | |
void | set_x0 (const double &x0min, const double &x0max) |
sets bounds on initial objective function parameter values. Bounds are the same across all dimensions, and initial value is sampled uniformly within these bounds. | |
void | set_x0 (const double *x0min, const double *x0max) |
sets bounds on initial objective function parameter values. Initial value is sampled uniformly within these bounds. | |
void | set_x0 (const std::vector< double > &x0min, const std::vector< double > &x0max) |
sets bounds on initial objective function parameter values. Initial value is sampled uniformly within these bounds. | |
void | set_x0 (const dVec &x0min, const dVec &x0max) |
sets bounds on initial objective function parameter values. Initial value is sampled uniformly within these bounds. | |
dVec | get_x0min () const |
returns lower bound on x0 vector | |
dVec | get_x0max () const |
returns upper bound on x0 vector | |
void | set_fixed_p (const int &index, const double &value) |
freezes a parameter to a given value during optimization. | |
void | unset_fixed_p (const int &index) |
unfreezes a parameter. | |
void | set_max_iter (const int &maxiter) |
sets the maximum number of iterations allowed for the optimization. | |
int | get_max_iter () const |
returns maximum number of iterations | |
void | set_max_fevals (const int &fevals) |
sets the maximum budget of objective function calls allowed for the optimization. | |
int | get_max_fevals () const |
returns maximum budget of objective function calls | |
void | set_ftarget (const double &val) |
sets the objective function target value when known. | |
void | reset_ftarget () |
resets the objective function target value to its inactive state. | |
double | get_ftarget () const |
returns objective function target value. | |
void | set_seed (const int &seed) |
sets random generator's seed, 0 is special value to generate random seed. | |
int | get_seed () const |
returns random generator's seed. | |
void | set_ftolerance (const double &v) |
sets function tolerance as stopping criteria for TolHistFun: monitors the difference in function value over iterations and stops optimization when below tolerance. | |
double | get_ftolerance () const |
returns function tolerance | |
void | set_xtolerance (const double &v) |
sets parameter tolerance as stopping criteria for TolX. | |
double | get_xtolerance () const |
returns parameter tolerance | |
int | lambda () const |
returns lambda, number of offsprings per generation | |
int | dim () const |
returns the problem's dimension | |
void | set_quiet (const bool &quiet) |
sets the quiet mode (no output from the library) for the optimization at hand | |
bool | quiet () const |
returns whether the quiet mode is on. | |
void | set_algo (const int &algo) |
sets the optimization algorithm. | |
int | get_algo () const |
returns which algorithm is set for the optimization at hand. | |
void | set_gp (const TGenoPheno &gp) |
sets the genotype/phenotype transform object. | |
TGenoPheno | get_gp () const |
returns the current genotype/phenotype transform object. | |
void | set_fplot (const std::string &fplot) |
sets the output filename (activates the output to file). | |
void | set_full_fplot (const bool &b) |
activates / deactivates the full output (for legacy plotting). | |
std::string | get_fplot () const |
returns the current output filename. | |
void | set_gradient (const bool &gradient) |
activates the gradient injection scheme. If no gradient function is defined, injects a numerical gradient solution instead | |
bool | get_gradient () const |
returns whether the gradient injection scheme is activated. | |
void | set_edm (const bool &edm) |
activates computation of expected distance to minimum when optimization has completed | |
bool | get_edm () const |
returns whether edm is activated. | |
void | set_mt_feval (const bool &mt) |
activate / deactivate the parallel evaluation of objective function | |
bool | get_mt_feval () const |
returns whether the parallel evaluation of objective function is activated | |
void | set_max_hist (const int &m) |
sets maximum history size, allows to keep memory requirements fixed. | |
void | set_maximize (const bool &maximize) |
active internal maximization scheme (simply returns -f instead of f) | |
bool | get_maximize () const |
returns whether the maximization mode is enabled | |
void | set_initial_fvalue (const bool &b) |
whether to compute initial objective function value (i.e. at x0) | |
void | set_uh (const bool &b) |
activates / deactivates uncertainty handling scheme. | |
bool | get_uh () const |
get uncertainty handling status. | |
void | set_tpa (const int &b) |
activates / deactivates two-point adaptation step-size mechanism | |
int | get_tpa () const |
get two-point adapation step-size mechanism status. | |
Private Attributes | |
int | _mu |
dVec | _weights |
double | _csigma |
double | _c1 |
double | _cmu |
double | _cc |
double | _muw |
double | _dsigma |
double | _fact_ps |
double | _fact_pc |
double | _chi |
double | _sigma_init |
int | _nrestarts = 9 |
bool | _lazy_update |
double | _lazy_value |
double | _cm |
double | _alphacov |
double | _alphaminusold |
double | _deltamaxsigma |
double | _lambdamintarget |
double | _alphaminusmin |
bool | _sep = false |
bool | _vd = false |
bool | _elitist = false |
bool | _initial_elitist = false |
bool | _initial_elitist_on_restart = false |
std::map< int, bool > | _stoppingcrit |
Friends | |
class | CMASolutions |
template<class U , class V > | |
class | CMAStrategy |
template<class U , class V , class W > | |
class | ESOStrategy |
template<class U > | |
class | CMAStopCriteria |
template<class U , class V > | |
class | IPOPCMAStrategy |
template<class U , class V > | |
class | BIPOPCMAStrategy |
class | CovarianceUpdate |
class | ACovarianceUpdate |
template<class U > | |
class | errstats |
class | VDCMAUpdate |
Additional Inherited Members | |
![]() | |
int | _dim |
int | _lambda = -1 |
int | _max_iter = -1 |
int | _max_fevals = -1 |
bool | _quiet = true |
std::string | _fplot = "" |
bool | _full_fplot = false |
dVec | _x0min |
dVec | _x0max |
double | _ftarget = -std::numeric_limits<double>::infinity() |
double | _ftolerance = 1e-12 |
double | _xtol = 1e-12 |
uint64_t | _seed = 0 |
int | _algo = 0 |
bool | _with_gradient =false |
bool | _with_edm =false |
std::unordered_map< int, double > | _fixed_p |
TGenoPheno | _gp |
bool | _mt_feval = false |
int | _max_hist = -1 |
bool | _maximize = false |
bool | _initial_fvalue = false |
bool | _uh = false |
double | _rlambda |
double | _epsuh = 1e-7 |
double | _thetauh = 0.2 |
double | _csuh = 1.0 |
double | _alphathuh = 1.0 |
int | _tpa = 1 |
double | _tpa_csigma = 0.3 |
![]() | |
static std::map< std::string, int > | _algos = {{"cmaes",0},{"ipop",1},{"bipop",2},{"acmaes",3},{"aipop",4},{"abipop",5},{"sepcmaes",6},{"sepipop",7},{"sepbipop",8},{"sepacmaes",9},{"sepipop",10},{"sepbipop",11},{"vdcma",12},{"vdipopcma",13},{"vdbipopcma",14}} |
Parameters for various flavors of the CMA-ES algorithm.
libcmaes::CMAParameters< TGenoPheno >::CMAParameters | ( | const int & | dim, |
const double * | x0, | ||
const double & | sigma, | ||
const int & | lambda = -1 , |
||
const uint64_t & | seed = 0 , |
||
const TGenoPheno & | gp = TGenoPheno() |
||
) |
Constructor.
dim | problem dimensions |
x0 | initial search point |
sigma | initial distribution step size (positive, otherwise automatically set) |
lambda | number of offsprings sampled at each step |
seed | initial random seed, useful for reproducing results (if unspecified, automatically generated from current time) |
gp | genotype / phenotype object |
sep | whether to use sep-CMA-ES, using diagonal covariance matrix (modifies covariance default learning rate) |
libcmaes::CMAParameters< TGenoPheno >::CMAParameters | ( | const std::vector< double > & | x0, |
const double & | sigma, | ||
const int & | lambda = -1 , |
||
const uint64_t & | seed = 0 , |
||
const TGenoPheno & | gp = TGenoPheno() |
||
) |
Constructor.
x0 | initial search point as vector of problem dimension |
sigma | initial distribution step size (positive, otherwise automatically set) |
lambda | number of offsprings sampled at each step |
seed | initial random seed, useful for reproducing results (if unspecified, automatically generated from current time) |
gp | genotype / phenotype object |
sep | whether to use sep-CMA-ES, using diagonal covariance matrix (modifies covariance default learning rate) |
libcmaes::CMAParameters< TGenoPheno >::CMAParameters | ( | const std::vector< double > & | x0, |
const std::vector< double > & | sigma, | ||
const int & | lambda = -1 , |
||
const std::vector< double > & | lbounds = std::vector<double>() , |
||
const std::vector< double > & | ubounds = std::vector<double>() , |
||
const uint64_t & | seed = 0 |
||
) |
Constructor.
x0 | initial search point as vector of problem dimension |
sigma | vector of initial distribution step sizes (positive, otherwise automatically set) |
lambda | number of offsprings sampled at each step |
seed | initial random seed, useful for reproducing results (if unspecified, automatically generated from current time) |
gp | genotype / phenotype object |
sep | whether to use sep-CMA-ES, using diagonal covariance matrix (modifies covariance default learning rate) |
|
inline |
get lazy update status.
whether | lazy update is activated |
|
inline |
get the number of restarts (applies to IPOP and BIPOP).
|
inline |
returns initial sigma value
|
inline |
whether algorithm leverages separability.
|
inline |
whether algorithm uses vd update.
|
inline |
sets the optimization algorithm. Note: overrides Parameters::set_algo
algo | from CMAES_DEFAULT, IPOP_CMAES, BIPOP_CMAES, aCMAES, aIPOP_CMAES, aBIPOP_CMAES, sepCMAES, sepIPOP_CMAES, sepBIPOP_CMAES, sepaCMAES, sepaIPOP_CMAES, sepaBIPOP_CMAES, VD_CMAES, VD_IPOP_CMAES, VD_BIPOP_CMAES |
void libcmaes::CMAParameters< TGenoPheno >::set_fixed_p | ( | const int & | index, |
const double & | value | ||
) |
freezes a parameter to a given value in genotype during optimization. Adapts some generic parameters as well.
index | dimension index of the parameter to be frozen |
value | frozen value of the parameter |
|
inline |
activates the gradient injection scheme. If no gradient function is defined, injects a numerical gradient solution instead Note: overrides Parameters::set_gradient
gradient | true/false |
|
inline |
sets the lazy update (i.e. updates the eigenvalues every few steps).
lz | whether to activate the lazy update |
|
inline |
sets the maximum number of restarts (applies to IPOP and BIPOP).
nrestarts | maximum number of restarts |
|
inline |
all stopping criteria are active by default, this allows to control them
criteria | stopping criteria CMAStopCritType, see cmastopcriteria.h |
active | whether to activate this criteria |
|
inline |
sets the optimization algorithm.
algo | as string from cmaes,ipop,bipop,acmaes,aipop,abipop,sepcmaes,sepipop,sepbipop,sepacmaes,sepaipop,sepabipop,vdcma,vdipopcma,vdbipopcma |
void libcmaes::CMAParameters< TGenoPheno >::set_tpa | ( | const int & | b | ) |
activates / deactivates two-point adaptation step-size mechanism. Overrides parameters::set_tpa by automatically setting dsigma value.
b | 0: no, 1: auto, 2: yes |
|
inline |
sets dsigma value, use with care.
d | dsigma |
void libcmaes::CMAParameters< TGenoPheno >::unset_fixed_p | ( | const int & | index | ) |
unfreezes a parameter.
index | dimenion index of the parameter to unfreeze |
|
private |
= 2 (active CMA only)
|
private |
= 1 (active CMA only)
|
private |
in [0,1] (active CMA only)
|
private |
covariance matrix learning rate for the rank one update using pc.
|
private |
cumulation constant for pc.
|
private |
norm of N(0,I)
|
private |
learning rate for the mean.
|
private |
covariance matrix learning reate for the rank mu update.
|
private |
cumulation constant for step size.
|
private |
infinite (active CMA only)
|
private |
step size damping factor.
|
private |
re-inject the best-ever seen solution.
|
private |
re-inject x0.
|
private |
activate the restart from and re-injection of the best seen solution if not the final one.
|
private |
= 0.66 (active CMA only)
|
private |
covariance lazy update.
|
private |
reference trigger for lazy update.
|
private |
number of candidate solutions used to update the distribution parameters.
|
private |
\sum^\mu _weights .
|
private |
maximum number of restart, when applicable.
|
private |
whether to use diagonal covariance matrix.
|
private |
initial sigma value.
|
private |
control list of stopping criteria.
|
private |
offsprings weighting scheme.