paradiseo/eo/tutorial/html/eoEngine.html
2000-12-19 18:32:09 +00:00

421 lines
22 KiB
HTML

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (X11; U; Linux 2.2.17-21mdksmp i686) [Netscape]">
<title>Genetic Engine</title>
</head>
<body text="#000000" link="#0000EF" vlink="#51188E" alink="#FF0000" background="beige009.jpg">
<b><font color="#CC0000">General: </font></b><a href="eoTopDown.html">Algorithm-Based</a>
- <a href="eoBottomUp.html">Component-Based</a> - <a href="eoProgramming.html">Programming
hints</a> - <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/index.html">EO
documentation
<hr WIDTH="100%"></a></font></font><font color="#CC0000">Local: </font></b><a href="#introduction">Introduction</a>&nbsp;
- <a href="#selection">Selection</a> - <a href="#replacement">Replacement</a>
- <a href="#popular">Popular evolution engines</a> - <a href="#tournament">Tournaments</a>
- <a href="#merge">Merge</a> - <a href="#reduce">Reduce</a> - <a href="#howmany">HowMany</a>
- <a href="#SAD">SurviveAndDie</a>
<hr WIDTH="100%">
<center>
<h1>
<b><font color="#CC0000">Evolution Engine</font></b></h1></center>
<hr WIDTH="100%">
<br><a NAME="introduction"></a><b><font color="#000099"><font size=+2>Evolution
Engines</font></font></b>
<p>The term <b><font color="#FF6600">evolution engine</font></b> denotes
the different parts of an Evolutionary Algorithm that simulate the Darwinism:
<center>
<p><i><font color="#009900">The fittest individuals are more likely to
reproduce and survive.</font></i></center>
<p>Darwinism takes place in two different phases of an EA, though in many
<a href="#popular">popular
variants</a>, only one phase is activated.
<p><a href="#selection">Selection</a> is the Darwinistic choice of parents
that will be allowed to <b><font color="#009900">reproduce</font></b><font color="#CC33CC">.</font>
<br><a href="#replacement">Replacement</a> takes place after reproduction,
and is the Darwinistic choice of those individuals that will <b><font color="#009900">survive</font></b>,
i.e. become the parents of the next generation.
<p>Both selection and replacement will be discussed in turn, before some
helper classes that are used within selection and replacement procedures
are presented.
<p>
<hr WIDTH="100%"><a NAME="selection"></a><b><font color="#000099"><font size=+2>Selection</font></font></b>
<br>&nbsp;
<br>&nbsp;
<p>
<hr WIDTH="100%">
<br><a NAME="replacement"></a><b><font color="#000099"><font size=+2>Replacement</font></font></b>
<p>The replacement phase takes place <font color="#FF6600">after the birth
of all offspring</font> through variation operators. The idea is to close
the generation loop, i.e. to end up with a population of individuals that
will be the initial population of next generation. That population will
be <font color="#FF6600">built upon the old parents and the new-born offspring</font>.
In all algorithms that come up with EO, the <font color="#FF6600">population
size</font> is supposed to be <font color="#FF6600">constant</font> from
one generation to the next one - though nothing stops you from writing
an algorithm with varying population size.
<p><b><font color="#000099">Replacement: </font><font color="#FF0000">The
interface</font></b>
<p>The abstract class for replacement procedures is the functor class
<font color="#009900">eoReplacement</font>,
and the interface for its <tt><font color="#993300">operator()</font></tt>
is
<center>
<p><b><tt><font color="#993300">void operator()(eoPop&lt;EOT>&amp; _parents,
eoPop&lt;EOT>&amp; _offspring)</font></tt></b></center>
<p>which you could have guessed from the inheritance tree for class <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/class_eoreplacement.html">eoReplacement</a></font></font></b>.,
as you see there that <font color="#009900">eoReplacement</font> derives
from <tt><font color="#993300">class eoBF&lt;eoPop&lt;EOT>&amp;, eoPop&lt;EOT>&amp;,
void></font></tt>.
<br>This means that it takes <font color="#FF6600">2 populations</font>
(called, for obvious anthropomorphic reasons, _parents and _offspring :-)
and is free to modify both, but the resulting population should be placed
in the first argument (usually called_parents) to close the loop and go
to next generation.
<p><b><font color="#000099">Replacement: </font><font color="#FF0000">Instances</font></b>
<ul>
<li>
<b><tt><font color="#009900">eoGenerationalReplacement </font></tt></b>This
is the most straightforward replacement, called <font color="#FF6600">generational
replacement</font>: all offspring replace all parents (used in Holland's
and Goldberg's traditional GAs).&nbsp; It takes no argument, and supposes
that offspring and parents are of the same size (but does not check!).</li>
<br>&nbsp;
<li>
<b><tt><font color="#009900">eoMergeReduce</font></tt></b> This is one
the basic types of replacement in EO. It has two major steps, <font color="#FF6600">merging</font>
both populations of parents and offspring, and <font color="#FF6600">reducing</font>
this big population to the right size. It <font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/class_eomegereduce.html">contains
two objects</a></font></font> of respective types <b><font color="#009900"><a href="#merge">eoMerge</a></font></b>
and <b><font color="#009900"><a href="#reduce">eoReduce</a></font></b>
and you can probably guess what each of them actually does :-)</li>
<br>&nbsp;
<p>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<p>Available <font color="#FF6600">instances of eoMergeReduce</font> replacement
include
<ul>
<li>
<b><tt><font color="#009900">eoCommaReplacement</font></tt></b>, one of
the two standard strategies in <font color="#FF6600">Evolution Strategies</font>,
selects the best offspring. It is an <b><tt><font color="#993300">eoMergeReduce(eoNoElitism,
eoTruncate)</font></tt></b>.</li>
<li>
<b><tt><font color="#009900">eoPlusReplacement</font></tt></b>, the other
standard <font color="#FF6600">Evolution Startegies</font> replacement,
where the best from offspring+parents become the next generation. It is
an <b><tt><font color="#993300">eoMergeReduce(eoPlus, eoTruncate)</font></tt></b>.</li>
<li>
<b><tt><font color="#009900">eoEPReplacement</font></tt></b>, used in the
<font color="#FF6600">Evolutionary
Programming</font> historical algorithm, doing a stochastic tournament
among parents + offspring. It is an <b><tt><font color="#993300">eoMergeReduce(eoPlus,
eoEPReduce)</font></tt></b> and its constructor requires as argument the
size of the tournament (unsigned int).</li>
</ul>
<li>
<b><tt><font color="#009900">eoReduceMerge</font></tt></b> is another important
type of eoReplacement: the parents are first reduced, and then merged with
the offspring. Note that the parent population is reduced of the exact
number of offspring.</li>
<br>Though not mandatory, it is implicitely assumed that few offspring
have been generated. Hence, all derived replacement procedures of class
<b><tt><font color="#009900">eoReduceMerge</font></tt></b>
are termed <b><tt><font color="#009900">eoSGAxxx</font></tt></b>, as they
are the ones to use in SteadyState Genetic Algorithm engine. This gives
the following <font color="#FF6600">instances of eoReduceMerge</font>:
<ul>
<li>
&nbsp;<b><tt><font color="#009900">eoSSGAWorseReplacement</font></tt></b>
in which the worse parents are killed and replaced by all offsprings (no
additional argument needed);</li>
<li>
<b><tt><font color="#009900">eoSSGADetTournamentReplacement</font></tt></b>
in which parents to be killed are chosen by a (reverse) determinitic tournament.
Additional parameter (in the constructor) is the tournament size, an <b><tt><font color="#993300">unsigned
int</font></tt></b>).</li>
<li>
<b><tt><font color="#009900">eoSSGAStochTournamentReplacement</font></tt></b>
in which parents to be killed are chosen by a (reverse) stochastic tournament.
Additional parameter (in the constructor) is the tournament rate, a <b><tt><font color="#993300">double</font></tt></b>).</li>
</ul>
<li>
<b><tt><font color="#009900">eoSurviveAndDie</font></tt></b> is</li>
</ul>
<b><font color="#000099">Replacement: </font><font color="#FF0000">Adding
(weak) elitism</font></b>
<p>You can add what is called <font color="#FF6600">weak elitism</font>
to any replacement by encapsulating it into an <b><tt><font color="#009900">eoWeakElitismReplacement</font></tt></b>
object. Weak elitism ensures that the overall <font color="#FF6600">best
fitness</font> in the population <font color="#FF6600">will never decrease</font>:
if the best fitness in the new population is less than the best fitness
of the parent population, then the best parent is added back to the new
population, replacing the worse.
<p>Within EO, this is very easy to add:
<p>First, declare your replacement functor (here, generational, but it
can be any replacement object):
<br><b><tt><font color="#009900">eoGenerationalReplacement&lt;Indi> genReplace;</font></tt></b>
<br>Then wrap the weak elitism around it:
<br><b><tt><font color="#009900">eoWeakElitismReplacement&lt;Indi> replace(genReplace);</font></tt></b>
<br>and use now replace as your replacement procedure within your algorithm.
<p><font color="#FF0000">Note</font>: of course, adding weak elitism to
an elitist replacement makes no sense - but will not harm either :-)
<p><b><font color="#000099">Replacement: </font><font color="#FF0000">Test
file</font></b>
<p>The file <b><tt><font color="#993300">t-eoReplacement</font></tt></b>
in the <b><font color="#FF6600">test directory</font></b> implements all
above replacmenet procedures withni a very simple and easy-to-monitor Dummy
EO class.
<p>
<hr WIDTH="100%">
<br><a NAME="popular"></a><b><font color="#000099"><font size=+2>Popular
evolution engines</font></font></b>
<p>This section will be completed soon - in the meantime just trust us
that all of these are already implemented in EO (except maybe some of the
last category :-) !!!!!!
<p>The most popular evolution engines are listed below, together with the
way to use them in EO. If you don't find your particuler algorithm, please
send it to us, and we might include it here!
<ul>
<li>
<a NAME="GGA"></a>Generational Genetic Algorihtm</li>
<li>
<a NAME="SSGA"></a>Steady-State Genetic Algorithm</li>
<li>
<a NAME="ESPlus"></a>(MU+Lambda)-Evolution Strategy</li>
<li>
<a NAME="ESComma"></a>(MU,LAMBDA)-Evolution Strategy</li>
<li>
<a NAME="EP"></a>Evolutionary Programming</li>
<li>
<a NAME="General"></a>You name it :-)</li>
</ul>
<hr WIDTH="100%">
<br><a NAME="tournament"></a><b><font color="#000099"><font size=+2>Tournaments</font></font></b>
<p>Tournaments are an easy and quick way to <b><font color="#FF6600">select</font></b>
individuals within a population based on simple comparisons. Though usually
based on fitness comparisons, they can use any comparison operator.
<br>In EO, there are two variants of tournaments used to select one single
individual, namely <b><tt><font color="#009900">Deterministic Tournament</font></tt></b>
and <b><tt><font color="#009900">Stochastic Tournament</font></tt></b>,
that are used in selection and in replacement procedures, and a global
tournament-based selection of a whole bunch of individuals, the <b><tt><font color="#009900">EP
Tournament</font></tt></b>. Though the single-selection tournaments can
be repeated to select more than one individual, and the batch tournament
selection can be used to select a single individual, both uses are probably
a waste of CPU time.
<ul>
<li>
<b><tt><font color="#009900">Deterministic Tournament</font></tt></b> of
size T selects returns the best of T uniformly chosen individuals in the
population. It is implemented in the <b><tt><font color="#009900">eoDetTournamentSelect</font></tt></b>
class, a sub-class of eoSelectOne, as well as in the <b><tt><font color="#009900">eoDetTournamentTruncate</font></tt></b>
class that repeatidly removes from the population the "winner" of the inverse
tournament.&nbsp; These objects use the C++ function determinitic_tournament
in&nbsp; <a href="../../doc/html/selectors_h-source.html">selectors.h</a>.</li>
<li>
<b><tt><font color="#009900">Stochastic Tournament</font></tt></b> of rate
R first choses two individuals from the population, and selects the best
one with probability R and the worse one with probability (1-R). It is
implemented in the <b><tt><font color="#009900">eoStochTournamentSelect</font></tt></b>
class, a sub-class of eoSelectOne, as well as in the <b><tt><font color="#009900">eoStochTournamentTruncate</font></tt></b>
class that repeatidly removes from the population the "winner" of the inverse
tournament.&nbsp; These objects use the C++ function determinitic_tournament
in&nbsp; <a href="../../doc/html/selectors_h-source.html">selectors.h</a>.</li>
<li>
<b><tt><font color="#009900">EP Tournament</font></tt></b> of size T is
a global tournament: it works by assigning a score to all individuals in
the population the following way: starting with a score of 0, each individual
I is "opposed" T times to a uniformly chosen individual. Everytime I wins,
its score in incremented by 1 (and by 0.5 for every draw). The individuals
are then selected deterministically based on their scores from that procedure.
The <b><tt><font color="#009900">EP Tournament</font></tt></b> is implemented
in the&nbsp; <b><tt><font color="#009900">eoEPReduce</font></tt></b> truncation
method used in some replacement procedures.</li>
</ul>
<p><br>
<hr WIDTH="100%">
<br><a NAME="merge"></a><b><font color="#000099"><font size=+2>Merging
populations</font></font></b>
<p>In replacement procedures, one frequently needs to merge two populations
(computed form old parents and new-born offspring). Classes derived from
the abstract class eoMerge are written for that purpose.
<p><b><font color="#000099">eoMerge</font></b>: <b><font color="#FF0000">interface</font></b>
<br>The abstract class for merging procedures is the functor class
<font color="#009900">eoMerge</font>,
and the interface for its <tt><font color="#993300">operator()</font></tt>
is
<center>
<p><b><tt><font color="#993300">void operator()(const eoPop&lt;EOT>&amp;
_parents, eoPop&lt;EOT>&amp; _offspring)</font></tt></b></center>
<p>which you could have guessed from the inheritance tree for class <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/class_eomerge.html">eoMerge</a></font></font></b>,
as you see there that <font color="#009900">eoMerge</font> derives from
<br><tt><font color="#993300">class eoBF&lt;const eoPop&lt;EOT>&amp;, eoPop&lt;EOT>&amp;,
void></font></tt>.
<br>This means that it takes <font color="#FF6600">2 populations</font>
and modifies the seond one by adding some individuals from the first one
(which is supposed to remain <b><tt><font color="#993300">const</font></tt></b>ant).
<p><b><font color="#000099">eoMerge</font></b>: <b><font color="#FF0000">instances</font></b>
<br>Available <font color="#FF6600">instances of eoMerge</font> objects
are <b><tt><font color="#009900">eoPlus</font></tt></b>, that simply adds
the parents to the offspring, or <b><tt><font color="#009900">eoElitism</font></tt></b>,
that adds only some of the (best) parents to the offspring. A special case
of eoElistism is <b><tt><font color="#009900">eoNoElitism</font></tt></b>,
an eoMerge that does nothing.
<p>
<hr WIDTH="100%">
<br><a NAME="reduce"></a><b><font color="#000099"><font size=+2>Reducing
populations</font></font></b>
<p>The other useful component of replacement procedures, <font color="#009900">eoReduce</font>,
<font color="#FF6600">kills
some individuals</font> from a given population.
<p><b><font color="#000099">eoReduce</font></b>: <b><font color="#FF0000">interface</font></b>
<br>The abstract class for reducing procedures is the functor class
<font color="#009900">eoReduce</font>,
and the interface for its <tt><font color="#993300">operator()</font></tt>
is
<center>
<p><b><tt><font color="#993300">void operator()(eoPop&lt;EOT>&amp; _parents,
unsigned int new_size)</font></tt></b></center>
<p>which you could have guessed from the inheritance tree for class <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/class_eoreduce.html">eoReduce</a></font></font></b>,
as you see there that <font color="#009900">eoReduce</font> derives from
<br><tt><font color="#993300">class eoBF&lt;eoPop&lt;EOT>&amp;, unsigned
int, void></font></tt>.
<br>An <font color="#009900">eoReduce</font> shoud take a<font color="#FF6600">
population</font> and shrink it to the required size.
<p><b><font color="#000099">eoReduce</font></b>: <b><font color="#FF0000">instances</font></b>
<br>Available <font color="#FF6600">instances of eoReduce</font> are
<ul>
<li>
<b><tt><font color="#009900">eoTruncate</font></tt></b>, deterministically
kills the worse individuals, keeping only the required number. It starts
by sorting teh populations, and hence does <font color="#FF6600">modify
its order</font>.</li>
<li>
<b><tt><font color="#009900">eoLinearTruncate</font></tt></b>, deterministically
kills the worse individuals, keeping only the required number. It does
so by repeatedly removing the worsr individual. Hence does <font color="#FF6600">not
modify its order</font>, but takes longer time than <b><tt><font color="#009900">eoTruncate</font></tt></b>
in case of many offspring.</li>
<li>
<b><tt><font color="#009900">eoEPReduce</font></tt></b>, uses the <a href="#EPtournament">EP
stochastic tournament</a> to reduce the population. It requires an additinal
argument, the tournament size.</li>
<li>
<b><tt><font color="#009900">eoDetTournamentTruncate</font></tt></b> uses
inverse deterministic tournament to repeatidly kill one individual until
the propoer size is reached. As <b><tt><font color="#009900">eoLinearTruncate</font></tt></b>,
it might take some time in the case of many offspring. It requires the
size of the tournament (<b><tt><font color="#993300">unsigned int</font></tt></b>)
as parameter in the constructor (default is 2).</li>
<li>
<b><tt><font color="#009900">eoStochTournamentruncate</font></tt></b>&nbsp;
uses inverse stochastic tournament to repeatidly kill individuals from
the population. It requires the rate of the tournament (<b><tt><font color="#993300">double</font></tt></b>)
as parameter in the constructor (default is 0.75).</li>
</ul>
<p><br>
<hr WIDTH="100%">
<br><a NAME="howmany"></a><b><font color="#000099"><font size=+2>eoHowMany:
Choosing a number of individuals</font></font></b>
<p>Many classes in selection/replacement procedures will handle a number
of individuals that may either be fixed or be a fraction of some argument-population
size.
<br>Of course, it is possible to write two different classes that will
only differ by the way they compute the number of individuals they have
to treat, as it is done for selectors with the two classes <font color="#009900">eoSelectPerc</font>
and <font color="#009900">eoSelectNumber</font> (it could also have been
possible to have some pure abstrat class and implement the computation
of the number of individuals to treat in some derived classes).
<br>However, rather than multiply the number of class, EO has defined a
class that will handle the problem once and for all, the class <b><tt><font color="#993300">eoHowMany</font></tt></b>.
It receives a <b><tt><font color="#993300">double</font></tt></b>, and
a <b><tt><font color="#993300">boolean</font></tt></b> indicating whether
that double is to be treated <b><font color="#FF6600">as a rate</font></b>
or as <b><font color="#FF6600">an absolute (unisgned) interger.</font></b>
<p><b><font color="#000099">eoHowMany</font></b>: <b><font color="#FF0000">interface</font></b>
<br>The class interface for its <tt><font color="#993300">operator()</font></tt>
is
<center>
<p><b><tt><font color="#993300">unsigned int operator()(unsigned int _pop_size)</font></tt></b></center>
<p>which you could have guessed from the inheritance tree for class <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/class_eohowmany.html">eoHowMany</a></font></font></b>,
as you see there that <b><tt><font color="#993300">eoHowMany</font></tt></b>
derives from
<br><tt><font color="#993300">class eoUF&lt;unsigned int, unsigned int></font></tt>.
<p>Its constructor takes 2 argumenrts:
<center>
<p><b><tt><font color="#993300">eoHowMany(double _rate, bool _interpret_as_rate
=
true)</font></tt></b></center>
so by default the double is indeed interpreted as a rate.
<p>It is used in <font color="#009900">eoSelectMany</font> (which supersedes
<font color="#009900">eoSelectPerc</font>
and <font color="#009900">eoSelectNumber</font>, but they are left there
for tutorial reasons!) as well as in many <a href="#reduce">truncation</a>
methods.
<p>
<hr WIDTH="100%">
<br><a NAME="SAD"></a><b><font color="#000099"><font size=+2>Survive and
Die</font></font></b>
<p>
<hr WIDTH="100%"><b><font color="#CC0000">Local: </font></b><a href="#introduction">Introduction</a>&nbsp;
- <a href="#selection">Selection</a> - <a href="#replacement">Replacement</a>
- <a href="#popular">Popular evolution engines</a> - <a href="#tournament">Tournaments</a>
- <a href="#merge">Merge</a> - <a href="#reduce">Reduce</a> - <a href="#howmany">HowMany</a>
- <a href="#SAD">SurviveAndDie</a>
<br>
<hr WIDTH="100%">
<br><b><font color="#CC0000">General: </font></b><a href="eoTopDown.html">Algorithm-Based</a>
- <a href="eoBottomUp.html">Component-Based</a> - <a href="eoProgramming.html">Programming
hints</a> - <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/index.html">EO
documentation</a></font></font></b>
<hr WIDTH="100%">
<address>
<a href="mailto:Marc.Schoenauer@polytechnique.fr">Marc Schoenauer</a></address>
<br><!-- Created: Mon Oct 30 07:27:13 CET 2000 --><!-- hhmts start -->Last
modified: Tue. Dec. 19 2000&nbsp;<!-- hhmts end -->
</body>
</html>