Forgotten ES files + start of tutorial Lesson4 (about make_XXX)
This commit is contained in:
parent
10064ad967
commit
17484feeef
5 changed files with 700 additions and 11 deletions
186
eo/src/es/make_op_es.h
Normal file
186
eo/src/es/make_op_es.h
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// make_op.h - the real-valued version
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _make_op_h
|
||||
#define _make_op_h
|
||||
|
||||
// the operators
|
||||
#include <eoOp.h>
|
||||
#include <eoGenOp.h>
|
||||
#include <eoCloneOps.h>
|
||||
#include <eoOpContainer.h>
|
||||
// combinations of simple eoOps (eoMonOp and eoQuadOp)
|
||||
#include <eoProportionalCombinedOp.h>
|
||||
|
||||
// the specialized Real stuff
|
||||
#include <es/eoReal.h>
|
||||
#include <es/eoRealAtomXover.h>
|
||||
#include <es/eoEsChromInit.h>
|
||||
#include <es/eoEsMutationInit.h>
|
||||
#include <es/eoEsMutate.h>
|
||||
#include <es/eoEsGlobalXover.h>
|
||||
#include <es/eoEsLocalXover.h>
|
||||
// also need the parser and param includes
|
||||
#include <utils/eoParser.h>
|
||||
#include <utils/eoState.h>
|
||||
|
||||
|
||||
/*
|
||||
* This function builds the operators that will be applied to the eoReal
|
||||
*
|
||||
* It uses a parser (to get user parameters) and a state (to store the memory)
|
||||
* the last argument is an individual, needed for 2 reasons
|
||||
* it disambiguates the call after instanciations
|
||||
* some operator might need some private information about the indis
|
||||
*
|
||||
* This is why the template is the complete EOT even though only the fitness
|
||||
* is actually templatized here: the following only applies to bitstrings
|
||||
*
|
||||
* Note : the last parameter is an eoInit: if some operator needs some info
|
||||
* about the gneotypes, the init has it all (e.g. bounds, ...)
|
||||
* Simply do
|
||||
* EOT myEO;
|
||||
* _init(myEO);
|
||||
* and myEO is then an ACTUAL object
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoRealInitBounded<EOT>& _init)
|
||||
{
|
||||
// First, decide whether the objective variables are bounded
|
||||
eoValueParam<eoParamParamType>& boundsParam = _parser.createParam(eoParamParamType("(0,1)"), "objectBounds", "Bounds for variables (unbounded if absent)", 'B', "Variation Operators");
|
||||
|
||||
// get vector size
|
||||
unsigned vecSize = _init.size();
|
||||
|
||||
// the bounds pointer
|
||||
eoRealVectorBounds * ptBounds;
|
||||
if (_parser.isItThere(boundsParam)) // otherwise, no bounds
|
||||
{
|
||||
/////Warning: this code should probably be replaced by creating
|
||||
///// some eoValueParam<eoRealVectorBounds> with specific implementation
|
||||
//// in eoParser.cpp. At the moment, it is there (cf also make_genotype
|
||||
eoParamParamType & ppBounds = boundsParam.value(); // pair<string,vector<string> >
|
||||
// transform into a vector<double>
|
||||
vector<double> v;
|
||||
vector<string>::iterator it;
|
||||
for (it=ppBounds.second.begin(); it<ppBounds.second.end(); it++)
|
||||
{
|
||||
istrstream is(it->c_str());
|
||||
double r;
|
||||
is >> r;
|
||||
v.push_back(r);
|
||||
}
|
||||
// now create the eoRealVectorBounds object
|
||||
if (v.size() == 2) // a min and a max for all variables
|
||||
ptBounds = new eoRealVectorBounds(vecSize, v[0], v[1]);
|
||||
else // no time now
|
||||
throw runtime_error("Sorry, only unique bounds for all variables implemented at the moment. Come back later");
|
||||
// we need to give ownership of this pointer to somebody
|
||||
/////////// end of temporary code
|
||||
}
|
||||
else // no param for bounds was given
|
||||
ptBounds = new eoRealVectorNoBounds(vecSize); // DON'T USE eoDummyVectorNoBounds
|
||||
// as it does not have any dimension
|
||||
|
||||
// now we read Pcross and Pmut,
|
||||
eoValueParam<string>& operatorParam = _parser.createParam(string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators");
|
||||
|
||||
if (operatorParam.value() != string("SGA"))
|
||||
throw runtime_error("Sorry, only SGA-like operator available right now\n");
|
||||
|
||||
// now we read Pcross and Pmut,
|
||||
// and create the eoGenOp that is exactly
|
||||
// crossover with pcross + mutation with pmut
|
||||
|
||||
eoValueParam<double>& pCrossParam = _parser.createParam(1.0, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
||||
throw runtime_error("Invalid pCross");
|
||||
|
||||
eoValueParam<double>& pMutParam = _parser.createParam(1.0, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
||||
throw runtime_error("Invalid pMut");
|
||||
|
||||
|
||||
// crossover
|
||||
/////////////
|
||||
// ES crossover
|
||||
eoValueParam<string>& crossTypeParam = _parser.createParam(string("Global"), "crossType", "Type of ES recombination (gloabl or local)", 'C', "Variation Operators");
|
||||
|
||||
eoValueParam<string>& crossObjParam = _parser.createParam(string("Discrete"), "crossObj", "Recombination of object variables (Discrete or Intermediate)", 'O', "Variation Operators");
|
||||
eoValueParam<string>& crossStdevParam = _parser.createParam(string("Intermediate"), "crossStdev", "Recombination of mutation strategy parameters (Intermediate or Discrete)", 'S', "Variation Operators");
|
||||
|
||||
// The pointers: first the atom Xover
|
||||
eoBinOp<double> *ptObjAtomCross = NULL;
|
||||
eoBinOp<double> *ptStdevAtomCross = NULL;
|
||||
// then the global one
|
||||
eoGenOp<EOT> *ptCross;
|
||||
|
||||
// check for the atom Xovers
|
||||
if (crossObjParam.value() == string("Discrete"))
|
||||
ptObjAtomCross = new eoRealAtomExchange;
|
||||
else if (crossObjParam.value() == string("Intermediate"))
|
||||
ptObjAtomCross = new eoRealAtomExchange;
|
||||
else throw runtime_error("Invalid Object variable crossover type");
|
||||
|
||||
if (crossStdevParam.value() == string("Discrete"))
|
||||
ptStdevAtomCross = new eoRealAtomExchange;
|
||||
else if (crossStdevParam.value() == string("Intermediate"))
|
||||
ptStdevAtomCross = new eoRealAtomExchange;
|
||||
else throw runtime_error("Invalid mutation strategy parameter crossover type");
|
||||
|
||||
// and build the indi Xover
|
||||
if (crossTypeParam.value() == string("Global"))
|
||||
ptCross = new eoEsGlobalXover<EOT>(*ptObjAtomCross, *ptStdevAtomCross);
|
||||
else if (crossTypeParam.value() == string("Local"))
|
||||
ptCross = new eoEsLocalXover<EOT>(*ptObjAtomCross, *ptStdevAtomCross);
|
||||
else throw runtime_error("Invalide Object variable crossover type");
|
||||
|
||||
// now that everything is OK, DON'T FORGET TO STORE MEMORY
|
||||
_state.storeFunctor(ptObjAtomCross);
|
||||
_state.storeFunctor(ptStdevAtomCross);
|
||||
_state.storeFunctor(ptCross);
|
||||
|
||||
// mutation
|
||||
/////////////
|
||||
|
||||
// Ok, time to set up the self-adaptive mutation
|
||||
// Proxy for the mutation parameters
|
||||
eoEsMutationInit mutateInit(_parser, "Variation Operators");
|
||||
|
||||
eoEsMutate<EOT> * ptMon = new eoEsMutate<EOT>(mutateInit, *ptBounds);
|
||||
_state.storeFunctor(ptMon);
|
||||
|
||||
// encapsulate into an eoGenop
|
||||
eoMonGenOp<EOT> * op = new eoMonGenOp<EOT>(*ptMon);
|
||||
_state.storeFunctor(op);
|
||||
|
||||
// that's it!
|
||||
return *op;
|
||||
}
|
||||
#endif
|
||||
257
eo/src/es/make_op_real.h
Normal file
257
eo/src/es/make_op_real.h
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// make_op.h - the real-valued version
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _make_op_h
|
||||
#define _make_op_h
|
||||
|
||||
// the operators
|
||||
#include <eoOp.h>
|
||||
#include <eoGenOp.h>
|
||||
#include <eoCloneOps.h>
|
||||
#include <eoOpContainer.h>
|
||||
// combinations of simple eoOps (eoMonOp and eoQuadOp)
|
||||
#include <eoProportionalCombinedOp.h>
|
||||
|
||||
// the specialized Real stuff
|
||||
#include <es/eoReal.h>
|
||||
#include <es/eoEsChromInit.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#include <es/eoNormalMutation.h>
|
||||
// also need the parser and param includes
|
||||
#include <utils/eoParser.h>
|
||||
#include <utils/eoState.h>
|
||||
|
||||
|
||||
/*
|
||||
* This function builds the operators that will be applied to the eoReal
|
||||
*
|
||||
* It uses a parser (to get user parameters) and a state (to store the memory)
|
||||
* the last argument is an individual, needed for 2 reasons
|
||||
* it disambiguates the call after instanciations
|
||||
* some operator might need some private information about the indis
|
||||
*
|
||||
* This is why the template is the complete EOT even though only the fitness
|
||||
* is actually templatized here: the following only applies to bitstrings
|
||||
*
|
||||
* Note : the last parameter is an eoInit: if some operator needs some info
|
||||
* about the gneotypes, the init has it all (e.g. bounds, ...)
|
||||
* Simply do
|
||||
* EOT myEO;
|
||||
* _init(myEO);
|
||||
* and myEO is then an ACTUAL object
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoRealInitBounded<EOT>& _init)
|
||||
{
|
||||
// First, decide whether the objective variables are bounded
|
||||
eoValueParam<eoParamParamType>& boundsParam = _parser.createParam(eoParamParamType("(0,1)"), "objectBounds", "Bounds for variables (unbounded if absent)", 'B', "Variation Operators");
|
||||
|
||||
// get vector size
|
||||
unsigned vecSize = _init.size();
|
||||
|
||||
// the bounds pointer
|
||||
eoRealVectorBounds * ptBounds;
|
||||
if (_parser.isItThere(boundsParam)) // otherwise, no bounds
|
||||
{
|
||||
/////Warning: this code should probably be replaced by creating
|
||||
///// some eoValueParam<eoRealVectorBounds> with specific implementation
|
||||
//// in eoParser.cpp. At the moemnt, it is there (cf also make_genotype
|
||||
eoParamParamType & ppBounds = boundsParam.value(); // pair<string,vector<string> >
|
||||
// transform into a vector<double>
|
||||
vector<double> v;
|
||||
vector<string>::iterator it;
|
||||
for (it=ppBounds.second.begin(); it<ppBounds.second.end(); it++)
|
||||
{
|
||||
istrstream is(it->c_str());
|
||||
double r;
|
||||
is >> r;
|
||||
v.push_back(r);
|
||||
}
|
||||
// now create the eoRealVectorBounds object
|
||||
if (v.size() == 2) // a min and a max for all variables
|
||||
ptBounds = new eoRealVectorBounds(vecSize, v[0], v[1]);
|
||||
else // no time now
|
||||
throw runtime_error("Sorry, only unique bounds for all variables implemented at the moment. Come back later");
|
||||
// we need to give ownership of this pointer to somebody
|
||||
/////////// end of temporary code
|
||||
}
|
||||
else // no param for bounds was given
|
||||
ptBounds = new eoRealVectorNoBounds(vecSize); // DON'T USE eoDummyVectorNoBounds
|
||||
// as it does not have any dimension
|
||||
|
||||
// this is a temporary version(!),
|
||||
// while Maarten codes the full tree-structured general operator input
|
||||
// BTW we must leave that simple version available somehow, as it is the one
|
||||
// that 90% people use!
|
||||
eoValueParam<string>& operatorParam = _parser.createParam(string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators");
|
||||
|
||||
if (operatorParam.value() != string("SGA"))
|
||||
throw runtime_error("Sorry, only SGA-like operator available right now\n");
|
||||
|
||||
// now we read Pcross and Pmut,
|
||||
// the relative weights for all crossovers -> proportional choice
|
||||
// the relative weights for all mutations -> proportional choice
|
||||
// and create the eoGenOp that is exactly
|
||||
// crossover with pcross + mutation with pmut
|
||||
|
||||
eoValueParam<double>& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
||||
throw runtime_error("Invalid pCross");
|
||||
|
||||
eoValueParam<double>& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
||||
throw runtime_error("Invalid pMut");
|
||||
|
||||
// the crossovers
|
||||
/////////////////
|
||||
// the parameters
|
||||
eoValueParam<double>& segmentRateParam = _parser.createParam(double(1.0), "segmentRate", "Relative rate for segment crossover", 's', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (segmentRateParam.value() < 0) )
|
||||
throw runtime_error("Invalid segmentRate");
|
||||
|
||||
eoValueParam<double>& arithmeticRateParam = _parser.createParam(double(2.0), "arithmeticRate", "Relative rate for arithmetic crossover", 'A', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (arithmeticRateParam.value() < 0) )
|
||||
throw runtime_error("Invalid arithmeticRate");
|
||||
|
||||
// minimum check
|
||||
bool bCross = true;
|
||||
if (segmentRateParam.value()+arithmeticRateParam.value()==0)
|
||||
{
|
||||
cerr << "Warning: no crossover" << endl;
|
||||
bCross = false;
|
||||
}
|
||||
|
||||
// Create the CombinedQuadOp
|
||||
eoPropCombinedQuadOp<EOT> *ptCombinedQuadOp = NULL;
|
||||
eoQuadOp<EOT> *ptQuad = NULL;
|
||||
|
||||
if (bCross)
|
||||
{
|
||||
// segment crossover for bitstring - pass it the bounds
|
||||
ptQuad = new eoSegmentCrossover<EOT>(*ptBounds);
|
||||
_state.storeFunctor(ptQuad);
|
||||
ptCombinedQuadOp = new eoPropCombinedQuadOp<EOT>(*ptQuad, segmentRateParam.value());
|
||||
|
||||
// arithmetic crossover
|
||||
ptQuad = new eoArithmeticCrossover<EOT>(*ptBounds);
|
||||
_state.storeFunctor(ptQuad);
|
||||
ptCombinedQuadOp->add(*ptQuad, arithmeticRateParam.value());
|
||||
|
||||
// don't forget to store the CombinedQuadOp
|
||||
_state.storeFunctor(ptCombinedQuadOp);
|
||||
}
|
||||
|
||||
// the mutations
|
||||
/////////////////
|
||||
// the parameters
|
||||
eoValueParam<double> & epsilonParam = _parser.createParam(0.01, "epsilon", "Half-size of interval for Uniform Mutation", 'e', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (epsilonParam.value() < 0) )
|
||||
throw runtime_error("Invalid epsilon");
|
||||
|
||||
eoValueParam<double> & uniformMutRateParam = _parser.createParam(1.0, "uniformMutRate", "Relative rate for uniform mutation", 'u', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (uniformMutRateParam.value() < 0) )
|
||||
throw runtime_error("Invalid uniformMutRate");
|
||||
|
||||
eoValueParam<double> & detMutRateParam = _parser.createParam(1.0, "detMutRate", "Relative rate for deterministic uniform mutation", 'd', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (detMutRateParam.value() < 0) )
|
||||
throw runtime_error("Invalid detMutRate");
|
||||
|
||||
eoValueParam<double> & normalMutRateParam = _parser.createParam(1.0, "normalMutRate", "Relative rate for Gaussian mutation", 'd', "Variation Operators" );
|
||||
// minimum check
|
||||
if ( (normalMutRateParam.value() < 0) )
|
||||
throw runtime_error("Invalid normalMutRate");
|
||||
|
||||
eoValueParam<double> & sigmaParam = _parser.createParam(0.3, "sigma", "Sigma (fixed) for Gaussian mutation", 's', "Variation Operators" );
|
||||
|
||||
// minimum check
|
||||
bool bMut = true;
|
||||
if (uniformMutRateParam.value()+detMutRateParam.value()+normalMutRateParam.value()==0)
|
||||
{
|
||||
cerr << "Warning: no mutation" << endl;
|
||||
bMut = false;
|
||||
}
|
||||
if (!bCross && !bMut)
|
||||
throw runtime_error("No operator called in SGA operator definition!!!");
|
||||
|
||||
// Create the CombinedMonOp
|
||||
eoPropCombinedMonOp<EOT> *ptCombinedMonOp = NULL;
|
||||
eoMonOp<EOT> *ptMon = NULL;
|
||||
|
||||
if (bMut)
|
||||
{
|
||||
// uniform mutation on all components:
|
||||
// offspring(i) uniformly chosen in [parent(i)-epsilon, parent(i)+epsilon]
|
||||
ptMon = new eoUniformMutation<EOT>(*ptBounds, epsilonParam.value());
|
||||
_state.storeFunctor(ptMon);
|
||||
// create the CombinedMonOp
|
||||
ptCombinedMonOp = new eoPropCombinedMonOp<EOT>(*ptMon, uniformMutRateParam.value());
|
||||
|
||||
// mutate exactly 1 component (uniformly) per individual
|
||||
ptMon = new eoDetUniformMutation<EOT>(*ptBounds, epsilonParam.value());
|
||||
_state.storeFunctor(ptMon);
|
||||
ptCombinedMonOp->add(*ptMon, detMutRateParam.value());
|
||||
|
||||
// mutate all component using Gaussian mutation
|
||||
ptMon = new eoNormalMutation<EOT>(*ptBounds, sigmaParam.value());
|
||||
_state.storeFunctor(ptMon);
|
||||
ptCombinedMonOp->add(*ptMon, normalMutRateParam.value());
|
||||
_state.storeFunctor(ptCombinedMonOp);
|
||||
}
|
||||
|
||||
// now build the eoGenOp:
|
||||
// to simulate SGA (crossover with proba pCross + mutation with proba pMut
|
||||
// we must construct
|
||||
// a sequential combination of
|
||||
// with proba 1, a proportional combination of
|
||||
// a QuadCopy and our crossover
|
||||
// with proba pMut, our mutation
|
||||
|
||||
// the crossover - with probability pCross
|
||||
eoProportionalOp<EOT> * cross = new eoProportionalOp<EOT> ;
|
||||
_state.storeFunctor(cross);
|
||||
ptQuad = new eoQuadCloneOp<EOT>;
|
||||
_state.storeFunctor(ptQuad);
|
||||
cross->add(*ptCombinedQuadOp, pCrossParam.value()); // user crossover
|
||||
cross->add(*ptQuad, 1-pCrossParam.value()); // clone operator
|
||||
|
||||
// now the sequential
|
||||
eoSequentialOp<EOT> *op = new eoSequentialOp<EOT>;
|
||||
_state.storeFunctor(op);
|
||||
op->add(*cross, 1.0); // always crossover (but clone with prob 1-pCross
|
||||
op->add(*ptCombinedMonOp, pMutParam.value());
|
||||
|
||||
// that's it!
|
||||
return *op;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -142,7 +142,7 @@ See the parameter section of the Component-Based tutorial, or wait until
|
|||
class, whose only purpose is the input of parameters.</font></li>
|
||||
</ul>
|
||||
|
||||
<hr WIDTH="50%"><b><font color="#000099">eoParser:</font><font color="#FF0000">
|
||||
<hr WIDTH="50%"><A NAME="paraminput"><b><font color="#000099">eoParser:</font><font color="#FF0000">
|
||||
Modifying parameter values at run-time:</font></b>
|
||||
<br><font color="#000000">Using an eoParser object, the parameter values
|
||||
are read, by order of priority</font>
|
||||
|
|
@ -154,7 +154,7 @@ are read, by order of priority</font>
|
|||
<font color="#000000">from a text file</font></li>
|
||||
|
||||
<li>
|
||||
<font color="#000000">from the environment</font></li>
|
||||
<font color="#000000">from the environment (forthcoming, if somebody insists)</font></li>
|
||||
|
||||
<li>
|
||||
<font color="#000000">from default values</font></li>
|
||||
|
|
@ -174,8 +174,8 @@ the command-line or in a text file)</li>
|
|||
<br>
|
||||
|
||||
<b><tt><font color="#660000">--longKeyword=value</font></tt></b>
|
||||
or <b><tt><font color="#660000">-c=value</font></tt></b>
|
||||
if 'c' is the short keyword
|
||||
or <b><tt><font color="#660000">-cvalue</font></tt></b>
|
||||
if 'c' is the short keyword (though <b><tt><font color="#660000">-c=value</font></tt></b> also works)
|
||||
<br>
|
||||
<li>
|
||||
so, after compiling the executable for Lesson 3 (<b><tt><font color="#FF6666">make
|
||||
|
|
|
|||
237
eo/tutorial/html/eoLesson4.html
Normal file
237
eo/tutorial/html/eoLesson4.html
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
<!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.73 [en] (X11; I; Linux 2.2.15-4mdk i686) [Netscape]">
|
||||
<title>Tutorial: Lesson 3</title>
|
||||
</head>
|
||||
<body text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000" background="beige009.jpg">
|
||||
<a href="eoLesson2.html">Lesson 3</a> -
|
||||
<a href="eoLesson4.html">Lesson
|
||||
5</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 4: fully operational EA</font></h1></center>
|
||||
In this lesson, you will still use the same Evolutionary Algorithm. But
|
||||
this time you will have <b><font color="#FF6600">full control of all components</font></b>
|
||||
from the c<b><font color="#FF6600">ommand-line or a parameter file</font></b>.
|
||||
You can even use the algorithm decribed here without any other knowledge
|
||||
of EO, just by writing your fitness function as a plain C++ function. This
|
||||
is why this lesson starts with a <a href="#programmerguide">user's guide</a>,
|
||||
most of it being representation-independent, with some parts that are specific
|
||||
of respectively the <a href="#binary">binary</a> and the <a href="#real">real</a>
|
||||
algorithms.
|
||||
<br>However, the ultimate purpose of this tutorial is to be able to do
|
||||
your own experiments - and these these will likely fall outside the scope
|
||||
of these two programs. This is why you should also read the programmer's
|
||||
guides, as the structure and memory managements are here radically different
|
||||
that in the 3 previous lessons - though relying of course on the same objects.
|
||||
<br>
|
||||
<p>
|
||||
<hr WIDTH="100%">
|
||||
<br><a NAME="userguide"></a><b><font color="#000099"><font size=+2>User's
|
||||
guide</font></font></b>
|
||||
<br><font color="#000000">As already said, the behavior of the algorithms
|
||||
will be exactly the same as the previous one as far as optimization is
|
||||
concerned. Only now you will be able to tune every component of the algorithms
|
||||
- except the type of genotype - using run-time parameters.</font>
|
||||
<br><font color="#000000">Also, as in previous lessons, most of the code
|
||||
is representation-independent, i.e. is the same for both the binary genotypes
|
||||
and the real-valued genotypes. This small user's guide reflects that, but
|
||||
you can go directly to the <a href="#binary">binary</a> or the <a href="#real">real</a>
|
||||
parts if you wish. Parameters input The way to input parameters has already
|
||||
be described in <a href="eoLEsson3.html#paraminput">Lesson 3</a>. To get
|
||||
a list of parameters, type the command with option --help (or -h): with
|
||||
both testBit and testReal this will result in</font>
|
||||
<ul>
|
||||
<li>
|
||||
<font color="#000000">Printing the list of keywords on the standard output</font></li>
|
||||
|
||||
<li>
|
||||
<font color="#000000">Creating (or overwriting) a file name testBit.status
|
||||
or testReal.status that contains the list of all recognized parameters
|
||||
and has the format of an input parameter file.</font></li>
|
||||
</ul>
|
||||
<b><font color="#000099"><font size=+1>User's guide:</font></font></b><font color="#000000">
|
||||
</font><b><font color="#FF0000">The status file</font></b>
|
||||
<br><font color="#000000">This file will always contain the list of the
|
||||
parameters that have been actually used by the last run of the program,
|
||||
however thay have been entered (try </font><b><tt><font color="#FF6666"><font size=+1>testBit
|
||||
-G1</font></font></tt></b><font color="#000000"> and take a look a the
|
||||
status file). The parameters that are commented out (a # character comments
|
||||
out the rest of the line) in the file were not specified by the user.</font><font color="#000000"></font>
|
||||
<p><b><font color="#000099"><font size=+1>User's guide:</font></font></b><font color="#000000">
|
||||
</font><b><font color="#FF0000">Representation-independent parameters</font></b><font color="#000000"></font>
|
||||
<br><font color="#000000">The parameters are organized in sections.</font>
|
||||
<br><font color="#000000">The first section only contains the random seed.</font><font color="#000000"></font>
|
||||
<p><b><tt><font color="#993300"><font size=+1>###### General ######</font></font></tt></b>
|
||||
<br><b><tt><font color="#993300"><font size=+1># --help=0 # -h : Prints
|
||||
this message</font></font></tt></b>
|
||||
<br><font color="#000000">Whether or not help was requested is handled
|
||||
through a boolean parameter</font>
|
||||
<br><b><tt><font color="#993300"><font size=+1># --seed=988700289 # -S
|
||||
: Random number seed</font></font></tt></b>
|
||||
<br><font color="#000000">The seed for the <a href="eoProgramming.html#random">Random
|
||||
Number Generator</a></font>
|
||||
<p><b><tt><font color="#3333FF"><font size=+1>###### Output ######</font></font></tt></b>
|
||||
<br><font color="#000000">This section contains parameters related to output
|
||||
(to screen, to files, graphical, ...).</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --useEval=1 # Use nb of
|
||||
eval. as counter (vs nb of gen.)</font></font></tt></b>
|
||||
<br><font color="#000000">Boolean parameter, whether or not you want the
|
||||
nb of evluations to be displayed and used as counter in plots</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --printBestStat=1 # Print
|
||||
Best/avg/stdev every gen.</font></font></tt></b>
|
||||
<br><font color="#000000">Boolean parameter, toggles screen output of indicated
|
||||
statistics</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --plotBestStat=0 # Plot
|
||||
Best/avg Stat</font></font></tt></b>
|
||||
<br><font color="#000000">Boolean parameter, toggles gnuplot output of
|
||||
best and average plots (Linux only at the moment)</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --BestFileName=best.xg
|
||||
# Name of file for Best/avg/stdev</font></font></tt></b>
|
||||
<br><font color="#000000">String parameter, if present, the statistics
|
||||
are stored in that file (no default)</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --printPop=0 # Print sorted
|
||||
pop. every gen.</font></font></tt></b>
|
||||
<br><font color="#000000">Boolean parameter, adds a dump of the whole population
|
||||
to the screen every generation</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --printFDC=1 # Print FDC
|
||||
coeff. every gen.</font></font></tt></b>
|
||||
<br><font color="#000000">Boolean parameter, adds Fitness Distance Correlation
|
||||
to output every generation</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --plotFDCStat=0 # Plot
|
||||
FDC scatter plot</font></font></tt></b>
|
||||
<br><font color="#000000">Boolean parameter, toggles the Fitness Distance
|
||||
Correlation plot (Fitness vs distance to best)</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --plotHisto=0 # Plot histogram
|
||||
of fitnesses</font></font></tt></b>
|
||||
<br><font color="#000000">Boolean parameter: if on, gnuplot is used to
|
||||
plot the sorted population (fitness vs rank). Gives a graphical idea of
|
||||
the diversity.</font><font color="#000000"></font>
|
||||
<p><b><tt><font color="#3333FF"><font size=+1>###### Persistence ######</font></font></tt></b>
|
||||
<br><font color="#000000">This section contains parameters handling job
|
||||
restart</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --Load= # -L : A save
|
||||
file to restart from</font></font></tt></b>
|
||||
<br><font color="#000000">String parameter: if present, the initial population
|
||||
(and the RNG status) is read from indicated file. That file </font><b><font color="#FF0000">must</font></b><font color="#000000">
|
||||
come from a previous save (or must be in same format!), i.e. must contain
|
||||
a popualtion, the RNG and all parameters. If no other parameter is modified,
|
||||
using a previously saved population and RNG will give exactly the same
|
||||
results than having run that previous run longer. And a way to be sure
|
||||
to re-use the same parameters is to ... use that very save file as parameter
|
||||
file, as it contains all actual parameters in the right format.</font>
|
||||
<br><font color="#000000">Note that if not enough individuals are read,
|
||||
the remaining are randomly initialized. No default value.</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --recomputeFitness=0 #
|
||||
-r : Recompute the fitness after re-loading the pop.?</font></font></tt></b>
|
||||
<br><font color="#000000">Boolean parameter: in case some individuals are
|
||||
read from a file, their fitness is read too. If this one is true, it is
|
||||
nevertheless recomputed.</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --saveFrequency=0 # Save
|
||||
every F generation (0 = only final state, absent = never)</font></font></tt></b>
|
||||
<br><font color="#000000">Integer parameter: interval between two dump
|
||||
to disk of the whole population (+RNG + parameters) to disk, in a file
|
||||
named genNN.sav, where NN is the generation number. If this prameter
|
||||
is present (even with 0 or negative value), the final population will always
|
||||
be saved, whatever the reason for stopping. Hence the only way to avoid
|
||||
all saves is to omit the parameter (there is no default value).</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --saveTimeInterval=0 #
|
||||
Save every T seconds (0 or absent = never)</font></font></tt></b>
|
||||
<br><font color="#000000">Integer parameter: time interval between two
|
||||
population (+RNG + parameters) dumps to disks. Files are names timeNN.sav.
|
||||
See pervious parameter description for ore details. No default value.</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --status=t-eoGA.status
|
||||
# Status file</font></font></tt></b>
|
||||
<br><font color="#000000">String parameter: name of the status file (that
|
||||
contains all parameters in the input format). There is no way to avoid
|
||||
creating that file except recompiling ... or giving the name /dev/null
|
||||
(Unix).</font><b><tt><font color="#3333FF"><font size=+1></font></font></tt></b>
|
||||
<p><b><tt><font color="#3333FF"><font size=+1>###### Stopping criterion
|
||||
######</font></font></tt></b>
|
||||
<br><font color="#000000">This section allows to decide when the algorithm
|
||||
will stop.</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --maxGen=100 # -G : Maximum
|
||||
number of generations (0 = none)</font></font></tt></b>
|
||||
<br><font color="#000000">Integer parameter: maximum number of generations.
|
||||
Default is 0 which is equivalent to infinity.</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --steadyGen=100 # -s :
|
||||
Number of generations with no improvement</font></font></tt></b>
|
||||
<br><font color="#000000">Integer parameter: stops whenever that number
|
||||
of generations is passed without any improvement of the best fitness in
|
||||
the population, provided the following minimum number of generations has
|
||||
been done. No default value.</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --minGen=0 # -g : Minimum
|
||||
number of generations</font></font></tt></b>
|
||||
<br><font color="#000000">Integer parameter: the above steadyGen parameter
|
||||
starts its job only after that minimum nuber of generations is passed.
|
||||
No default value.</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --maxEval=0 # -E : Maximum
|
||||
number of evaluations (0 = none)</font></font></tt></b>
|
||||
<br><font color="#000000">Integer parameter: maximum number of generations.
|
||||
No default value.</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --targetFitness=0 # -T
|
||||
: Stop when fitness reaches</font></font></tt></b>
|
||||
<br><font color="#000000">Real-valued parameter: the algorithm stops whenever
|
||||
the best fitness reaches that target. No default value.</font>
|
||||
<br><b><tt><font color="#3333FF"><font size=+1># --CtrlC=0 # -C : Terminate
|
||||
current generation upon Ctrl C</font></font></tt></b>
|
||||
<br><font color="#000000">Boolean parameter: if true, Ctrl C only stops
|
||||
after the current generation as completed (eventually dumping population
|
||||
to a file if some saver is active).</font>
|
||||
<p><b><tt><font color="#009900"><font size=+1>###### engine ######</font></font></tt></b>
|
||||
<br><font color="#000000">In this section, one chooses all components of
|
||||
the Evolution Engine (selection, replacemenet and the like).</font>
|
||||
<br><b><tt><font color="#009900"><font size=+1># --selection=DetTour(2)
|
||||
# -S : Selection: Roulette, DetTour(T), StochTour(t) or Sequential(ordered/unordered)</font></font></tt></b>
|
||||
<br><font color="#000000">String parameter: Name of selection procedure.
|
||||
Availabable are the </font><b><font color="#FF6600">roulette wheel</font></b><font color="#000000">
|
||||
(name </font><b><tt><font color="#009900"><font size=+1>Roulette</font></font></tt></b><font color="#000000">,
|
||||
fitness scaling coming soon), </font><b><font color="#FF6600">deterministic
|
||||
tournament</font></b><font color="#000000"> (name </font><b><tt><font color="#009900"><font size=+1>DetTour</font></font></tt></b><font color="#000000">
|
||||
with size - integer > 2 - in parentheses right after the name, use double
|
||||
quotes on the command line), stochastic tournament (name </font><b><tt><font color="#009900"><font size=+1>StochTour</font></font></tt></b><font color="#000000">
|
||||
with probability - float in [0.5, 1] - in parentheses), sequential (name
|
||||
</font><b><tt><font color="#009900"><font size=+1>Sequential</font></font></tt></b><font color="#000000">,
|
||||
all individuals in turn), either from best to worst (option </font><b><tt><font color="#009900"><font size=+1>ordered</font></font></tt></b><font color="#000000">
|
||||
in parentheses), or in random ordered (option </font><b><tt><font color="#009900"><font size=+1>unordered</font></font></tt></b><font color="#000000">)
|
||||
or finally repeated independent uniform choices (name </font><b><tt><font color="#009900"><font size=+1>Random</font></font></tt></b><font color="#000000">).</font>
|
||||
<br><b><tt><font color="#009900"><font size=+1># --offspringRate=100% #
|
||||
-O : Nb of offspring (percentage or absolute)</font></font></tt></b><b><tt><font color="#009900"><font size=+1></font></font></tt></b>
|
||||
<p><b><tt><font color="#009900"><font size=+1># --replacement=Comma # -R
|
||||
: Replacement: Comma, Plus or EPTour(T)</font></font></tt></b>
|
||||
<br><font color="#000000">String parameter: Name of replacement procedure.
|
||||
Availabable are</font>
|
||||
<br><b><tt><font color="#009900"><font size=+1># --weakElitism=0 # -w :
|
||||
Old best parent replaces new worst offspring *if necessary*</font></font></tt></b>
|
||||
<br><font color="#009900"></font>
|
||||
<p>
|
||||
<hr WIDTH="100%">
|
||||
<br><a NAME="programmerguide"></a><b><font color="#000099"><font size=+2>Programmer's
|
||||
guide
|
||||
<hr WIDTH="100%"></font></font></b><font color="#000000"><a href="eoLesson2.html">Lesson
|
||||
3</a> -
|
||||
<a href="eoLesson4.html">Lesson 5</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@polytechnique.fr">Marc
|
||||
Schoenauer</a></font></address>
|
||||
|
||||
<br><!-- Created: Tue May 1 14:49:12 CET 2001 --><!-- hhmts start --><font color="#000000">Last
|
||||
modified: None of your business!</font><!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -47,24 +47,33 @@ populations,
|
|||
<b><font color="#3366FF">restart</font></b> stopped runs,
|
||||
...).</li>
|
||||
|
||||
<p><br>Current version (Jan. 5, 2001) stops here, but ...
|
||||
<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 ...
|
||||
<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>
|
||||
|
||||
<li>
|
||||
Lesson 4 - More about <b><font color="#3366FF">checkpointing</font></b>:
|
||||
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>:
|
||||
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 5 - More <b><font color="#CC33CC">general operators</font></b>:
|
||||
e.g. binary, n-ary, or even specific mate selection (your brain and my
|
||||
beauty)!</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
|
||||
|
|
|
|||
Reference in a new issue