Added the continue.tmpl template - and modified the html pages accordingly

(though eoCheckPoint.html is still a long way to complete).
Added some comments in all template files - and replaced
the protected by private (don't remember why these were protected!!!).
This commit is contained in:
evomarc 2001-04-05 16:47:54 +00:00
commit f0813c55ca
10 changed files with 163 additions and 30 deletions

View file

@ -1,3 +1,8 @@
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
The above line is usefulin Emacs-like editors
*/
/* /*
Template for simple binary crossover operators Template for simple binary crossover operators
============================================== ==============================================
@ -11,6 +16,10 @@ based on the second
#include <eoOp.h> #include <eoOp.h>
/**
Always write a comment in this format before class definition
if you want the class to be documented by Doxygen
*/
template<class Indi> template<class Indi>
class eoMyDerivedBinOp: public eoBinOp<Indi> class eoMyDerivedBinOp: public eoBinOp<Indi>
{ {
@ -38,7 +47,7 @@ public:
// return false; // return false;
} }
protected: private:
paramType anyParameter paramType anyParameter
}; };

View file

@ -0,0 +1,46 @@
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
The above line is usefulin Emacs-like editors
*/
/*
Template for continuator in EO, i.e. stopping conditions for EO algorithms
==========================================================================
*/
#ifndef _eoMyContinue_h
#define _eoMyContinue_h
#include <eoMyContinue.h>
/**
Always write a comment in this format before class definition
if you want the class to be documented by Doxygen
*/
template< class EOT>
class eoMyContinue: public eoContinue<EOT> {
public:
/// Ctor
eoMyContinue( paramType _anyParameter) :
anyParameter(_anyParameter) {}
/** Returns false when you want to stop
*/
virtual bool operator() ( const eoPop<EOT>& _pop )
{
bool stopCondition = ... ; // compute the stopping condition
if (stopCondition) // the algo will stop upon return FALSE
{
cout << "STOP in eoMyContinue: blablabla \n";
return false;
}
return true; // == do not stop
}
private:
paramType anyParameter
};
#endif

View file

@ -1,3 +1,8 @@
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
The above line is usefulin Emacs-like editors
*/
/* /*
Template for general operators Template for general operators
=============================== ===============================
@ -13,6 +18,10 @@ Second version, get parents using an external eoSelectOne
#include <eoGenOp.h> #include <eoGenOp.h>
/**
Always write a comment in this format before class definition
if you want the class to be documented by Doxygen
*/
template<class Indi> template<class Indi>
class eoLessOffspringExternalSelectorGenOp: public eoGenOp<Indi> class eoLessOffspringExternalSelectorGenOp: public eoGenOp<Indi>
{ {
@ -61,7 +70,7 @@ public:
} }
protected: private:
eoSelectOne<EOT> & sel; eoSelectOne<EOT> & sel;
paramType anyParameter paramType anyParameter
}; };

View file

@ -1,3 +1,8 @@
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
The above line is usefulin Emacs-like editors
*/
/* /*
Template for general operators Template for general operators
=============================== ===============================
@ -13,6 +18,10 @@ First version, get parents from populator using the ibbedded select() method
#include <eoGenOp.h> #include <eoGenOp.h>
/**
Always write a comment in this format before class definition
if you want the class to be documented by Doxygen
*/
template<class Indi> template<class Indi>
class eoLessOffspringSameSelectorGenOp: public eoGenOp<Indi> class eoLessOffspringSameSelectorGenOp: public eoGenOp<Indi>
{ {
@ -57,7 +66,7 @@ public:
parentN.invalidate(); parentN.invalidate();
} }
protected: private:
paramType anyParameter paramType anyParameter
}; };

View file

@ -1,3 +1,8 @@
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
The above line is usefulin Emacs-like editors
*/
/* /*
Template for general operators Template for general operators
=============================== ===============================
@ -12,6 +17,10 @@ than there are parents
#include <eoGenOp.h> #include <eoGenOp.h>
/**
Always write a comment in this format before class definition
if you want the class to be documented by Doxygen
*/
template<class Indi> template<class Indi>
class eoMoreOffspringGenOp: public eoGenOp<Indi> class eoMoreOffspringGenOp: public eoGenOp<Indi>
{ {
@ -58,7 +67,7 @@ public:
} }
protected: private:
paramType anyParameter paramType anyParameter
}; };

View file

@ -1,3 +1,8 @@
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
The above line is usefulin Emacs-like editors
*/
/* /*
Template for simple mutation operators Template for simple mutation operators
====================================== ======================================
@ -9,6 +14,10 @@ Template for simple mutation operators
#include <eoOp.h> #include <eoOp.h>
/**
Always write a comment in this format before class definition
if you want the class to be documented by Doxygen
*/
template<class Indi> template<class Indi>
class eoMyDerivedMonOp: public eoMonOp<Indi> class eoMyDerivedMonOp: public eoMonOp<Indi>
{ {
@ -35,7 +44,7 @@ public:
// return false; // return false;
} }
protected: private:
paramType anyParameter paramType anyParameter
}; };

View file

@ -1,3 +1,8 @@
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
The above line is usefulin Emacs-like editors
*/
/* /*
Template for simple quadratic crossover operators Template for simple quadratic crossover operators
================================================= =================================================
@ -10,6 +15,10 @@ Quadratic crossover operators modify the both parents
#include <eoOp.h> #include <eoOp.h>
/**
Always write a comment in this format before class definition
if you want the class to be documented by Doxygen
*/
template<class Indi> template<class Indi>
class eoMyDerivedQuadOp: public eoQuadOp<Indi> class eoMyDerivedQuadOp: public eoQuadOp<Indi>
{ {
@ -38,7 +47,7 @@ public:
// return false; // return false;
} }
protected: private:
paramType anyParameter paramType anyParameter
}; };

View file

@ -54,7 +54,7 @@ to go directly to the corresponding section of the tutorial.
<area SHAPE="rect" HREF="eoRepresentation.html" COORDS="270,350,460,370"> <area SHAPE="rect" HREF="eoRepresentation.html" COORDS="270,350,460,370">
<area SHAPE="rect" HREF="eoEngine.html" COORDS="15,377,400,397"> <area SHAPE="rect" HREF="eoEngine.html" COORDS="15,377,400,397">
<area SHAPE="rect" HREF="eoEval.html" COORDS="15,403,230,423"> <area SHAPE="rect" HREF="eoEval.html" COORDS="15,403,230,423">
<area SHAPE="rect" HREF="eoCheckpoint.html" COORDS="15,430,221,450"> <area SHAPE="rect" HREF="eoCheckPoint.html" COORDS="15,430,221,450">
<area SHAPE="rect" HREF="eoCheckpoint.html#stop" COORDS="221,430,345,450"> <area SHAPE="rect" HREF="eoCheckpoint.html#stop" COORDS="221,430,345,450">
<area SHAPE="rect" HREF="eoCheckpoint.html#stat" COORDS="375,430,445,450"> <area SHAPE="rect" HREF="eoCheckpoint.html#stat" COORDS="375,430,445,450">
</map> </map>

View file

@ -27,7 +27,7 @@ is Checkpointing about?</font></font></b>
<p><b><font color="#FF0000">EO classes described in this page</font></b>: <p><b><font color="#FF0000">EO classes described in this page</font></b>:
<ul> <ul>
<li> <li>
<b><font color="#FF0000">Base classes</font></b>: eoCheckPoint, eoContinue, <b><font color="#FF0000">Base classes</font></b>: eoCheckPoint, <a href="#continuator">eoContinue</a>,
eoStat, eoSortedStat, eoMonitor, eoUpdater</li> eoStat, eoSortedStat, eoMonitor, eoUpdater</li>
<li> <li>
@ -40,23 +40,31 @@ eoStat, eoSortedStat, eoMonitor, eoUpdater</li>
<br>&nbsp; <br>&nbsp;
<p> <p>
<hr WIDTH="100%"><a NAME="continuator"></a><b><font color="#000099"><font size=+1>Continuators:</font></font></b> <hr WIDTH="100%"><a NAME="continuator"></a><b><font color="#000099"><font size=+1>Continuators:</font></font></b>
<br>&nbsp;
<p>Continuators are functors that compute stopping critera. They receive <p>Continuators are functors that compute stopping critera. They receive
a population and return a boolean value which is set to false only when a population and return a boolean value which is set to false only when
some stopping vriterion is met. All algorithms in EO have a loop that goes some stopping vriterion is met. All algorithms in EO have a loop that goes
<b><font color="#993300">while(continuator(pop) <b><font color="#993300">do{...}while(continuator(pop)</font></b>which
{ ... }<tt> </tt></font></b>which means that the algorithm stops only when means that the algorithm stops only when the continuator returns <b><font color="#993300">false</font></b>.
the continuator returns <b><font color="#993300">false</font></b>. <p><b><font color="#FF0000">Interface</font></b>:&nbsp; The abstract class
<p><b><font color="#FF0000">Interface</font></b>: for computing stopping conditions is <b><font color="#3366FF">eoContinue</font></b>,
<br>&nbsp; and the interface for its operator() is
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b><tt><font color="#993300"><font size=+1>bool operator()(const eoPop&lt;EOT>&amp;
)</font></font></tt></b>
<p>which you could have guessed from the <a href="../../doc/html/class_eocontinue.html">inheritance
diagram</a> for class <b><font color="#3366FF">eoContinue</font></b>, as
you see there that <b><font color="#3366FF">eoContinue</font></b> derives
from class <b><tt><font color="#993300"><font size=+1>eoUF&lt;const eoPop&lt;EOT>&amp;,
bool></font></font></tt></b>.
<p><b><font color="#FF0000">Using a continuator</font></b>: <p><b><font color="#FF0000">Using a continuator</font></b>:
<br>You can find an first example of using a continuator in the code for <br>You can find an first example of using a continuator in the code for
<a href="FirstBitGA.html#stop">FirstBitEA</a> in <a href="eoLesson2.html#tour">Lesson2</a>. <a href="FirstBitGA.html#stop">FirstBitEA</a>
ior more sophisticated continue conditions in&nbsp; <a href="eoLesson2.html#combinedContinue">Lesson2</a>.
<br>If you want to find out how it is used inside an algorithm, go and <br>If you want to find out how it is used inside an algorithm, go and
see for instance in eoSGA, the simplest EA within EO. see for instance in eoSGA, the simplest EA within EO.
<p><a NAME="writing_continuator"></a><b><font color="#FF0000">Writing a <p><a NAME="writing_continuator"></a><b><font color="#FF0000">Writing a
continuator:</font></b> continuator:</font></b>
<br>There are only two things to modify in the <a href="../Templates/continuator.tmpl">template <br>There are only two things to modify in the <a href="../Templates/continue.tmpl">template
class definitions</a> provided (apart from the name of the class you are class definitions</a> provided (apart from the name of the class you are
creating!) creating!)
<ul> <ul>
@ -66,11 +74,21 @@ any useful parameter (see the private data at end of class definition).</li>
<li> <li>
The <font color="#FF6600">operator()</font> method, which performs the The <font color="#FF6600">operator()</font> method, which performs the
actual test on the population.</li> computation of the actual test using the population plus any other parameter
passed at construct time. Don't forget to <b><font color="#FF6600">returnfalse</font></b>
when the stopping criterion <b><font color="#FF6600">is met!</font></b></li>
</ul> </ul>
Don't forget to <b><font color="#FF6600">return</font></b> <b><font color="#FF6600">false</font></b> <a NAME="existingContinue"></a><b><font color="#FF0000">Existing continuators:
when the stopping criterion <b><font color="#FF6600">is met!</font></b> </font></b>Of course you can find out all existing (non-virtual!) subclasses
<p> of eoContinue by looking at its&nbsp; <a href="../../doc/html/class_eocontinue.html">inheritance
diagram</a>. But you might find it more convenient to have them listed
here:
<ul>
<li>
</li>
</ul>
<b><font color="#FF0000"></font></b>
<p><br>
<hr WIDTH="100%"><a NAME="combined_continue"></a><b><font color="#000099"><font size=+1>Combining <hr WIDTH="100%"><a NAME="combined_continue"></a><b><font color="#000099"><font size=+1>Combining
continuators:</font></font></b> continuators:</font></font></b>
<p> <p>

View file

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (X11; U; Linux 2.2.17-21mdk i686) [Netscape]"> <meta name="GENERATOR" content="Mozilla/4.76 [en] (X11; U; Linux 2.2.17-21mdksmp i686) [Netscape]">
<title>Tutorial: Lesson 2</title> <title>Tutorial: Lesson 2</title>
<!-- Changed by: Marc Schoenauer, 29-Nov-2000 --> <!-- Changed by: Marc Schoenauer, 29-Nov-2000 -->
</head> </head>
@ -67,7 +67,11 @@ argument is a <a href="binary_value.html">vector&lt;bool></a> or a <a href="real
and not an unknown type. This will allow to use the same file for any EO and not an unknown type. This will allow to use the same file for any EO
object that is a sub-class of the corresponding STL vector class.</font></li> object that is a sub-class of the corresponding STL vector class.</font></li>
<p><br><b><font color="#FF0000">Note:</font></b> <font color="#000000">Also, <br>&nbsp;
<p>&nbsp;
<br>&nbsp;
<br>&nbsp;
<p><b><font color="#FF0000">Note:</font></b> <font color="#000000">Also,
a non-templatized fitness can be </font><b><font color="#FF6600">compiled a non-templatized fitness can be </font><b><font color="#FF6600">compiled
separately</font></b><font color="#000000"> (not done here) into an object separately</font></b><font color="#000000"> (not done here) into an object
file once and for all (<a href="eoProgramming.html#templates">remember</a> file once and for all (<a href="eoProgramming.html#templates">remember</a>
@ -82,8 +86,12 @@ have to declare 3 template arguments: the type of EO object it will be
applied to, the return type and the type of argument the function actually applied to, the return type and the type of argument the function actually
requires.</font></li> requires.</font></li>
<p><br><b><font color="#FF0000">Note:</font></b> <font color="#000000">In <br>&nbsp;
the previous files (<a href="FirstBitGA.html#eval">Bit</a> - <a href="FirstRealGA.html#eval">Real</a>) <p>&nbsp;
<br>&nbsp;
<br>&nbsp;
<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 , the last 2 types were deduced from the first (2nd argument = fitness
type of EO object, third = first).</font> type of EO object, third = first).</font>
<br>&nbsp; <br>&nbsp;
@ -99,13 +107,17 @@ rather than maximize a fitness function (see <a href="#Execrise1">Exercise
of the population is now </font><b><font color="#CC33CC">encapsulated</font></b><font color="#000000">into of the population is now </font><b><font color="#CC33CC">encapsulated</font></b><font color="#000000">into
a </font><font color="#CC33CC"><b>separate initializer</b> </font><font color="#000000">(based a </font><font color="#CC33CC"><b>separate initializer</b> </font><font color="#000000">(based
on a <a href="FirstBitEA.html#init">boolean generator</a> or a <a href="FirstRealEA.html#init">double-number on a <a href="FirstBitEA.html#init">boolean generator</a> or a <a href="FirstRealEA.html#init">double-number
generator</a> -see <a href="../../doc/html/class_eorndgenerator.html">random_generators.h</a>) generator</a> -see <a href="../../doc/html/class_random_generator.html">random_generators.h</a>)
that is then used in the constructor of the population to build the individuals. that is then used in the constructor of the population to build the individuals.
You can also use different initializers and call them in turn through the You can also use different initializers and call them in turn through the
call to <a href="../../doc/html/class_eopop.html#a2">pop.append()</a> function call to <a href="../../doc/html/class_eopop.html#a2">pop.append()</a> function
(see <a href="#exercise2">Exercise 2</a>).</font></li> (see <a href="#exercise2">Exercise 2</a>).</font></li>
<p><br><b><font color="#FF0000">Note</font><font color="#CC33CC">: </font></b><font color="#000000">Don't <br>&nbsp;
<p>&nbsp;
<br>&nbsp;
<br>&nbsp;
<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">: forget to </font><b><font color="#CC0000">evaluate the population</font></b><font color="#000000">:
the eoPop has no idea of the eval function, so it has to be done from outside!!!</font> the eoPop has no idea of the eval function, so it has to be done from outside!!!</font>
<br>&nbsp; <br>&nbsp;
@ -199,12 +211,15 @@ several stopping criteria by using an object of the class </font><b><tt><font co
</font></tt></b><font color="#000000">(<a href="FirstBitEA.html#stop">Bit</a> </font></tt></b><font color="#000000">(<a href="FirstBitEA.html#stop">Bit</a>
- <a href="FirstRealEA.html#stop">Real</a>). Initialize it with an object - <a href="FirstRealEA.html#stop">Real</a>). Initialize it with an object
of class </font><font color="#3366FF"><b><tt>eoContinue</tt></b>, </font><font color="#000000">and of class </font><font color="#3366FF"><b><tt>eoContinue</tt></b>, </font><font color="#000000">and
</font><b><tt><font color="#3366FF">add</font></tt></b><font color="#000000">as </font><b><tt><font color="#3366FF">add</font></tt></b><font color="#000000">
many of other such objects as you wish. And as an </font><b><tt><font color="#3366FF">eoCombinedContinue as many of other such objects as you wish. And as an </font><b><tt><font color="#3366FF">eoCombinedContinue
</font></tt><font color="#FF6600">is </font></tt><font color="#FF6600">is
an</font><tt><font color="#3366FF">eoContinue</font></tt></b><font color="#000000">, an</font><tt><font color="#3366FF"> eoContinue</font></tt></b><font color="#000000">,
simply pass it to the algorithm (<a href="FirstBitEA.html#generation">Bit</a> simply pass it to the algorithm (<a href="FirstBitEA.html#generation">Bit</a>
- <a href="FirstRealEA.html#generation">Real</a>).</font></li> - <a href="FirstRealEA.html#generation">Real</a>). To find out more, and
to get the list and syntax of existing eoContinue subclasses, check out
the corresponding <a href="eoCheckPoint.html#existingContinue">component-based
page</a>.</font></li>
<br>&nbsp; <br>&nbsp;
<li> <li>