diff --git a/eo/app/gprop/gprop.cc b/eo/app/gprop/gprop.cc index 3b7d93ec..dc17379a 100644 --- a/eo/app/gprop/gprop.cc +++ b/eo/app/gprop/gprop.cc @@ -7,17 +7,7 @@ #include // cerr cout #include // ifstream #include // string -#include // eoParser -#include // eoPop -#include // eoEvalFunc -#include // eoStochTournament -#include // eoGenContinue -#include // eoFitContinue -#include // eoCombinedContinue -#include // eoCheckPoint -#include // eoBestFitnessStat -#include // eoStdoutMonitor -#include // eoSGA +#include // all usefull eo stuff #include "gprop.h" // Chrom eoChromInit eoChromMutation eoChromXover eoChromEvaluator //----------------------------------------------------------------------------- @@ -134,7 +124,7 @@ void ga() apply(evaluator, pop); // selector - eoStochTournament select; + eoStochTournamentSelect select; // genetic operators eoChromMutation mutation; diff --git a/eo/app/mastermind/mastermind.cc b/eo/app/mastermind/mastermind.cc index 6be66e84..0db39120 100644 --- a/eo/app/mastermind/mastermind.cc +++ b/eo/app/mastermind/mastermind.cc @@ -7,17 +7,7 @@ #include // cerr cout #include // ifstream #include // string -#include // eoParser -#include // eoPop -#include // eoEvalFunc -#include // eoProportional -#include // eoGenContinue -#include // eoFitContinue -#include // eoCombinedContinue -#include // eoCheckPoint -#include // eoBestFitnessStat -#include // eoStdoutMonitor -#include // eoSGA +#include // all usefull eo stuff #include "mastermind.h" // Chrom eoChromInit eoChromMutation eoChromXover eoChromEvaluator //----------------------------------------------------------------------------- @@ -103,7 +93,7 @@ void ga() apply(evaluator, pop); // selector - eoProportional select(pop); + eoProportionalSelect select(pop); // genetic operators eoChromMutation mutation; diff --git a/eo/src/eo b/eo/src/eo index 62c8de89..5f1a3f6b 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -92,21 +92,24 @@ #include // Continuators -#include +// #include // already included in the following #include #include #include #include // Selection -#include -#include -#include -#include -#include +// the eoSelectOne +#include +#include +#include +#include +// the batch selection - from an eoSelectOne #include #include #include +// other batch selections +#include // Replacement @@ -129,6 +132,8 @@ //#include +#include + // Algorithms #include #include diff --git a/eo/src/eoDetTournamentSelect.h b/eo/src/eoDetTournamentSelect.h new file mode 100755 index 00000000..dcc04876 --- /dev/null +++ b/eo/src/eoDetTournamentSelect.h @@ -0,0 +1,69 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoDetTournament.h +// (c) GeNeura Team, 1998 - EEAAX 1999 +/* + 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 + */ +//----------------------------------------------------------------------------- + +#ifndef eoDetTournament_h +#define eoDetTournament_h + +//----------------------------------------------------------------------------- + +#include // +#include // accumulate + +#include +#include +#include + +//----------------------------------------------------------------------------- +/** eoDetTournamentSelect: a selection method that selects ONE individual by + deterministic tournament + -MS- 24/10/99 */ +//----------------------------------------------------------------------------- + +template class eoDetTournamentSelect: public eoSelectOne +{ + public: + /// (Default) Constructor. + eoDetTournamentSelect(unsigned _Tsize = 2 ):eoSelectOne(), Tsize(_Tsize) { + // consistency check + if (Tsize < 2) { + cout << "Warning, Tournament size should be >= 2\nAdjusted\n"; + Tsize = 2; + } + } + + /// Perform deterministic tournament + virtual const EOT& operator()(const eoPop& pop) + { + return deterministic_tournament(pop, Tsize); + } + + private: + unsigned Tsize; +}; + +//----------------------------------------------------------------------------- + +#endif eoDetTournamentSelect_h + diff --git a/eo/src/eoEvolutionStrategy.h b/eo/src/eoEvolutionStrategy.h index ab626116..b863ae8a 100644 --- a/eo/src/eoEvolutionStrategy.h +++ b/eo/src/eoEvolutionStrategy.h @@ -73,7 +73,7 @@ class eoEvolutionStrategy: public eoAlgo eoPlus plus; eoNoElitism noElitism; eoTruncate truncate; - eoSelectRandom randomSelect; + eoRandomSelect randomSelect; eoSelectPerc selectPerc; eoInplaceTransform2 transform; diff --git a/eo/src/eoInplaceTransform.h b/eo/src/eoInplaceTransform.h index f1462408..17a358cc 100644 --- a/eo/src/eoInplaceTransform.h +++ b/eo/src/eoInplaceTransform.h @@ -123,7 +123,7 @@ template class eoInplaceTransform1 : public eoTransform private: eoOpSelector& opSel; - eoSelectRandom defaultSelect; + eoRandomSelect defaultSelect; eoSelectOne& select; }; @@ -181,7 +181,7 @@ template class eoInplaceTransform2 : public eoTransform private: eoGOpSelector& opSel; - eoSelectRandom defaultSelect; + eoRandomSelect defaultSelect; eoSelectOne& select; }; diff --git a/eo/src/eoMergeReduce.h b/eo/src/eoMergeReduce.h index 6a7aebf0..f0c6a1b5 100644 --- a/eo/src/eoMergeReduce.h +++ b/eo/src/eoMergeReduce.h @@ -94,5 +94,22 @@ class eoCommaReplacement : public eoMergeReduce eoTruncate truncate; }; +/** +EP type of replacement strategy: first add parents to population, + then truncate using EP tournament +*/ +template +class eoEPReplacement : public eoMergeReduce +{ +public : + eoEPReplacement(int _tSize) : eoMergeReduce(plus, truncate), truncate(_tSize) + // {truncate.setSize(_tSize);} + {} +private : + eoPlus plus; + eoEPReduce truncate; +}; + + #endif diff --git a/eo/src/eoProportionalSelect.h b/eo/src/eoProportionalSelect.h new file mode 100755 index 00000000..36a0da26 --- /dev/null +++ b/eo/src/eoProportionalSelect.h @@ -0,0 +1,71 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoProportionalSelect.h +// (c) GeNeura Team, 1998 - EEAAX 1999, Maarten Keijzer 2000 +/* + 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 + mak@dhi.dk + */ +//----------------------------------------------------------------------------- + +#ifndef eoProportionalSelect_h +#define eoProportionalSelect_h + +//----------------------------------------------------------------------------- + +#include +#include +#include + +//----------------------------------------------------------------------------- +/** eoProportionalSelect: select an individual proportional to her stored fitness + value + +*/ +//----------------------------------------------------------------------------- + +template class eoProportionalSelect: public eoSelectOne +{ +public: + /// Sanity check + eoProportionalSelect(const eoPop& pop = eoPop()): + total((pop.size() == 0) ? -1.0 : sum_fitness(pop)) + { + if (minimizing_fitness()) + throw logic_error("eoProportionalSelect: minimizing fitness"); + } + + void setup(const eoPop& _pop) + { + total = sum_fitness(_pop); + } + + /** do the selection, call roulette_wheel. + */ + const EOT& operator()(const eoPop& _pop) + { + return roulette_wheel(_pop, total) ; + } + +private : + typename EOT::Fitness total; +}; + +#endif + diff --git a/eo/src/eoRandomSelect.h b/eo/src/eoRandomSelect.h new file mode 100644 index 00000000..9d57e869 --- /dev/null +++ b/eo/src/eoRandomSelect.h @@ -0,0 +1,52 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoRandomSelect.h +// (c) GeNeura Team, 1998 - EEAAX 1999, Maarten Keijzer 2000 +/* + 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 + mak@dhi.dk + */ +//----------------------------------------------------------------------------- + +#ifndef eoRandomSelect_h +#define eoRandomSelect_h + +//----------------------------------------------------------------------------- + +#include +#include + +//----------------------------------------------------------------------------- +/** eoRandomSelect: a selection method that selects ONE individual randomly + -MS- 22/10/99 */ +//----------------------------------------------------------------------------- + +template class eoRandomSelect: public eoSelectOne +{ + public: + + /// not a big deal!!! + virtual const EOT& operator()(const eoPop& pop) + { + return pop[rng.random(pop.size())] ; + } +}; + +#endif eoRandomSelect_h + diff --git a/eo/src/eoReduce.h b/eo/src/eoReduce.h index 138dc59f..715a412c 100644 --- a/eo/src/eoReduce.h +++ b/eo/src/eoReduce.h @@ -69,7 +69,7 @@ template class eoEPReduce : public eoReduce public: typedef typename EOT::Fitness Fitness; - eoEPReduce(unsigned _t_size): + eoEPReduce(unsigned _t_size ): t_size(_t_size) { if (t_size < 2) @@ -79,17 +79,24 @@ typedef typename EOT::Fitness Fitness; } /// helper struct for comparing on pairs + // compares the scores + // uses the fitness if scores are equals ???? typedef pair::iterator> EPpair; - struct Cmp { - bool operator()(const EPpair a, const EPpair b) const - { return b.first < a.first; } - }; - - - void operator()(eoPop& _newgen, unsigned _newsize) - { - unsigned int presentSize = _newgen.size(); - if (presentSize == _newsize) + struct Cmp { + bool operator()(const EPpair a, const EPpair b) const + { + if (b.first == a.first) + return (*b.second < *a.second); + return b.first < a.first; + } + }; + + + void operator()(eoPop& _newgen, unsigned _newsize) + { + unsigned int presentSize = _newgen.size(); + + if (presentSize == _newsize) return; if (presentSize < _newsize) throw std::logic_error("eoTruncate: Cannot truncate to a larger size!\n"); @@ -107,12 +114,30 @@ typedef typename EOT::Fitness Fitness; scores[i].first += 0.5; } } + // now we have the scores typename vector::iterator it = scores.begin() + _newsize; - std::nth_element(scores.begin(), it, scores.end(), Cmp()); - it = scores.begin() + _newsize; // just in case ??? - while (it < scores.end()) - _newgen.erase(it->second); + std::nth_element(scores.begin(), it, scores.end(), Cmp()); + // sort(scores.begin(), scores.end(), Cmp()); + unsigned j; +// cout << "Les scores apres tri\n"; +// for (j=0; j tmPop; + for (j=0; j<_newsize; j++) + { + tmPop.push_back(*scores[j].second); + } + _newgen.swap(tmPop); + // erase does not work, but I'm sure there is a way in STL to mark + // and later delete all inside a vector ?????? + // this would avoid all copies here + +// it = scores.begin() + _newsize; +// while (it < scores.end()) +// _newgen.erase(it->second); } private: unsigned t_size; diff --git a/eo/src/eoSGATransform.h b/eo/src/eoSGATransform.h index 96a6e39e..63bd462a 100644 --- a/eo/src/eoSGATransform.h +++ b/eo/src/eoSGATransform.h @@ -91,7 +91,7 @@ template class eoSGATransform : public eoTransform }; /***************************************************************************** - * eoSDynGATransform: transforms a population using genetic operators. + * eoDynSGATransform: transforms a population using genetic operators. * It is the Dynamic version of the above eoSGATransform * i.e. the operators probabilities can be passed as an eoValueParam, * and hence can be modified from outside @@ -109,15 +109,15 @@ template class eoDynSGATransform : public eoTransform mutate(_mutate), mutationProbaHolder(_mProba), mutationProba(mutationProbaHolder) {} - /// This constructor receives references + /// This constructor receives pointers // these will usually be some eoValueParam.value() - // the ...Holder will bever be used in this object - eoDynSGATransform(eoQuadraticOp& _cross, double& _cProbaRef, - eoMonOp& _mutate, double& _mProbaRef) + // hence the ...Holder data will bever be used in this case + eoDynSGATransform(eoQuadraticOp& _cross, double* _cProbaRef, + eoMonOp& _mutate, double* _mProbaRef) : cross(_cross), - crossoverProbaHolder(0), crossoverProba(_cProbaRef), + crossoverProbaHolder(0), crossoverProba(*_cProbaRef), mutate(_mutate), - mutationProbaHolder(0), mutationProba(_mProbaRef) {} + mutationProbaHolder(0), mutationProba(*_mProbaRef) {} /** @@ -146,8 +146,11 @@ template class eoDynSGATransform : public eoTransform } }; - - private: + // accessors - mainly for EASEA + double & PCrossHandle() { return crossoverProba;} + double & PMutHandle() { return mutationProba;} + +private: // difference with eoSGATransform: the operator probabilities // they can be passed by reference or by value. // hence we need here to use a reference, and to eventually store a value diff --git a/eo/src/eoStochTournamentSelect.h b/eo/src/eoStochTournamentSelect.h new file mode 100755 index 00000000..0b9989e3 --- /dev/null +++ b/eo/src/eoStochTournamentSelect.h @@ -0,0 +1,69 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoStochTournamentSelect.h +// (c) GeNeura Team, 1998 - EEAAX 1999 +/* + 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 + */ +//----------------------------------------------------------------------------- + +#ifndef eoStochTournamentSelect_h +#define eoStochTournamentSelect_h + +//----------------------------------------------------------------------------- + +#include +#include // accumulate +#include // eoSelectOne +#include // stochastic_tournament + +//----------------------------------------------------------------------------- +/** eoStochTournamentSelect: a selection method that selects ONE individual by + binary stochastic tournament + -MS- 24/10/99 */ +//----------------------------------------------------------------------------- + +template class eoStochTournamentSelect: public eoSelectOne +{ + public: + + /// + eoStochTournamentSelect(float _Trate = 1.0 ) : eoSelectOne(), Trate(_Trate) + { + // consistency check + if (Trate < 0.5) { + cerr << "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n"; + Trate = 0.55; + } + } + + /** Perform the stochastic tournament */ + virtual const EOT& operator()(const eoPop& pop) + { + return stochastic_tournament(pop, Trate); + } + +private: + float Trate; +}; + +//----------------------------------------------------------------------------- + +#endif eoStochTournamentSelect_h + diff --git a/eo/src/eoDetTournament.h b/eo/src/obsolete/eoDetTournament.h similarity index 100% rename from eo/src/eoDetTournament.h rename to eo/src/obsolete/eoDetTournament.h diff --git a/eo/src/eoProportional.h b/eo/src/obsolete/eoProportional.h similarity index 100% rename from eo/src/eoProportional.h rename to eo/src/obsolete/eoProportional.h diff --git a/eo/src/eoSelectRandom.h b/eo/src/obsolete/eoSelectRandom.h similarity index 100% rename from eo/src/eoSelectRandom.h rename to eo/src/obsolete/eoSelectRandom.h diff --git a/eo/src/eoStochTournament.h b/eo/src/obsolete/eoStochTournament.h similarity index 100% rename from eo/src/eoStochTournament.h rename to eo/src/obsolete/eoStochTournament.h diff --git a/eo/test/t-eoReplacement.cpp b/eo/test/t-eoReplacement.cpp index 2806b1b8..fef8b247 100644 --- a/eo/test/t-eoReplacement.cpp +++ b/eo/test/t-eoReplacement.cpp @@ -103,6 +103,7 @@ cout << "Initial parents (odd)\n" << orgParents << "\n And initial offsprings (e // the replacement procedures under test eoGenerationalReplacement genReplace; eoPlusReplacement plusReplace; + eoEPReplacement epReplace(tSize); eoCommaReplacement commaReplace; eoWeakElitistReplacement weakElitistReplace(commaReplace); // the SSGA replacements @@ -129,6 +130,15 @@ cout << "Parents (originally odd)\n" << parents << "\n And offsprings (orogonall plusReplace(parents, offspring); cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << endl; + // EP (proche d'un PLUS + parents = orgParents; + offspring = orgOffspring; + + cout << "eoEPReplacement\n"; + cout << "===============\n"; + epReplace(parents, offspring); +cout << "Parents (originally odd)\n" << parents << "\n And offsprings (originally even)\n" << offspring << endl; + // Comma parents = orgParents; offspring = orgOffspring; diff --git a/eo/test/t-eoSymreg.cpp b/eo/test/t-eoSymreg.cpp index 3f5d62a1..21a0d94d 100644 --- a/eo/test/t-eoSymreg.cpp +++ b/eo/test/t-eoSymreg.cpp @@ -235,7 +235,7 @@ int main() seqSel.addOp(mutation, 0.25); seqSel.addOp(xover, 0.75); - eoDetTournament selector(5); + eoDetTournamentSelect selector(5); eoDetTournamentInserter inserter(eval, 5); diff --git a/eo/test/t-eobin.cpp b/eo/test/t-eobin.cpp index e4a9802e..55dee20b 100644 --- a/eo/test/t-eobin.cpp +++ b/eo/test/t-eobin.cpp @@ -147,7 +147,7 @@ void main_function() monitor.add(stats); checkpoint.add(stats); - eoProportional select; + eoProportionalSelect select; eoEvalFuncPtr eval(binary_value); eoSGA sga(select, xover, 0.8f, bitflip, 0.1f, eval, checkpoint); diff --git a/eo/tutorial/Lesson1/FirstBitGA.cpp b/eo/tutorial/Lesson1/FirstBitGA.cpp index db7dc22c..97b5a0f8 100644 --- a/eo/tutorial/Lesson1/FirstBitGA.cpp +++ b/eo/tutorial/Lesson1/FirstBitGA.cpp @@ -94,7 +94,7 @@ void main_function(int argc, char **argv) //////////////////////////////////// // SELECT // The robust tournament selection - eoDetTournament select(T_SIZE); // T_SIZE in [2,POP_SIZE] + eoDetTournamentSelect select(T_SIZE); // T_SIZE in [2,POP_SIZE] // REPLACE // The simple GA evolution engine uses generational replacement diff --git a/eo/tutorial/Lesson1/FirstRealGA.cpp b/eo/tutorial/Lesson1/FirstRealGA.cpp index ff1cadd3..f1b719a6 100644 --- a/eo/tutorial/Lesson1/FirstRealGA.cpp +++ b/eo/tutorial/Lesson1/FirstRealGA.cpp @@ -94,7 +94,7 @@ void main_function(int argc, char **argv) //////////////////////////////////// // SELECT // The robust tournament selection - eoDetTournament select(T_SIZE); // T_SIZE in [2,POP_SIZE] + eoDetTournamentSelect select(T_SIZE); // T_SIZE in [2,POP_SIZE] // REPLACE // eoSGA uses generational replacement by default diff --git a/eo/tutorial/Lesson2/FirstBitEA.cpp b/eo/tutorial/Lesson2/FirstBitEA.cpp index 331afbec..0c34adae 100644 --- a/eo/tutorial/Lesson2/FirstBitEA.cpp +++ b/eo/tutorial/Lesson2/FirstBitEA.cpp @@ -95,7 +95,7 @@ void main_function(int argc, char **argv) //////////////////////////////////// // SELECT // The robust tournament selection - eoDetTournament selectOne(T_SIZE); // T_SIZE in [2,POP_SIZE] + eoDetTournamentSelect selectOne(T_SIZE); // T_SIZE in [2,POP_SIZE] // is now encapsulated in a eoSelectPerc (entage) eoSelectPerc select(selectOne);// by default rate==1 diff --git a/eo/tutorial/Lesson2/FirstRealEA.cpp b/eo/tutorial/Lesson2/FirstRealEA.cpp index 43256c70..603b6a32 100644 --- a/eo/tutorial/Lesson2/FirstRealEA.cpp +++ b/eo/tutorial/Lesson2/FirstRealEA.cpp @@ -93,7 +93,7 @@ void main_function(int argc, char **argv) //////////////////////////////////// // SELECT // The robust tournament selection - eoDetTournament selectOne(T_SIZE); + eoDetTournamentSelect selectOne(T_SIZE); // is now encapsulated in a eoSelectPerc (entage) eoSelectPerc select(selectOne);// by default rate==1 diff --git a/eo/tutorial/Lesson3/SecondBitEA.cpp b/eo/tutorial/Lesson3/SecondBitEA.cpp index ebdae5e6..5ec56882 100644 --- a/eo/tutorial/Lesson3/SecondBitEA.cpp +++ b/eo/tutorial/Lesson3/SecondBitEA.cpp @@ -184,11 +184,9 @@ void main_function(int argc, char **argv) //////////////////////////////////// // SELECT // The robust tournament selection - eoDetTournament selectOne(tSize); // tSize in [2,POPSIZE] + eoDetTournamentSelect selectOne(tSize); // tSize in [2,POPSIZE] // is now encapsulated in a eoSelectPerc (stands for Percentage) eoSelectPerc select(selectOne); - // or eoSelectPerc select(selectOne, rate); - // but by default rate==1 // REPLACE // And we now have the full slection/replacement - though with diff --git a/eo/tutorial/html/FirstBitEA.html b/eo/tutorial/html/FirstBitEA.html index 9474a5fa..0663d8a2 100644 --- a/eo/tutorial/html/FirstBitEA.html +++ b/eo/tutorial/html/FirstBitEA.html @@ -201,7 +201,7 @@ The actual code is in boldface and the comment in normal face.  // The robust tournament selection
-  eoDetTournament<Indi> selectOne(T_SIZE);            // T_SIZE in [2,POP_SIZE]
+  eoDetTournamentSelect<Indi> selectOne(T_SIZE);            // T_SIZE in [2,POP_SIZE]
 // is now encapsulated in a eoSelectPerc (entage)
 eoSelectPerc<Indi> select(selectOne);// by default rate==1
diff --git a/eo/tutorial/html/FirstBitGA.html b/eo/tutorial/html/FirstBitGA.html index ef40176a..e6e4368e 100644 --- a/eo/tutorial/html/FirstBitGA.html +++ b/eo/tutorial/html/FirstBitGA.html @@ -209,7 +209,7 @@ The actual code is in boldface and the comment in normal face.  // The robust tournament selection
-  eoDetTournament<Indi> select(T_SIZE);  // T_SIZE in [2,POP_SIZE]
+  eoDetTournamentSelect<Indi> select(T_SIZE);  // T_SIZE in [2,POP_SIZE]
diff --git a/eo/tutorial/html/FirstRealEA.html b/eo/tutorial/html/FirstRealEA.html index fb524dea..79387472 100644 --- a/eo/tutorial/html/FirstRealEA.html +++ b/eo/tutorial/html/FirstRealEA.html @@ -202,7 +202,7 @@ The actual code is in boldface and the comment in normal face.  // The robust tournament selection
-  eoDetTournament<Indi> selectOne(T_SIZE);
+  eoDetTournamentSelect<Indi> selectOne(T_SIZE);
 // is now encapsulated in a eoSelectPerc (entage)
 eoSelectPerc<Indi> select(selectOne);// by default rate==1
diff --git a/eo/tutorial/html/FirstRealGA.html b/eo/tutorial/html/FirstRealGA.html index 40224cf9..b375629f 100644 --- a/eo/tutorial/html/FirstRealGA.html +++ b/eo/tutorial/html/FirstRealGA.html @@ -209,7 +209,7 @@ The actual code is in boldface and the comment in normal face.  // The robust tournament selection
-  eoDetTournament<Indi> select(T_SIZE);            // T_SIZE in [2,POP_SIZE]
+  eoDetTournamentSelect<Indi> select(T_SIZE);            // T_SIZE in [2,POP_SIZE]
diff --git a/eo/tutorial/html/NoWay.html b/eo/tutorial/html/NoWay.html index de53a993..0976a771 100644 --- a/eo/tutorial/html/NoWay.html +++ b/eo/tutorial/html/NoWay.html @@ -2,15 +2,15 @@ - + Tutorial: Solutions Tutorial main page - -Algorithm-Based -page - Component-Based - Programming -hints -EO -documentation +Algorithm-Based +- Component-Based - Programming +hints -EO +documentation

@@ -36,8 +36,9 @@ according to the corresponding instructions of the exercise
  • compile mytest.cpp by typing -make mytest at system prompt, -and you will hopefully get an executable file named mytest +make +mytest at system prompt, and you will hopefully get an +executable file named mytest (for Unix systems: if eventually someone tells me how to do that in Windows, apart that you'll probably end up with an executable file named mytest.exe...).
  • @@ -46,23 +47,25 @@ apart that you'll probably end up with an executable file named What you may do later:

    All solutions to exercises are in the same sub-dir of the Tutorial directory than the example files (i.e. -Lesson1 for Lesson1, yes!). Hence you may browse through the code, eventually -modifying it, and then simply type, in the corresponding directory, -
    ... % make exerciseN -
    which will compile file exerciseN.cpp -into executable exerciseN +Lesson1 for Lesson1, yes!) and are named exerciseN.p.cpp +where N is the lesson number and p the exercise number. Hence you may browse +through the code, eventually modifying it, and then simply type, in the +corresponding directory, +
    ... % make exerciseN.p +
    which will compile file exerciseN.p.cpp +into executable exerciseN.p (for Unix systems: if eventually someone tells me how to do that in Windows, -you'll probably end up with an executable file named exerciseN.exe). +you'll probably end up with an executable file named exerciseN.p.exe).



    What you may not do:
    Complain that it does not work under Windows :-)

    Tutorial main page - -Algorithm-Based -page - Component-Based - Programming -hints - EO -documentation +Algorithm-Based +- Component-Based - Programming +hints - EO +documentation

    diff --git a/eo/tutorial/html/SecondBitEA.html b/eo/tutorial/html/SecondBitEA.html index 4061d9c0..c73bf43e 100644 --- a/eo/tutorial/html/SecondBitEA.html +++ b/eo/tutorial/html/SecondBitEA.html @@ -310,7 +310,7 @@ of initializatio of the population
     // The robust tournament selection -
     eoDetTournament<Indi> selectOne(tSize);       +
     eoDetTournamentSelect<Indi> selectOne(tSize);       // tSize in [2,POPSIZE]
     // is now encapsulated in a diff --git a/eo/tutorial/html/eoEngine.html b/eo/tutorial/html/eoEngine.html index ecd9d5ec..cfb095f8 100644 --- a/eo/tutorial/html/eoEngine.html +++ b/eo/tutorial/html/eoEngine.html @@ -42,21 +42,163 @@ helper classes that are used within selection and replacement procedures are presented.


    Selection -
      -
      +

    The very beginning of the generation loop is the selection phase, where +some individuals from the population are chosen to become the parents, +to be later modified by the variation operators and become the offspring. +This is the first step of the artificial Darwinism, +where the fittest individuals are allowed to reproduce. +
    Conceptually, there are two distinct ways to choose the lucky ones: +one by one from the very same population (i.e. with replacement), which +means that at the extreme the same individual can be chosen every time; +or as a whole, in some sort of batch procedure. Of course, repeated selection +of one individual results in a batch selection! +

    There are hence two basic EO classes for selection: eoSelectOne +and eoSelect, with different interfaces. +
    +


    +
    eoSelectOne: The +interface +

    The abstract class for selection of a single individual from a population +is eoSelectOne, and the interface for its +operator() +is +

    +

    const EOT & operator()(const eoPop<EOT>& +_parents)

    + +

    which you could have guessed from the inheritance tree for class eoSelectOne., +as you see there that eoSelectOne derives +from class eoUF<const eoPop<EOT>&, +const EOT&>. +
    This means that it takes 1 population +(without the right to modify it - see the const +keyword in argument) and returns a const reference to an individual (again, +the const keyword ensures +that nothing will happen to the individual in the population - remember +it returns a reference). +
    +


    +
    eoSelectOne: Instances +
      +
    • +eoDetTournamentSelect uses +the (deterministic) tournament to choose one +individual. Its constructor has one parameter, the tournament size (integer +>= 2).
    • + +
    • +eoStochTournamentSelect uses +the binary stochastic tournament to choose +one individual. Its constructor has one parameter, the tournament rate +(real in [0.5,1]).
    • + +
    • eoProportionalSelect +is the original roulette wheel selection: +each parent is selected with a probability proportional to its fitness.
    • + +
    • +eoRandomSelect is the random +selection and should give bad results! At the moment, it selects one individual +uniformly, but it would be easy to use any probability distribution.
    • +
    + +
    +
    eoSelect: The +interface +

    The abstract class for batch selection of a  whole set of individuals +from a population is eoSelect, and the interface +for its +operator() is +

    +

    void operator()(const eoPop<EOT>& +_source, eoPop<EOT>& _dest)

    + +

    which you could have guessed from the inheritance tree for class eoSelect., +as you see there that eoSelect derives from +class +eoBF<const eoPop<EOT>&, eoPop<EOT>&, void>. +
    This means that it takes 2 populations, +and fills the second one with individuals from the first one without modifying +it (see the const keyword). +This raises two questions: +

      +
    • +How does it know how many individuals to select?
    • + +
    • +How to use repeated selection of one individual (see above the eoSelectOne +class)?
    • +
    + +
    +
    eoSelect: HowMany +

    There are two ways an  can derive the number of individuals it +has to select: either it is a fixed number, or it is some percentage of +the source population size (any positive real number). In both case, this +must be passed to the constructor. In most instances, however, the constructor +will accept a real number (double) and a boolean indicating whether this +real number should be used as an absolute integer or as a rate, thanks +to the eoHowMany class. +

    Note: an eoSelect +can select more individuals than there are in the original population. +It is the job of the replacement to ensure +that the population size does not grow along the generations.

    +


    eoSelectMany: Encapsulating +eoSelectOne +

    It is clear that repeated selection of a single individual is a way +to do batch selection. This is why it is possible to encapsulate an object +of class eoSelectOne into an object of class +eoSelect +using the class eoSelectMany. Class eoSelectMany +is derived from class eoSelect and takes in +its constructor an eoSelectOne (plus the number +of individuals it should select, according to the eoHowMany +paradigm). +

    Note: some procedures for selecting +a single individual require some pre-processing of the whole population +that takes place before any selection, and will be repeated identically +for every individual. The encapsulation of an  into an  allows +to call such technical processing only once through the use of method setup +of class . This method does nothing by default, but is mandatory +
    +


    +
    eoSelect: Other +instances +
      +
    • +eoDetSelect selects individuals +deterministically, +i.e. starting from the best ones down to the worse ones. If the total number +to select is less than the size of the source populations, the best individuals +are selected once. If more individuals are needed after reaching the bottom +of the population, then the selection starts again at top. It the total +number required is N times that of the source size, all individuals are +selected exactly N times.
    • +
    +No other instances of eoSelect that are not +encapsualtions of eoSelectOne procedures are +avaiable as of today (Jan. 4 2001). +


    Replacement -

    The replacement phase takes place after the birth -of all offspring through variation operators. The idea is to close -the generation loop, i.e. to end up with a population of individuals that -will be the initial population of next generation. That population will -be built upon the old parents and the new-born offspring. -In all algorithms that come up with EO, the population -size is supposed to be constant from -one generation to the next one - though nothing stops you from writing -an algorithm with varying population size. -

    Replacement: The +

    The replacement phase takes place after the birth +of all offspring through variation operators. This is the second +step of the artificial Darwinism, where the +fittest +individuals are allowed to survive. +
    It can also be viewed on the algorithmic side as closing the generation +loop, i.e. building the population that will be the initial population +of next generation. That population will be built +upon the old parents and the new-born offspring. In all algorithms +that come up with EO, the population size +is supposed to be constant from one generation +to the next one - though nothing stops you from writing an algorithm with +varying population size. +
    +


    +
    Replacement: The interface

    The abstract class for replacement procedures is the functor class eoReplacement, @@ -75,7 +217,9 @@ void>. and is free to modify both, but the resulting population should be placed in the first argument (usually called_parents) to close the loop and go to next generation. -

    Replacement: Instances +
    +


    +
    Replacement: Instances

    The other useful component of replacement procedures, eoReduce, kills some individuals from a given population. -

    eoReduce: interface +
    +


    +
    eoReduce: interface
    The abstract class for reducing procedures is the functor class eoReduce, and the interface for its operator() @@ -311,7 +470,9 @@ as you see there that eoReduce derives from int, void>
    .
    An eoReduce shoud take a population and shrink it to the required size. -

    eoReduce: instances +
    +


    +
    eoReduce: instances
    Available instances of eoReduce are
    • @@ -347,7 +508,6 @@ the population. It requires the rate of the tournament (
      eoHowMany: Choosing a number of individuals @@ -366,7 +526,9 @@ It receives a double, and a boolean indicating whether that double is to be treated as a rate or as an absolute (unisgned) interger. -

      eoHowMany: interface +
      +


      +
      eoHowMany: interface
      The class interface for its operator() is
      diff --git a/eo/tutorial/html/eoLesson1.html b/eo/tutorial/html/eoLesson1.html index 22a09acb..581b07f2 100644 --- a/eo/tutorial/html/eoLesson1.html +++ b/eo/tutorial/html/eoLesson1.html @@ -358,27 +358,30 @@ are available!
    • You already know the tournament selection
    • -
      Syntax:  eoDetTournament<Indi> +
      Syntax:  eoDetTournamentSelect<Indi> select(T_SIZE);   // T_SIZE in [2,POP_SIZE)
    • Try the well-known roulette wheel
    • -
       Syntax:    eoProportional<Indi> +
       Syntax:    eoProportionalSelect<Indi> select;
    • Or the stochastic binary tournament
    • -
      Syntax:  eoStochTournament<Indi> -select(RATE);     // RATE in ]0.5,1] +
      Syntax:  eoStochTournamentSelect<Indi> +select(RATE);     +// RATE in ]0.5,1]
    • and of course the random selection should give bad results!
    • -
      Syntax:  eoSelectRandom<Indi> +
      Syntax:  eoRandomSelect<Indi> select;
    Note that all these classes of eoObjects are derived from the abstract class eoSelectOne. +To find out exactly how each procedure selects the individuals, read the +corresponding component-based page.


    Lessons learned:
      diff --git a/eo/tutorial/html/eoLesson2.html b/eo/tutorial/html/eoLesson2.html index 6e0a4d34..5e7b50e9 100644 --- a/eo/tutorial/html/eoLesson2.html +++ b/eo/tutorial/html/eoLesson2.html @@ -69,6 +69,10 @@ object that is a sub-class of the corresponding STL vector class.
       

        +
        +
        +
        +
       

      Note: Also, a non-templatized fitness can be compiled separately (not done here) into an object @@ -88,6 +92,8 @@ requires.

       
       
        +
        +
       

      Note: In the previous files (Bit - Real) , the last 2 types were deduced from the first (2nd argument = fitness @@ -113,6 +119,10 @@ call to pop.append() function
       

        +
        +
        +
        +
       

      Note: Don't forget to evaluate the population: the eoPop has no idea of the eval function, so it has to be done from outside!!! @@ -263,7 +273,7 @@ the population in [-2,-1] and the other half in [1,2], with and without the segment and arithmetic crossovers (and for large values of VEC_SIZE, the size of the vectors). Amazing, isn't it! Explain that result.

      Exercise -3:  replacement +3:  full selection/replacement
      You can now twiddle the number of offspring that will be generated from the parents. But of course you need to adjust the replacement to keep a constant population size. @@ -281,6 +291,14 @@ into an eoSelectPerc object. For instance, try eoSelectPerc<Indi> select(selectOne,2.0)

      to generate twice as many offspring as there are parents. +
      You can also use the other encapsulator that +takes as second argument an absolute number (e.g. if you want to generate +2 offspring whatever the population size): +
                      +eoSelectNumber<Indi> select(selectOne,2) +
      Or you can use the HowMany +paradigm and the eoSelectMany to +do either one depending on some command-line input (advanced).

    • To keep a constant population size, you can use either the eoCommaReplacement @@ -297,21 +315,14 @@ or Strategies.
    • Question: what do you -get if you have use a rate of 1/POP_SIZE for the selection, and an eoPlusReplacement +get if you select 1 offspring only, and an eoPlusReplacement strategy? Yes, you get almost the replace_worst Steady-State GA, though -rather inefficient, as you sort the population at every generation, which -could be avoided - and will be in a later lesson).
    • +rather inefficient, as you sort the population at every generation.
    • -Homework: Write the -eoCommaPlusReplacement -that would start by taking the best of the offspring, and if some are still -missing to keep the population size constant, take the best of the parents. -Write the eoConservativeReplacement -that starts by taking a percentage of the parents (the best ones) and then -adds the best from the offspring. In both cases, send -use the code as we haven't done that yet (and -hence there is no solution available at the moment - Nov. 29 :-)
    • +Hint: there are a few +Steady-State replacement strategies already there in EO. See the Replacement +page.
    Remember: all solutions are in the same sub-directory of the Tutorial dir than the examples (i.e. diff --git a/eo/tutorial/html/eoLesson3.html b/eo/tutorial/html/eoLesson3.html index b69671cc..ef4c3f87 100644 --- a/eo/tutorial/html/eoLesson3.html +++ b/eo/tutorial/html/eoLesson3.html @@ -12,8 +12,8 @@ Main page - Algorithm-Based - Component-Based - Hints -- EO -documentation +- EO +documentation

    @@ -102,14 +102,10 @@ operators and the evolution engine&nbs sections are similar to the ones in Lesson2
  • -The parameter section  -is completely different from the previous one. All variables corresponding -to program parameters -are now declared -in the main_function -(as before), but their values are set in a new -function, called read_param. -See the eoParser description for more details.
  • +The parameter +section  is completely different from the previous one. All variables +corresponding to program parameters +are now read at run-time using an object of class eoParser.
  • The stopping criterion @@ -145,7 +141,9 @@ See the parameter section of the Component-Based tutorial, or wait until The eoParser class, whose only purpose is the input of parameters.
  • -Modifying parameter values at run-time: + +
    eoParser: +Modifying parameter values at run-time:
    Using an eoParser object, the parameter values are read, by order of priority
      @@ -173,7 +171,7 @@ and optionally by a short (1 character) keyword. -
                        +
                     --longKeyword=value     or     -c=value    @@ -184,12 +182,12 @@ so, after compiling the executable for Lesson 3 (ma lesson3 at system prompt in Unix), you can try to type in -
                         +
                      SecondBitEA
      and see the algorithm run as before (OneMax optimized on 8-bits bitstrings). But you can now type in -
                         +
                      SecondBitEA --vecSize=100
      and see the output of the optimization of OneMax on 100-bit bitstrings. @@ -197,7 +195,7 @@ But you can now type in
    1. Take a look at all available parameters by typing in
    2. -
                         +
                      SecondBitEA --help
      or by going into the code: all parameter inputs have been grouped in @@ -210,7 +208,7 @@ it contains the list of all actual parameters used, and can directly be used as parameter input file: change the file name (e.g. to SecondBitEA.param), edit it, change whichever parameter you want, and type in -
                           +
                        SecondBitEA @SecondBitEA.param
      and you will see all values that you defined into the file taken into account. @@ -220,9 +218,12 @@ The priority remains to the c so you can still override the values in the parameter file by giving a new value directly on the command-line. -Programming parameter input: -
      the code of SeconBitEA provides examples of parameters reading. Lets -take the example of the random number generator seed.  + +
      eoParser: +Programming parameter input: +
      The code of SeconBitEA provides examples of parameters reading. Lets +take the example of the
      random number +generator seed.  Of course, you first need to declare an eoParser object (it needs the standard argc and argv in its constructor).
        @@ -240,7 +241,11 @@ that will be used to make the output of the parser look clean and ordered.
      • Finally, you need to assign the -value to the variable seed
      • +value to the variable seed. +Note that the value() method +of eoParam returns a reference, so you can eventually modify its value +somewhere else later (though of course this is not any useful for variable +seed!).

      @@ -296,16 +301,16 @@ an object whose
      operator()
      -
      eoCheckpoint: -Stopping +
      eoCheckpoint: +Stopping
      The eoContinue part of an eoCheckpoint is a single object, passed to the constructor. If you want more that one stopping criterion, use an eoCombinedContinue object as described in Lesson2.
      -
      -
      eoCheckpoint: Computing +
      +
      eoCheckpoint: Computing statistics
      Statistics are computed using eoStat objects, i.e. functor objects whose operator() @@ -322,9 +327,10 @@ objects. And this allows eoStat< to be used within
      eoMonitor object, and hence displayed to the user! -

      Available statistics: Some widely -used statistics are already available (and of course you can build you -own!). +

      Statistics: Available +instances +
      Some widely used statistics are already available (and of course you +can build you own!).

      • eoBestFitnessStat returns @@ -344,28 +350,33 @@ diversity in the population: assuming that there is a distance function defined among individuals, it returns the average inter-individuals distance. See also Exercise 2.
      -Programming: To compute some statistics -within your algorithm, simply declare +Statistics: Adding +to the checkpoint +
      To compute more statistics when your algorithm is running, simply declare the corresponding eoStat objects, and add them to the eoCheckpoint you -use in the algorithm. +use in the algorithm. But it hardly makes any sense if you don't monitor +those statistics (i.e. either displaying them on the screen, or storing +them into a file): see next section!

      Note: actually, there are 2 distinct classes that compute and give access to statistics: eoStatand eoSortedStat. As its name indicate, the latter is used whenever computing the statistics require a sorted population: not only this avoids to sort the population many times, but also it avoids changing the order of the population at -all as eoSortedStat work on a temporary vector of fitnesses . But as +all as eoSortedStat objects +work on a temporary vector of fitnesses . But as far as their usage is concerned, its makes no difference.
      -


      -
      eoCheckpoint: Displaying +
      +
      eoCheckpoint: Monitoring eoParameters
      The eoMonitor -objects are used to display a set of eoValueParam +objects are used to display or store to a file a set of eoValueParam objects. -

      Available monitors: A few monitors -are available in the EO distribution: +

      Monitors: Available +instances +
      A few monitors are available in the EO distribution:

      • eoStdoutMonitor displays its @@ -394,15 +405,16 @@ at the end of the run, while it is otherwise kept (though it will be overwritten by next call to the same program).
      -


      Programming: To display something -while the algorithm is running, you need to declare +


      Monitors: Adding +to the checkpoint +
      To display something while the algorithm is running, you need to declare an eoMonitor object, add some objects (that must be eoValueParam objects) to that monitor, and of course add the monitor to the eoCheckpoint you use in the algorithm.
      -


      +

      eoCheckpoint: Updating things
      The last type of objects that  eoCheckpoint @@ -411,8 +423,8 @@ objects. You should simply encapsulate in an operator() method does not receive any argument. -

      Available monitors: A few updaters -are available in the EO distribution: +

      Updater: Available +instances: A few updaters are available in the EO distribution:

      • eoIncrementor A simple updater @@ -430,7 +442,8 @@ be used to save some existing Programming: +Updater: Adding to +the checkpoint
        A very simple example of using an eoUpdater is given in the code for SecondBitEA: First declare an eoValueParam object, then @@ -468,8 +481,8 @@ otherwise the standard deviations won't make any sense here.
      • Then run
      • -
                  -exercise1 --vecSize=1000 --maxGen=1000 +
                  +exercise1 --vecSize=1000 --maxGen=1000
        to get a chance to see something happening before the program ends!
      @@ -479,9 +492,9 @@ stat computation and test it. Thanks to send us the code!



      Exercise 3: -
      Write the code for an eoGnuplot1DwithErrorbarsMonitor -that would take into account the standard deviations and display them as -error-bars. +
      Write the code for an eoGnuplotSecondStatMonitor +that would display the eoSecondMomentStat +(i.e. take into account the standard deviations and display them as error-bars.
      Again, send us the code afterwards, thanks :-)

      @@ -489,32 +502,30 @@ error-bars.
      • Value of program parameters can be set at run-time -using the eoParser -class.
      • +using the eoParser class.
      • Snapshots of the algorithms can easily be saved (and restored) -thanks to the eoState -class.
      • +thanks to the eoState class.
      • -The eoCheckpoint -mechanism let you do things every generation +The eoCheckpoint mechanism +let you do things every generation without modifying existing algorithms, by simply writing the necessary -code and encapsulating it into an object that eoCheckpoint +code and encapsulating it into an object that eoCheckpoint is aware of, that are at the moment the following:
      • computing statistics, displaying parameters (e.g. statistics),  saving the -(eo)State +(eo)State of the program.
      In next lesson you will find out that many adaptive techniques (the state-of-the-art in Evolutionary Computation) can easily -be programmed through the eoUpdater +be programmed through the eoUpdater construct.

      Lesson 2 - @@ -523,14 +534,14 @@ construct. Main page - Algorithm-Based - Component-Based - Hints -- EO -documentation +- EO +documentation

      Marc Schoenauer

      Last -modified: Mon Nov 27 8:49:12 CET 2000 +modified: None of your business! - + diff --git a/eo/tutorial/html/eoTopDown.html b/eo/tutorial/html/eoTopDown.html index a4448d19..9ae7e34a 100644 --- a/eo/tutorial/html/eoTopDown.html +++ b/eo/tutorial/html/eoTopDown.html @@ -26,9 +26,9 @@ of "lessons" for you.
    3. Lesson 1 - a gentle introduction to the EO way: your first steps into EO representations -using a simple generational GA. Please, spend -the necessary time on that one, since all basic constructs presented -there are used throughout EO.
    4. +using a simple generational GA. Please, spend +the necessary time on that one, since all basic constructs +presented there are used throughout EO.
    5. Lesson 2 - encapsulate, @@ -47,32 +47,40 @@ populations, restart stopped runs, ...).
    6. -
        -

        -

      Current version (Nov. 29, 2000) stops here, but here are the plans (subjected -to many changes, of course!) +


      Current version (Jan. 5, 2001) stops here, but ... +

      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 :-)
       

    7. -Lesson 4 - More about checkpointing: write your first adaptive -mechanism, and find out how easy it is to update -and monitor dynamic -parameters
    8. +Lesson 4 - More about checkpointing: +write your first adaptive mechanism, +and find out how easy it is to update +and monitor dynamic +parameters
    9. -Lesson 5 - more general operators: e.g. binary, n-ary, or even specific -mate selection (your brain and my beauty)!
    10. +Lesson 5 - More general operators: +e.g. binary, n-ary, or even specific mate selection (your brain and my +beauty)!
    11. -Lesson 6 - why not go parallel? From the simple asynchronous SSGA to the -more sophisticated island model (no totally distributed population yet).
    12. +Lesson 6 - Why not go parallel? From +the simple asynchronous SSGA to the more sophisticated island model (no +totally distributed population yet).
    13. -Lesson 7 - ...
    14. +Lesson 7 - Use your own representation. +You need only to write the base individual class, the initilization class +and the variation operators. EO provides many helps: The eoExternal +paradigm let you encapsulate into EO classes existing code. And the eoFixedLength +and eoVariableLength super classes +allow quick definition of new genotypes that handle identical Atoms. -Of course, in each lesson, you have links to the Component-Based of the -corresponding component of an EA you are modifying. -
      ( ... Well, to tell you the truth, as of today, November 28, this is -not true :-) +Of course, in each lesson, you have links to the corresponding Component-Based +page. ( ... Well, to tell you the truth, as of today, Jan. 5, 2001, this +is not exactly true :-)


      Tutorial main page - Algorithm-Based diff --git a/eo/tutorial/html/index.html b/eo/tutorial/html/index.html new file mode 100644 index 00000000..00734f65 --- /dev/null +++ b/eo/tutorial/html/index.html @@ -0,0 +1,199 @@ + + + + + + Tutorial EO + + +Algorithm-Based - Component-Based +- Programming hints - EO +documentation +
      +
      Welcome to EO, the Evolving Objects library, +and to +  +

      +EO Tutorial

      + +
      Version 0.92 - Jan. 5 2001
      + +

      The short term idea of this tutorial is to help you build +your own Evolutionary Algorithms using EO - while the long term +idea is that you will be able to contribute to EO, and ultimately write +our +EAs :-) +

      + +
      About this tutorial

      +This tutorial can be used in 2 different ways: algorithm-based and component-based. +
        +
      • +Algorithm-Based means you start from a very +simple, ready-to-run algorithm, and gradually modify it, making +it both more powerful and more complex.
      • + +
      • +Component-Based means you start by examining +the +components of an EA one by one, down to +the level of complexity you feel comfortable with, and then build the whole +algorithm using those components you need (or the one you are mastering). +Such approach might be viewed as going through a simplified user guide, +too.
      • +
      +However, it is strongly recommended +that you take some time on the first lesson of the Algorithm-Based approach +to get familiar with the basic concepts that are used throughout EO. Anyway, +as of today, December 19, the Component-Based is only very sparsely written +:-) +

      +


      Links and Related +documents +
        +
      • +There are of course a few (very few) programming +hints that you should know.
      • + +
      • +THe EO documentation - automatically +generated from the comments in the code - is very helpful to get an idea +of the inheritance diagrams of EO classes, +and to quickly reach some specific part of the code.
      • + +
        The top page of each class documentation is for instance the inheritance +diagram of the class, and you'll learn a lot by simply looking at it. +
      • +And, last but not least, we assume you know approximately that an Evolutionary +Algorithm looks like this, but otherwise you can try this very +brief introduction (not written yet, Jan. 2001, sorry).
      • +
      + +


      +


      Colors and navigation: +

      You will see this diagram in quite many places, as for instance at the +top of all examples - usually it will be clickable and will help you navigate +among the different parts of an EO program. See the brief +introduction to Evolutionary Computation for a detailed explanation. +

      +

      + +

      But in the text itself, colors are important, +as they will be used throughout this tutorial to clearly mark which part +of the algorithm we are discussing. So please keep in mind that, whereas +orange +is for emphasis, +

        +
      • +Yellowish is for representation, +i.e. the choice of the genotype
      • + +
      • +Magenta is for the stochastic +operators that are representation-dependent, +i.e. initialisation and variation operators +(crossover, mutation +and the like).
      • + +
      • +Green is for the implementation of Darwinism, +i.e. the way the individuals are selected +for reproduction and survive.
      • + +
      • +Red is for evaluation, i.e. the computation +of the fitness of all individuals
      • + +
      • +Blue is for interactions of the user and the +program, as for instance choice of stopping criterion, +on-line display of nice statistics or initial +choice +of all program parameters.
      • + +
      • +Brown is for everything that is NOT part of +any of the above, i.e. random number generator, or basic C++/STL syntax +.
      • + +
      • +Note that pink will be used to describe the +syntax of compile orders (i.e. at the operating system level, see e.g. +below).
      • + +
      • +Last, but not least, all +links into EO documentation will use the Helvetica typeface, like this +line you are now reading.
      • +
      + +
      This tutorial is +not +
        +
      • +A course on Evolutionary Computation. You can find such things on the Internet, +maybe you can start here.
      • + +
      • +An interface that would allow you to build your Evolutionary Programs by +a few clicks; such a thing does exist, is called EASEA, +and is complementary to this tutorial as it helps the user to build some +simple EO programs from simple description. But there are things that EASEA +cannot do, and you will have to do it yourself and will need to increase +your knowledge about EO for that - hence this tutorial.
      • + +
      • +A coffee machine - though you might want to spend some time here when you're +tired of everything else, to improve your knowledge of EO slowly and gradually +rather than when you have something urgent to code :-)
      • +
      + +
      Before +you start +

      You should of course have downloaded and installed the whole EO +library (how did you get this file if not???). +
      So we'll assume that you are now in the Tutorial directory, and that +your prompt looks something like +

      (myname@myhost) EOdir/Tutorial % +

      so you should now type in +

      make lesson1 +

      and see something like +

      (myname@myhost) +EOdir/Tutorial % make lesson1 +
      c++ -DPACKAGE=\"eo\" -DVERSION=\"0.9.1\" +-I. -I../../src -Wall -g -c FirstBitGA.cpp +
      c++ -Wall -g -o FirstBitGA FirstBitGA.o +../../src/libeo.a ../../src/utils/libeoutils.a +
      c++ -DPACKAGE=\"eo\" -DVERSION=\"0.9.1\" +-I. -I../../src -Wall -g -c FirstRealGA.cpp +
      c++ -Wall -g -o FirstRealGA FirstRealGA.o +../../src/libeo.a ../../src/utils/libeoutils.a +

      and two now executable files should have appeared in the subdirectory +Lesson1, namely FirstBitGA +and FirstRealGA (see First +lesson to know more about these two ready-to-run programs). If this +doesn't work, please go back to the main EO directory and run the installation +program. +

      You should also test that you can access the EO documentation in the +menu line below: you might not need to go there immediately, but just in +case you make rapid progress ... This menu bar should be on all pages of +this tutorial, allowing you to navigate easily. +

      Last, but not least: EO is improving only  from the good will of +contributors. This is also true for this tutorial: If you find anything +that you think could be improved, you are welcome to e-mail +me. +

      +

      Enjoy! +


      Algorithm-Based +- Component-Based - Programming +hints - EO +documentation
      + +
      +
      +Marc Schoenauer
      + +
      Last +modified: Fri Nov 28 2000  + +
    • eoGenerationalReplacement This @@ -86,22 +230,27 @@ that offspring and parents are of the same size (but does not check!).

    •  
    • -eoMergeReduce This is one -the basic types of replacement in EO. It has two major steps, merging -both populations of parents and offspring, and reducing -this big population to the right size. It contains +eoMergeReduce +This is one the basic types of replacement in EO. It has two major steps, +merging both populations of parents and offspring, +and reducing this big population to the right +size. It contains two objects of respective types eoMerge and eoReduce and you can probably guess what each of them actually does :-)
    • -


      Available instances of eoMergeReduce -replacement include +
        +

        +

      Available instances of eoMergeReduce replacement +include

      • eoCommaReplacement, one of the two standard strategies in Evolution Strategies, -selects the best offspring. It is an -eoMergeReduce(eoNoElitism, eoTruncate).
      • +selects +the best offspring. It is an +eoMergeReduce(eoNoElitism, +eoTruncate).
      • eoPlusReplacement, the other @@ -112,9 +261,8 @@ eoTruncate).
      • eoEPReplacement, used in the -Evolutionary -Programming historical algorithm, does an EP stochastic tournament -among parents + offspring. It is an eoMergeReduce(eoPlus, +Evolutionary Programming historical algorithm, does an EP stochastic +tournament among parents + offspring. It is an eoMergeReduce(eoPlus, eoEPReduce) and its constructor requires as argument T, the size of the tournament (unsigned int).
      @@ -152,7 +300,9 @@ Additional parameter (in the constructor) is the tournament rate, a eoSurviveAndDie is
    -Replacement: Adding + +
    +
    Replacement: Adding (weak) elitism

    You can add what is called weak elitism to any replacement by encapsulating it into an eoWeakElitismReplacement @@ -170,11 +320,13 @@ can be any replacement object):
    and use now replace as your replacement procedure within your algorithm.

    Note: of course, adding weak elitism to an elitist replacement makes no sense - but will not harm either :-) -

    Replacement: Test +
    +


    +
    Replacement: Test file

    The file t-eoReplacement in the test directory implements all -above replacmenet procedures within a very simple and easy-to-monitor Dummy +above replacement procedures within a very simple and easy-to-monitor Dummy EO class.


    @@ -239,10 +391,10 @@ parameter R should be in [0.5,1]. It is implemented in the eoStochTournamentTruncate class that repeatidly removes from the population the "winner" of the inverse tournament.  These objects use the C++ function determinitic_tournament -in  selectors.h.
    -Note: A stochastic tournament with -rate 1.0 is strictly identical to a deterministic tournament of size 2. +in  selectors.h. +
    Note: A stochastic tournament with +rate 1.0 is strictly identical to a deterministic tournament of size 2.
  • EP Tournament of size T is a global tournament: it works by assigning a score to all @@ -252,12 +404,13 @@ Everytime I wins, its score in incremented by 1 (and by 0.5 for every draw). The individuals are then selected deterministically based on their scores from that procedure. The EP Tournament is implemented in the  eoEPReduce -truncation method used in some replacement procedures. 
    -Note: whereas both the determinitic +truncation method used in the eoEPReplacement +procedure.
  • + +
    Note: whereas both the determinitic and the stochastic tournament select one individual, the EP tournament is designed for batch selection. Of course it could be used to select a -single individual, but at a rather high computational cost. - +single individual, but at a rather high computational cost.



    @@ -266,7 +419,9 @@ populations

    In replacement procedures, one frequently needs to merge two populations (computed form old parents and new-born offspring). Classes derived from the abstract class eoMerge are written for that purpose. -

    eoMerge: interface +
    +


    +
    eoMerge: interface
    The abstract class for merging procedures is the functor class eoMerge, and the interface for its operator() @@ -282,7 +437,9 @@ void>
    .
    This means that it takes 2 populations and modifies the seond one by adding some individuals from the first one (which is supposed to remain constant). -

    eoMerge: instances +
    +


    +
    eoMerge: instances
    Available instances of eoMerge objects are eoPlus, that simply adds the parents to the offspring, or eoElitism, @@ -296,7 +453,9 @@ populations