Migration from SVN
This commit is contained in:
parent
d7d6c3a217
commit
8cd56f37db
29069 changed files with 0 additions and 4096888 deletions
157
eo/tutorial/html/eoSGA.html
Normal file
157
eo/tutorial/html/eoSGA.html
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
<!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-21mdk i686) [Netscape]">
|
||||
<title>eoSGA.h</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
<a href="eoLesson1.html">Back to Lesson 1</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Algorithm-Based</a> - <a href="eoBottomUp.html">Component-Based
|
||||
page</a> - <a href="eoProgramming.html">Programming hints</a> - <font face="Arial,Helvetica"><a href="../../doc/html/index.html">EO
|
||||
documentation</a></font>
|
||||
<br>
|
||||
<hr WIDTH="100%"><!-- -------------- End of header ------------------ --><!-- ----------------------------------------------- -->
|
||||
<center>
|
||||
<h1>
|
||||
<font color="#FF0000">eoSGA.h</font></h1></center>
|
||||
<a NAME="start"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCC99" NOSAVE >
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE><tt><font color="#993300">//-----------------------------------------------------------------------------</font></tt>
|
||||
<br><tt><font color="#993300">// eoSGA.h</font></tt>
|
||||
<br><tt><font color="#993300">//-----------------------------------------------------------------------------</font></tt>
|
||||
<br><b><tt><font color="#993300">#ifndef _eoSGA_h</font></tt></b>
|
||||
<br><b><tt><font color="#993300">#define _eoSGA_h</font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <eoOp.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <eoContinue.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <eoPop.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <eoSelectOne.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <eoSelectPerc.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <eoEvalFunc.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <eoAlgo.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <apply.h></font></tt></b>
|
||||
<br><tt><font color="#993300">/** The Simple Genetic Algorithm, following
|
||||
Holland and Goldberg </font></tt>
|
||||
<br><tt><font color="#993300">* Needs a selector (class eoSelectOne)
|
||||
a crossover (eoQuadratic, </font></tt>
|
||||
<br><tt><font color="#993300">* i.e. a 2->2
|
||||
operator) and a mutation with their respective rates, </font></tt>
|
||||
<br><tt><font color="#993300">* of course
|
||||
an evaluation function (eoEvalFunc) and a continuator </font></tt>
|
||||
<br><tt><font color="#993300">* (eoContinue)
|
||||
which gives the stopping criterion. Performs full</font></tt>
|
||||
<br><tt><font color="#993300">* generational
|
||||
replacement.</font></tt>
|
||||
<br><tt><font color="#993300">*/ </font></tt>
|
||||
<br><b><tt><font color="#993300">template <class EOT></font></tt></b>
|
||||
<br><b><tt><font color="#993300">class eoSGA : public eoAlgo<EOT></font></tt></b>
|
||||
<br><b><tt><font color="#993300">{</font></tt></b>
|
||||
<br><b><tt><font color="#993300">public :</font></tt></b>
|
||||
<br><tt><font color="#993300"><b> </b>// added this second ctor as
|
||||
I didn't like the ordering of the parameters</font></tt>
|
||||
<br><tt><font color="#993300"><b> </b>// in the one above. Any objection
|
||||
:-) MS</font></tt>
|
||||
<br><a NAME="constructor"></a><b><tt><font color="#993300">eoSGA(</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> eoSelectOne<EOT>&
|
||||
_select,</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> eoQuadraticOp<EOT>&
|
||||
_cross, float _crate,</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> eoMonOp<EOT>&
|
||||
_mutate, float _mrate,</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> eoEvalFunc<EOT>&
|
||||
_eval,</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> eoContinue<EOT>&
|
||||
_cont)</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> : cont(_cont), </font></tt></b>
|
||||
<br><b><tt><font color="#993300"> mutate(_mutate), </font></tt></b>
|
||||
<br><b><tt><font color="#993300"> mutationRate(_mrate),</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> cross(_cross),</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> crossoverRate(_crate),</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> select(_select),</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> eval(_eval)
|
||||
{}</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="generation"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCC99" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#FF6666"> void operator()(eoPop<EOT>&
|
||||
_pop)</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666"> {</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666"> eoPop<EOT> offspring;</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666"> do {</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
select(_pop, offspring);</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
unsigned i;</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
for (i=0; i<_pop.size()/2; i++) </font></tt></b>
|
||||
<br><tt><font color="#FF6666"><b>
|
||||
{ </b>// generates 2 offspring from two parents</font></tt>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
if ( rng.flip(crossoverRate) ) </font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
{ </font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
cross(offspring[2*i], offspring[2*i+1]);</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
}</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
}</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
for (i=0; i < _pop.size(); i++) </font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
{</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
if (rng.flip(mutationRate) ) </font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
{</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
mutate(offspring[i]);</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
}</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
}</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
_pop.swap(offspring);</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666">
|
||||
apply<EOT>(eval, _pop);</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666"> } while (cont(_pop));</font></tt></b>
|
||||
<br><b><tt><font color="#FF6666"> }</font></tt></b>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="parametres"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCFFFF" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF">private :</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> eoContinue<EOT>& cont;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> eoMonOp<EOT>& mutate;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> float mutationRate;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> eoQuadraticOp<EOT>& cross;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> float crossoverRate;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> eoSelectPerc<EOT> select;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> eoEvalFunc<EOT>& eval;</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="general"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCC99" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993300">};</font></tt></b>
|
||||
<br><b><tt><font color="#993300">#endif</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr WIDTH="100%"><a href="eoLesson1.html">Back to Lesson 1</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Algorithm-Based</a> - <a href="eoBottomUp.html">Component-Based
|
||||
page</a> - <a href="eoProgramming.html">Programming hints</a> - <font face="Arial,Helvetica"><a href="../../doc/html/index.html">EO
|
||||
documentation</a></font>
|
||||
<hr>
|
||||
<address>
|
||||
<a href="mailto:Marc.Schoenauer@inria.fr">Marc Schoenauer</a></address>
|
||||
|
||||
<br><!-- Created: Nov 2000 --><!-- hhmts start -->Last modified: Sun Nov
|
||||
19 19:36:21 2000<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue