Making Your Own Strategy : A Simple EDA¶
As seen in the Covariance Matrix Adaptation Evolution Strategy example, the
eaGenerateUpdate()
algorithm is suitable for algorithms
learning the problem distribution from the population. Here we’ll cover how to
implement a strategy that generates individuals based on an updated sampling
function learnt from the sampled population.
Estimation of distribution¶
The basic concept concept behind EDA is to sample \(\lambda\) individuals
with a certain distribution and estimate the problem distribution from the
\(\mu\) best individuals. This really simple concept adhere to the
generate-update logic. The strategy contains a random number generator which
is adapted from the population. The following EDA
class do just that.
A normal random number generator is initialized with a certain mean
(centroid) and standard deviation (sigma) for each
dimension. The generate()
method uses numpy to generate lambda_
sequences in dim dimensions, then the sequences are used to initialize
individuals of class given in the ind_init argument. Finally, the
update()
computes the average (centre) of the mu best individuals and
estimates the variance over all attributes of each individual. Once
update()
is called the distributions parameters are changed and a new
population can be generated.
Objects Needed¶
Two classes are needed, a minimization fitness and a individual that will
combine the fitness and the real values. Moreover, we will use
numpy.ndarray
as base class for our individuals.
Operators¶
The eaGenerateUpdate()
algorithm requires to set in a
toolbox an evaluation function, an generation method and an update method.
We will use the method of an initialized EDA
. For the generate
method, we set the class that the individuals are transferred in to our
Individual
class containing a fitness.
The complete examples/eda/fctmin.