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:
parent
ddc6650ce5
commit
f0813c55ca
10 changed files with 163 additions and 30 deletions
|
|
@ -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
|
||||
==============================================
|
||||
|
|
@ -11,6 +16,10 @@ based on the second
|
|||
|
||||
#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>
|
||||
class eoMyDerivedBinOp: public eoBinOp<Indi>
|
||||
{
|
||||
|
|
@ -38,7 +47,7 @@ public:
|
|||
// return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
paramType anyParameter
|
||||
};
|
||||
|
||||
|
|
|
|||
46
eo/tutorial/Templates/continue.tmpl
Normal file
46
eo/tutorial/Templates/continue.tmpl
Normal 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
|
||||
|
||||
|
|
@ -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
|
||||
===============================
|
||||
|
|
@ -13,6 +18,10 @@ Second version, get parents using an external eoSelectOne
|
|||
|
||||
#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>
|
||||
class eoLessOffspringExternalSelectorGenOp: public eoGenOp<Indi>
|
||||
{
|
||||
|
|
@ -61,7 +70,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
protected:
|
||||
private:
|
||||
eoSelectOne<EOT> & sel;
|
||||
paramType anyParameter
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
===============================
|
||||
|
|
@ -13,6 +18,10 @@ First version, get parents from populator using the ibbedded select() method
|
|||
|
||||
#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>
|
||||
class eoLessOffspringSameSelectorGenOp: public eoGenOp<Indi>
|
||||
{
|
||||
|
|
@ -57,7 +66,7 @@ public:
|
|||
parentN.invalidate();
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
paramType anyParameter
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
===============================
|
||||
|
|
@ -12,6 +17,10 @@ than there are parents
|
|||
|
||||
#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>
|
||||
class eoMoreOffspringGenOp: public eoGenOp<Indi>
|
||||
{
|
||||
|
|
@ -58,7 +67,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
protected:
|
||||
private:
|
||||
paramType anyParameter
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
======================================
|
||||
|
|
@ -9,6 +14,10 @@ Template for simple mutation operators
|
|||
|
||||
#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>
|
||||
class eoMyDerivedMonOp: public eoMonOp<Indi>
|
||||
{
|
||||
|
|
@ -35,7 +44,7 @@ public:
|
|||
// return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
paramType anyParameter
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
=================================================
|
||||
|
|
@ -10,6 +15,10 @@ Quadratic crossover operators modify the both parents
|
|||
|
||||
#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>
|
||||
class eoMyDerivedQuadOp: public eoQuadOp<Indi>
|
||||
{
|
||||
|
|
@ -38,7 +47,7 @@ public:
|
|||
// return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
paramType anyParameter
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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="eoEngine.html" COORDS="15,377,400,397">
|
||||
<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#stat" COORDS="375,430,445,450">
|
||||
</map>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ is Checkpointing about?</font></font></b>
|
|||
<p><b><font color="#FF0000">EO classes described in this page</font></b>:
|
||||
<ul>
|
||||
<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>
|
||||
|
||||
<li>
|
||||
|
|
@ -40,23 +40,31 @@ eoStat, eoSortedStat, eoMonitor, eoUpdater</li>
|
|||
<br>
|
||||
<p>
|
||||
<hr WIDTH="100%"><a NAME="continuator"></a><b><font color="#000099"><font size=+1>Continuators:</font></font></b>
|
||||
<br>
|
||||
<p>Continuators are functors that compute stopping critera. They receive
|
||||
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
|
||||
<b><font color="#993300">while(continuator(pop)
|
||||
{ ... }<tt> </tt></font></b>which means that the algorithm stops only when
|
||||
the continuator returns <b><font color="#993300">false</font></b>.
|
||||
<p><b><font color="#FF0000">Interface</font></b>:
|
||||
<br>
|
||||
<b><font color="#993300">do{...}while(continuator(pop)</font></b>which
|
||||
means that the algorithm stops only when the continuator returns <b><font color="#993300">false</font></b>.
|
||||
<p><b><font color="#FF0000">Interface</font></b>: The abstract class
|
||||
for computing stopping conditions is <b><font color="#3366FF">eoContinue</font></b>,
|
||||
and the interface for its operator() is
|
||||
<p>
|
||||
<b><tt><font color="#993300"><font size=+1>bool operator()(const eoPop<EOT>&
|
||||
)</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<const eoPop<EOT>&,
|
||||
bool></font></font></tt></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
|
||||
<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 <a href="eoLesson2.html#combinedContinue">Lesson2</a>.
|
||||
<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.
|
||||
<p><a NAME="writing_continuator"></a><b><font color="#FF0000">Writing a
|
||||
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
|
||||
creating!)
|
||||
<ul>
|
||||
|
|
@ -66,11 +74,21 @@ any useful parameter (see the private data at end of class definition).</li>
|
|||
|
||||
<li>
|
||||
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>
|
||||
Don't forget to <b><font color="#FF6600">return</font></b> <b><font color="#FF6600">false</font></b>
|
||||
when the stopping criterion <b><font color="#FF6600">is met!</font></b>
|
||||
<p>
|
||||
<a NAME="existingContinue"></a><b><font color="#FF0000">Existing continuators:
|
||||
</font></b>Of course you can find out all existing (non-virtual!) subclasses
|
||||
of eoContinue by looking at its <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
|
||||
continuators:</font></font></b>
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -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.76 [en] (X11; U; Linux 2.2.17-21mdksmp i686) [Netscape]">
|
||||
<title>Tutorial: Lesson 2</title>
|
||||
<!-- Changed by: Marc Schoenauer, 29-Nov-2000 -->
|
||||
</head>
|
||||
|
|
@ -67,7 +67,11 @@ argument is a <a href="binary_value.html">vector<bool></a> or a <a href="real
|
|||
and not an unknown type. This will allow to use the same file for any EO
|
||||
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>
|
||||
<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
|
||||
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
|
||||
requires.</font></li>
|
||||
|
||||
<p><br><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>)
|
||||
<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
|
||||
type of EO object, third = first).</font>
|
||||
<br>
|
||||
|
|
@ -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
|
||||
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
|
||||
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.
|
||||
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
|
||||
(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>
|
||||
<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>
|
||||
<br>
|
||||
|
|
@ -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>
|
||||
- <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
|
||||
</font><b><tt><font color="#3366FF">add</font></tt></b><font color="#000000">as
|
||||
many of other such objects as you wish. And as an </font><b><tt><font color="#3366FF">eoCombinedContinue
|
||||
</font><b><tt><font color="#3366FF">add</font></tt></b><font color="#000000">
|
||||
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
|
||||
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>
|
||||
- <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>
|
||||
<li>
|
||||
|
|
|
|||
Reference in a new issue