Added normal mutation for reals, and corrected error of segment-> arithmetic
for the crossover operators
This commit is contained in:
parent
c00c15145d
commit
e5ff1bf59c
3 changed files with 63 additions and 20 deletions
|
|
@ -272,7 +272,7 @@ The actual code is in boldface and the comment in normal face.
|
||||||
<td>
|
<td>
|
||||||
<tt><font color="#993399">
|
<tt><font color="#993399">
|
||||||
<b> </b>// offspring(i) is a linear combination of parent(i)<br>
|
<b> </b>// offspring(i) is a linear combination of parent(i)<br>
|
||||||
<b> eoArithmeticCrossover<Indi> xover;</b><br>
|
<b> eoSegmentCrossover<Indi> xover;</b><br>
|
||||||
</font></tt>
|
</font></tt>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ objects of class</font> <b><font face="Arial,Helvetica"><font size=+1><a href=".
|
||||||
(unary operator). These operators are applied in turn to all selected
|
(unary operator). These operators are applied in turn to all selected
|
||||||
parents, according to user-defined probabilities. These probabilities
|
parents, according to user-defined probabilities. These probabilities
|
||||||
are defined with all other <a href="#parametres">parameters</a>, and will
|
are defined with all other <a href="#parametres">parameters</a>, and will
|
||||||
be passed to the <b><tt><font color="#FF6666"><font size=+1>eoSGA</font></font></tt></b><a href="#parametres">algorithm</a><font color="#000000">.</font></li>
|
be passed to the <b><tt><font color="#FF6666"><font size=+1>eoSGA </font></font></tt></b><a href="#parametres">algorithm</a><font color="#000000">.</font></li>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
|
@ -240,7 +240,7 @@ bit, which is specific of the bit-flip mutation. Hence, to run the
|
||||||
same algorithm as Goldberg's SGA, the mutation probability (at individual
|
same algorithm as Goldberg's SGA, the mutation probability (at individual
|
||||||
level) is 1, and the probability of flipping each bit is <b><tt>P_MUT_PER_BIT.</tt></b>
|
level) is 1, and the probability of flipping each bit is <b><tt>P_MUT_PER_BIT.</tt></b>
|
||||||
<li>
|
<li>
|
||||||
<a href="FirstRealGA.html#operators">Real</a> The crossover <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/class_eoarithmeticcrossover.html">eoArithmeticCrossover</a></font></font></b>
|
<a href="FirstRealGA.html#operators">Real</a> The crossover <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/class_eosegmentcrossover.html">eoSegmentCrossover</a></font></font></b>
|
||||||
is the standard <font color="#CC33CC">arithmetic crossover</font> for real-valued
|
is the standard <font color="#CC33CC">arithmetic crossover</font> for real-valued
|
||||||
vectors, that chooses a point randomly on the segment between both parents
|
vectors, that chooses a point randomly on the segment between both parents
|
||||||
(also termed <font color="#CC33CC">BLX-0</font>). <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/class_eouniformmutation.html">eoUniformMutation</a></font></font></b>
|
(also termed <font color="#CC33CC">BLX-0</font>). <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/class_eouniformmutation.html">eoUniformMutation</a></font></font></b>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<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]">
|
<meta name="GENERATOR" content="Mozilla/4.75 [en] (X11; U; Linux 2.2.17-21mdksmp i686) [Netscape]">
|
||||||
<title>Tutorial: Lesson 2</title>
|
<title>Tutorial: Lesson 2</title>
|
||||||
<!-- Changed by: Marc Schoenauer, 29-Nov-2000 -->
|
<!-- Changed by: Marc Schoenauer, 29-Nov-2000 -->
|
||||||
</head>
|
</head>
|
||||||
<body text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000" background="beige009.jpg">
|
<body text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000" background="beige009.jpg">
|
||||||
<a href="eoLesson1.html">Lesson 1</a> -
|
<a href="eoLesson1.html">Lesson 1</a> -
|
||||||
|
|
@ -67,7 +67,7 @@ argument is a <a href="binary_value.html">vector<bool></a> or a <a href="real
|
||||||
and not an unknown type. This will allow to use the same file for any EO
|
and not an unknown type. This will allow to use the same file for any EO
|
||||||
object that is a sub-class of the corresponding STL vector class.</font></li>
|
object that is a sub-class of the corresponding STL vector class.</font></li>
|
||||||
|
|
||||||
<p><b><font color="#FF0000">Note:</font></b> <font color="#000000">Also,
|
<p><br><b><font color="#FF0000">Note:</font></b> <font color="#000000">Also,
|
||||||
a non-templatized fitness can be </font><b><font color="#FF6600">compiled
|
a non-templatized fitness can be </font><b><font color="#FF6600">compiled
|
||||||
separately</font></b><font color="#000000"> (not done here) into an object
|
separately</font></b><font color="#000000"> (not done here) into an object
|
||||||
file once and for all (<a href="eoProgramming.html#templates">remember</a>
|
file once and for all (<a href="eoProgramming.html#templates">remember</a>
|
||||||
|
|
@ -82,8 +82,8 @@ have to declare 3 template arguments: the type of EO object it will be
|
||||||
applied to, the return type and the type of argument the function actually
|
applied to, the return type and the type of argument the function actually
|
||||||
requires.</font></li>
|
requires.</font></li>
|
||||||
|
|
||||||
<p><b><font color="#FF0000">Note:</font></b> <font color="#000000">In the
|
<p><br><b><font color="#FF0000">Note:</font></b> <font color="#000000">In
|
||||||
previous files (<a href="FirstBitGA.html#eval">Bit</a> - <a href="FirstRealGA.html#eval">Real</a>)
|
the previous files (<a href="FirstBitGA.html#eval">Bit</a> - <a href="FirstRealGA.html#eval">Real</a>)
|
||||||
, the last 2 types were deduced from the first (2nd argument = fitness
|
, the last 2 types were deduced from the first (2nd argument = fitness
|
||||||
type of EO object, third = first).</font>
|
type of EO object, third = first).</font>
|
||||||
<br>
|
<br>
|
||||||
|
|
@ -105,7 +105,7 @@ You can also use different initializers and call them in turn through the
|
||||||
call to <a href="../../doc/html/class_eopop.html#a2">pop.append()</a> function
|
call to <a href="../../doc/html/class_eopop.html#a2">pop.append()</a> function
|
||||||
(see <a href="#exercise2">Exercise 2</a>).</font></li>
|
(see <a href="#exercise2">Exercise 2</a>).</font></li>
|
||||||
|
|
||||||
<p><b><font color="#FF0000">Note</font><font color="#CC33CC">: </font></b><font color="#000000">Don't
|
<p><br><b><font color="#FF0000">Note</font><font color="#CC33CC">: </font></b><font color="#000000">Don't
|
||||||
forget to </font><b><font color="#CC0000">evaluate the population</font></b><font color="#000000">:
|
forget to </font><b><font color="#CC0000">evaluate the population</font></b><font color="#000000">:
|
||||||
the eoPop has no idea of the eval function, so it has to be done from outside!!!</font>
|
the eoPop has no idea of the eval function, so it has to be done from outside!!!</font>
|
||||||
<br>
|
<br>
|
||||||
|
|
@ -113,24 +113,67 @@ the eoPop has no idea of the eval function, so it has to be done from outside!!!
|
||||||
<a NAME="combined_operators"></a><font color="#000000">You can now use
|
<a NAME="combined_operators"></a><font color="#000000">You can now use
|
||||||
</font><font color="#CC33CC"><b>different
|
</font><font color="#CC33CC"><b>different
|
||||||
</b>crossover
|
</b>crossover
|
||||||
and mutation
|
</font><font color="#000000">and</font><font color="#CC33CC"> mutation
|
||||||
<b>operators</b></font><font color="#000000">in the same algorithm
|
<b>operators</b></font><font color="#000000">in
|
||||||
(<a href="FirstBitEA.html#operators">Bit</a> - <a href="FirstRealEA.html#operators">Real</a>),
|
the same algorithm, choosing among them according to
|
||||||
choosing among them according to
|
</font><b><font color="#FF6600">relative
|
||||||
</font><font color="#CC33CC"><b>relative
|
rates.</font></b><font color="#CC33CC"> </font><font color="#000000">The
|
||||||
rates.</b> </font><font color="#000000">The class </font><font color="#CC33CC"><b>eoPropCombinedxxxOp</b>,
|
class </font><font color="#CC33CC"><b>eoPropCombinedxxxOp</b>,
|
||||||
</font><font color="#000000">where
|
</font><font color="#000000">where
|
||||||
xxx is either Mon (for mutation, of class </font><font color="#CC33CC"><b><tt>eoMonOp</tt></b>)</font><font color="#000000">
|
xxx is either Mon (for mutations, of class </font><font color="#CC33CC"><b><tt>eoMonOp</tt></b>)</font><font color="#000000">
|
||||||
or Quad (for crossovers, of class </font><b><tt><font color="#CC33CC">eoQuadOp</font></tt></b><font color="#000000">),
|
or Quad (for crossovers, of class </font><b><tt><font color="#CC33CC">eoQuadOp</font></tt></b><font color="#000000">),
|
||||||
is derived from the corresponding eoxxxOp class. When applying the eoPropCombinedxxxOp,
|
is derived from the corresponding eoxxxOp class. When applying the eoPropCombinedxxxOp,
|
||||||
one of the eoxxxOp it contains is chosen by a <a href="../../doc/html/class_eorng.html#a12">roulette
|
one of the eoxxxOp it contains is chosen by a <a href="../../doc/html/class_eorng.html#a12">roulette
|
||||||
wheel,</a> according to their respective rates, and is applied to the arguments.</font></li>
|
wheel,</a> according to their respective rates, and is applied to the arguments.</font></li>
|
||||||
|
|
||||||
<p><b><font color="#FF0000">Note:</font></b> A third optional argument
|
<ul>
|
||||||
in method <b><tt><font color="#660000">add</font></tt></b> is a boolean
|
<li>
|
||||||
(defaulted to false). When true, the actual rates for all operators are
|
<font color="#000000"><a href="FirstBitEA.html#operators">Bit</a> <br>
|
||||||
displayed on the screen as percentages: you don't have to input rates that
|
Three </font><b><font color="#FF6600">crossover operators</font></b><font color="#000000">
|
||||||
sum up to 1, all rates are scaled anyway.
|
are available: the </font><font color="#FF6600">one-point</font><font color="#000000">
|
||||||
|
crossover is still there (class ), but now you also have the </font><font color="#FF6600">N-point</font><font color="#000000">
|
||||||
|
crossover </font><font color="#CC33CC">eoBinNxOver</font><font color="#000000">
|
||||||
|
(the number of points is 2 by default, but as always you can change
|
||||||
|
that in the constructor), and the </font><font color="#FF6600">Uniform</font><font color="#000000">
|
||||||
|
crossover </font><font color="#CC33CC">eoBinUxOver</font><font color="#000000">
|
||||||
|
(where you can eventually twidle the choice from one parent to the other
|
||||||
|
by providing a probability in the constructore - defaulted to 0.5, which
|
||||||
|
amounts to symmetrical choice).<br>
|
||||||
|
As for </font><b><font color="#FF6600">mutation operators</font></b><font color="#000000">,
|
||||||
|
apart from the </font><font color="#CC33CC">eoBinMutation</font><font color="#000000">
|
||||||
|
(standard bitstring mutation flipping one bit with a given probability)
|
||||||
|
you can also use the </font><font color="#CC33CC">eoDetBitFlip</font><font color="#000000">
|
||||||
|
that always filps the same number of bits (1 by default, but you can change
|
||||||
|
that in the constructor), randomly chosen in the bitstring. Even though
|
||||||
|
the average number of bits flipped is the same if the </font><font color="#CC33CC">eoBinMutation
|
||||||
|
</font><font color="#000000">is used with a rate of 1/N (N is the bitstring
|
||||||
|
length) </font><font color="#FF6600">the behavior of these mutation can
|
||||||
|
be very different</font><font color="#000000"> on many problems.</font></li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<font color="#000000"><a href="FirstRealEA.html#operators">Real</a> <br>
|
||||||
|
Two </font><b><font color="#FF6600">crossover operators</font></b><font color="#000000">
|
||||||
|
are available: the </font><font color="#CC33CC">eoSegmentCrossover</font><font color="#000000">
|
||||||
|
chooses one point uniformly on the segment joining the parents, while the
|
||||||
|
</font><font color="#CC33CC">eoArithmeticCrossover</font><font color="#000000">
|
||||||
|
performs a segment crossover on each coordinate independently, which amount
|
||||||
|
to choosing the offspring uniformly in the hypercube whose diagonal is
|
||||||
|
the segment joining the parents.<br>
|
||||||
|
As for </font><b><font color="#FF6600">mutation operators</font></b><font color="#000000">,
|
||||||
|
apart from the </font><font color="#CC33CC">eoBinMutation</font><font color="#000000">
|
||||||
|
(standard bitstring mutation flipping one bit with a given probability)
|
||||||
|
you can also use the </font><font color="#CC33CC">eoDetBitFlip</font><font color="#000000">
|
||||||
|
that always filps the same number of bits (1 by default, but you can change
|
||||||
|
that in the constructor), randomly chosen in the bitstring. And last but
|
||||||
|
not least, the normal mutation eoNormMutation modifies all coordinates
|
||||||
|
with a Gaussian noise, with standard deviation passed in the constructor.</font><br>
|
||||||
|
<BR></li>
|
||||||
|
</ul>
|
||||||
|
<b><font color="#FF0000">Note:</font></b> A third optional argument in
|
||||||
|
method <b><tt><font color="#660000">add</font></tt></b> is a boolean (defaulted
|
||||||
|
to false). When true, the actual rates for all operators are displayed
|
||||||
|
on the screen as percentages: you don't have to input rates that sum up
|
||||||
|
to 1, all rates are scaled anyway.
|
||||||
<p><b><font color="#FF0000">Note:</font></b> The operators have to be encapsulated
|
<p><b><font color="#FF0000">Note:</font></b> The operators have to be encapsulated
|
||||||
into an <b><tt><font color="#CC33CC">eoTransform</font></tt></b> object
|
into an <b><tt><font color="#CC33CC">eoTransform</font></tt></b> object
|
||||||
(<a href="FirstBitEA.html#transform">Bit</a> - <a href="FirstRealEA.html#transform">Real</a>)
|
(<a href="FirstBitEA.html#transform">Bit</a> - <a href="FirstRealEA.html#transform">Real</a>)
|
||||||
|
|
|
||||||
Reference in a new issue