paradiseo/eo/tutorial/html/eoLesson5.html
2012-08-30 11:30:11 +02:00

415 lines
25 KiB
HTML

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.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>
<b><blink><font color="#FF0000">New</font></blink></b> May 2004 : A
second script, <b><tt><font color="#993300">createSimple</font></tt></b>,
was added some time ago, that generates much simpler
set of files, and the <font color="#3366FF"><b>stat.tmpl</b></font>
file is now used to allow you to
<font color="#FF0000"><b>compute</b></font> and
<font color="#FF0000"><b>print</b></font> and
<font color="#FF0000"><b>save-to-disk</b></font> and
<font color="#FF0000"><b>plot-on-line</b></font> your
own <font color="#3366FF"><b>statistics</b></font>.
But you'll have to find out by yourself how those work, sorry, no
time. It should be easy by just looking at the code (in main file, and
in <b><tt><font color="#993300">OneMaxEA.cpp</font></tt></b>
and the newly created
<b><tt><font color="#993300">eoOneMaxStat.h</font></tt></b>.<br><br>
<b><blink><font color="#FF0000">New</font></blink></b> May 2004 : In
the same simplified main file (e.g. <b><tt><font
color="#993300">OneMaxEA.cpp</font></tt></b> after running
<b><tt><font color="#FF6666">./createsimple OneMax</font></tt></b> in
dir <b><tt><font
color="#FF6666"><b>.../eo/tutorial/Templates</b></font></tt></b>), you
will also be able to use fitness sharing (together with roulette) as a
possible selector.
<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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <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&nbsp; a directory name (suppose
it's called APPLICATION here)</li>
<br><b><tt><font color="#FF6666">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
./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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
cd ../APPLICATION</font></tt></b>
<br>You should see the following files:
<br>&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">OneMaxEA.cpp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>the main main file, includes all other, to be compiled
<br>&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">Makefile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>with default target eoOneMaxEA
<br>&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">eoOneMax.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>class eoOneMax, the genotype
<br>&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">eoOneMaxEvalFunc.h&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>class for the computation of fitness
<br>&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">eoOneMaxInit.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>class for genotype initlialization
<br>&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">eoOneMaxMutation.h&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>class for mutation
<br>&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">eoOneMaxQuadCrossover.h
</font></tt></b>class
for (quadratic) crossover
<br>&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">make_genotype_OneMax.h
</font></tt></b>helper function that create the initializer
<br>&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">make_op_OneMax.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>helper function that handles the rates of application of
the variation operators<br>
&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">OneMaxLibEA.cpp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>another main file, for separate compilation of representation-independent
stuff
<br>&nbsp;&nbsp;&nbsp; <b><tt><font color="#993300">make_OneMaxEA.cpp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>the source for the representation-independent stuff
<br>&nbsp;
<li>
Compile the whole application</li>
<br><b><tt><font color="#FF6666">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
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&nbsp; changes that you
will need are</li>
<br>&nbsp;&nbsp; in <b><tt><font color="#993300">eoOneMax.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>define your genotype
<br>&nbsp;&nbsp; in <b><tt><font color="#993300">eoOneMaxInit.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>define the initialization of one genotype
<br>&nbsp;&nbsp; in <b><tt><font color="#993300">eoOneMaxMutation.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></tt></b>define the mutation of one genotype
<br>&nbsp;&nbsp; in <b><tt><font color="#993300">eoOneMaxQuadCrossover.h&nbsp;
</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&nbsp; 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&nbsp;
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>.&nbsp;
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&nbsp; <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&nbsp; <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>&nbsp;
and change all names <b><tt><font color="#CC33CC">eoOneMaxQuadCrossover</font></tt></b>
to&nbsp; <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>.&nbsp; 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>&nbsp;
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
<tr>
<td><b><tt><font color="#009900">#include &lt;do/make_algo_scalar.h></font></tt></b>
<br><b><tt><font color="#009900">eoAlgo&lt;Indi>&amp;&nbsp; make_algo_scalar(eoParser&amp;
_parser, eoState&amp; _state, eoEvalFunc&lt;Indi>&amp; _eval, eoContinue&lt;Indi>&amp;
_continue, eoGenOp&lt;Indi>&amp; _op)</font></tt></b>
<br><b><tt><font color="#009900">{</font></tt></b>
<br><b><tt><font color="#009900">&nbsp;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>).&nbsp;
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>&nbsp; <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&nbsp; 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>