Implements the Cross Entropy Method. More...
#include <shark/Algorithms/DirectSearch/CrossEntropyMethod.h>
Classes | |
class | ConstantNoise |
Constant noise term z_t = noise. More... | |
class | INoiseType |
Interface class for noise type. More... | |
class | LinearNoise |
Linear noise term z_t = a + t / b. More... | |
Public Types | |
typedef boost::shared_ptr< INoiseType > | StrongNoisePtr |
Smart pointer for noise type. More... | |
Public Types inherited from shark::AbstractSingleObjectiveOptimizer< RealVector > | |
typedef base_type::SearchPointType | SearchPointType |
typedef base_type::SolutionType | SolutionType |
typedef base_type::ResultType | ResultType |
typedef base_type::ObjectiveFunctionType | ObjectiveFunctionType |
Public Types inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > > | |
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 | CrossEntropyMethod () |
Default c'tor. More... | |
std::string | name () const |
From INameable: return the class name. More... | |
void | read (InArchive &archive) |
Read the component from the supplied archive. More... | |
void | write (OutArchive &archive) const |
Write the component to the supplied archive. More... | |
SHARK_EXPORT_SYMBOL void | init (ObjectiveFunctionType const &function, SearchPointType const &p) |
Initializes the algorithm for the supplied objective function and the initial mean p. More... | |
SHARK_EXPORT_SYMBOL void | init (ObjectiveFunctionType const &function, SearchPointType const &initialSearchPoint, unsigned int populationSize, unsigned int selectionSize, RealVector initialSigma) |
Initializes the algorithm for the supplied objective function. More... | |
SHARK_EXPORT_SYMBOL void | step (ObjectiveFunctionType const &function) |
Executes one iteration of the algorithm. More... | |
RealVector const & | variance () const |
Access the current variance. More... | |
void | setVariance (RealVector variance) |
Set the variance to a vector. More... | |
void | setVariance (double variance) |
Set all variance values. More... | |
RealVector const & | mean () const |
Access the current population mean. More... | |
unsigned int | selectionSize () const |
Returns the size of the parent population. More... | |
unsigned int & | selectionSize () |
Returns a mutable reference to the size of the parent population. More... | |
unsigned int | populationSize () const |
Returns a immutable reference to the size of the population. More... | |
unsigned int & | populationSize () |
Returns a mutable reference to the size of the population. More... | |
void | setNoiseType (INoiseType *noiseType) |
Set the noise type from a raw pointer. More... | |
const INoiseType & | getNoiseType () const |
Get an immutable reference to Noise Type. More... | |
Public Member Functions inherited from shark::AbstractSingleObjectiveOptimizer< RealVector > | |
std::size_t | numInitPoints () const |
By default most single objective optimizers only require a single point. More... | |
virtual void | init (ObjectiveFunctionType const &function, std::vector< SearchPointType > const &initPoints) |
Initialize the optimizer for the supplied objective function using a set of initialisation points. More... | |
virtual const SolutionType & | solution () const |
returns the current solution of the optimizer More... | |
Public Member Functions inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > > | |
const Features & | features () const |
virtual void | updateFeatures () |
bool | requiresValue () const |
bool | requiresFirstDerivative () const |
bool | requiresSecondDerivative () const |
bool | canSolveConstrained () const |
bool | requiresClosestFeasible () const |
virtual | ~AbstractOptimizer () |
virtual void | init (ObjectiveFunctionType const &function) |
Initialize the optimizer for the supplied objective function. More... | |
Public Member Functions inherited from shark::INameable | |
virtual | ~INameable () |
Public Member Functions inherited from shark::ISerializable | |
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 unsigned | suggestPopulationSize () |
Sets default value for Population size. More... | |
static SHARK_EXPORT_SYMBOL unsigned | suggestSelectionSize (unsigned int populationSize) |
Calculates selection size for the supplied population size. More... | |
Protected Types | |
typedef Individual< RealVector, double, RealVector > | IndividualType |
Protected Member Functions | |
SHARK_EXPORT_SYMBOL void | updateStrategyParameters (std::vector< IndividualType > const &parents) |
Updates the strategy parameters based on the supplied parent population. More... | |
Protected Member Functions inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > > | |
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... | |
Protected Attributes | |
std::size_t | m_numberOfVariables |
Stores the dimensionality of the search space. More... | |
unsigned int | m_selectionSize |
Number of vectors chosen when updating distribution parameters. More... | |
unsigned int | m_populationSize |
Number of vectors sampled in a generation. More... | |
RealVector | m_variance |
Variance for sample parameters. More... | |
RealVector | m_mean |
The mean of the population. More... | |
unsigned | m_counter |
Counter for generations. More... | |
StrongNoisePtr | m_noise |
Noise type to apply in the update of distribution parameters. More... | |
Protected Attributes inherited from shark::AbstractSingleObjectiveOptimizer< RealVector > | |
SolutionType | m_best |
Current solution of the optimizer. More... | |
Protected Attributes inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > > | |
Features | m_features |
Implements the Cross Entropy Method.
This class implements the noisy cross entropy method as descibed in the following article.
Christophe Thiery, Bruno Scherrer. Improvements on Learning Tetris with Cross Entropy. International Computer Games Association Journal, ICGA, 2009, 32. <inria-00418930>
The algorithm aims to minimize an objective function through stochastic search. It works iteratively until a certain stopping criteria is met. At each iteration, it samples a number of vectors from a Gaussian distribution and evaluates each of these against the supplied objective function. Based on the return value from the objective function, a subset of the the best ranked vectors are chosen to update the search parameters of the next generation.
The mean of the Gaussian distribution is set to the centroid of the best ranked vectors, and the variance is set to the variance of the best ranked vectors in each individual dimension.
Definition at line 70 of file CrossEntropyMethod.h.
|
protected |
Definition at line 232 of file CrossEntropyMethod.h.
typedef boost::shared_ptr<INoiseType> shark::CrossEntropyMethod::StrongNoisePtr |
Smart pointer for noise type.
Definition at line 86 of file CrossEntropyMethod.h.
SHARK_EXPORT_SYMBOL shark::CrossEntropyMethod::CrossEntropyMethod | ( | ) |
Default c'tor.
Referenced by shark::CrossEntropyMethod::LinearNoise::name().
|
inline |
Get an immutable reference to Noise Type.
Definition at line 226 of file CrossEntropyMethod.h.
References m_noise.
|
virtual |
Initializes the algorithm for the supplied objective function and the initial mean p.
Implements shark::AbstractSingleObjectiveOptimizer< RealVector >.
Referenced by name().
SHARK_EXPORT_SYMBOL void shark::CrossEntropyMethod::init | ( | ObjectiveFunctionType const & | function, |
SearchPointType const & | initialSearchPoint, | ||
unsigned int | populationSize, | ||
unsigned int | selectionSize, | ||
RealVector | initialSigma | ||
) |
Initializes the algorithm for the supplied objective function.
|
inline |
Access the current population mean.
Definition at line 183 of file CrossEntropyMethod.h.
References m_mean.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 128 of file CrossEntropyMethod.h.
References init(), populationSize(), read(), selectionSize(), SHARK_EXPORT_SYMBOL, step(), suggestPopulationSize(), suggestSelectionSize(), and write().
|
inline |
Returns a immutable reference to the size of the population.
Definition at line 204 of file CrossEntropyMethod.h.
References m_populationSize.
Referenced by name().
|
inline |
Returns a mutable reference to the size of the population.
Definition at line 211 of file CrossEntropyMethod.h.
References m_populationSize.
|
virtual |
Read the component from the supplied archive.
[in,out] | archive | The archive to read from. |
Reimplemented from shark::ISerializable.
Referenced by name().
|
inline |
Returns the size of the parent population.
Definition at line 190 of file CrossEntropyMethod.h.
References m_selectionSize.
Referenced by name().
|
inline |
Returns a mutable reference to the size of the parent population.
Definition at line 197 of file CrossEntropyMethod.h.
References m_selectionSize.
|
inline |
Set the noise type from a raw pointer.
Definition at line 218 of file CrossEntropyMethod.h.
References m_noise.
|
inline |
Set the variance to a vector.
Definition at line 172 of file CrossEntropyMethod.h.
References m_variance, and variance().
|
inline |
Set all variance values.
Definition at line 178 of file CrossEntropyMethod.h.
References m_variance.
|
virtual |
Executes one iteration of the algorithm.
Implements shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > >.
Referenced by name().
|
static |
Sets default value for Population size.
Referenced by name().
|
static |
Calculates selection size for the supplied population size.
Referenced by name().
|
protected |
Updates the strategy parameters based on the supplied parent population.
|
inline |
Access the current variance.
Definition at line 167 of file CrossEntropyMethod.h.
References m_variance.
Referenced by setVariance().
|
virtual |
Write the component to the supplied archive.
[in,out] | archive | The archive to write to. |
Reimplemented from shark::ISerializable.
Referenced by name().
|
protected |
Counter for generations.
Definition at line 247 of file CrossEntropyMethod.h.
|
protected |
The mean of the population.
Definition at line 245 of file CrossEntropyMethod.h.
Referenced by mean().
|
protected |
Noise type to apply in the update of distribution parameters.
Definition at line 249 of file CrossEntropyMethod.h.
Referenced by shark::CrossEntropyMethod::ConstantNoise::ConstantNoise(), getNoiseType(), shark::CrossEntropyMethod::ConstantNoise::name(), and setNoiseType().
|
protected |
Stores the dimensionality of the search space.
Definition at line 238 of file CrossEntropyMethod.h.
|
protected |
Number of vectors sampled in a generation.
Definition at line 240 of file CrossEntropyMethod.h.
Referenced by populationSize().
|
protected |
Number of vectors chosen when updating distribution parameters.
Definition at line 239 of file CrossEntropyMethod.h.
Referenced by selectionSize().
|
protected |
Variance for sample parameters.
Definition at line 242 of file CrossEntropyMethod.h.
Referenced by setVariance(), and variance().