Adding the Lesson5 - how to create your own genotype
This commit is contained in:
parent
b407bf5e81
commit
c5e225551a
14 changed files with 2476 additions and 72 deletions
360
eo/tutorial/html/OneMaxEA.html
Normal file
360
eo/tutorial/html/OneMaxEA.html
Normal file
|
|
@ -0,0 +1,360 @@
|
|||
<!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.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
|
||||
<title>Templates/OneMaxEA.cpp</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
<a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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">Templates/OneMaxEA.cpp</font></h1></center>
|
||||
The places where you have to put some code are on <b><font color="#FF6666">pink
|
||||
background</font></b>.. Only the the <a href="eoTutorial.html#colors">character
|
||||
colors have the usual meaning</a>.
|
||||
<br><a NAME="start"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE><tt><font color="#993300">/** -*- mode: c++; c-indent-level:
|
||||
4; c++-member-init-indent: 8; comment-column: 35; -*-</font></tt>
|
||||
<br><tt><font color="#993300">The above line is usefulin Emacs-like editors</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<br><tt><font color="#993300">/*</font></tt>
|
||||
<br><tt><font color="#993300">Template for creating a new representation
|
||||
in EO</font></tt>
|
||||
<br><tt><font color="#993300">================================================</font></tt>
|
||||
<br><tt><font color="#993300">This is the template main file.</font></tt>
|
||||
<br><tt><font color="#993300">It includes all other files that have been
|
||||
generated by the script create.sh</font></tt>
|
||||
<br><tt><font color="#993300">so it is the only file to compile.</font></tt>
|
||||
<br><tt><font color="#993300">In case you want to build up a separate library
|
||||
for your new Evolving Object,</font></tt>
|
||||
<br><tt><font color="#993300">you'll need some work - follow what's done
|
||||
in the src/ga dir, used in the</font></tt>
|
||||
<br><tt><font color="#993300">main file BitEA in tutorial/Lesson4 dir.</font></tt>
|
||||
<br><tt><font color="#993300">Or you can wait until we do it :-)</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<br><tt><font color="#993300">// Miscilaneous include and declaration </font></tt>
|
||||
<br><b><tt><font color="#993300">#include <iostream></font></tt></b>
|
||||
<br><b><tt><font color="#993300">using namespace std;</font></tt></b>
|
||||
<br><tt><font color="#993300">// eo general include</font></tt>
|
||||
<br><b><tt><font color="#993300">#include "eo"</font></tt></b>
|
||||
<br><tt><font color="#993300">// the real bounds (not yet in general eo
|
||||
include)</font></tt>
|
||||
<br><b><tt><font color="#993300">#include "utils/eoRealVectorBounds.h"</font></tt></b>
|
||||
<br><tt><font color="#993300">// include here whatever specific files for
|
||||
your representation</font></tt>
|
||||
<br><tt><font color="#993300">// Basically, this should include at least
|
||||
the following</font></tt>
|
||||
<br><tt><font color="#993300">/** definition of representation: </font></tt>
|
||||
<br><tt><font color="#993300">* class eoOneMax MUST derive from EO<FitT>
|
||||
for some fitness</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="representation"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900">#include "eoOneMax.h"</font></tt></b>
|
||||
<br><tt><font color="#999900">/** definition of initilizqtion: </font></tt>
|
||||
<br><tt><font color="#999900">* class eoOneMaxInit MUST derive from eoInit<eoOneMax></font></tt>
|
||||
<br><tt><font color="#999900">*/</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="init"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399">#include "eoOneMaxInit.h"</font></tt></b>
|
||||
<br><tt><font color="#993399">/** definition of evaluation: </font></tt>
|
||||
<br><tt><font color="#993399">* class eoOneMaxEvalFunc MUST derive from
|
||||
eoEvalFunc<eoOneMax></font></tt>
|
||||
<br><tt><font color="#993399">* and should test for validity before doing
|
||||
any computation</font></tt>
|
||||
<br><tt><font color="#993399">* see tutorial/Templates/evalFunc.tmpl</font></tt>
|
||||
<br><tt><font color="#993399">*/</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="fitness"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#CC0000">#include "eoOneMaxEvalFunc.h"</font></tt></b>
|
||||
<br><tt><font color="#CC0000">// GENOTYPE eoOneMax ***MUST***
|
||||
be templatized over the fitness</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#CC0000">// START fitness type: double or eoMaximizingFitness
|
||||
if you are maximizing</font></tt>
|
||||
<br><tt><font color="#CC0000">//
|
||||
eoMinimizingFitness if you are minimizing</font></tt>
|
||||
<br><tt><font color="#CC0000"><b>typedef eoMinimizingFitness MyFitT ; </b>//
|
||||
type of fitness </font></tt>
|
||||
<br><tt><font color="#CC0000">// END fitness type</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="representation"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#999900">// Then define your EO objects using that
|
||||
fitness type</font></tt>
|
||||
<br><tt><font color="#999900"><b>typedef eoOneMax<MyFitT> Indi; </b>
|
||||
// ***MUST*** derive from EO </font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="init"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993399">// create an initializer</font></tt>
|
||||
<br><b><tt><font color="#993399">#include "make_genotype_OneMax.h"</font></tt></b>
|
||||
<br><b><tt><font color="#993399">eoInit<Indi> & make_genotype(eoParser&
|
||||
_parser, eoState&_state, Indi _eo)</font></tt></b>
|
||||
<br><b><tt><font color="#993399">{</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> return do_make_genotype(_parser,
|
||||
_state, _eo);</font></tt></b>
|
||||
<br><b><tt><font color="#993399">} </font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="operators"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993399">// and the variation operaotrs</font></tt>
|
||||
<br><b><tt><font color="#993399">#include "make_op_OneMax.h"</font></tt></b>
|
||||
<br><b><tt><font color="#993399">eoGenOp<Indi>& make_op(eoParser&
|
||||
_parser, eoState& _state, eoInit<Indi>& _init)</font></tt></b>
|
||||
<br><b><tt><font color="#993399">{</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> return do_make_op(_parser, _state,
|
||||
_init);</font></tt></b>
|
||||
<br><b><tt><font color="#993399">}</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="init"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993399">// Use existing modules to define representation
|
||||
independent routines</font></tt>
|
||||
<br><tt><font color="#993399">// These are parser-based definitions of
|
||||
objects</font></tt>
|
||||
<br><tt><font color="#993399">// how to initialize the population </font></tt>
|
||||
<br><tt><font color="#993399">// it IS representation independent if an
|
||||
eoInit is given</font></tt>
|
||||
<br><b><tt><font color="#993399">#include <do/make_pop.h></font></tt></b>
|
||||
<br><b><tt><font color="#993399">eoPop<Indi >& make_pop(eoParser&
|
||||
_parser, eoState& _state, eoInit<Indi> & _init)</font></tt></b>
|
||||
<br><b><tt><font color="#993399">{</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> return do_make_pop(_parser, _state,
|
||||
_init);</font></tt></b>
|
||||
<br><b><tt><font color="#993399">}</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="stop"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#3366FF">// the stopping criterion</font></tt>
|
||||
<br><b><tt><font color="#3366FF">#include <do/make_continue.h></font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">eoContinue<Indi>& make_continue(eoParser&
|
||||
_parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval)</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">{</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> return do_make_continue(_parser,
|
||||
_state, _eval);</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">}</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="stat"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#3366FF">// outputs (stats, population dumps, ...)</font></tt>
|
||||
<br><b><tt><font color="#3366FF">#include <do/make_checkpoint.h></font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">eoCheckPoint<Indi>& make_checkpoint(eoParser&
|
||||
_parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>&
|
||||
_continue) </font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">{</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> return do_make_checkpoint(_parser,
|
||||
_state, _eval, _continue);</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">}</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="engine"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#009900">// evolution engine (selection and replacement)</font></tt>
|
||||
<br><b><tt><font color="#009900">#include <do/make_algo_scalar.h></font></tt></b>
|
||||
<br><b><tt><font color="#009900">eoAlgo<Indi>& make_algo_scalar(eoParser&
|
||||
_parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>&
|
||||
_continue, eoGenOp<Indi>& _op)</font></tt></b>
|
||||
<br><b><tt><font color="#009900">{</font></tt></b>
|
||||
<br><b><tt><font color="#009900"> return do_make_algo_scalar(_parser,
|
||||
_state, _eval, _continue, _op);</font></tt></b>
|
||||
<br><b><tt><font color="#009900">}</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="general"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993300">// simple call to the algo. stays there for
|
||||
consistency reasons </font></tt>
|
||||
<br><tt><font color="#993300">// no template for that one</font></tt>
|
||||
<br><b><tt><font color="#993300">#include <do/make_run.h></font></tt></b>
|
||||
<br><tt><font color="#993300">// the instanciating fitnesses</font></tt>
|
||||
<br><b><tt><font color="#993300">#include <eoScalarFitness.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">void run_ea(eoAlgo<Indi>& _ga,
|
||||
eoPop<Indi>& _pop)</font></tt></b>
|
||||
<br><b><tt><font color="#993300">{</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> do_run(_ga, _pop);</font></tt></b>
|
||||
<br><b><tt><font color="#993300">}</font></tt></b>
|
||||
<br><tt><font color="#993300">// checks for help demand, and writes the
|
||||
status file</font></tt>
|
||||
<br><tt><font color="#993300">// and make_help; in libutils</font></tt>
|
||||
<br><b><tt><font color="#993300">void make_help(eoParser & _parser);</font></tt></b>
|
||||
<br><tt><font color="#993300">// now use all of the above, + representation
|
||||
dependent things</font></tt>
|
||||
<br><b><tt><font color="#993300">int main(int argc, char* argv[])</font></tt></b>
|
||||
<br><b><tt><font color="#993300">{</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> try</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> {</font></tt></b>
|
||||
<br><tt><font color="#993300"><b> eoParser parser(argc, argv); </b>
|
||||
// for user-parameter reading</font></tt>
|
||||
<br><tt><font color="#993300"><b> eoState state; </b>
|
||||
// keeps all things allocated</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="eval"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#CC0000"><b> </b> //
|
||||
The fitness</font></tt>
|
||||
<br><tt><font color="#CC0000"><b> </b> //////////////</font></tt>
|
||||
<br><tt><font color="#CC0000"><b> eoOneMaxEvalFunc<Indi>
|
||||
plainEval</b> /* (varType _anyVariable) */;<b>;</b></font></tt>
|
||||
<br><tt><font color="#CC0000"><b> </b> // turn that object
|
||||
into an evaluation counter</font></tt>
|
||||
<br><b><tt><font color="#CC0000"> eoEvalFuncCounter<Indi>
|
||||
eval(plainEval);</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="representation"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#999900"><b> </b> // the genotype - through a
|
||||
genotype initializer</font></tt>
|
||||
<br><b><tt><font color="#999900"> eoInit<Indi>& init = make_genotype(parser,
|
||||
state, Indi());</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="operators"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993399"><b> </b> // Build the variation operator
|
||||
(any seq/prop construct)</font></tt>
|
||||
<br><b><tt><font color="#993399"> eoGenOp<Indi>& op = make_op(parser,
|
||||
state, init);</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> //// Now the representation-independent
|
||||
things </font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // YOU SHOULD NOT NEED TO MODIFY
|
||||
ANYTHING BEYOND THIS POINT</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // unless you want to add specific
|
||||
statistics to the checkpoint</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //////////////////////////////////////////////</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="init"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993399"><b> </b> // initialize the population</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // yes, this is representation
|
||||
indepedent once you have an eoInit</font></tt>
|
||||
<br><b><tt><font color="#993399"> eoPop<Indi>& pop
|
||||
= make_pop(parser, state, init);</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="stop"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#3366FF"><b> </b> // stopping criteria</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> eoContinue<Indi> & term =
|
||||
make_continue(parser, state, eval);</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="output"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#3366FF"><b> </b> // output</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> eoCheckPoint<Indi> & checkpoint
|
||||
= make_checkpoint(parser, state, eval, term);</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="general"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993300"><b> </b> // algorithm (need the operator!)</font></tt>
|
||||
<br><b><tt><font color="#993300"> eoAlgo<Indi>& ga = make_algo_scalar(parser,
|
||||
state, eval, checkpoint, op);</font></tt></b>
|
||||
<br><tt><font color="#993300"><b> </b> ///// End of construction of
|
||||
the algorithm</font></tt>
|
||||
<br><tt><font color="#993300"><b> </b> /////////////////////////////////////////</font></tt>
|
||||
<br><tt><font color="#993300"><b> </b> // to be called AFTER all parameters
|
||||
have been read!!!</font></tt>
|
||||
<br><b><tt><font color="#993300"> make_help(parser);</font></tt></b>
|
||||
<br><tt><font color="#993300"><b> </b> //// GO</font></tt>
|
||||
<br><tt><font color="#993300"><b> </b> ///////</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="eval"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#CC0000"><b> </b> // evaluate intial population
|
||||
AFTER help and status in case it takes time</font></tt>
|
||||
<br><b><tt><font color="#CC0000"> apply<Indi>(eval, pop);</font></tt></b>
|
||||
<br><tt><font color="#CC0000"><b> </b> // if you want to print it
|
||||
out</font></tt>
|
||||
<br><tt><font color="#CC0000">// cout << "Initial
|
||||
Population\n";</font></tt>
|
||||
<br><tt><font color="#CC0000">// pop.sortedPrintOn(cout);</font></tt>
|
||||
<br><tt><font color="#CC0000">// cout << endl;</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="general"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993300"><b> run_ea(ga, pop); </b>// run the
|
||||
ga</font></tt>
|
||||
<br><b><tt><font color="#993300"> cout << "Final Population\n";</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> pop.sortedPrintOn(cout);</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> cout << endl;</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> }</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> catch(exception& e)</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> {</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> cout <<
|
||||
e.what() << endl;</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> }</font></tt></b>
|
||||
<br><b><tt><font color="#993300"> return 0;</font></tt></b>
|
||||
<br><b><tt><font color="#993300">}</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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: Sat May
|
||||
4 07:37:41 2002<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -460,7 +460,7 @@ page</a> - <a href="eoProgramming.html">Programming hints</a> - <font face="Aria
|
|||
documentation</a></font>
|
||||
<hr>
|
||||
<address>
|
||||
<a href="mailto:marc.schoenauer@polytechnique.fr">Marc Schoenauer</a></address>
|
||||
<a href="mailto:marc.schoenauer@inria.fr">Marc Schoenauer</a></address>
|
||||
<br><!-- Created: Nov 2000 --><!-- hhmts start -->Last
|
||||
modified: Sun Apr 28 06:42:44 2002
|
||||
<!-- hhmts end -->
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ hints</a> - <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/htm
|
|||
documentation
|
||||
<hr WIDTH="100%"></a></font></font><font color="#CC0000">Local: </font></b><a href="#introduction">Introduction</a>
|
||||
- <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>
|
||||
- <a href="#general">General 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>
|
||||
|
|
@ -314,6 +314,8 @@ the that uses a deterministic MergeReduce.</li>
|
|||
|
||||
<br>
|
||||
<p>
|
||||
<br>
|
||||
<br>
|
||||
<p><b><font color="#FF0000">Note</font></b>: The basic use (and initial
|
||||
motivation) for <b><tt><font color="#009900">eoSurviveAndDie</font></tt></b>
|
||||
takes 2 arguments, an eoMergeReduce and a number of surviving parents.
|
||||
|
|
@ -350,11 +352,81 @@ above replacement procedures within a very simple and easy-to-monitor Dummy
|
|||
EO class.
|
||||
<p>
|
||||
<hr WIDTH="100%">
|
||||
<br><a NAME="general"></a><b><font color="#000099"><font size=+2>General
|
||||
Replacement: eoReduceMergeReduce</font></font></b>
|
||||
<p>In an attempt to unify all the well-known replacements, plus most of
|
||||
the less-known-though-often-used, the <b><tt><font color="#009900">eoReduceMergeReduce</font></tt></b>
|
||||
replacement has been designed, and supersedes all of the above instances.
|
||||
<br>It allows to implement <b><font color="#FF0000">strong elistism</font></b>
|
||||
(i.e. some parents survive, whatever their fitness and that of the offspring),
|
||||
as well as multiple weak elistism (the best parents are put back in the
|
||||
next population if they outperform the best offspring).
|
||||
<p>Basically, an <b><tt><font color="#009900">eoReduceMergeReduce</font></tt></b>
|
||||
starts by eventually preserving the (strong) elite parents, proceeds by
|
||||
reducing both the parent and offspring populations, merges those populations,
|
||||
and eventually reduces the resulting populations (augmented with the elite
|
||||
parents) to the right size. Last, the weak elitism is taken care of if
|
||||
necessary.
|
||||
<br>The following image, taken from the graphical interface of EASEA, somehow
|
||||
demonstrates the different parameters of an <b><tt><font color="#009900">eoReduceMergeReduce.</font></tt></b>
|
||||
<br>
|
||||
<hr WIDTH="50%">
|
||||
<br><b><font color="#000099">eoReduceMergeReduce: </font><font color="#FF0000">The
|
||||
interface</font></b>
|
||||
<br>Of course the interface is that of eoReplacement. Let's concentrate
|
||||
on the constructor.
|
||||
<p>The constructor takes 6 arguments:
|
||||
<ol>
|
||||
<li>
|
||||
<b><tt><font color="#993300">eoHowMany elite</font></tt></b> determines
|
||||
the number of parents to be treated as elite (actual behavior determined
|
||||
by next parameter) using the <a href="#howmany">eoHowMany</a> behavior.</li>
|
||||
|
||||
<li>
|
||||
<b><tt><font color="#993300">bool strongElitism</font></tt></b> tells whether
|
||||
the elite above corresponds to strong (true) or false(weak) elitism.</li>
|
||||
|
||||
<br><b><font color="#FF0000">Note</font></b>: the case of no elitism is
|
||||
obtained by setting elite to 0
|
||||
<li>
|
||||
<b><tt><font color="#993300">eoHowMany reducedParents </font></tt></b>gives
|
||||
the number of parents remaining after reducing them</li>
|
||||
|
||||
<br><b><font color="#FF0000">Note</font></b>: 0 means that no parent survive
|
||||
(except the possible elite), as in <b><tt><font color="#009900">eoCommaReplacement</font></tt></b>
|
||||
<br>
|
||||
-1 is used inside <b><tt><font color="#009900">eoSSGAReplacement</font></tt></b>s
|
||||
(one parent is killed to make room for the newborn)
|
||||
<li>
|
||||
<b><tt><font color="#993300">eoReduce<EOT> & reduceParents</font></tt></b>
|
||||
indicates how the parents will be reduced (see <a href="#reduce">available
|
||||
instances</a>).</li>
|
||||
|
||||
<li>
|
||||
<b><tt><font color="#993300">eoHowMany reducedOffspring </font></tt></b>gives
|
||||
the number of offspring remaining after reducing them</li>
|
||||
|
||||
<br><b><font color="#FF0000">Note</font></b>: 0 is impossible (no evolution!!!)
|
||||
<li>
|
||||
<b><tt><font color="#993300">eoReduce<EOT> & reduceOffspring</font></tt></b>
|
||||
indicates how the offspring will be reduced (see <a href="#reduce">available
|
||||
instances</a>).</li>
|
||||
|
||||
<li>
|
||||
<b><tt><font color="#993300">eoReduce<EOT> & reduceFinal</font></tt></b>
|
||||
indicates how the merged reduced-parents/reduced-offspring will be reduced
|
||||
(see <a href="#reduce">available instances</a>).</li>
|
||||
|
||||
<br><b><font color="#FF0000">Note</font></b>: the number of individuals
|
||||
remaining after that reduction is of course the original size of the population.</ol>
|
||||
All popular evolution engines use some replacement procedure that can be
|
||||
viewed as an instance of an <b><tt><font color="#009900">eoReduceMergeReduce</font></tt></b>.
|
||||
<br>Moreover, a <b><font color="#FF0000">parser-based</font></b> input
|
||||
of a general is proposed in file do/make_checkpoint.h.
|
||||
<br>
|
||||
<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! In the following, P will denote
|
||||
|
|
@ -372,10 +444,10 @@ a positive scalar fitness</font></b><font color="#000000">, ranking or
|
|||
tournament (stochatic or deterministic) in all cases.</font>
|
||||
<br><font color="#FF0000">Replacement:</font><font color="#000000"> Generational.</font>
|
||||
<br><font color="#FF0000">Remark:</font><font color="#000000"> You could
|
||||
use also the Comma replacement, with exactly the same result as there are
|
||||
as many offspring as we need indiviudals in the next population. And using
|
||||
the eoSSGAWorseReplacement would also give the same result, but would be
|
||||
very inefficient!</font>
|
||||
use also the </font><b><tt><font color="#009900">eoCommaReplacement</font></tt></b><font color="#000000">,
|
||||
with exactly the same result as there are as many offspring as we need
|
||||
indiviudals in the next population. And using the </font><b><tt><font color="#009900">eoSSGAWorseReplacement</font></tt></b><font color="#000000">
|
||||
would also give the same result, but would be very inefficient!</font>
|
||||
<br><font color="#000000">You can also add <a href="#weakelitism">weak
|
||||
elitism</a> to preserve the best individual.</font>
|
||||
<li>
|
||||
|
|
@ -461,7 +533,7 @@ is implemented in the <b><tt><font color="#009900">eoDetTournamentSelect</font><
|
|||
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. These objects use the C++ function determinitic_tournament
|
||||
in <a href="../../doc/html/selectors_8h-source.html">selectors.h</a>.</li>
|
||||
in <a href="../../doc/html/selectors_h-source.html">selectors.h</a>.</li>
|
||||
|
||||
<li>
|
||||
<a NAME="stochTournament"></a><b><tt><font color="#009900">Stochastic Tournament</font></tt></b>
|
||||
|
|
@ -471,7 +543,7 @@ parameter R should be in [0.5,1]. It is implemented in the <b><tt><font color="#
|
|||
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. These objects use the C++ function determinitic_tournament
|
||||
in <a href="../../doc/html/selectors_8h-source.html">selectors.h</a>.</li>
|
||||
in <a href="../../doc/html/selectors_h-source.html">selectors.h</a>.</li>
|
||||
|
||||
<br><b><font color="#FF0000">Note</font></b>: A stochastic tournament with
|
||||
rate 1.0 is strictly identical to a deterministic tournament of size 2.
|
||||
|
|
@ -592,21 +664,29 @@ as parameter in the constructor (default is 0.75).</li>
|
|||
<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
|
||||
of individuals that may either be fixed or be related to 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>
|
||||
<br>Of course, it is possible to write 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>
|
||||
<br>
|
||||
<br>However, the class <b><tt><font color="#993300">eoHowMany</font></tt></b>
|
||||
allows one to handle in a single class three different behaviors when given
|
||||
a poopulatio size as argument:
|
||||
<ul>
|
||||
<li>
|
||||
return a given rate of the argument population size</li>
|
||||
|
||||
<li>
|
||||
return an absolute (unsigned) integer, whatever the argument population
|
||||
size</li>
|
||||
|
||||
<li>
|
||||
return the argument population size minus a given number</li>
|
||||
</ul>
|
||||
|
||||
<hr WIDTH="50%">
|
||||
<br><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>
|
||||
|
|
@ -618,16 +698,34 @@ is
|
|||
as you see there that <b><tt><font color="#993300">eoHowMany</font></tt></b>
|
||||
derives from
|
||||
<br><tt><font color="#993300">class eoUF<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
|
||||
<p>It has 3 possible constructors, that determine its behavior:
|
||||
<ul>
|
||||
<li>
|
||||
<b><tt><font color="#993300">eoHowMany(double _rate, bool _interpret_as_rate
|
||||
= true)</font></tt></b> where <b><tt><font color="#993300">_rate</font></tt></b>
|
||||
is by default the fixed rate of behavior 1 above. However, if the boolean
|
||||
second argument is false, the rate is transformed into a positive integer,
|
||||
and is used for behavior 2 above</li>
|
||||
|
||||
<li>
|
||||
<b><tt><font color="#993300">eoHowMany(int _combien)</font></tt></b>: if
|
||||
<b><tt><font color="#993300">_combien</font></tt></b>
|
||||
is positive, it is the absolute number of behavior 2 above, and if <b><tt><font color="#993300">_combien</font></tt></b>
|
||||
is negative, its absolute value is used to decrease the argument population
|
||||
in behavior 3 above</li>
|
||||
|
||||
<li>
|
||||
<b><tt><font color="#993300">eoHowMany(unsigned int _combien)</font></tt></b>:
|
||||
<b><tt><font color="#993300">_combien</font></tt></b>
|
||||
(positive!) is the absolute number of behavior 2 above. <b><font color="#FF6600">Note</font></b>
|
||||
that this constructor is mandatory to avoid ambiguity, as an unsigned int
|
||||
can be casted to either an int or a double.</li>
|
||||
</ul>
|
||||
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.
|
||||
methods, and it is used a lot in the eoGeneralReplacement construct.
|
||||
<p>
|
||||
<hr WIDTH="100%">
|
||||
<br><a NAME="SAD"></a><b><font color="#000099"><font size=+2>Survive and
|
||||
|
|
@ -661,9 +759,9 @@ should be erased from the source.
|
|||
<p>
|
||||
<hr WIDTH="100%"><b><font color="#CC0000">Local: </font></b><a href="#introduction">Introduction</a>
|
||||
- <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>
|
||||
- <a href="#general">General 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>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.76 [en] (X11; U; Linux 2.2.17-21mdksmp i686) [Netscape]">
|
||||
<meta name="GENERATOR" content="Mozilla/4.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
|
||||
<title>Tutorial: Lesson 2</title>
|
||||
<!-- Changed by: Marc Schoenauer, 29-Nov-2000 -->
|
||||
</head>
|
||||
|
|
@ -69,8 +69,6 @@ object that is a sub-class of the corresponding STL vector class.</font></li>
|
|||
|
||||
<br>
|
||||
<p>
|
||||
<br>
|
||||
<br>
|
||||
<p><b><font color="#FF0000">Note:</font></b> <font color="#000000">Also,
|
||||
a non-templatized fitness can be </font><b><font color="#FF6600">compiled
|
||||
separately</font></b><font color="#000000"> (not done here) into an object
|
||||
|
|
@ -88,8 +86,6 @@ requires.</font></li>
|
|||
|
||||
<br>
|
||||
<p>
|
||||
<br>
|
||||
<br>
|
||||
<p><b><font color="#FF0000">Note:</font></b> <font color="#000000">In 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
|
||||
|
|
@ -115,8 +111,6 @@ call to <a href="../../doc/html/classeo_pop.html#a2">pop.append()</a> function
|
|||
|
||||
<br>
|
||||
<p>
|
||||
<br>
|
||||
<br>
|
||||
<p><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">:
|
||||
the eoPop has no idea of the eval function, so it has to be done from outside!!!</font>
|
||||
|
|
@ -130,7 +124,7 @@ mutation
|
|||
<b>operators</b></font><font color="#000000">in the same algorithm,
|
||||
choosing among them according to
|
||||
</font><b><font color="#FF6600">relative
|
||||
rates.</font></b><font color="#CC33CC"> </font><font color="#000000">The
|
||||
weights.</font></b><font color="#CC33CC"> </font><font color="#000000">The
|
||||
class </font><font color="#CC33CC"><b>eoPropCombinedxxxOp</b>,
|
||||
</font><font color="#000000">where
|
||||
xxx is either Mon (for mutations, of class <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/classeo_mon_op.html">eoMonOp</a></font></font></b></font><font color="#CC33CC">)</font><font color="#000000">
|
||||
|
|
|
|||
388
eo/tutorial/html/eoLesson5.html
Normal file
388
eo/tutorial/html/eoLesson5.html
Normal file
|
|
@ -0,0 +1,388 @@
|
|||
<!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.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
|
||||
<title>Tutorial: Lesson 5</title>
|
||||
</head>
|
||||
<body text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000" background="beige009.jpg">
|
||||
<a href="eoLesson4.html">Lesson 4</a> -
|
||||
<a href="eoLesson6.html">Lesson
|
||||
6</a> -
|
||||
<a href="eoTutorial.html">Main page</a> -
|
||||
<a href="eoTopDown.html">Algorithm-Based</a>
|
||||
- <a href="eoBottomUp.html">Component-Based</a> - <a href="eoProgramming.html">Hints</a>
|
||||
- <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/index.html">EO
|
||||
documentation</a></font></font></b>
|
||||
<br>
|
||||
<hr WIDTH="100%"><!-- -------------- End of header ------------------ --><!-- ----------------------------------------------- -->
|
||||
<center>
|
||||
<h1>
|
||||
<font color="#FF0000">Tutorial Lesson 5: using your own genotype</font></h1></center>
|
||||
In this lesson, you will learn how to design and evolve <b><font color="#FF0000">your
|
||||
own genotype structure</font></b>. Note that at the moment, only algorithms
|
||||
involving a scalar fitness (double) are implemented (see test dir for Pareto
|
||||
optimization of multiple-objective fitness - or be patient :-)
|
||||
<p>The minimum code you'll have to write is first, of course, the code
|
||||
for the <a href="genotype">genotype structure</a>. Then, the representation-dependent
|
||||
code: <a href="#initialization">intialization procedure(s)</a>,
|
||||
<a href="#variation">variation
|
||||
operators</a> (quadratic crossover, mutation operator), ... and <a href="evaluation">evaluation
|
||||
function</a> - and that's it : we have prepared some template files and
|
||||
the script create.sh that will take care of generating a few other files
|
||||
to make your application complete.
|
||||
<p>In what follows, we will suppose that you want to evolve some data structure,
|
||||
and that you have enough programming skills to be able to write C code
|
||||
for its random initilialization, its crossover, its mutation and the computation
|
||||
of its fitness.
|
||||
<br>The examples will be described supposing you want to evolve ... bitstings
|
||||
to solve the OneMax problem (oh no!!!).
|
||||
<p>
|
||||
<hr WIDTH="100%"><a NAME="using"></a><b><font color="#000099"><font size=+2>Using
|
||||
template files</font></font></b>
|
||||
<br>Follow this very simple procedure:
|
||||
<ul>
|
||||
<li>
|
||||
choose a <b><font color="#FF6600">name</font></b> for you application -
|
||||
here <b><font color="#FF6600">OneMax</font></b> will be used</li>
|
||||
|
||||
<li>
|
||||
go to the <b><tt><font color="#993300">tutorial/Templates</font></tt></b>
|
||||
dir</li>
|
||||
|
||||
<br><tt><font color="#FF6666"> <b>cd
|
||||
pathWhereEOisInstalled/tutorial/Templates</b></font></tt>
|
||||
<li>
|
||||
run the <b><tt><font color="#993300">create.sh</font></tt></b> script with
|
||||
argument OneMax and second optional argument a directory name (suppose
|
||||
it's called APPLICATION here)</li>
|
||||
|
||||
<br><b><tt><font color="#FF6666">
|
||||
./create.sh OneMax APPLICATION</font></tt></b>
|
||||
<br>This will create a directory <b><tt><font color="#993300">tutorial/APPLICATION</font></tt></b>
|
||||
<li>
|
||||
Go to the APPLICATION directory</li>
|
||||
|
||||
<br><b><tt><font color="#FF6666">
|
||||
cd ../APPLICATION</font></tt></b>
|
||||
<br>You should see the following files:
|
||||
<br> <b><tt><font color="#993300">OneMaxEA.cpp
|
||||
</font></tt></b>the main main file, includes all other, to be compiled
|
||||
<br> <b><tt><font color="#993300">Makefile
|
||||
</font></tt></b>with default target eoOneMaxEA
|
||||
<br> <b><tt><font color="#993300">eoOneMax.h
|
||||
</font></tt></b>class eoOneMax, the genotype
|
||||
<br> <b><tt><font color="#993300">eoOneMaxEvalFunc.h
|
||||
|
||||
</font></tt></b>class for the computation of fitness
|
||||
<br> <b><tt><font color="#993300">eoOneMaxInit.h
|
||||
</font></tt></b>class for genotype initlialization
|
||||
<br> <b><tt><font color="#993300">eoOneMaxMutation.h
|
||||
</font></tt></b>class for mutation
|
||||
<br> <b><tt><font color="#993300">eoOneMaxQuadCrossover.h
|
||||
</font></tt></b>class
|
||||
for (quadratic) crossover
|
||||
<br> <b><tt><font color="#993300">make_genotype_OneMax.h
|
||||
|
||||
</font></tt></b>helper function that create the initializer
|
||||
<br> <b><tt><font color="#993300">make_op_OneMax.h
|
||||
</font></tt></b>helper function that handles the rates of application of
|
||||
the variation operators<br>
|
||||
<b><tt><font color="#993300">OneMaxLibEA.cpp
|
||||
</font></tt></b>another main file, for separate compilation of representation-independent
|
||||
stuff
|
||||
<br> <b><tt><font color="#993300">make_OneMaxEA.cpp
|
||||
</font></tt></b>the source for the representation-independent stuff
|
||||
<br>
|
||||
<li>
|
||||
Compile the whole application</li>
|
||||
|
||||
<br><b><tt><font color="#FF6666">
|
||||
make</font></tt></b>
|
||||
<br>and you should have no error there and see a new executable file named
|
||||
<b><tt><font color="#FF6666">OneMaxEA</font></tt></b>.
|
||||
You can run it and ... it will do nothing (what did you expect???).<br>
|
||||
<BR>
|
||||
<li>
|
||||
Now you should go and edit the files. The minimal changes that you
|
||||
will need are</li>
|
||||
|
||||
<br> in <b><tt><font color="#993300">eoOneMax.h
|
||||
</font></tt></b>define your genotype
|
||||
<br> in <b><tt><font color="#993300">eoOneMaxInit.h
|
||||
</font></tt></b>define the initialization of one genotype
|
||||
<br> in <b><tt><font color="#993300">eoOneMaxMutation.h
|
||||
|
||||
</font></tt></b>define the mutation of one genotype
|
||||
<br> in <b><tt><font color="#993300">eoOneMaxQuadCrossover.h
|
||||
|
||||
</font></tt></b>define the crossover of 2 genotypes</ul>
|
||||
<font color="#FF0000"><font size=+1>Smooth application building:</font></font>
|
||||
<ul>
|
||||
<li>
|
||||
After editing a particular file, <b><font color="#FF6600">compile</font></b>
|
||||
the whole thing immediately (by running make) <b><font color="#FF6600">and
|
||||
run</font></b> the algorithm, to validate your code</li>
|
||||
|
||||
<li>
|
||||
In each file, start by only adding code between keyword-pairs <b><tt><font color="#993300">START</font></tt></b>
|
||||
and <b><font color="#993300">END</font></b></li>
|
||||
</ul>
|
||||
We shall now take a look in turn at the 4 files mentionned above, then
|
||||
describe rapidly the other files, especially the main files.
|
||||
<br>
|
||||
<hr WIDTH="100%"><a NAME="genotype"></a><b><font color="#000099"><font size=+2>Genotype
|
||||
- and its pre-requisites: </font></font><tt><font color="#993300"><font size=+1>eoOneMax.h</font></font></tt></b>
|
||||
<p>First thing is to write the code for <font color="#999900"><b>the structure
|
||||
of the genotype</b>.</font> This is done by filling in the template file
|
||||
<a href="eoOneMax.html">eoOneMax.h</a>.
|
||||
There are 4 places that you should consider filling in:
|
||||
<ul>
|
||||
<li>
|
||||
Of course, <a href="eoOneMax.html#data">the data</a> that will build up
|
||||
the genotype. The convention in EO is to have it at the end of the class
|
||||
definition, and as private data.</li>
|
||||
|
||||
<li>
|
||||
The <a href="eoOneMax.html#constructor">default constructor</a> of an instance.
|
||||
Note that <b><font color="#FF6600">you must provide a default constructor</font></b>,
|
||||
and that no other constructor will be called within EO code. you might
|
||||
think you need some other constructor to initialize problem-specific data.
|
||||
This should be rather done in the eoInit object used to randomly initialize
|
||||
all individuals, or in the eoEvalFunc object, used to compute the fitness.</li>
|
||||
|
||||
<li>
|
||||
The <a href="eoOneMax.html#print">printOn</a> method, that writes the object
|
||||
to a stream. You<font color="#000000"> must</font><b><font color="#FF6600">
|
||||
call the EO::printOn</font></b> method that will take care of the fitness,
|
||||
and then write the specific code for your data structure.</li>
|
||||
|
||||
<li>
|
||||
The <a href="eoOneMax.html#read">readFrom</a> method, that will read an
|
||||
object from a stream. Again, you should <b><font color="#FF6600">call the
|
||||
EO::readFrom</font></b> method first to take care of the fitness.</li>
|
||||
|
||||
<br>Also note that readFrom will be generally called from an object that
|
||||
will have been constructed through the default constructor. This is why
|
||||
the EO objects that we provide always start printing structures with their
|
||||
length...</ul>
|
||||
You can of course also add <a href="eoOneMax.html#destructor">a destructor</a>
|
||||
if needed, and any other helper method. For instance, you will probably
|
||||
consider adding <b><font color="#FF6600">accessors and setters</font></b>
|
||||
for the private data - unless you prefer to make everything public :-(
|
||||
<br>See now an example of <a href="eoOneMax_complete.html">a comple eoOneMax.h</a>
|
||||
file. Note that this is the only "colored" completed file we will show,
|
||||
you will have to go to the <b><tt><font color="#993300">.../tutorial/OneMax</font></tt></b>
|
||||
dir to <a href="../OneMax">browse all files at once</a>.
|
||||
<br>
|
||||
<hr WIDTH="100%"><a NAME="initialization"></a><b><font color="#000099"><font size=+2>Initialization:</font></font></b>
|
||||
<p><font size=+1><font color="#FF0000">Initializer: </font><b><tt><font color="#993300">eoOneMaxInit.h</font></tt></b></font>
|
||||
<br>You must provide an <b><tt><font color="#CC33CC">eoInit</font></tt></b>
|
||||
object for your genotype, that is an object that will <b><font color="#FF6600">randomize
|
||||
a genotype built by the default constructor</font></b> of the EO class
|
||||
(here, an eoOneMax object) . Here you must at least fill <a href="eoOneMaxInit.html#operator">the
|
||||
code for such randomization.</a>
|
||||
<br>But you might also need some parameters (e.g. the size of the bitstring
|
||||
in eoOneMax): you should then <a href="eoOneMaxInit.html#constructor">pass
|
||||
them through the constructor</a> of the eoOneMaxInit class, and <a href="eoOneMaxInit.html#data">store
|
||||
it in its private data</a>.
|
||||
<br>And of course you might need to add a destructor (no example here)
|
||||
if you use complex data type in the object.
|
||||
<p><font size=+1><font color="#FF0000">Parameters: </font><b><tt><font color="#993300">make_genotype_OneMax.h</font></tt></b></font>
|
||||
<br>There is another file you will probably want to modify as far as initialization
|
||||
is concerned, that is <a href="make_genotype_OneMax.html">make_genotype_OneMax.h.</a>
|
||||
Such helper files are used for all components of advanced EO programs (see
|
||||
Lesson 4). The main reason for that is to allow separate compilation of
|
||||
such sub-components for known EO types, as this is done in the directories
|
||||
src/ga and src/es. But a useful consequence is to make your code modular.
|
||||
For instance, the <a href="make_genotype_OneMax.html#representation">make_genotype_OneMax.h</a>
|
||||
file takes care of all the preparation of all data regarding the eoInit
|
||||
object - and returns to the main fonction a reference to an eoInit that
|
||||
will later be used to <a href="OneMaxEA.html#initPop">initialize the whole
|
||||
population</a> in a representation-independent way.
|
||||
<br>What you have to do in that file is to set values for all parameters
|
||||
needed by the eoOneMaxInit class, for instance by reading them from the
|
||||
parser: this allows later to modify them easily from the command-line.
|
||||
Note however that an alternative could be to pass the parser to the constructor
|
||||
of the eoOneMaxInit class, and to read all parameters there...
|
||||
<br><b><font color="#FF0000">Note</font></b>: Remember that the make_xxx
|
||||
files were first introduced to allow the user to compile sepearately most
|
||||
of the code of standard Evolutionary Algorithm written in EO for bitstring
|
||||
and real vector representations (
|
||||
<br>
|
||||
<hr WIDTH="100%"><a NAME="evaluation"></a><b><font color="#000099"><font size=+2>Evaluation:
|
||||
</font></font><tt><font color="#993300"><font size=+1>eoOneMaxEvalFunc.h</font></font></tt></b>
|
||||
<p>The <b><tt><font color="#CC0000">eoOneMaxEvalFunc</font></tt></b> is
|
||||
the object that will <b><font color="#FF6600">compute the fitness of an
|
||||
eoOneMax object</font></b>. You have to fill in the <a href="eoOneMaxEvalFunc.html#operator">code
|
||||
for the computation of the fitness value</a> (there is no way that this
|
||||
can be done automatically :-) Note that this code must be run <b><font color="#FF6600">only
|
||||
if</font></b> the <b><tt><font color="#993300">_eo.invalid() </font></tt></b>test
|
||||
returns true, to avoid computing the fitness of an object that has not
|
||||
been modified and thus still holds a valid fitness value. After computing
|
||||
the fitness, store it into the object by calling the <b><tt><font color="#993300">fitness(FitnessType)</font></tt></b>
|
||||
method.
|
||||
<br>Should you need some specific data for that, the <a href="eoOneMaxEvalFunc.html#constructor">constructor
|
||||
of the object</a> is the place to get such data, and you should, again,
|
||||
store it in some <a href="eoOneMaxEvalFunc.html#data">private data</a>
|
||||
of the class.
|
||||
<br>
|
||||
<hr WIDTH="100%"><a NAME="variation"></a><b><font color="#000099"><font size=+2>Variation
|
||||
Operators</font></font></b>
|
||||
<br>You can write as many crossover and mutation operators as you like.
|
||||
However, we only provide the template files for <a href="eoOperators.html#crossover">quadratic
|
||||
crossover </a>and <a href="eoOperators.html#mutation">mutation</a>, but
|
||||
you could then easily write the equivalent code for binary crossover, or
|
||||
general variation operator.
|
||||
<p><font size=+1><font color="#FF0000">Crossover: </font><b><tt><font color="#993300">eoOneMaxQuadCrossover.h</font></tt></b></font>
|
||||
<br>As usual, you must go and write the <a href="eoOneMaxQuadCrossover.html#operator">code
|
||||
for the operator()</a> that will perform the crossover, possibly modifying
|
||||
both arguments. Don't forget to <b><font color="#FF6600">update the boolean
|
||||
parameter</font></b> that will report whether the genotypes have been modified
|
||||
- allowing to recompute the fitness only of the ones that have actually
|
||||
been modified. You can also have <b><font color="#FF6600">parameters</font></b>
|
||||
to the crossover by <a href="eoOneMaxQuadCrossover.html#constructor">passing
|
||||
them to the constructor</a>, ans storing them in the <a href="eoOneMaxQuadCrossover.html#data">private
|
||||
data of the crossover object</a>.
|
||||
<p><font size=+1><font color="#FF0000">Mutation: </font><b><tt><font color="#993300">eoOneMaxMutation.h</font></tt></b></font>
|
||||
<br>Here again, you must go and write the code for the operator() that
|
||||
will perform the mutation, eventually modifying its arguments. Don't forget
|
||||
to <b><font color="#FF6600">update the boolean parameter</font></b> that
|
||||
will report whether the genotype has been modified - allowing to recompute
|
||||
the fitness only of the ones that have actually been modified. You can
|
||||
also have <b><font color="#FF6600">parameters</font></b> to the mutation
|
||||
by <a href="eoOneMaxMutation.html#constructor">passing them to the constructor</a>,
|
||||
ans storing them in the <a href="eoOneMaxMutation.html#data">private data
|
||||
of the mutation object</a>.
|
||||
<p><font size=+1><font color="#FF0000">Parameters: </font><b><tt><font color="#993300">make_op_OneMax.h</font></tt></b></font>
|
||||
<br>First of all, if you intend to use <b><font color="#FF6600">only one
|
||||
crossover</font></b> operator and <b><font color="#FF6600">one mutation</font></b>
|
||||
operator, you have <b><font color="#FF6600">nothing to modify</font></b>
|
||||
in <a href="make_op_OneMax.html">make_op_OneMax function</a>, except maybe
|
||||
reading user-defined parameters (copy the code from <a href="make_genotype_OneMax.html#representation">make_genotype_OneMax</a>)
|
||||
and passing them to <a href="make_op_OneMax.html#cross_ctor">the appropriate
|
||||
operator constructor</a>.
|
||||
<br>As it is written now, it allows you enter a crossover probability <b><tt><font color="#CC33CC">Pcross</font></tt></b>
|
||||
and a mutation probability <b><tt><font color="#CC33CC">Pmut</font></tt></b>,
|
||||
and to build an eoGeneralOp that will call in sequence the <b><tt><font color="#CC33CC">eoOneMaxQuadCrossover</font></tt></b>
|
||||
that is defined above with probability <b><tt><font color="#CC33CC">Pcross</font></tt></b>
|
||||
and the <b><tt><font color="#CC33CC">eoOneMaxMutation</font></tt></b> also
|
||||
defined above with probability <b><tt><font color="#CC33CC">Pmut</font></tt></b>.
|
||||
Beware that all allocated objects must be stored in the eoState otherwise
|
||||
you will run into trouble (see <a href="eoProgramming.html#memory">EO Memory
|
||||
Management explanations</a>).
|
||||
<p>However, everything is there (commented out) to allow you to use <a href="make_op_OneMax.html#crossover">more
|
||||
than one crossover</a> and <a href="make_op_OneMax.html#mutation">one mutation</a>
|
||||
- provided you write the code for them , of course.
|
||||
<p>The code starts by defining an <b><tt><font color="#CC33CC">eoOneMaxQuadCrossover</font></tt></b>object,
|
||||
then reads some application rate that is totally useless if you have only
|
||||
one crossover, then creates an <b><tt><font color="#CC33CC"><a href="eoLesson2.html#combined_operators">eoPropCombinedQuadOp</a></font></tt></b>
|
||||
with this simple oeprator. The same story repeats for the mutation. <a href="make_op_OneMax.html#donottouch">Finally</a>,
|
||||
the <b><tt><font color="#CC33CC"><a href="eoOperators.html#general_combination">eoGeneralOp</a></font></tt></b>
|
||||
is created from those combined operators and the individulal level probabilities
|
||||
<b><tt><font color="#CC33CC">Pcross</font></tt></b>
|
||||
and <b><tt><font color="#CC33CC">Pmut</font></tt></b>.
|
||||
<p>In order to add a second crossover operator for instance (called <b><tt><font color="#CC33CC">eoOneMaxSecondCrossover</font></tt></b>
|
||||
in the commented code) all you need to is
|
||||
<ul>
|
||||
<li>
|
||||
Create the code for the new class <b><tt><font color="#CC33CC">eoOneMaxSecondCrossover</font></tt></b>:
|
||||
simply copy the <b><tt><font color="#993300">eoOneMaxQuadCrossover.h</font></tt></b>
|
||||
file into <b><tt><font color="#993300">eoOneMaxSecondCrossover.h</font></tt></b>
|
||||
and change all names <b><tt><font color="#CC33CC">eoOneMaxQuadCrossover</font></tt></b>
|
||||
to <b><tt><font color="#CC33CC">eoOneMaxSecondCrossover </font></tt></b>(inlcluding
|
||||
after the #ifdef statement!!!);</li>
|
||||
|
||||
<li>
|
||||
Uncomment the <a href="make_op_OneMax.html#crossover">corresponding lines
|
||||
in make_op_OneMax.h</a>, possibly adding user-defined parameter reading</li>
|
||||
|
||||
<li>
|
||||
Repeat as many times as you have operators, using of course different names!
|
||||
The same recommendations hold for mutations.</li>
|
||||
</ul>
|
||||
In case you have more than one operator of a kind, then of course the relative
|
||||
weights of application do make sense, allowing you to tune with command-line
|
||||
parameters the proportion with which each operator that will be applied.
|
||||
<p>
|
||||
<hr WIDTH="100%"><a NAME="main"></a><b><font color="#000099"><font size=+2>Main
|
||||
files: </font></font><tt><font color="#993300"><font size=+1>OneMaxEA.cpp
|
||||
</font></font></tt></b>and<b><tt><font color="#993300"><font size=+1> OneMaxLibEA.cpp</font></font></tt></b><font color="#FF0000"><font size=+1></font></font>
|
||||
<p>As a start, you should only (eventually) modify in <b><tt><font color="#993300">OneMaxEA.cpp
|
||||
</font></tt></b>the <a href="OneMax.cpp#fitness">type of fitness</a> you
|
||||
will be handling, namely <b><tt><font color="#CC0000">double</font></tt></b>
|
||||
if you are <b><font color="#FF6600">maximizing</font></b>, or <b><tt><font color="#CC0000">eoMinimizingFitness</font></tt></b>
|
||||
if you are <b><font color="#FF6600">minimizing</font></b>. Then running
|
||||
<b><tt><font color="#FF6666">make</font></tt></b> will result in a perfectly
|
||||
valid executable named <b><tt><font color="#FF6666">OneMaxEA</font></tt></b>.
|
||||
<p>The skeleton of the main file here mimics that of the main file in
|
||||
<a href="eoLesson4.html">Lesson4</a>,
|
||||
and <a href="eoLesson4.html#programmerguide">uses the make_xxx separate
|
||||
files construct</a>: the part of an Evolutionary Algorithm related to the
|
||||
<b><font color="#009900">evolution
|
||||
engine</font></b> is <b><font color="#FF6600">indepenent of the representation</font></b>,
|
||||
and can be directly used ... provided it is compiled with the right template
|
||||
(remember everything in EO is <a href="eoProgramming.html#templates">templatized
|
||||
over the EO objects it handles</a>. Main file <b><tt><font color="#993300">OneMaxEA.cpp</font></tt></b>
|
||||
is written so that it includes eveything - and thus everytime you run <b><tt><font color="#FF6666">make</font></tt></b>
|
||||
(or <b><tt><font color="#FF6666">make OneMaxEA</font></tt></b>), you compile
|
||||
the code for make_pop, make_continue and make_checkpoint that is defined
|
||||
in the .../src/do directory.
|
||||
<p>The basic construct is (for instance to build the evolution engine)
|
||||
<br>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#009900">#include <do/make_algo_scalar.h></font></tt></b>
|
||||
<br><b><tt><font color="#009900">eoAlgo<Indi>& make_algo_scalar(eoParser&
|
||||
_parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>&
|
||||
_continue, eoGenOp<Indi>& _op)</font></tt></b>
|
||||
<br><b><tt><font color="#009900">{</font></tt></b>
|
||||
<br><b><tt><font color="#009900"> return do_make_algo_scalar(_parser,
|
||||
_state, _eval, _continue, _op);</font></tt></b>
|
||||
<br><b><tt><font color="#009900">}</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
First, include the code (from the do directory). Then define the make_xxx
|
||||
function from the do_make_xxx function.
|
||||
<br>Of course, such construct is stupid here, as you could perfectly call
|
||||
directly the do_make_xxx function in the main. However, if you ever want
|
||||
to do separate compilation of some parts, you will need such construct
|
||||
(see <a href="eoLesson4.html">Lesson4</a>) so we have kept it here for
|
||||
consistency reasons.
|
||||
<p>Go in your application directory, and look at the differences between
|
||||
both files and you'll see how this is handled in both cases.
|
||||
<p><b><font color="#FF0000">Reducing compilation time:</font></b>
|
||||
<br>However, we also provide another main file (<b><tt><font color="#993300">OneMaxLibEA.cpp</font></tt></b>)that
|
||||
only includes the code that is specific to your application, and is supposed
|
||||
to be linked with another object file that will contain the code that is
|
||||
representation independent (<b><tt><font color="#993300">make_OneMax.cpp</font></tt></b>).
|
||||
This is done by running <b><tt><font color="#FF6666">make OneMaxLibEA</font></tt></b>
|
||||
on the command-line.
|
||||
<br>For example, on a PentiumIII 400MHz with g++ 2.96, compiling <b><tt><font color="#FF6666">OneMaxEA</font></tt></b>
|
||||
takes about <b><font color="#FF6600">33s</font></b>, compiling both <b><tt><font color="#FF6666">make_OneMax.o</font></tt></b>
|
||||
and <b><tt><font color="#FF6666">OneMaxLibEA</font></tt></b> takes about
|
||||
<b><font color="#FF6600">54s</font></b> but compiling only <b><tt><font color="#FF6666">OneMaxLibEA</font></tt></b>
|
||||
takes only <b><font color="#FF6600">14s</font></b> <b><tt><font color="#FF6666">make_OneMax.o</font></tt></b>
|
||||
is up-to-date ...
|
||||
<p><b><font color="#FF0000">Hints:</font></b>
|
||||
<br>While developping the genotype structure itself in file <b><tt><font color="#993300">eoOneMax.h</font></tt></b>,
|
||||
you should use the <b><tt><font color="#993300">OneMaxEA.cpp</font></tt></b>
|
||||
file. But after the <b><tt><font color="#993300">eoOneMax.h</font></tt></b>
|
||||
file is frozen, you should use the <b><tt><font color="#993300">eoOneMaxLibEA.cpp</font></tt></b>
|
||||
file. Of course, both resulting programs are strictly identical!
|
||||
<p>
|
||||
<hr WIDTH="100%"><font color="#000000"><a href="eoLesson4.html">Lesson
|
||||
4</a> -
|
||||
<a href="eoLesson6.html">Lesson 6</a> -
|
||||
<a href="eoTutorial.html">Main
|
||||
page</a> -
|
||||
<a href="eoTopDown.html">Algorithm-Based</a> - <a href="eoBottomUp.html">Component-Based</a>
|
||||
- <a href="eoProgramming.html">Hints</a> -<b> <font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/index.html">EO
|
||||
documentation</a></font></font></b></font>
|
||||
<br>
|
||||
<hr>
|
||||
<address>
|
||||
<font color="#000000"><a href="mailto:Marc.Schoenauer@inria.fr">Marc Schoenauer</a></font></address>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
209
eo/tutorial/html/eoOneMax.html
Normal file
209
eo/tutorial/html/eoOneMax.html
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
<!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.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
|
||||
<title>Templates/eoOneMax.h</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
<a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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">Templates/eoOneMax.h</font></h1></center>
|
||||
The places where you have to put some code are on <b><font color="#FF6666">pink
|
||||
background</font></b>.. Only the the <a href="eoTutorial.html#colors">character
|
||||
colors have the usual meaning</a>.
|
||||
<br><a NAME="start"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE><tt><font color="#993300">/** -*- mode: c++; c-indent-level:
|
||||
4; c++-member-init-indent: 8; comment-column: 35; -*-</font></tt>
|
||||
<br><tt><font color="#993300">The above line is usefulin Emacs-like editors</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<br><tt><font color="#993300">/*</font></tt>
|
||||
<br><tt><font color="#993300">Template for creating a new representation
|
||||
in EO</font></tt>
|
||||
<br><tt><font color="#993300">================================================</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<br><b><tt><font color="#993300">#ifndef _eoOneMax_h</font></tt></b>
|
||||
<br><b><tt><font color="#993300">#define _eoOneMax_h</font></tt></b>
|
||||
<br><tt><font color="#993300">/** </font></tt>
|
||||
<br><tt><font color="#993300">* Always write a comment in this format
|
||||
before class definition</font></tt>
|
||||
<br><tt><font color="#993300">* if you want the class to be documented
|
||||
by Doxygen</font></tt>
|
||||
<br><tt><font color="#993300">* Note that you MUST derive your structure
|
||||
from EO<fitT></font></tt>
|
||||
<br><tt><font color="#993300">* but you MAY use some other already prepared
|
||||
class in the hierarchy</font></tt>
|
||||
<br><tt><font color="#993300">* like eoVector for instance, if you handle
|
||||
a vector of something....</font></tt>
|
||||
<br><tt><font color="#993300">* If you create a structure from scratch,</font></tt>
|
||||
<br><tt><font color="#993300">* the only thing you need to provide are </font></tt>
|
||||
<br><tt><font color="#993300">*
|
||||
a default constructor</font></tt>
|
||||
<br><tt><font color="#993300">*
|
||||
IO routines printOn and readFrom</font></tt>
|
||||
<br><tt><font color="#993300">*</font></tt>
|
||||
<br><tt><font color="#993300">* Note that operator<< and operator>>
|
||||
are defined at EO level</font></tt>
|
||||
<br><tt><font color="#993300">* using these routines</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="representation"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900">template< class FitT></font></tt></b>
|
||||
<br><b><tt><font color="#999900">class eoOneMax: public EO<FitT> {</font></tt></b>
|
||||
<br><b><tt><font color="#999900">public:</font></tt></b>
|
||||
<br><tt><font color="#999900"><b> </b> /** Ctor: you MUST provide
|
||||
a default ctor.</font></tt>
|
||||
<br><tt><font color="#999900"> * though such individuals will
|
||||
generally be processed </font></tt>
|
||||
<br><tt><font color="#999900"> * by some eoInit object</font></tt>
|
||||
<br><tt><font color="#999900"> */</font></tt>
|
||||
<br><b><tt><font color="#999900"> eoOneMax() </font></tt></b>
|
||||
<br><b><tt><font color="#999900"> { </font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="constructor"></a><tt><font color="#999900"><b> </b>
|
||||
// START Code of default Ctor of an eoOneMax object</font></tt>
|
||||
<br><tt><font color="#999900"><b> </b> //
|
||||
END Code of default Ctor of an eoOneMax object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900"> }</font></tt></b>
|
||||
<p><b><tt><font color="#999900"> virtual ~eoOneMax()</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> {</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="destructor"></a><tt><font color="#999900"><b> </b>
|
||||
// START Code of Destructor of an eoEASEAGenome object</font></tt>
|
||||
<br><tt><font color="#999900"><b> </b> //
|
||||
END Code of Destructor of an eoEASEAGenome object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900"> }</font></tt></b>
|
||||
<p><b><tt><font color="#999900"> virtual string className() const
|
||||
{ return "eoOneMax"; }</font></tt></b>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="output"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#3366FF"><b> </b> /** printing... */</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> void printOn(ostream& os) const</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> {</font></tt></b>
|
||||
<br><tt><font color="#3366FF"><b> </b> //
|
||||
First write the fitness</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> EO<FitT>::printOn(os);</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> os << '
|
||||
';</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="print"></a><tt><font color="#3366FF"><b> </b>
|
||||
// START Code of default output </font></tt>
|
||||
<p><tt><font color="#3366FF">/** HINTS</font></tt>
|
||||
<br><tt><font color="#3366FF">* in EO we systematically write the sizes
|
||||
of things before the things</font></tt>
|
||||
<br><tt><font color="#3366FF">* so readFrom is easier to code (see below)</font></tt>
|
||||
<br><tt><font color="#3366FF">*/</font></tt>
|
||||
<p><tt><font color="#3366FF"><b> </b> // END
|
||||
Code of default output</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF"> }</font></tt></b>
|
||||
<p><tt><font color="#3366FF"><b> </b> /** reading... </font></tt>
|
||||
<br><tt><font color="#3366FF"> * of course, your readFrom must
|
||||
be able to read what printOn writes!!!</font></tt>
|
||||
<br><tt><font color="#3366FF"> */</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> void readFrom(istream& is)</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> {</font></tt></b>
|
||||
<br><tt><font color="#3366FF"><b> </b> //
|
||||
of course you should read the fitness first!</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> EO<FitT>::readFrom(is);</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="read"></a><tt><font color="#3366FF"><b> </b>
|
||||
// START Code of input</font></tt>
|
||||
<p><tt><font color="#3366FF">/** HINTS</font></tt>
|
||||
<br><tt><font color="#3366FF">* remember the eoOneMax object will come
|
||||
from the default ctor</font></tt>
|
||||
<br><tt><font color="#3366FF">* this is why having the sizes written out
|
||||
is useful</font></tt>
|
||||
<br><tt><font color="#3366FF">*/</font></tt>
|
||||
<p><tt><font color="#3366FF"><b> </b> // END
|
||||
Code of input</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF"> }</font></tt></b>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="data"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#999900"><b>private: </b> //
|
||||
put all data here</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#999900"><b> </b> //
|
||||
START Private data of an eoOneMax object</font></tt>
|
||||
<br><tt><font color="#999900"><b> </b> //
|
||||
END Private data of an eoOneMax object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900">};</font></tt></b>
|
||||
<p><b><tt><font color="#999900">#endif</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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: Fri May
|
||||
3 06:06:09 2002<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
160
eo/tutorial/html/eoOneMaxEvalFunc.html
Normal file
160
eo/tutorial/html/eoOneMaxEvalFunc.html
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
<!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.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
|
||||
<title>Templates/eoOneMaxEvalFunc.h</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
<a href="eoLesson5.html">Back to Lesson 5</a>
|
||||
- <a href="eoTutorial.html">Tutorial main page </a>- <a href="eoTopDown.html">Top-Down
|
||||
page</a> - <a href="eoBottomUp.html">Bottom-up 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">Templates/eoOneMaxEvalFunc.h</font></h1></center>
|
||||
The places where you have to put some code are on <b><font color="#FF6666">pink
|
||||
background</font></b>.. Only the the <a href="eoTutorial.html#colors">character
|
||||
colors have the usual meaning</a>.
|
||||
<br><a NAME="start"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE><tt><font color="#993300">/** -*- mode: c++; c-indent-level:
|
||||
4; c++-member-init-indent: 8; comment-column: 35; -*-</font></tt>
|
||||
<p><tt><font color="#993300">The above line is usefulin Emacs-like editors</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<p><tt><font color="#993300">/*</font></tt>
|
||||
<br><tt><font color="#993300">Template for evaluator in EO, a functor that
|
||||
computes the fitness of an EO</font></tt>
|
||||
<br><tt><font color="#993300">==========================================================================</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<p><b><tt><font color="#993300">#ifndef _eoOneMaxEvalFunc_h</font></tt></b>
|
||||
<br><b><tt><font color="#993300">#define _eoOneMaxEvalFunc_h</font></tt></b>
|
||||
<p><tt><font color="#993300">// include whatever general include you need</font></tt>
|
||||
<br><b><tt><font color="#993300">#include <stdexcept></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <fstream></font></tt></b>
|
||||
<p><tt><font color="#993300">// include the base definition of eoEvalFunc</font></tt>
|
||||
<br><b><tt><font color="#993300">#include "eoEvalFunc.h"</font></tt></b>
|
||||
<p><tt><font color="#993300">/** </font></tt>
|
||||
<br><tt><font color="#993300"> Always write a comment in this format
|
||||
before class definition</font></tt>
|
||||
<br><tt><font color="#993300"> if you want the class to be documented
|
||||
by Doxygen</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="eval"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#CC0000">template <class EOT></font></tt></b>
|
||||
<br><b><tt><font color="#CC0000">class eoOneMaxEvalFunc : public eoEvalFunc<EOT></font></tt></b>
|
||||
<br><b><tt><font color="#CC0000">{</font></tt></b>
|
||||
<br><b><tt><font color="#CC0000">public:</font></tt></b>
|
||||
<br><tt><font color="#CC0000">/// Ctor - no requirement</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="constructor"></a><tt><font color="#CC0000">// START eventually
|
||||
add or modify the anyVariable argument</font></tt>
|
||||
<br><b><tt><font color="#CC0000"> eoOneMaxEvalFunc()</font></tt></b>
|
||||
<br><tt><font color="#CC0000"><b> </b> // eoOneMaxEvalFunc(
|
||||
varType _anyVariable) : anyVariable(_anyVariable) </font></tt>
|
||||
<br><tt><font color="#CC0000">// END eventually add or modify the anyVariable
|
||||
argument</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#CC0000"> {</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#CC0000"><b> </b> //
|
||||
START Code of Ctor of an eoOneMaxEvalFunc object</font></tt>
|
||||
<br><tt><font color="#CC0000"><b> </b> //
|
||||
END Code of Ctor of an eoOneMaxEvalFunc object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#CC0000"> }</font></tt></b>
|
||||
<p><tt><font color="#CC0000"><b> </b> /** Actually compute the fitness</font></tt>
|
||||
<br><tt><font color="#CC0000"> *</font></tt>
|
||||
<br><tt><font color="#CC0000"> * @param EOT & _eo the EO
|
||||
object to evaluate</font></tt>
|
||||
<br><tt><font color="#CC0000"> *
|
||||
it should stay templatized to be usable </font></tt>
|
||||
<br><tt><font color="#CC0000"> *
|
||||
with any fitness type</font></tt>
|
||||
<br><tt><font color="#CC0000"> */</font></tt>
|
||||
<br><b><tt><font color="#CC0000"> void operator()(EOT & _eo)</font></tt></b>
|
||||
<br><b><tt><font color="#CC0000"> {</font></tt></b>
|
||||
<br><tt><font color="#CC0000"><b> </b> //
|
||||
test for invalid to avoid recomputing fitness of unmodified individuals</font></tt>
|
||||
<br><b><tt><font color="#CC0000"> if (_eo.invalid())</font></tt></b>
|
||||
<br><b><tt><font color="#CC0000">
|
||||
{</font></tt></b>
|
||||
<br><tt><font color="#CC0000"><b>double fit; </b>
|
||||
// to hold fitness value</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="operator"></a><tt><font color="#CC0000"><b> </b>
|
||||
// START Code of computation of fitness of the eoOneMax object</font></tt>
|
||||
<br><tt><font color="#CC0000">// fit = blablabla</font></tt>
|
||||
<br><tt><font color="#CC0000"><b> </b> //
|
||||
END Code of computation of fitness of the eoOneMax object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#CC0000">_eo.fitness(fit);</font></tt></b>
|
||||
<br><b><tt><font color="#CC0000">
|
||||
}</font></tt></b>
|
||||
<br><b><tt><font color="#CC0000"> }</font></tt></b>
|
||||
<p><b><tt><font color="#CC0000">private:</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="data"></a><tt><font color="#CC0000">// START Private data
|
||||
of an eoOneMaxEvalFunc object</font></tt>
|
||||
<br><tt><font color="#CC0000"><b> </b> // varType anyVariable;
|
||||
// for example ...</font></tt>
|
||||
<br><tt><font color="#CC0000">// END Private data of
|
||||
an eoOneMaxEvalFunc object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#CC0000">};</font></tt></b>
|
||||
<br><b><tt><font color="#CC0000">#endif</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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: Fri May
|
||||
3 06:14:25 2002<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
153
eo/tutorial/html/eoOneMaxInit.html
Normal file
153
eo/tutorial/html/eoOneMaxInit.html
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
<!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.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
|
||||
<title>Templates/eoOneMaxInit.h</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
<a href="eoLesson5.html">Back to Lesson 5</a> -
|
||||
<a href="eoTutorial.html">Tutorial main page </a>- <a href="eoTopDown.html">Top-Down
|
||||
page</a> - <a href="eoBottomUp.html">Bottom-up 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">Templates/eoOneMaxInit.h</font></h1></center>
|
||||
The places where you have to put some code are on <b><font color="#FF6666">pink
|
||||
background</font></b>.. Only the the <a href="eoTutorial.html#colors">character
|
||||
colors have the usual meaning</a>.
|
||||
<br><a NAME="start"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE><tt><font color="#993300">/** -*- mode: c++; c-indent-level:
|
||||
4; c++-member-init-indent: 8; comment-column: 35; -*-</font></tt>
|
||||
<br><tt><font color="#993300">The above line is usefulin Emacs-like editors</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<p><tt><font color="#993300">/*</font></tt>
|
||||
<br><tt><font color="#993300">Template for EO objects initialization in
|
||||
EO</font></tt>
|
||||
<br><tt><font color="#993300">============================================</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<p><b><tt><font color="#993300">#ifndef _eoOneMaxInit_h</font></tt></b>
|
||||
<br><b><tt><font color="#993300">#define _eoOneMaxInit_h</font></tt></b>
|
||||
<p><tt><font color="#993300">// include the base definition of eoInit</font></tt>
|
||||
<br><b><tt><font color="#993300">#include <eoInit.h></font></tt></b>
|
||||
<p><tt><font color="#993300">/** </font></tt>
|
||||
<br><tt><font color="#993300">* Always write a comment in this format
|
||||
before class definition</font></tt>
|
||||
<br><tt><font color="#993300">* if you want the class to be documented
|
||||
by Doxygen</font></tt>
|
||||
<br><tt><font color="#993300">*</font></tt>
|
||||
<br><tt><font color="#993300">* There is NO ASSUMPTION on the class GenoypeT.</font></tt>
|
||||
<br><tt><font color="#993300">* In particular, it does not need to derive
|
||||
from EO (e.g. to initialize </font></tt>
|
||||
<br><tt><font color="#993300">* atoms of
|
||||
an eoVector you will need an eoInit<AtomType>)</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="init"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399">template <class GenotypeT></font></tt></b>
|
||||
<br><b><tt><font color="#993399">class eoOneMaxInit: public eoInit<GenotypeT>
|
||||
{</font></tt></b>
|
||||
<br><b><tt><font color="#993399">public:</font></tt></b>
|
||||
<br><tt><font color="#993399">/// Ctor - no requirement</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="constructor"></a><tt><font color="#993399">// START eventually
|
||||
add or modify the anyVariable argument</font></tt>
|
||||
<br><b><tt><font color="#993399"> eoOneMaxInit()</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> // eoOneMaxInit( varType
|
||||
_anyVariable) : anyVariable(_anyVariable) </font></tt>
|
||||
<br><tt><font color="#993399">// END eventually add or modify the anyVariable
|
||||
argument</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399"> {</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993399"><b> </b> //
|
||||
START Code of Ctor of an eoOneMaxInit object</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
END Code of Ctor of an eoOneMaxInit object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399"> }</font></tt></b>
|
||||
<p><tt><font color="#993399"><b> </b> /** initialize a genotype</font></tt>
|
||||
<br><tt><font color="#993399"> *</font></tt>
|
||||
<br><tt><font color="#993399"> * @param _genotype generally
|
||||
a genotype that has been default-constructed</font></tt>
|
||||
<br><tt><font color="#993399"> *
|
||||
whatever it contains will be lost</font></tt>
|
||||
<br><tt><font color="#993399"> */</font></tt>
|
||||
<br><b><tt><font color="#993399"> void operator()(GenotypeT &
|
||||
_genotype)</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> {</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="operator"></a><tt><font color="#993399"><b> </b>
|
||||
// START Code of random initialization of an eoOneMax object</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
END Code of random initialization of an eoOneMax object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993399"><b> _genotype.invalidate(); </b>
|
||||
// IMPORTANT in case the _genotype is old</font></tt>
|
||||
<br><b><tt><font color="#993399"> }</font></tt></b>
|
||||
<p><b><tt><font color="#993399">private:</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="data"></a><tt><font color="#993399">// START Private data
|
||||
of an eoOneMaxInit object</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // varType anyVariable;
|
||||
// for example ...</font></tt>
|
||||
<br><tt><font color="#993399">// END Private data of
|
||||
an eoOneMaxInit object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399">};</font></tt></b>
|
||||
<p><b><tt><font color="#993399">#endif</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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: Fri May
|
||||
3 06:17:21 2002<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
168
eo/tutorial/html/eoOneMaxMutation.html
Normal file
168
eo/tutorial/html/eoOneMaxMutation.html
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<!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="cpp2html Marc Schoenauer">
|
||||
<title>eoOneMaxMutation.h</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
<a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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">eoOneMaxMutation.h</font></h1></center>
|
||||
The places where you have to put some code are on pink background.
|
||||
Only the the <a href="eoTutorial.html#colors">character colors have the usual meaning</a>.
|
||||
<br>
|
||||
<A NAME="start"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE><tt><font color="#993300">
|
||||
<b>/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-</b><br>
|
||||
<b>The above line is useful in Emacs-like editors</b><br>
|
||||
<b> */</b><br>
|
||||
<b>/*</b><br>
|
||||
<b>Template for simple mutation operators</b><br>
|
||||
<b>======================================</b><br>
|
||||
<b>*/</b><br>
|
||||
<b>#ifndef eoOneMaxMutation_H</b><br>
|
||||
<b>#define eoOneMaxMutation_H</b><br>
|
||||
<b>#include <eoOp.h></b><br>
|
||||
<b>/** </b><br>
|
||||
<b> * Always write a comment in this format before class definition</b><br>
|
||||
<b> * if you want the class to be documented by Doxygen</b><br>
|
||||
<b> *</b><br>
|
||||
<b> * THere is NO ASSUMPTION on the class GenoypeT.</b><br>
|
||||
<b> * In particular, it does not need to derive from EO</b><br>
|
||||
<b> */</b><br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="mutation"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#993399">
|
||||
<b>template<class GenotypeT> </b><br>
|
||||
<b>class eoOneMaxMutation: public eoMonOp<GenotypeT></b><br>
|
||||
<b>{</b><br>
|
||||
<b>public:</b><br>
|
||||
<b> /**</b><br>
|
||||
<b> * Ctor - no requirement</b><br>
|
||||
<b> */</b><br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#993399">
|
||||
// START eventually add or modify the anyVariable argument<br>
|
||||
<b> eoOneMaxMutation()</b><br>
|
||||
<b> </b>// eoOneMaxMutation( varType _anyVariable) : anyVariable(_anyVariable) <br>
|
||||
// END eventually add or modify the anyVariable argument<br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#993399">
|
||||
<b> {</b><br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#993399">
|
||||
<b> </b>// START Code of Ctor of an eoOneMaxEvalFunc object<br>
|
||||
<b> </b>// END Code of Ctor of an eoOneMaxEvalFunc object<br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#993399">
|
||||
<b> }</b><br>
|
||||
<b> </b>/// The class name. Used to display statistics<br>
|
||||
<b> string className() const { return "eoOneMaxMutation"; }</b><br>
|
||||
<b> /**</b><br>
|
||||
<b> * modifies the parent</b><br>
|
||||
<b> * @param _genotype The parent genotype (will be modified)</b><br>
|
||||
<b> */</b><br>
|
||||
<b> bool operator()(GenotypeT & _genotype) </b><br>
|
||||
<b> {</b><br>
|
||||
<b> bool isModified;</b><br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#993399">
|
||||
<b> </b>// START code for mutation of the _genotype object<br>
|
||||
<b> /** Requirement</b><br>
|
||||
<b>* if (_genotype has been modified)</b><br>
|
||||
<b>* isModified = true;</b><br>
|
||||
<b>* else</b><br>
|
||||
<b>* isModified = false;</b><br>
|
||||
<b>*/</b><br>
|
||||
<b> return isModified;</b><br>
|
||||
<b> </b>// END code for mutation of the _genotype object<br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#993399">
|
||||
<b> }</b><br>
|
||||
<b>private:</b><br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#993399">
|
||||
// START Private data of an eoOneMaxMutation object<br>
|
||||
<b> </b>// varType anyVariable; // for example ...<br>
|
||||
// END Private data of an eoOneMaxMutation object<br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#993399">
|
||||
<b>};</b><br>
|
||||
<b>#endif</b><br>
|
||||
</font></font></font></td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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: Wed May 1 07:18:00 2002
|
||||
<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
168
eo/tutorial/html/eoOneMaxQuadCrossover.html
Normal file
168
eo/tutorial/html/eoOneMaxQuadCrossover.html
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<!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.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
|
||||
<title>Templates/eoOneMaxQuadCrossover.h</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
<a href="eoLesson5.html">Back to Lesson
|
||||
5</a> - <a href="eoTutorial.html">Tutorial main page </a>- <a href="eoTopDown.html">Top-Down
|
||||
page</a> - <a href="eoBottomUp.html">Bottom-up 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">Templates/eoOneMaxQuadCrossover.h</font></h1></center>
|
||||
The places where you have to put some code are on <b><font color="#FF6666">pink
|
||||
background</font></b>.. Only the the <a href="eoTutorial.html#colors">character
|
||||
colors have the usual meaning</a>.
|
||||
<br><a NAME="start"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE><tt><font color="#993300">/** -*- mode: c++; c-indent-level:
|
||||
4; c++-member-init-indent: 8; comment-column: 35; -*-</font></tt>
|
||||
<br><tt><font color="#993300">The above line is usefulin Emacs-like editors</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<br><tt><font color="#993300">/*</font></tt>
|
||||
<br><tt><font color="#993300">Template for simple quadratic crossover operators</font></tt>
|
||||
<br><tt><font color="#993300">=================================================</font></tt>
|
||||
<br><tt><font color="#993300">Quadratic crossover operators modify the
|
||||
both genotypes</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<p><b><tt><font color="#993300">#ifndef eoOneMaxQuadCrossover_H</font></tt></b>
|
||||
<br><b><tt><font color="#993300">#define eoOneMaxQuadCrossover_H</font></tt></b>
|
||||
<p><b><tt><font color="#993300">#include <eoOp.h></font></tt></b>
|
||||
<p><tt><font color="#993300">/** </font></tt>
|
||||
<br><tt><font color="#993300">* Always write a comment in this format
|
||||
before class definition</font></tt>
|
||||
<br><tt><font color="#993300">* if you want the class to be documented
|
||||
by Doxygen</font></tt>
|
||||
<br><tt><font color="#993300">*</font></tt>
|
||||
<br><tt><font color="#993300">* THere is NO ASSUMPTION on the class GenoypeT.</font></tt>
|
||||
<br><tt><font color="#993300">* In particular, it does not need to derive
|
||||
from EO</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="crossover"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399">template<class GenotypeT> </font></tt></b>
|
||||
<br><b><tt><font color="#993399">class eoOneMaxQuadCrossover: public eoQuadOp<GenotypeT></font></tt></b>
|
||||
<br><b><tt><font color="#993399">{</font></tt></b>
|
||||
<br><b><tt><font color="#993399">public:</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> /**</font></tt>
|
||||
<br><tt><font color="#993399"> * Ctor - no requirement</font></tt>
|
||||
<br><tt><font color="#993399"> */</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="constructor"></a><tt><font color="#993399">// START eventually
|
||||
add or modify the anyVariable argument</font></tt>
|
||||
<br><b><tt><font color="#993399"> eoOneMaxQuadCrossover()</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> // eoOneMaxQuadCrossover(
|
||||
varType _anyVariable) : anyVariable(_anyVariable) </font></tt>
|
||||
<br><tt><font color="#993399">// END eventually add or modify the anyVariable
|
||||
argument</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399"> {</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#993399"><b> </b> //
|
||||
START Code of Ctor of an eoOneMaxEvalFunc object</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
END Code of Ctor of an eoOneMaxEvalFunc object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399"> }</font></tt></b>
|
||||
<p><tt><font color="#993399"><b> </b> /// The class name. Used to
|
||||
display statistics</font></tt>
|
||||
<br><b><tt><font color="#993399"> string className() const { return
|
||||
"eoOneMaxQuadCrossover"; }</font></tt></b>
|
||||
<p><tt><font color="#993399"><b> </b> /**</font></tt>
|
||||
<br><tt><font color="#993399"> * eoQuad crossover - modifies
|
||||
both parents</font></tt>
|
||||
<br><tt><font color="#993399"> * @param _genotype1 The first
|
||||
parent</font></tt>
|
||||
<br><tt><font color="#993399"> * @param _genotype2 The second
|
||||
parent</font></tt>
|
||||
<br><tt><font color="#993399"> */</font></tt>
|
||||
<br><b><tt><font color="#993399"> bool operator()(GenotypeT& _genotype1,
|
||||
GenotypeT & _genotype2) </font></tt></b>
|
||||
<br><b><tt><font color="#993399"> {</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> bool oneAtLeastIsModified;</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="operator"></a><tt><font color="#993399"><b> </b>
|
||||
// START code for crossover of _genotype1 and _genotype2 objects</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b>
|
||||
/** Requirement</font></tt>
|
||||
<br><tt><font color="#993399">* if (at least one genotype has been modified)
|
||||
// no way to distinguish</font></tt>
|
||||
<br><tt><font color="#993399">*
|
||||
oneAtLeastIsModified = true;</font></tt>
|
||||
<br><tt><font color="#993399">* else</font></tt>
|
||||
<br><tt><font color="#993399">*
|
||||
oneAtLeastIsModified = false;</font></tt>
|
||||
<br><tt><font color="#993399">*/</font></tt>
|
||||
<br><b><tt><font color="#993399"> return oneAtLeastIsModified;</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
END code for crossover of _genotype1 and _genotype2 objects</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399"> }</font></tt></b>
|
||||
<p><b><tt><font color="#993399">private:</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="data"></a><tt><font color="#993399">// START Private data
|
||||
of an eoOneMaxQuadCrossover object</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // varType anyVariable;
|
||||
// for example ...</font></tt>
|
||||
<br><tt><font color="#993399">// END Private data of
|
||||
an eoOneMaxQuadCrossover object</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399">};</font></tt></b>
|
||||
<p><b><tt><font color="#993399">#endif</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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: Fri May
|
||||
3 07:47:13 2002<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
192
eo/tutorial/html/eoOneMax_complete.html
Normal file
192
eo/tutorial/html/eoOneMax_complete.html
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
<!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.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
|
||||
<title>Templates/eoOneMax_complete.h</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
<a href="eoLesson5.html">Back to Lesson 5</a>
|
||||
- <a href="eoTutorial.html">Tutorial main page </a>- <a href="eoTopDown.html">Top-Down
|
||||
page</a> - <a href="eoBottomUp.html">Bottom-up 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">Templates/eoOneMax_complete.h</font></h1></center>
|
||||
The user-defined code is on <b><font color="#FF6666">pink background</font></b>..
|
||||
Only the the <a href="eoTutorial.html#colors">character colors have the
|
||||
usual meaning</a>.
|
||||
<p><a NAME="start"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE><tt><font color="#993300">/** -*- mode: c++; c-indent-level:
|
||||
4; c++-member-init-indent: 8; comment-column: 35; -*-</font></tt>
|
||||
<br><tt><font color="#993300">The above line is usefulin Emacs-like editors</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<p><tt><font color="#993300">/*</font></tt>
|
||||
<br><tt><font color="#993300">Template for creating a new representation
|
||||
in EO</font></tt>
|
||||
<br><tt><font color="#993300">================================================</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<p><b><tt><font color="#993300">#ifndef _eoOneMax_h</font></tt></b>
|
||||
<br><b><tt><font color="#993300">#define _eoOneMax_h</font></tt></b>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#000000">/** </font></tt>
|
||||
<br><tt><font color="#000000">* A simple example class for bitstring (is
|
||||
NOT supposed to be used :-)</font></tt>
|
||||
<br><tt><font color="#000000">*/</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="representation"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900">template< class FitT></font></tt></b>
|
||||
<br><b><tt><font color="#999900">class eoOneMax: public EO<FitT> {</font></tt></b>
|
||||
<br><b><tt><font color="#999900">public:</font></tt></b>
|
||||
<br><tt><font color="#999900"><b> </b> /** Deafult Ctor: nothing to
|
||||
be done */</font></tt>
|
||||
<br><b><tt><font color="#999900"> eoOneMax() {}</font></tt></b>
|
||||
<p><b><tt><font color="#999900"> virtual string className() const
|
||||
{ return "eoOneMax"; }</font></tt></b>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="output"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#3366FF"><b> </b> /** printing... */</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> void printOn(ostream&
|
||||
_os) const</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> {</font></tt></b>
|
||||
<br><tt><font color="#3366FF"><b> </b>
|
||||
// First write the fitness</font></tt>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
EO<FitT>::printOn(_os);</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
_os << ' ';</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF">
|
||||
_os << b.size() << ' ' ;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
for (unsigned i=0; i<b.size(); i++)</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
_os << b[i] << ' ' ;</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF"> }</font></tt></b>
|
||||
<p><tt><font color="#3366FF"><b> </b> /** reading... </font></tt>
|
||||
<br><tt><font color="#3366FF"> * of course, your readFrom must
|
||||
be able to read what printOn writes!!!</font></tt>
|
||||
<br><tt><font color="#3366FF"> */</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> void readFrom(istream& _is)</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> {</font></tt></b>
|
||||
<br><tt><font color="#3366FF"><b> </b> //
|
||||
of course you should read the fitness first!</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> EO<FitT>::readFrom(_is);</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF"> unsigned s;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> _is >> s;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> b.resize(s);</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> for (unsigned
|
||||
i=0; i<s; i++)</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
{</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
bool bTmp;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
_is >> bTmp;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
b[i] = bTmp;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
} </font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF"> }</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="representation"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#999900"><b> </b> // brute setting (we could
|
||||
also have defined a Ctor from a vector<bool>)</font></tt>
|
||||
<br><b><tt><font color="#999900"> void setB(vector<bool> &
|
||||
_b)</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> {</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> b=_b;</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> }</font></tt></b>
|
||||
<p><tt><font color="#999900"><b> </b> // brute accessing (we could
|
||||
also define operator[] ...)</font></tt>
|
||||
<br><b><tt><font color="#999900"> const vector<bool> & B()</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> {</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> return b;</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> }</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<br><tt><font color="#999900"><b>private: </b> //
|
||||
put all data here</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900"> std::vector<bool> b;</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900">};</font></tt></b>
|
||||
<p><b><tt><font color="#999900">#endif</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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: Sat May
|
||||
4 06:02:46 2002<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<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]">
|
||||
<meta name="GENERATOR" content="Mozilla/4.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
|
||||
<title>EO - The Algorithm-Based approach</title>
|
||||
</head>
|
||||
<body text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000" background="beige009.jpg">
|
||||
|
|
@ -26,9 +26,9 @@ of "lessons" for you.
|
|||
<li>
|
||||
<a href="eoLesson1.html">Lesson 1 </a>- a gentle introduction to the <font color="#FF6600">EO
|
||||
way</font>: your first steps into <b><font color="#999900">EO representations</font></b>
|
||||
using a simple generational GA. Please, <b><blink><font color="#FF0000">spend
|
||||
the necessary time</font></blink></b> on that one, since all basic constructs
|
||||
presented there are used throughout EO.</li>
|
||||
using a simple generational GA. Please, <b><font color="#FF0000">spend
|
||||
the necessary time</font></b> on that one, since all basic constructs presented
|
||||
there are used throughout EO.</li>
|
||||
|
||||
<li>
|
||||
<a href="eoLesson2.html">Lesson 2</a> - <font color="#FF6600">encapsulate</font>,
|
||||
|
|
@ -48,48 +48,51 @@ populations,
|
|||
...).</li>
|
||||
|
||||
<li>
|
||||
<a href="eoLesson3.html">Lesson 4 </a>- The same algorithms - again! - but now fully operational:
|
||||
<font color="#FF6600">every component</font> of the algorithm can be defined
|
||||
<font color="#FF6600">on the command-line</font>, except the type of genotype;
|
||||
moreover, you now have a full library, i.e. everything except your fitness function is
|
||||
<font color="#FF6600">already compiled.</font>
|
||||
</li>
|
||||
<a href="eoLesson3.html">Lesson 4 </a>- The same algorithms - again! -
|
||||
but now fully operational: <font color="#FF6600">every component</font>
|
||||
of the algorithm can be defined <font color="#FF6600">on the command-line</font>,
|
||||
except the type of genotype; moreover, you now have a full library, i.e.
|
||||
everything except your fitness function is <font color="#FF6600">already
|
||||
compiled.</font></li>
|
||||
|
||||
<p><br>Current version (May. 5, 2001) stops here, but ...
|
||||
<li>
|
||||
<a href="eoLesson5.html">Lesson 5</a> <b><blink><font color="#FF6600">(new)</font></blink></b>
|
||||
- Use your own <b><font color="#999900">representation</font></b>. Thanks
|
||||
to <font color="#FF6600">template files and a little script</font> in Unix,
|
||||
or the <font color="#FF6600">Application template</font> in MSVC++, you
|
||||
can easily define a new genotype and run an Evolutionary Algorithm that
|
||||
will intantly benefit from the power of <b><font color="#009900">all EO
|
||||
Evolution Engines</font></b> (including <b><font color="#3366FF">easy user-parameter
|
||||
input </font></b>presented in Lesson 4). You simply need to gradually fill
|
||||
in the shell-files that the script will generate for you.</li>
|
||||
</ul>
|
||||
<br>Current version (May. 5, 2002) stops here, but ...
|
||||
<p>From there on, you don't need to follow the lesson order any more: you
|
||||
can go directly to any lesson and experiment. Of course, you will need
|
||||
to bring together the different pieces to write exactly what you want -
|
||||
but only because we had no idea of what you exactly want :-)
|
||||
<br>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Lesson 4 - More <b><font color="#CC33CC">general operators</font></b>:
|
||||
e.g. binary, n-ary, or even specific mate selection (your brain and my
|
||||
beauty)! Add your own to the basic algorithm using the template files.</li>
|
||||
|
||||
<li>
|
||||
Lesson 5 - More about <b><font color="#3366FF">checkpointing</font></b>:
|
||||
Lesson 6 (forthcoming) - More about <b><font color="#3366FF">checkpointing</font></b>:
|
||||
write your first <b><font color="#FF6600">adaptive mechanism</font></b>,
|
||||
and find out how easy it is to <b><font color="#3366FF">update</font></b>
|
||||
and <b><font color="#3366FF">monitor </font><font color="#FF6600">dynamic
|
||||
parameters</font></b></li>
|
||||
|
||||
<li>
|
||||
Lesson 6 - Why not go <b><font color="#993300">parallel</font></b>? From
|
||||
the simple asynchronous SSGA to the more sophisticated island model (no
|
||||
totally distributed population yet).</li>
|
||||
Lesson 7 - More <b><font color="#CC33CC">general operators</font></b>:
|
||||
e.g. binary, n-ary, or even specific mate selection (your brain and my
|
||||
beauty)! Add your own to the basic algorithm using the template files.</li>
|
||||
|
||||
<li>
|
||||
Lesson 7 - Use your own <b><font color="#999900">representation</font></b>.
|
||||
You need only to write the base individual class, the initilization class
|
||||
and the variation operators. EO provides many helps: The <b><font color="#999900">eoExternal</font></b>
|
||||
paradigm let you encapsulate into EO classes existing code. And the <b><font color="#999900">eoFixedLength</font></b>
|
||||
and <b><font color="#999900">eoVariableLength</font></b> super classes
|
||||
allow quick definition of new genotypes that handle identical Atoms.</li>
|
||||
Lesson 7 - Use predefined generic <b><font color="#999900">representations</font></b>.
|
||||
The <b><font color="#999900">eoFixedLength</font></b> and <b><font color="#999900">eoVariableLength</font></b>
|
||||
super classes allow quick definition of new genotypes that handle identical
|
||||
Atoms, together with generic variation operators.</li>
|
||||
</ul>
|
||||
Of course, in each lesson, you have links to the corresponding Component-Based
|
||||
page. ( ... Well, to tell you the truth, as of today, Jan. 5, 2001, this
|
||||
is not exactly true :-)
|
||||
page. ( ... Well, to tell you the truth, as of today, this is not exactly
|
||||
true :-)
|
||||
<br>
|
||||
<hr WIDTH="100%">
|
||||
<br><a href="eoTutorial.html">Tutorial main page </a>- <a href="eoTopDown.html">Algorithm-Based</a>
|
||||
|
|
|
|||
160
eo/tutorial/html/make_genotype_OneMax.html
Normal file
160
eo/tutorial/html/make_genotype_OneMax.html
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
<!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="cpp2html Marc Schoenauer">
|
||||
<title>Templates/make_genotype_OneMax.h</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
<a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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">Templates/make_genotype_OneMax.h</font></h1></center>
|
||||
The places where you have to put some code are on <b><font color="#FF6666">pink
|
||||
background</font></b>..
|
||||
Only the the <a href="eoTutorial.html#colors">character colors have the usual meaning</a>.
|
||||
<br>
|
||||
<A NAME="start"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE><tt><font color="#993300">
|
||||
<b></b>
|
||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-<br>
|
||||
<b></b>
|
||||
//-----------------------------------------------------------------------------<br>
|
||||
<b></b>
|
||||
// make_genotype.h<br>
|
||||
<b></b>
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001<br>
|
||||
<b></b>
|
||||
/* <br>
|
||||
This library is free software; you can redistribute it and/or<br>
|
||||
modify it under the terms of the GNU Lesser General Public<br>
|
||||
License as published by the Free Software Foundation; either<br>
|
||||
version 2 of the License, or (at your option) any later version.<br>
|
||||
This library is distributed in the hope that it will be useful,<br>
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br>
|
||||
Lesser General Public License for more details.<br>
|
||||
You should have received a copy of the GNU Lesser General Public<br>
|
||||
License along with this library; if not, write to the Free Software<br>
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br>
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es<br>
|
||||
Marc.Schoenauer@inria.fr<br>
|
||||
mkeijzer@dhi.dk<br>
|
||||
*/<br>
|
||||
<b></b>
|
||||
//-----------------------------------------------------------------------------<br>
|
||||
<b>#ifndef _make_genotype_h</b><br>
|
||||
<b>#define _make_genotype_h</b><br>
|
||||
<b>#include <eoOneMax.h></b><br>
|
||||
<b>#include <eoOneMaxInit.h></b><br>
|
||||
<b> </b>
|
||||
// also need the parser and param includes<br>
|
||||
<b>#include <utils/eoParser.h></b><br>
|
||||
<b>#include <utils/eoState.h></b><br>
|
||||
<b></b>
|
||||
/*<br>
|
||||
* This fuction does the create an eoInit<eoOneMax><br>
|
||||
*<br>
|
||||
* It could be here tempatized only on the fitness, as it can be used <br>
|
||||
* to evolve structures with any fitness.<br>
|
||||
* However, for consistency reasons, it was finally chosen, as in <br>
|
||||
* the rest of EO, to templatize by the full EOT, as this eventually <br>
|
||||
* allows to choose the type of genotype at run time (see in es dir)<br>
|
||||
*<br>
|
||||
* It returns an eoInit<EOT> that can later be used to initialize <br>
|
||||
* the population (see make_pop.h).<br>
|
||||
*<br>
|
||||
* It uses a parser (to get user parameters) and a state (to store the memory)<br>
|
||||
* the last argument is to disambiguate the call upon different instanciations.<br>
|
||||
*<br>
|
||||
* WARNING: that last argument will generally be the result of calling <br>
|
||||
* the default ctor of EOT, resulting in most cases in an EOT <br>
|
||||
* that is ***not properly initialized***<br>
|
||||
*/<br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="representation"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#999900">
|
||||
<b>template <class EOT></b><br>
|
||||
<b>eoInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT)</b><br>
|
||||
<b>{</b><br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#999900">
|
||||
<b> </b>
|
||||
// read any useful parameter here from the parser <br>
|
||||
<b> </b>
|
||||
// the param itself will belong to the parser (as far as memory is concerned)<br>
|
||||
<b> </b>
|
||||
// paramType & param = _parser.createParam(deafultValue, "Keyword", "Comment to appear in help and status", 'c',"Section of status file").value();<br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#999900">
|
||||
<b> </b>
|
||||
// Then built the initializer - a pointer, stored in the eoState<br>
|
||||
<b> eoInit<EOT>* init = new eoOneMaxInit<EOT> </b>
|
||||
/* ( param ) */ ;<b> ;</b><br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#999900">
|
||||
<b> </b>
|
||||
// Eventually by passing the parameters you need<br>
|
||||
<b> // eoInit<EOT>* init = new eoOneMaxInit<EOT> </b>
|
||||
/* ( param ) */ ;<b> ;</b><br>
|
||||
</font></tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<tt><font color="#999900">
|
||||
<b> </b>
|
||||
// store in state<br>
|
||||
<b> _state.storeFunctor(init);</b><br>
|
||||
<b> </b>
|
||||
// and return a reference<br>
|
||||
<b> return *init;</b><br>
|
||||
<b>}</b><br>
|
||||
<b>#endif</b><br>
|
||||
</font></font></font></td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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: Fri May 3 07:10:52 2002
|
||||
<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
351
eo/tutorial/html/make_op_OneMax.html
Normal file
351
eo/tutorial/html/make_op_OneMax.html
Normal file
|
|
@ -0,0 +1,351 @@
|
|||
<!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.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
|
||||
<title>Templates/make_op_OneMax.h</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
<a href="eoLesson5.html">Back to Lesson 5</a>
|
||||
- <a href="eoTutorial.html">Tutorial main page </a>- <a href="eoTopDown.html">Top-Down
|
||||
page</a> - <a href="eoBottomUp.html">Bottom-up 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">Templates/make_op_OneMax.h</font></h1></center>
|
||||
The places where you have to put some code are on <b><font color="#FF6666">pink
|
||||
background</font></b>.. Only the the <a href="eoTutorial.html#colors">character
|
||||
colors have the usual meaning</a>.
|
||||
<p><a NAME="start"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr NOSAVE>
|
||||
<td NOSAVE><tt><font color="#993300">// -*- mode: c++; c-indent-level:
|
||||
4; c++-member-init-indent: 8; comment-column: 35; -*-</font></tt>
|
||||
<p><tt><font color="#993300">//-----------------------------------------------------------------------------</font></tt>
|
||||
<br><tt><font color="#993300">// make_op_OneMax.h</font></tt>
|
||||
<br><tt><font color="#993300">// (c) Marc Schoenauer, Maarten Keijzer and
|
||||
GeNeura Team, 2001</font></tt>
|
||||
<br><tt><font color="#993300">/* </font></tt>
|
||||
<br><tt><font color="#993300"> This library is
|
||||
free software; you can redistribute it and/or</font></tt>
|
||||
<br><tt><font color="#993300"> modify it under
|
||||
the terms of the GNU Lesser General Public</font></tt>
|
||||
<br><tt><font color="#993300"> License as published
|
||||
by the Free Software Foundation; either</font></tt>
|
||||
<br><tt><font color="#993300"> version 2 of the
|
||||
License, or (at your option) any later version.</font></tt>
|
||||
<br><tt><font color="#993300"> This library is
|
||||
distributed in the hope that it will be useful,</font></tt>
|
||||
<br><tt><font color="#993300"> but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of</font></tt>
|
||||
<br><tt><font color="#993300"> MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font></tt>
|
||||
<br><tt><font color="#993300"> Lesser General Public
|
||||
License for more details.</font></tt>
|
||||
<br><tt><font color="#993300"> You should have
|
||||
received a copy of the GNU Lesser General Public</font></tt>
|
||||
<br><tt><font color="#993300"> License along with
|
||||
this library; if not, write to the Free Software</font></tt>
|
||||
<br><tt><font color="#993300"> Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</font></tt>
|
||||
<br><tt><font color="#993300"> Contact: todos@geneura.ugr.es,
|
||||
http://geneura.ugr.es</font></tt>
|
||||
<br><tt><font color="#993300">
|
||||
Marc.Schoenauer@inria.fr</font></tt>
|
||||
<br><tt><font color="#993300">
|
||||
mkeijzer@dhi.dk</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<br><tt><font color="#993300">//-----------------------------------------------------------------------------</font></tt>
|
||||
<p><b><tt><font color="#993300">#ifndef _make_op_OneMax_h</font></tt></b>
|
||||
<br><b><tt><font color="#993300">#define _make_op_OneMax_h</font></tt></b>
|
||||
<p><tt><font color="#993300">// the operators</font></tt>
|
||||
<br><b><tt><font color="#993300">#include <eoOp.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <eoGenOp.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <eoCloneOps.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <eoOpContainer.h></font></tt></b>
|
||||
<br><tt><font color="#993300">// combinations of simple eoOps (eoMonOp
|
||||
and eoQuadOp)</font></tt>
|
||||
<br><b><tt><font color="#993300">#include <eoProportionalCombinedOp.h></font></tt></b>
|
||||
<p><tt><font color="#993300">/** definition of mutation: </font></tt>
|
||||
<br><tt><font color="#993300">* class eoOneMaxMonop MUST derive from eoMonOp<eoOneMax></font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<br><b><tt><font color="#993300">#include "eoOneMaxMutation.h"</font></tt></b>
|
||||
<p><tt><font color="#993300">/** definition of crossover (either as eoBinOp
|
||||
(2->1) or eoQuadOp (2->2): </font></tt>
|
||||
<br><tt><font color="#993300">* class eoOneMaxBinCrossover MUST derive
|
||||
from eoBinOp<eoOneMax></font></tt>
|
||||
<br><tt><font color="#993300">* OR </font></tt>
|
||||
<br><tt><font color="#993300">* class eoOneMaxQuadCrossover MUST derive
|
||||
from eoQuadOp<eoOneMax></font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<br><tt><font color="#993300">// #include "eoOneMaxBinOp.h"</font></tt>
|
||||
<br><tt><font color="#993300">// OR</font></tt>
|
||||
<br><b><tt><font color="#993300">#include "eoOneMaxQuadCrossover.h"</font></tt></b>
|
||||
<p><tt><font color="#993300"><b> </b> // also need the parser and
|
||||
state includes</font></tt>
|
||||
<br><b><tt><font color="#993300">#include <utils/eoParser.h></font></tt></b>
|
||||
<br><b><tt><font color="#993300">#include <utils/eoState.h></font></tt></b>
|
||||
<p><tt><font color="#993300">/////////////////// variation operators ///////////////</font></tt>
|
||||
<br><tt><font color="#993300">// canonical (crossover + mutation) only
|
||||
at the moment //</font></tt>
|
||||
<p><tt><font color="#993300">/*</font></tt>
|
||||
<br><tt><font color="#993300">* This function builds the operators that
|
||||
will be applied to the eoOneMax</font></tt>
|
||||
<br><tt><font color="#993300">*</font></tt>
|
||||
<br><tt><font color="#993300">* It uses a parser (to get user parameters),
|
||||
a state (to store the memory)</font></tt>
|
||||
<br><tt><font color="#993300">* the last
|
||||
parameter is an eoInit: if some operator needs some info </font></tt>
|
||||
<br><tt><font color="#993300">* about the
|
||||
genotypes, the init has it all (e.g. bounds, ...)</font></tt>
|
||||
<br><tt><font color="#993300">* Simply do </font></tt>
|
||||
<br><tt><font color="#993300">*
|
||||
EOT myEO;</font></tt>
|
||||
<br><tt><font color="#993300">*
|
||||
_init(myEO);</font></tt>
|
||||
<br><tt><font color="#993300">* and myEO
|
||||
is then an ACTUAL object</font></tt>
|
||||
<br><tt><font color="#993300">*</font></tt>
|
||||
<br><tt><font color="#993300">* As usual, the template is the complete
|
||||
EOT even though only the fitness</font></tt>
|
||||
<br><tt><font color="#993300">* is actually templatized here: the following
|
||||
only applies to eoOneMax</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="operators"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#993399">template <class EOT></font></tt></b>
|
||||
<br><b><tt><font color="#993399">eoGenOp<EOT> & do_make_op(eoParameterLoader&
|
||||
_parser, eoState& _state, eoInit<EOT>& _init)</font></tt></b>
|
||||
<br><b><tt><font color="#993399">{</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> // this is a temporary version,
|
||||
while Maarten codes the full tree-structured</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // general operator input</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // BTW we must leave that simple
|
||||
version available somehow, as it is the one</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // that 90% people use!</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> /////////////////////////////</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
Variation operators</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> ////////////////////////////</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
read crossover and mutations, combine each in a proportional Op</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
and create the eoGenOp that calls crossover at rate pCross </font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
then mutation with rate pMut</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // the
|
||||
crossovers</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> /////////////////</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // here
|
||||
we can have eoQuadOp (2->2) only - no time for the eoBinOp case</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // you
|
||||
can have more than one - combined in a proportional way</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // first,
|
||||
define the crossover objects and read their rates from the parser</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // A
|
||||
first crossover </font></tt>
|
||||
<br><a NAME="cross_ctor"></a><tt><font color="#993399"><b>
|
||||
eoQuadOp<Indi> *cross = new eoOneMaxQuadCrossover<Indi> </b>/* </font><font color="#FF6666">(varType
|
||||
_anyVariable)</font><font color="#993399"> */;</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
store in the state</font></tt>
|
||||
<br><b><tt><font color="#993399"> _state.storeFunctor(cross);</font></tt></b>
|
||||
<p><tt><font color="#993399"><b> </b> // read its relative rate in
|
||||
the combination</font></tt>
|
||||
<br><b><tt><font color="#993399"> double cross1Rate
|
||||
= _parser.createParam(1.0, "cross1Rate", "Relative rate for crossover 1",
|
||||
'1', "Variation Operators").value();</font></tt></b>
|
||||
<p><tt><font color="#993399"><b> </b> // and create the combined operator
|
||||
with this one</font></tt>
|
||||
<br><b><tt><font color="#993399"> eoPropCombinedQuadOp<Indi> *propXover
|
||||
= </font></tt></b>
|
||||
<br><b><tt><font color="#993399"> new eoPropCombinedQuadOp<Indi>(*cross,
|
||||
cross1Rate);</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> // and of course stor it in
|
||||
the state</font></tt>
|
||||
<br><b><tt><font color="#993399"> _state.storeFunctor(propXover);</font></tt></b>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="crossover"></a><tt><font color="#993399"><b> </b>
|
||||
// Optional: A second(and third, and ...) crossover </font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
of course you must create the corresponding classes</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
and all ***MUST*** derive from eoQuadOp<Indi></font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> /* Uncomment if necessary -
|
||||
and replicate as many time as you need</font></tt>
|
||||
<br><tt><font color="#993399">
|
||||
cross = new eoOneMaxSecondCrossover<Indi>(varType _anyVariable); </font></tt>
|
||||
<br><tt><font color="#993399">
|
||||
_state.storeFunctor(cross);</font></tt>
|
||||
<br><tt><font color="#993399">
|
||||
double cross2Rate = _parser.createParam(1.0, "cross2Rate", "Relative rate
|
||||
for crossover 2", '2', "Variation Operators").value(); </font></tt>
|
||||
<br><tt><font color="#993399">
|
||||
propXover.add(*cross, cross2Rate); </font></tt>
|
||||
<br><tt><font color="#993399"> */</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // if you want some gentle
|
||||
output, the last one shoudl be like</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // propXover.add(*cross,
|
||||
crossXXXRate, true);</font></tt>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<br><tt><font color="#993399"><b> </b> // the mutation: same story</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> ////////////////</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // you can have more than one
|
||||
- combined in a proportional way</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // for each mutation, </font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // - define the mutator object</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // - read its rate from the
|
||||
parser</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // - add it to the proportional
|
||||
combination</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // a first mutation </font></tt>
|
||||
<br><a NAME="mut_ctor"></a><tt><font color="#993399"><b>eoMonOp<Indi>
|
||||
*mut = new eoOneMaxMutation<Indi></b> /* </font><font color="#FF6666">(varType
|
||||
_anyVariable)</font><font color="#993399"> */;</font></tt>
|
||||
<br><b><tt><font color="#993399"> _state.storeFunctor(mut);</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> // its relative rate in the
|
||||
combination</font></tt>
|
||||
<br><b><tt><font color="#993399"> double mut1Rate = _parser.createParam(1.0,
|
||||
"mut1Rate", "Relative rate for mutation 1", '1', "Variation Operators").value();</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> // and the creation of the
|
||||
combined operator with this one</font></tt>
|
||||
<br><b><tt><font color="#993399"> eoPropCombinedMonOp<Indi> *propMutation
|
||||
= new eoPropCombinedMonOp<Indi>(*mut, mut1Rate);</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> _state.storeFunctor(propMutation);</font></tt></b>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><a NAME="mutation"></a><tt><font color="#993399"><b> </b>
|
||||
// Optional: A second(and third, and ...) mutation with their rates</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
of course you must create the corresponding classes</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
and all ***MUST*** derive from eoMonOp<Indi></font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> /* Uncomment if necessary -
|
||||
and replicate as many time as you need</font></tt>
|
||||
<br><tt><font color="#993399">
|
||||
mut = new eoOneMaxSecondMutation<Indi>(varType _anyVariable);</font></tt>
|
||||
<br><tt><font color="#993399">
|
||||
_state.storeFunctor(mut);</font></tt>
|
||||
<br><tt><font color="#993399">
|
||||
double mut2Rate = _parser.createParam(1.0, "mut2Rate", "Relative rate for
|
||||
mutation 2", '2', "Variation Operators").value(); </font></tt>
|
||||
<br><tt><font color="#993399">
|
||||
propMutation.add(*mut, mut2Rate); </font></tt>
|
||||
<br><tt><font color="#993399"> */</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // if you want some gentle
|
||||
output, the last one shoudl be like</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // propMutation.add(*mut,
|
||||
mutXXXRate, true);</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // end of crossover and mutation
|
||||
definitions</font></tt>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<br><tt><font color="#993399">// from now on, you do not need to modify
|
||||
anything</font></tt>
|
||||
<br><tt><font color="#993399">// though you CAN add things to the checkpointing
|
||||
(see tutorial)</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // now build the eoGenOp:</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // to simulate SGA (crossover
|
||||
with proba pCross + mutation with proba pMut</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // we must construct</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
a sequential combination of</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
with proba 1, a proportional combination of </font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
a QuadCopy and our crossover</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
with proba pMut, our mutation</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // but of course you're free
|
||||
to use any smart combination you could think of</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // especially, if you have
|
||||
to use eoBinOp rather than eoQuad Op youùll have</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b> // to modify that part</font></tt>
|
||||
<p><a NAME="donottouch"></a><tt><font color="#993399"><b> </b> //
|
||||
First read the individual level parameters</font></tt>
|
||||
<br><b><tt><font color="#993399"> eoValueParam<double>&
|
||||
pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover",
|
||||
'C', "Variation Operators" );</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
minimum check</font></tt>
|
||||
<br><b><tt><font color="#993399"> if ( (pCrossParam.value()
|
||||
< 0) || (pCrossParam.value() > 1) )</font></tt></b>
|
||||
<br><b><tt><font color="#993399">
|
||||
throw runtime_error("Invalid pCross");</font></tt></b>
|
||||
<p><b><tt><font color="#993399"> eoValueParam<double>&
|
||||
pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation",
|
||||
'M', "Variation Operators" );</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b> //
|
||||
minimum check</font></tt>
|
||||
<br><b><tt><font color="#993399"> if ( (pMutParam.value()
|
||||
< 0) || (pMutParam.value() > 1) )</font></tt></b>
|
||||
<br><b><tt><font color="#993399">
|
||||
throw runtime_error("Invalid pMut");</font></tt></b>
|
||||
<p><tt><font color="#993399"><b> </b> // the crossover - with probability
|
||||
pCross</font></tt>
|
||||
<br><b><tt><font color="#993399"> eoProportionalOp<Indi> * propOp
|
||||
= new eoProportionalOp<Indi> ;</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> _state.storeFunctor(propOp);</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> eoQuadOp<Indi> *ptQuad = new
|
||||
eoQuadCloneOp<Indi>;</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> _state.storeFunctor(ptQuad);</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> propOp->add(*propXover, pCrossParam.value());
|
||||
</b>//
|
||||
crossover, with proba pcross</font></tt>
|
||||
<br><tt><font color="#993399"><b> propOp->add(*ptQuad, 1-pCrossParam.value());
|
||||
</b>//
|
||||
nothing, with proba 1-pcross</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // now the sequential</font></tt>
|
||||
<br><b><tt><font color="#993399"> eoSequentialOp<Indi> *op = new
|
||||
eoSequentialOp<Indi>;</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> _state.storeFunctor(op);</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> op->add(*propOp, 1.0); </b>// always
|
||||
do combined crossover</font></tt>
|
||||
<br><tt><font color="#993399"><b> op->add(*propMutation, pMutParam.value());
|
||||
</b>//
|
||||
then mutation, with proba pmut</font></tt>
|
||||
<p><tt><font color="#993399"><b> </b> // that's it - return a reference</font></tt>
|
||||
<br><b><tt><font color="#993399"> return *op;</font></tt></b>
|
||||
<br><b><tt><font color="#993399">}</font></tt></b>
|
||||
<p><b><tt><font color="#993399">#endif</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
|
||||
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
|
||||
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: Fri May
|
||||
3 08:06:20 2002<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue