Implements the CMA-ES. More...
#include <shark/Algorithms/DirectSearch/CMA.h>
Public Types | |
enum | RecombinationType { EQUAL = 0, LINEAR = 1, SUPERLINEAR = 2 } |
Models the recombination type. More... | |
![]() | |
typedef base_type::SearchPointType | SearchPointType |
typedef base_type::SolutionType | SolutionType |
typedef base_type::ResultType | ResultType |
typedef base_type::ObjectiveFunctionType | ObjectiveFunctionType |
![]() | |
enum | Feature |
Models features that the optimizer requires from the objective function. More... | |
typedef RealVector | SearchPointType |
typedef double | ResultType |
typedef SingleObjectiveResultSet< RealVector > | SolutionType |
typedef AbstractObjectiveFunction< RealVector, ResultType > | ObjectiveFunctionType |
typedef TypedFlags< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Member Functions | |
SHARK_EXPORT_SYMBOL | CMA (DefaultRngType &rng=Rng::globalRng) |
Default c'tor. More... | |
std::string | name () const |
From INameable: return the class name. More... | |
template<typename Container , typename Extractor > | |
RealVector | weightedSum (const Container &container, const RealVector &weights, const Extractor &e) |
Calculates the center of gravity of the given population \( \in \mathbb{R}^d\). More... | |
SHARK_EXPORT_SYMBOL void | read (InArchive &archive) |
Read the component from the supplied archive. More... | |
SHARK_EXPORT_SYMBOL void | write (OutArchive &archive) const |
Write the component to the supplied archive. More... | |
SHARK_EXPORT_SYMBOL void | init (ObjectiveFunctionType &function, SearchPointType const &p) |
Initializes the algorithm for the supplied objective function. More... | |
SHARK_EXPORT_SYMBOL void | init (ObjectiveFunctionType &function, SearchPointType const &initialSearchPoint, std::size_t lambda, std::size_t mu, double initialSigma, const boost::optional< RealMatrix > &initialCovarianceMatrix=boost::optional< RealMatrix >()) |
Initializes the algorithm for the supplied objective function. More... | |
SHARK_EXPORT_SYMBOL void | step (ObjectiveFunctionType const &function) |
Executes one iteration of the algorithm. More... | |
void | setInitialSigma (double initSigma) |
sets the initial step length sigma More... | |
double | sigma () const |
Accesses the current step size. More... | |
RealVector const & | mean () const |
Accesses the current population mean. More... | |
RealVector const & | weights () const |
Accesses the current weighting vector. More... | |
RealVector const & | evolutionPath () const |
Accesses the evolution path for the covariance matrix update. More... | |
RealVector const & | evolutionPathSigma () const |
Accesses the evolution path for the step size update. More... | |
RealMatrix const & | covarianceMatrix () const |
Accesses the covariance matrix of the normal distribution used for generating offspring individuals. More... | |
RecombinationType | recombinationType () const |
Accesses the recombination type. More... | |
RecombinationType & | recombinationType () |
Returns a mutable reference to the recombination type. More... | |
const double & | lowerBound () const |
Returns a const reference tothe lower bound on sigma times smalles eigenvalue. More... | |
std::size_t | mu () const |
Returns the size of the parent population \(\mu\). More... | |
void | setMu (std::size_t mu) |
Sets the number of selected samples. More... | |
void | setLambda (std::size_t lambda) |
Sets the number of sampled points. More... | |
std::size_t | lambda () const |
Returns a immutable reference to the size of the offspring population \(\mu\). More... | |
RealMatrix const & | eigenVectors () const |
Returns eigenvectors of covariance matrix (not considering step size) More... | |
RealVector const & | eigenValues () const |
Returns a eigenvectors of covariance matrix (not considering step size) More... | |
double | condition () const |
Returns condition of covariance matrix. More... | |
![]() | |
virtual void | init (ObjectiveFunctionType &function) |
virtual const SolutionType & | solution () const |
returns the current solution of the optimizer More... | |
![]() | |
const Features & | features () const |
virtual void | updateFeatures () |
bool | requiresValue () const |
bool | requiresFirstDerivative () const |
bool | requiresSecondDerivative () const |
bool | canSolveConstrained () const |
bool | requiresClosestFeasible () const |
virtual | ~AbstractOptimizer () |
Empty virtual d'tor. More... | |
![]() | |
virtual | ~INameable () |
![]() | |
virtual | ~ISerializable () |
Virtual d'tor. More... | |
void | load (InArchive &archive, unsigned int version) |
Versioned loading of components, calls read(...). More... | |
void | save (OutArchive &archive, unsigned int version) const |
Versioned storing of components, calls write(...). More... | |
BOOST_SERIALIZATION_SPLIT_MEMBER () | |
Static Public Member Functions | |
static SHARK_EXPORT_SYMBOL std::size_t | suggestLambda (std::size_t dimension) |
Calculates lambda for the supplied dimensionality n. More... | |
static SHARK_EXPORT_SYMBOL std::size_t | suggestMu (std::size_t lambda, RecombinationType recomb=SUPERLINEAR) |
Calculates mu for the supplied lambda and the recombination strategy. More... | |
Protected Types | |
typedef Individual< RealVector, double, RealVector > | IndividualType |
The type of individual used for the CMA. More... | |
Protected Member Functions | |
SHARK_EXPORT_SYMBOL std::vector< IndividualType > | generateOffspring () const |
Samples lambda individuals from the search distribution. More... | |
SHARK_EXPORT_SYMBOL void | updatePopulation (std::vector< IndividualType > const &offspring) |
Updates the strategy parameters based on the supplied offspring population. More... | |
SHARK_EXPORT_SYMBOL void | doInit (std::vector< SearchPointType > const &points, std::vector< ResultType > const &functionValues, std::size_t lambda, std::size_t mu, double initialSigma) |
![]() | |
void | checkFeatures (ObjectiveFunctionType const &objectiveFunction) |
Convenience function that checks whether the features of the supplied objective function match with the required features of the optimizer. More... | |
Additional Inherited Members | |
![]() | |
SolutionType | m_best |
current solution of the optimizer More... | |
![]() | |
Features | m_features |
Implements the CMA-ES.
The algorithm is described in
Hansen, N., S. Kern (2004). Evaluating the CMA Evolution Strategy on Multimodal Test Functions. In Proceedings of the Eighth International Conference on Parallel Problem Solving from Nature (PPSN VIII), pp. 282-291, LNCS, Springer-Verlag
|
protected |
SHARK_EXPORT_SYMBOL shark::CMA::CMA | ( | DefaultRngType & | rng = Rng::globalRng | ) |
Default c'tor.
|
inline |
Returns condition of covariance matrix.
Definition at line 230 of file CMA.h.
References shark::MultiVariateNormalDistribution::eigenValues(), eigenValues(), shark::blas::max(), and shark::blas::min().
Referenced by main().
|
inline |
Accesses the covariance matrix of the normal distribution used for generating offspring individuals.
Definition at line 163 of file CMA.h.
References shark::MultiVariateNormalDistribution::covarianceMatrix().
|
protected |
|
inline |
Returns a eigenvectors of covariance matrix (not considering step size)
Definition at line 223 of file CMA.h.
References shark::MultiVariateNormalDistribution::eigenValues().
Referenced by condition(), and main().
|
inline |
Returns eigenvectors of covariance matrix (not considering step size)
Definition at line 216 of file CMA.h.
References shark::MultiVariateNormalDistribution::eigenVectors().
Referenced by main().
|
inline |
|
inline |
|
protected |
Samples lambda individuals from the search distribution.
|
virtual |
Initializes the algorithm for the supplied objective function.
Implements shark::AbstractSingleObjectiveOptimizer< RealVector >.
Referenced by main(), and weightedSum().
SHARK_EXPORT_SYMBOL void shark::CMA::init | ( | ObjectiveFunctionType & | function, |
SearchPointType const & | initialSearchPoint, | ||
std::size_t | lambda, | ||
std::size_t | mu, | ||
double | initialSigma, | ||
const boost::optional< RealMatrix > & | initialCovarianceMatrix = boost::optional< RealMatrix >() |
||
) |
Initializes the algorithm for the supplied objective function.
|
inline |
Returns a immutable reference to the size of the offspring population \(\mu\).
Definition at line 209 of file CMA.h.
Referenced by setLambda(), and weightedSum().
|
inline |
|
inline |
|
inline |
Returns the size of the parent population \(\mu\).
Definition at line 191 of file CMA.h.
Referenced by setMu(), and weightedSum().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
|
virtual |
Read the component from the supplied archive.
[in,out] | archive | The archive to read from. |
Reimplemented from shark::ISerializable.
Referenced by weightedSum().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Executes one iteration of the algorithm.
Implements shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > >.
Referenced by main(), and weightedSum().
|
static |
Calculates lambda for the supplied dimensionality n.
Referenced by weightedSum().
|
static |
Calculates mu for the supplied lambda and the recombination strategy.
Referenced by weightedSum().
|
protected |
Updates the strategy parameters based on the supplied offspring population.
|
inline |
Calculates the center of gravity of the given population \( \in \mathbb{R}^d\).
Definition at line 84 of file CMA.h.
References init(), lambda(), mu(), read(), SHARK_EXPORT_SYMBOL, step(), suggestLambda(), suggestMu(), SUPERLINEAR, weights(), and write().
|
inline |
Accesses the current weighting vector.
Definition at line 148 of file CMA.h.
Referenced by weightedSum().
|
virtual |
Write the component to the supplied archive.
[in,out] | archive | The archive to write to. |
Reimplemented from shark::ISerializable.
Referenced by weightedSum().