libcmaes 0.10.2
A C++11 library for stochastic optimization with CMA-ES
Loading...
Searching...
No Matches
libcmaes::CMASolutions Class Reference

Holder of the set of evolving solutions from running an instance of CMA-ES. More...

#include <libcmaes/cmasolutions.h>

Public Member Functions

 CMASolutions ()
 dummy constructor.
 
template<class TGenoPheno = GenoPheno<NoBoundStrategy>>
 CMASolutions (Parameters< TGenoPheno > &p)
 initializes solutions from stochastic optimization parameters.
 
void sort_candidates ()
 sorts the current internal set of solution candidates.
 
void update_best_candidates ()
 updates the history of best candidates, as well as other meaningful values, typically used in termination criteria.
 
void update_eigenv (const dVec &eigenvalues, const dMat &eigenvectors)
 updates reference eigenvalue and eigenvectors, for use in termination criteria.
 
Candidate best_candidate () const
 returns current best solution candidate. NOTE: candidates MUST be sorted
 
Candidate get_best_seen_candidate () const
 returns the best seen candidate.
 
Candidate get_worst_seen_candidate () const
 returns the worst seen candidate.
 
Candidateget_candidate (const int &r)
 get a reference to the r-th candidate in current set
 
Candidate get_candidate (const int &r) const
 
std::vector< Candidate > & candidates ()
 get a reference to the full candidate set
 
int size () const
 number of candidate solutions.
 
void reset ()
 resets the solution object in order to restart from the current solution with fresh covariance matrix. Note: experimental.
 
void reset_as_fixed (const int &k)
 re-arrange solution object such that parameter 'k' is fixed (i.e. removed).
 
bool get_pli (const int &k, pli &p) const
 get profile likelihood if previously computed.
 
int dim () const
 return problem dimension.
 
double edm () const
 returns expected distance to minimum.
 
dMat cov () const
 returns error covariance matrix
 
const dMat & cov_ref () const
 returns reference to error covariance matrix
 
const doublecov_data () const
 returns pointer to covariance matrix array
 
dMat full_cov () const
 returns full covariance matrix. Similar to cov() but in case of linear-sized algorithms like sep and vd, returns the full covariance matrix anyways.
 
dMat sepcov () const
 returns separable covariance diagonal matrix, only applicable to sep-CMA-ES algorithms.
 
const dMat & sepcov_ref () const
 returns reference to separable covariance diagonal vector, only applicable to sep-CMA-ES algorithms.
 
const doublesepcov_data () const
 returns pointer to covariance diagnoal vector
 
dMat csqinv () const
 returns inverse root square of covariance matrix
 
dMat sepcsqinv () const
 returns inverse root square of separable covariance diagonal matrix, only applicable to sep-CMA-ES algorithms.
 
template<class TGenoPheno = GenoPheno<NoBoundStrategy>>
dVec stds (const CMAParameters< TGenoPheno > &cmaparams) const
 
template<class TGenoPheno = GenoPheno<NoBoundStrategy>>
dVec errors (const CMAParameters< TGenoPheno > &cmaparams) const
 
dMat corr () const
 returns correlation matrix
 
double corr (const int &i, const int &j) const
 returns correlation between parameter i and j (useful in large-scale settings)
 
double sigma () const
 returns current value of step-size sigma
 
void set_sigma (const double &sigma)
 sets new step-size value, use with care
 
dVec xmean () const
 returns current distribution's mean in parameter space
 
void set_xmean (const dVec &xmean)
 sets the current distributions' mean in parameter space
 
int run_status () const
 returns current optimization status.
 
std::string status_msg () const
 returns current optimization status' message.
 
int elapsed_time () const
 returns currently elapsed time spent on optimization
 
int elapsed_last_iter () const
 returns time spent on last iteration
 
int niter () const
 returns current number of iterations
 
int nevals () const
 returns current budget (number of objective function calls)
 
double min_eigenv () const
 returns current minimal eigen value
 
double max_eigenv () const
 returns current maximal eigen value
 
bool updated_eigen () const
 returns whether the last update is lazy
 
int fevals () const
 returns current number of objective function evaluations
 
dVec eigenvalues () const
 returns last computed eigenvalues
 
dMat eigenvectors () const
 returns last computed eigenvectors
 
template<class TGenoPheno = GenoPheno<NoBoundStrategy>>
std::ostream & print (std::ostream &out, const int &verb_level=0, const TGenoPheno &gp=TGenoPheno()) const
 print the solution object out.
 

Private Attributes

dMat _cov
 
dMat _csqinv
 
dMat _sepcov
 
dMat _sepcsqinv
 
dVec _xmean
 
dVec _psigma
 
dVec _pc
 
short _hsig = 1
 
double _sigma
 
std::vector< Candidate_candidates
 
std::vector< Candidate_best_candidates_hist
 
int _max_hist = -1
 
double _max_eigenv = 0.0
 
double _min_eigenv = 0.0
 
dVec _leigenvalues
 
dMat _leigenvectors
 
int _niter = 0
 
int _nevals = 0
 
int _kcand = 1
 
std::vector< Candidate_k_best_candidates_hist
 
std::vector< double_bfvalues
 
std::vector< double_median_fvalues
 
int _eigeniter = 0
 
bool _updated_eigen = true
 
int _run_status = 0
 
int _elapsed_time = 0
 
int _elapsed_last_iter = 0
 
std::map< int, pli_pls
 
double _edm = 0.0
 
Candidate _best_seen_candidate
 
int _best_seen_iter
 
Candidate _worst_seen_candidate
 
Candidate _initial_candidate
 
dVec _v
 
std::vector< RankedCandidate_candidates_uh
 
int _lambda_reev
 
double _suh
 
double _tpa_s = 0.0
 
int _tpa_p1 = 0
 
int _tpa_p2 = 1
 
dVec _tpa_x1
 
dVec _tpa_x2
 
dVec _xmean_prev
 

Friends

template<class U , class V >
class CMAStrategy
 
template<class U , class V , class W >
class ESOptimizer
 
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
 

Detailed Description

Holder of the set of evolving solutions from running an instance of CMA-ES.

Constructor & Destructor Documentation

◆ CMASolutions()

template<class TGenoPheno >
libcmaes::CMASolutions::CMASolutions ( Parameters< TGenoPheno > &  p)

initializes solutions from stochastic optimization parameters.

Parameters
pparameters

Member Function Documentation

◆ best_candidate()

Candidate libcmaes::CMASolutions::best_candidate ( ) const
inline

returns current best solution candidate. NOTE: candidates MUST be sorted

Returns
current best candidate
See also
CMASolutions::sort_candidates

◆ corr() [1/2]

dMat libcmaes::CMASolutions::corr ( ) const

returns correlation matrix

Returns
correlation matrix

◆ corr() [2/2]

double libcmaes::CMASolutions::corr ( const int i,
const int j 
) const

returns correlation between parameter i and j (useful in large-scale settings)

Returns
correlation between parameter i and j

◆ cov()

dMat libcmaes::CMASolutions::cov ( ) const
inline

returns error covariance matrix

Returns
error covariance matrix

◆ cov_data()

const double * libcmaes::CMASolutions::cov_data ( ) const
inline

returns pointer to covariance matrix array

Returns
pointer to covariance matrix array

◆ cov_ref()

const dMat & libcmaes::CMASolutions::cov_ref ( ) const
inline

returns reference to error covariance matrix

Returns
error covariance matrix

◆ csqinv()

dMat libcmaes::CMASolutions::csqinv ( ) const
inline

returns inverse root square of covariance matrix

Returns
square root of error covariance matrix

◆ dim()

int libcmaes::CMASolutions::dim ( ) const
inline

return problem dimension.

Returns
problem dimension

◆ edm()

double libcmaes::CMASolutions::edm ( ) const
inline

returns expected distance to minimum.

Returns
edm

◆ eigenvalues()

dVec libcmaes::CMASolutions::eigenvalues ( ) const
inline

returns last computed eigenvalues

Returns
last computed eigenvalues

◆ eigenvectors()

dMat libcmaes::CMASolutions::eigenvectors ( ) const
inline

returns last computed eigenvectors

Returns
last computed eigenvectors

◆ elapsed_last_iter()

int libcmaes::CMASolutions::elapsed_last_iter ( ) const
inline

returns time spent on last iteration

Returns
time spent on last iteration

◆ elapsed_time()

int libcmaes::CMASolutions::elapsed_time ( ) const
inline

returns currently elapsed time spent on optimization

Returns
time spent on optimization

◆ errors()

template<class TGenoPheno = GenoPheno<NoBoundStrategy>>
dVec libcmaes::CMASolutions::errors ( const CMAParameters< TGenoPheno > &  cmaparams) const
inline
Returns
standard deviation vector
Parameters
cmaparamsparameter object that hold the genotype/phenotype transform
Returns
standard deviation vector

◆ fevals()

int libcmaes::CMASolutions::fevals ( ) const
inline

returns current number of objective function evaluations

Returns
number of objective function evaluations

◆ full_cov()

dMat libcmaes::CMASolutions::full_cov ( ) const

returns full covariance matrix. Similar to cov() but in case of linear-sized algorithms like sep and vd, returns the full covariance matrix anyways.

Returns
full size covariance matrix

◆ get_best_seen_candidate()

Candidate libcmaes::CMASolutions::get_best_seen_candidate ( ) const
inline

returns the best seen candidate.

Returns
best seen candidate

◆ get_candidate()

Candidate & libcmaes::CMASolutions::get_candidate ( const int r)
inline

get a reference to the r-th candidate in current set

Parameters
rcandidate position

◆ get_worst_seen_candidate()

Candidate libcmaes::CMASolutions::get_worst_seen_candidate ( ) const
inline

returns the worst seen candidate.

Returns
worst seen candidate

◆ max_eigenv()

double libcmaes::CMASolutions::max_eigenv ( ) const
inline

returns current maximal eigen value

Returns
maximal eigen value

◆ min_eigenv()

double libcmaes::CMASolutions::min_eigenv ( ) const
inline

returns current minimal eigen value

Returns
minimal eigen value

◆ nevals()

int libcmaes::CMASolutions::nevals ( ) const
inline

returns current budget (number of objective function calls)

Returns
number of objective function calls

◆ niter()

int libcmaes::CMASolutions::niter ( ) const
inline

returns current number of iterations

Returns
number of iterations

◆ print()

template<class TGenoPheno >
template CMAES_EXPORT std::ostream & libcmaes::CMASolutions::print ( std::ostream &  out,
const int verb_level = 0,
const TGenoPheno gp = TGenoPheno() 
) const

print the solution object out.

Parameters
outoutput stream
verb_levelverbosity level: 0 for short, 1 for debug.

◆ reset_as_fixed()

void libcmaes::CMASolutions::reset_as_fixed ( const int k)

re-arrange solution object such that parameter 'k' is fixed (i.e. removed).

Parameters
kindex of the parameter to remove.

◆ run_status()

int libcmaes::CMASolutions::run_status ( ) const
inline

returns current optimization status.

Returns
status

◆ sepcov()

dMat libcmaes::CMASolutions::sepcov ( ) const
inline

returns separable covariance diagonal matrix, only applicable to sep-CMA-ES algorithms.

Returns
error covariance diagonal vector

◆ sepcov_data()

const double * libcmaes::CMASolutions::sepcov_data ( ) const
inline

returns pointer to covariance diagnoal vector

Returns
pointer to covariance diagonal array

◆ sepcov_ref()

const dMat & libcmaes::CMASolutions::sepcov_ref ( ) const
inline

returns reference to separable covariance diagonal vector, only applicable to sep-CMA-ES algorithms.

Returns
error covariance diagonal vector

◆ sepcsqinv()

dMat libcmaes::CMASolutions::sepcsqinv ( ) const
inline

returns inverse root square of separable covariance diagonal matrix, only applicable to sep-CMA-ES algorithms.

Returns
square root of error covariance diagonal matrix

◆ set_sigma()

void libcmaes::CMASolutions::set_sigma ( const double sigma)
inline

sets new step-size value, use with care

Parameters
sigmastep-size value

◆ set_xmean()

void libcmaes::CMASolutions::set_xmean ( const dVec &  xmean)
inline

sets the current distributions' mean in parameter space

Parameters
xmeanmean vector

◆ sigma()

double libcmaes::CMASolutions::sigma ( ) const
inline

returns current value of step-size sigma

Returns
current step-size

◆ size()

int libcmaes::CMASolutions::size ( ) const
inline

number of candidate solutions.

Returns
current number of solution candidates.

◆ status_msg()

std::string libcmaes::CMASolutions::status_msg ( ) const
inline

returns current optimization status' message.

Returns
status message

◆ stds()

template<class TGenoPheno = GenoPheno<NoBoundStrategy>>
dVec libcmaes::CMASolutions::stds ( const CMAParameters< TGenoPheno > &  cmaparams) const
inline
Returns
the unscaled standard deviation vector Note: this is only useful to compare amond standard deviations To get the true rescaled estimate of the error, use errors()
Parameters
cmaparamsparameter object that hold the genotype/phenotype transform
Returns
unscaled standard deviation vector

◆ update_best_candidates()

void libcmaes::CMASolutions::update_best_candidates ( )

updates the history of best candidates, as well as other meaningful values, typically used in termination criteria.

See also
CMAStopCriteria

◆ update_eigenv()

void libcmaes::CMASolutions::update_eigenv ( const dVec &  eigenvalues,
const dMat &  eigenvectors 
)

updates reference eigenvalue and eigenvectors, for use in termination criteria.

See also
CMAStopCriteria

◆ updated_eigen()

bool libcmaes::CMASolutions::updated_eigen ( ) const
inline

returns whether the last update is lazy

Returns
whether the last update is lazy

◆ xmean()

dVec libcmaes::CMASolutions::xmean ( ) const
inline

returns current distribution's mean in parameter space

Returns
mean

Member Data Documentation

◆ _best_candidates_hist

std::vector<Candidate> libcmaes::CMASolutions::_best_candidates_hist
private

history of best candidate solutions.

◆ _best_seen_candidate

Candidate libcmaes::CMASolutions::_best_seen_candidate
private

best seen candidate along the run.

◆ _bfvalues

std::vector<double> libcmaes::CMASolutions::_bfvalues
private

best function values over the past 20 steps, for termination criteria.

◆ _candidates

std::vector<Candidate> libcmaes::CMASolutions::_candidates
private

current set of candidate solutions.

◆ _candidates_uh

std::vector<RankedCandidate> libcmaes::CMASolutions::_candidates_uh
private

temporary set of candidates used by uncertainty handling scheme.

◆ _cov

dMat libcmaes::CMASolutions::_cov
private

covariance matrix.

◆ _edm

double libcmaes::CMASolutions::_edm = 0.0
private

expected vertical distance to the minimum.

◆ _eigeniter

int libcmaes::CMASolutions::_eigeniter = 0
private

eigenvalues computation last step, lazy-update only.

◆ _elapsed_last_iter

int libcmaes::CMASolutions::_elapsed_last_iter = 0
private

time consumed during last iteration.

◆ _elapsed_time

int libcmaes::CMASolutions::_elapsed_time = 0
private

final elapsed time of stochastic optimization.

◆ _hsig

short libcmaes::CMASolutions::_hsig = 1
private

0 or 1.

◆ _k_best_candidates_hist

std::vector<Candidate> libcmaes::CMASolutions::_k_best_candidates_hist
private

k-th best candidate history, for termination criteria, k is kcand=1+floor(0.1+lambda/4).

◆ _lambda_reev

int libcmaes::CMASolutions::_lambda_reev
private

number of reevaluated solutions at current step.

◆ _leigenvalues

dVec libcmaes::CMASolutions::_leigenvalues
private

last computed eigenvalues, for termination criteria.

◆ _leigenvectors

dMat libcmaes::CMASolutions::_leigenvectors
private

last computed eigenvectors, for termination criteria.

◆ _max_eigenv

double libcmaes::CMASolutions::_max_eigenv = 0.0
private

max eigenvalue, for termination criteria.

◆ _max_hist

int libcmaes::CMASolutions::_max_hist = -1
private

max size of the history, keeps memory requirements fixed.

◆ _median_fvalues

std::vector<double> libcmaes::CMASolutions::_median_fvalues
private

median function values of some steps, in the past, for termination criteria.

◆ _min_eigenv

double libcmaes::CMASolutions::_min_eigenv = 0.0
private

min eigenvalue, for termination criteria.

◆ _nevals

int libcmaes::CMASolutions::_nevals = 0
private

number of function calls to reach the current solution.

◆ _niter

int libcmaes::CMASolutions::_niter = 0
private

number of iterations to reach this solution, for termination criteria.

◆ _pc

dVec libcmaes::CMASolutions::_pc
private

cumulation for covariance.

◆ _pls

std::map<int,pli> libcmaes::CMASolutions::_pls
private

profile likelihood for parameters it has been computed for.

◆ _psigma

dVec libcmaes::CMASolutions::_psigma
private

cumulation for sigma.

◆ _run_status

int libcmaes::CMASolutions::_run_status = 0
private

current status of the stochastic optimization (e.g. running, or stopped under termination criteria).

◆ _sepcov

dMat libcmaes::CMASolutions::_sepcov
private

inverse root square of covariance matrix.

◆ _sigma

double libcmaes::CMASolutions::_sigma
private

step size.

◆ _suh

double libcmaes::CMASolutions::_suh
private

uncertainty level computed by uncertainty handling procedure.

◆ _updated_eigen

bool libcmaes::CMASolutions::_updated_eigen = true
private

last update is not lazy.

◆ _v

dVec libcmaes::CMASolutions::_v
private

complementary vector for use in vdcma.

◆ _xmean

dVec libcmaes::CMASolutions::_xmean
private

distribution mean.

◆ _xmean_prev

dVec libcmaes::CMASolutions::_xmean_prev
private

previous step's mean vector.


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