libcmaes 0.10.2
A C++11 library for stochastic optimization with CMA-ES
Loading...
Searching...
No Matches
libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno > Class Template Reference

ACM Surrogate strategy for CMA-ES, follows: 'Surrogate-Assisted Evolutionary Algorithms', Ilya Loshchilov, PhD Thesis, Universite Paris-Sud 11, 2013. http://www.loshchilov.com/phd.html see Chapter 4. More...

#include <libcmaes/surrogatestrategy.h>

Inheritance diagram for libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >:
libcmaes::SurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno > libcmaes::RSVMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >

Public Member Functions

 ACMSurrogateStrategy (FitFunc &func, CMAParameters< TGenoPheno > &parameters)
 constructor
 
dMat ask ()
 Generates a set of candidate points. Uses the pre-sampling of a larger than usual number of offprings, controled by 'lambdaprime', as needed.
 
void eval (const dMat &candidates, const dMat &phenocandidates=dMat(0, 0))
 Evaluates a set of candiates against the objective function or the surrogate model, as needed.
 
void tell ()
 Updates the state of the stochastic search, and prepares for the next iteration by training the surrogate model, as needed.
 
int optimize ()
 
bool do_train () const
 whether to train the model
 
void set_lambdaprime (const int &lp)
 sets the number of true objective function calls per iteration
 
int get_lambdaprime () const
 returns the number of calls to the true objective function per iteration
 
void set_prelambda (const int &pl)
 sets the number of pre-screened offsprings (sampled)
 
int get_prelambda () const
 returns the current number of pre-screened offpsrings (sampled)
 
void set_theta_sel0 (const double &s)
 sets the standard deviation of selection sampling step 0
 
double get_theta_sel0 () const
 returns the standard deviation of selection sampling step 0
 
void set_theta_sel1 (const double &s)
 sets the standard deviation of selection sampling step 1
 
double get_theta_sel1 () const
 returns the standard deviation of selection sampling step 0
 
- Public Member Functions inherited from libcmaes::SurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >
 SurrogateStrategy (FitFunc &func, CMAParameters< TGenoPheno > &parameters)
 constructor
 
int train (const std::vector< Candidate > &candidates, const dMat &cov)
 train a surrogate model
 
int predict (std::vector< Candidate > &candidates, const dMat &cov)
 predict from a surrogate model
 
double compute_error (const std::vector< Candidate > &test_set, const dMat &cov=dMat(0, 0))
 compute surrogate model error (copies and sorts the test_set)
 
bool do_train () const
 conditionals on training, to be specialized in inherited surrogate strategies
 
void set_ftrain (const CSurrFunc &train)
 sets the training function
 
void set_fpredict (const SurrFunc &predict)
 sets the prediction function
 
void set_l (const int &l)
 sets the size of the training set (number of points)
 
int get_l () const
 gets the size of the training set (number of points)
 
void set_exploit (const bool &exploit)
 sets whether to exploit the surrogate model
 
bool get_exploit () const
 gets the state of surrogate model exploitation
 
double get_train_error () const
 returns the surrogate model training error
 
double get_test_error () const
 returns the surrogate model test error
 
void set_train_error (const double &err)
 sets training error
 
void set_test_error (const double &err)
 sets the test error and updates the smoothed test err.
 
void add_to_training_set (const Candidate &c)
 adds a point to the training set (candidate = points + objective function value)
 
void set_nsteps (const int &nsteps)
 sets the lifelength of the surrogate, i.e. the number of steps in between to training steps
 
void reset_training_set ()
 resets training set and related information, useful when using algorithms with restarts
 
int get_nsteps () const
 returns the current surrogate lifelength
 

Protected Member Functions

void pre_selection_eval (const dMat &candidates)
 pre-selection + candidate evaluation scheme. Called by eval, evaluates lambdaprime candidates with surrogate model, then subsample the population in order to evaluate them with the original objective function, test the surrogate model and grow the training set with new points
 

Protected Attributes

double _prelambda = 500
 
double _theta_sel0 = 0.4
 
double _theta_sel1 = 0.8
 
int _lambdaprime
 
- Protected Attributes inherited from libcmaes::SurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >
bool _exploit = true
 
int _l = 200
 
std::vector< Candidate_tset
 
CSurrFunc _train
 
SurrFunc _predict
 
double _train_err = 0.0
 
double _test_err = 0.0
 
double _smooth_test_err = 0.5
 
double _beta_err = 0.2
 
int _nsteps = 1
 
int _auto_nsteps = false
 

Private Member Functions

void init_rd ()
 

Private Attributes

std::random_device _rd
 
std::normal_distribution< double_norm_sel0
 
std::normal_distribution< double_norm_sel1
 
std::mt19937 _gen0
 
std::mt19937 _gen1
 

Detailed Description

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
class libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >

ACM Surrogate strategy for CMA-ES, follows: 'Surrogate-Assisted Evolutionary Algorithms', Ilya Loshchilov, PhD Thesis, Universite Paris-Sud 11, 2013. http://www.loshchilov.com/phd.html see Chapter 4.

Implements a single-objective strategy for CMA-ES and related algorithms, that samples ans pre-screens a larger than usual number of offsprings at each generation, rank them with a rank-based surrogate model, and consumes a small portion of offsprings with the original (supposedly expensive) objective function.

This strategy overrides the ask/eval/tell functions of the base optimization strategy

Constructor & Destructor Documentation

◆ ACMSurrogateStrategy()

libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::ACMSurrogateStrategy ( FitFunc &  func,
CMAParameters< TGenoPheno > &  parameters 
)

constructor

Parameters
funcobjective function to minimize
parametersoptimization parameters

Member Function Documentation

◆ ask()

Generates a set of candidate points. Uses the pre-sampling of a larger than usual number of offprings, controled by 'lambdaprime', as needed.

Note: this function overrides the default ESOStrategy::ask

Returns
A matrix whose rows contain the candidate points.

◆ do_train()

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
bool libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::do_train ( ) const
inline

whether to train the model

Returns
whether to train the model

◆ eval()

void libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::eval ( const dMat &  candidates,
const dMat &  phenocandidates = dMat(0,0) 
)

Evaluates a set of candiates against the objective function or the surrogate model, as needed.

Note: this function overrides the default CMAStrategy::eval

Parameters
candidatesA matrix whose rows contain the candidates.
phenocandidatesThe candidates transformed into phenotype, leave empty if no pheno transform.

◆ get_lambdaprime()

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
int libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::get_lambdaprime ( ) const
inline

returns the number of calls to the true objective function per iteration

Returns
calls per iteration to the true objective function

◆ get_prelambda()

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
int libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::get_prelambda ( ) const
inline

returns the current number of pre-screened offpsrings (sampled)

Returns
number of offsprings

◆ get_theta_sel0()

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
double libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::get_theta_sel0 ( ) const
inline

returns the standard deviation of selection sampling step 0

Returns
standard deviation

◆ get_theta_sel1()

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
double libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::get_theta_sel1 ( ) const
inline

returns the standard deviation of selection sampling step 0

Returns
standard deviation

◆ pre_selection_eval()

void libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::pre_selection_eval ( const dMat &  candidates)
protected

pre-selection + candidate evaluation scheme. Called by eval, evaluates lambdaprime candidates with surrogate model, then subsample the population in order to evaluate them with the original objective function, test the surrogate model and grow the training set with new points

Parameters
candidatesA matrix whose rows contain the candidates.

◆ set_lambdaprime()

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
void libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::set_lambdaprime ( const int lp)
inline

sets the number of true objective function calls per iteration

Parameters
lptrue objective function calls per iteration

◆ set_prelambda()

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
void libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::set_prelambda ( const int pl)
inline

sets the number of pre-screened offsprings (sampled)

Parameters
numberof offsprings

◆ set_theta_sel0()

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
void libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::set_theta_sel0 ( const double s)
inline

sets the standard deviation of selection sampling step 0

Parameters
sstandard deviation

◆ set_theta_sel1()

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
void libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::set_theta_sel1 ( const double s)
inline

sets the standard deviation of selection sampling step 1

Parameters
sstandard deviation

◆ tell()

Updates the state of the stochastic search, and prepares for the next iteration by training the surrogate model, as needed.

Note: this function overrides the default CMAStrategy::tell

Member Data Documentation

◆ _lambdaprime

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
int libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::_lambdaprime
protected

true objective function calls per iteration.

◆ _prelambda

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
double libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::_prelambda = 500
protected

number of pre-screened offsprings.

◆ _theta_sel0

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
double libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::_theta_sel0 = 0.4
protected

standard deviation of selection sampling step 0.

◆ _theta_sel1

template<template< class U, class V > class TStrategy, class TCovarianceUpdate = CovarianceUpdate, class TGenoPheno = GenoPheno<NoBoundStrategy>>
double libcmaes::ACMSurrogateStrategy< TStrategy, TCovarianceUpdate, TGenoPheno >::_theta_sel1 = 0.8
protected

standard deviation of selection sampling step 1.


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