* EO.tpl, MyStructEA.cpp, MyStructSEA.cpp, make_MyStruct.cpp: Use
correct names for includes. * README.manual: This is a copy of the old README. * README: Describe the new way and setup of creating a new EO project. * createEOproject.sh, Makefile.am.src-tmpl, Makefile.am.top-tmpl: * configure.ac.tmpl: New files to create a standalone EO project from templates.
This commit is contained in:
parent
b28f39af40
commit
301e29ac02
12 changed files with 445 additions and 265 deletions
19
eo/tutorial/Templates/ChangeLog
Normal file
19
eo/tutorial/Templates/ChangeLog
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
2006-12-16 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||||
|
|
||||||
|
* EO.tpl, MyStructEA.cpp, MyStructSEA.cpp, make_MyStruct.cpp: Use
|
||||||
|
correct names for includes.
|
||||||
|
|
||||||
|
* README.manual: This is a copy of the old README.
|
||||||
|
|
||||||
|
* README: Describe the new way and setup of creating a new EO project.
|
||||||
|
|
||||||
|
* createEOproject.sh, Makefile.am.src-tmpl, Makefile.am.top-tmpl:
|
||||||
|
* configure.ac.tmpl: New files to create a standalone EO project from
|
||||||
|
templates.
|
||||||
|
|
||||||
|
|
||||||
|
* Local Variables:
|
||||||
|
* coding: iso-8859-1
|
||||||
|
* mode: flyspell
|
||||||
|
* fill-column: 80
|
||||||
|
* End:
|
||||||
|
|
@ -3,20 +3,20 @@
|
||||||
// (The above line is useful in Emacs-like editors)
|
// (The above line is useful in Emacs-like editors)
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
// EASEA.cpp
|
// EASEA.cpp
|
||||||
//
|
//
|
||||||
// C++ file generated by AESAE-EO v0.7
|
// C++ file generated by AESAE-EO v0.7
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Main file for creating a new representation in EO
|
// Main file for creating a new representation in EO
|
||||||
// =================================================
|
// =================================================
|
||||||
//
|
//
|
||||||
// This main file includes all other files that have been generated by the
|
// This main file includes all other files that have been generated by the
|
||||||
// script create.sh, so it is the only file to compile.
|
// script create.sh, so it is the only file to compile.
|
||||||
//
|
//
|
||||||
// In case you want to build up a separate library for your new Evolving Object,
|
// In case you want to build up a separate library for your new Evolving Object,
|
||||||
// you'll need some work - follow what's done in the src/ga dir, used in the
|
// you'll need some work - follow what's done in the src/ga dir, used in the
|
||||||
// main file BitEA in tutorial/Lesson4 dir.
|
// main file BitEA in tutorial/Lesson4 dir.
|
||||||
|
|
@ -49,12 +49,12 @@ inline float random(float b1=0, float b2=1){
|
||||||
|
|
||||||
\ANALYSE_PARAMETERS
|
\ANALYSE_PARAMETERS
|
||||||
\INSERT_USER_DECLARATIONS
|
\INSERT_USER_DECLARATIONS
|
||||||
\INSERT_INITIALISATION_FUNCTION
|
\INSERT_INITIALISATION_FUNCTION
|
||||||
|
|
||||||
// include here whatever specific files for your representation
|
// include here whatever specific files for your representation
|
||||||
// Basically, this should include at least the following
|
// Basically, this should include at least the following
|
||||||
|
|
||||||
/** definition of representation:
|
/** definition of representation:
|
||||||
* class EASEAGenome MUST derive from EO<FitT> for some fitness
|
* class EASEAGenome MUST derive from EO<FitT> for some fitness
|
||||||
*/
|
*/
|
||||||
#include "EASEAGenome.h"
|
#include "EASEAGenome.h"
|
||||||
|
|
@ -64,23 +64,23 @@ inline float random(float b1=0, float b2=1){
|
||||||
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||||
// START fitness type: double or eoMaximizingFitness if you are maximizing
|
// START fitness type: double or eoMaximizingFitness if you are maximizing
|
||||||
// eoMinimizingFitness if you are minimizing
|
// eoMinimizingFitness if you are minimizing
|
||||||
typedef \MINIMAXI MyFitT ; // type of fitness
|
typedef \MINIMAXI MyFitT ; // type of fitness
|
||||||
// END fitness type
|
// END fitness type
|
||||||
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||||
|
|
||||||
// Then define your EO objects using that fitness type
|
// Then define your EO objects using that fitness type
|
||||||
typedef EASEAGenome<MyFitT> Indi; // ***MUST*** derive from EO
|
typedef EASEAGenome<MyFitT> Indi; // ***MUST*** derive from EO
|
||||||
|
|
||||||
\INSERT_USER_FUNCTIONS
|
\INSERT_USER_FUNCTIONS
|
||||||
|
|
||||||
/** definition of evaluation:
|
/** definition of evaluation:
|
||||||
* class EASEAEvalFunc MUST derive from eoEvalFunc<EASEAGenome>
|
* class EASEAEvalFunc MUST derive from eoEvalFunc<EASEAGenome>
|
||||||
* and should test for validity before doing any computation
|
* and should test for validity before doing any computation
|
||||||
* see tutorial/Templates/evalFunc.tmpl
|
* see tutorial/Templates/evalFunc.tmpl
|
||||||
*/
|
*/
|
||||||
#include "EASEAEvalFunc.h"
|
#include "EASEAEvalFunc.h"
|
||||||
|
|
||||||
/** definition of initialization:
|
/** definition of initialization:
|
||||||
* class EASEAGenomeInit MUST derive from eoInit<EASEAGenome>
|
* class EASEAGenomeInit MUST derive from eoInit<EASEAGenome>
|
||||||
*/
|
*/
|
||||||
#include "EASEAInit.h"
|
#include "EASEAInit.h"
|
||||||
|
|
@ -93,34 +93,34 @@ typedef EASEAGenome<MyFitT> Indi; // ***MUST*** derive from EO
|
||||||
// Use existing modules to define representation independent routines
|
// Use existing modules to define representation independent routines
|
||||||
// These are parser-based definitions of objects
|
// These are parser-based definitions of objects
|
||||||
|
|
||||||
// how to initialize the population
|
// how to initialize the population
|
||||||
// it IS representation independent if an eoInit is given
|
// it IS representation independent if an eoInit is given
|
||||||
#include <do/make_pop.h>
|
#include <make_pop.h>
|
||||||
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init){
|
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init){
|
||||||
return do_make_pop(_parser, _state, _init);
|
return do_make_pop(_parser, _state, _init);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the stopping criterion
|
// the stopping criterion
|
||||||
#include "do/make_continue.h"
|
#include "make_continue.h"
|
||||||
eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval){
|
eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval){
|
||||||
return do_make_continue(_parser, _state, _eval);
|
return do_make_continue(_parser, _state, _eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
// outputs (stats, population dumps, ...)
|
// outputs (stats, population dumps, ...)
|
||||||
#include <do/make_checkpoint.h>
|
#include <make_checkpoint.h>
|
||||||
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue) {
|
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue) {
|
||||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// evolution engine (selection and replacement)
|
// evolution engine (selection and replacement)
|
||||||
#include <do/make_algo_easea.h>
|
#include <make_algo_easea.h>
|
||||||
eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op){
|
eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op){
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple call to the algo. stays there for consistency reasons
|
// simple call to the algo. stays there for consistency reasons
|
||||||
// no template for that one
|
// no template for that one
|
||||||
#include <do/make_run.h>
|
#include <make_run.h>
|
||||||
// the instanciating fitnesses
|
// the instanciating fitnesses
|
||||||
#include <eoScalarFitness.h>
|
#include <eoScalarFitness.h>
|
||||||
void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop){
|
void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop){
|
||||||
|
|
@ -149,12 +149,12 @@ try {
|
||||||
|
|
||||||
// a genotype initializer
|
// a genotype initializer
|
||||||
EASEAInit<Indi> init;
|
EASEAInit<Indi> init;
|
||||||
// or, if you need some parameters, you might as well
|
// or, if you need some parameters, you might as well
|
||||||
// - write a constructor of the eoMyStructInit that uses a parser
|
// - write a constructor of the eoMyStructInit that uses a parser
|
||||||
// - call it from here:
|
// - call it from here:
|
||||||
// eoEASEAInit<Indi> init(parser);
|
// eoEASEAInit<Indi> init(parser);
|
||||||
|
|
||||||
|
|
||||||
// Build the variation operator (any seq/prop construct)
|
// Build the variation operator (any seq/prop construct)
|
||||||
// here, a simple example with only 1 crossover (2->2, a QuadOp) and
|
// here, a simple example with only 1 crossover (2->2, a QuadOp) and
|
||||||
// one mutation, is given.
|
// one mutation, is given.
|
||||||
|
|
@ -162,7 +162,7 @@ try {
|
||||||
|
|
||||||
// A (first) crossover (possibly use the parser in its Ctor)
|
// A (first) crossover (possibly use the parser in its Ctor)
|
||||||
EASEAQuadCrossover<Indi> cross /* (eoParser parser) */;
|
EASEAQuadCrossover<Indi> cross /* (eoParser parser) */;
|
||||||
|
|
||||||
// IF MORE THAN ONE:
|
// IF MORE THAN ONE:
|
||||||
|
|
||||||
// read its relative rate in the combination
|
// read its relative rate in the combination
|
||||||
|
|
@ -176,9 +176,9 @@ try {
|
||||||
// 2- include that file here together with eoEASEAQuadCrossover above
|
// 2- include that file here together with eoEASEAQuadCrossover above
|
||||||
// 3- uncomment and duplicate the following lines:
|
// 3- uncomment and duplicate the following lines:
|
||||||
//
|
//
|
||||||
// eoEASEASecondCrossover<Indi> cross2(eoParser parser);
|
// eoEASEASecondCrossover<Indi> cross2(eoParser parser);
|
||||||
// double cross2Rate = parser.createParam(1.0, "cross2Rate", "Relative rate for crossover 2", '2', "Variation Operators").value();
|
// double cross2Rate = parser.createParam(1.0, "cross2Rate", "Relative rate for crossover 2", '2', "Variation Operators").value();
|
||||||
// cross.add(cross2, cross2Rate);
|
// cross.add(cross2, cross2Rate);
|
||||||
|
|
||||||
// NOTE: if you want some gentle output, the last one shoudl be like
|
// NOTE: if you want some gentle output, the last one shoudl be like
|
||||||
// cross.add(cross, crossXXXRate, true);
|
// cross.add(cross, crossXXXRate, true);
|
||||||
|
|
@ -201,9 +201,9 @@ try {
|
||||||
// 2- include that file here together with eoEASEAMutation above
|
// 2- include that file here together with eoEASEAMutation above
|
||||||
// 3- uncomment and duplicate the following lines:
|
// 3- uncomment and duplicate the following lines:
|
||||||
//
|
//
|
||||||
// eoEASEASecondMutation<Indi> mut2(eoParser parser);
|
// eoEASEASecondMutation<Indi> mut2(eoParser parser);
|
||||||
// double mut2Rate = parser.createParam(1.0, "mut2Rate", "Relative rate for mutation 2", '2', "Variation Operators").value();
|
// double mut2Rate = parser.createParam(1.0, "mut2Rate", "Relative rate for mutation 2", '2', "Variation Operators").value();
|
||||||
// mut.add(mut2, mut2Rate);
|
// mut.add(mut2, mut2Rate);
|
||||||
|
|
||||||
// NOTE: if you want some gentle output, the last one shoudl be like
|
// NOTE: if you want some gentle output, the last one shoudl be like
|
||||||
// mut.add(mut, mutXXXRate, true);
|
// mut.add(mut, mutXXXRate, true);
|
||||||
|
|
@ -227,7 +227,7 @@ try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// Now the representation-independent things
|
//// Now the representation-independent things
|
||||||
//
|
//
|
||||||
// YOU SHOULD NOT NEED TO MODIFY ANYTHING BEYOND THIS POINT
|
// YOU SHOULD NOT NEED TO MODIFY ANYTHING BEYOND THIS POINT
|
||||||
// unless you want to add specific statistics to the checkpoint
|
// unless you want to add specific statistics to the checkpoint
|
||||||
|
|
@ -279,18 +279,18 @@ try {
|
||||||
// (The above line is useful in Emacs-like editors)
|
// (The above line is useful in Emacs-like editors)
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
// EASEAGenome.h
|
// EASEAGenome.h
|
||||||
//
|
//
|
||||||
// C++ file generated by AESAE-EO v0.7
|
// C++ file generated by AESAE-EO v0.7
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef _EASEAGenome_h
|
#ifndef _EASEAGenome_h
|
||||||
#define _EASEAGenome_h
|
#define _EASEAGenome_h
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always write a comment in this format before class definition
|
* Always write a comment in this format before class definition
|
||||||
* if you want the class to be documented by Doxygen
|
* if you want the class to be documented by Doxygen
|
||||||
|
|
||||||
|
|
@ -299,7 +299,7 @@ try {
|
||||||
* like eoVector for instance, if you handle a vector of something....
|
* like eoVector for instance, if you handle a vector of something....
|
||||||
|
|
||||||
* If you create a structure from scratch,
|
* If you create a structure from scratch,
|
||||||
* the only thing you need to provide are
|
* the only thing you need to provide are
|
||||||
* a default constructor
|
* a default constructor
|
||||||
* IO routines printOn and readFrom
|
* IO routines printOn and readFrom
|
||||||
*
|
*
|
||||||
|
|
@ -313,41 +313,41 @@ template< class FitT>
|
||||||
class EASEAGenome: public EO<FitT> {
|
class EASEAGenome: public EO<FitT> {
|
||||||
public:
|
public:
|
||||||
/** Ctor: you MUST provide a default ctor.
|
/** Ctor: you MUST provide a default ctor.
|
||||||
* though such individuals will generally be processed
|
* though such individuals will generally be processed
|
||||||
* by some eoInit object
|
* by some eoInit object
|
||||||
*/
|
*/
|
||||||
EASEAGenome() : EO<FitT>()
|
EASEAGenome() : EO<FitT>()
|
||||||
{
|
{
|
||||||
// START Code of default Ctor of an EASEAGenome object
|
// START Code of default Ctor of an EASEAGenome object
|
||||||
\GENOME_CTOR
|
\GENOME_CTOR
|
||||||
// END Code of default Ctor of an EASEAGenome object
|
// END Code of default Ctor of an EASEAGenome object
|
||||||
}
|
}
|
||||||
|
|
||||||
EASEAGenome(const EASEAGenome & arg) : EO<FitT>()
|
EASEAGenome(const EASEAGenome & arg) : EO<FitT>()
|
||||||
{
|
{
|
||||||
\GENOME_CTOR
|
\GENOME_CTOR
|
||||||
copy(arg);
|
copy(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~EASEAGenome()
|
virtual ~EASEAGenome()
|
||||||
{
|
{
|
||||||
// START Code of Destructor of an EASEAGenome object
|
// START Code of Destructor of an EASEAGenome object
|
||||||
\GENOME_DTOR
|
\GENOME_DTOR
|
||||||
// END Code of Destructor of an EASEAGenome object
|
// END Code of Destructor of an EASEAGenome object
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual string className() const { return "EASEAGenome"; }
|
virtual string className() const { return "EASEAGenome"; }
|
||||||
|
|
||||||
EASEAGenome& operator=(const EASEAGenome & arg) {
|
EASEAGenome& operator=(const EASEAGenome & arg) {
|
||||||
copy(arg);
|
copy(arg);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy(const EASEAGenome& genome)
|
void copy(const EASEAGenome& genome)
|
||||||
{
|
{
|
||||||
if(&genome != this){
|
if(&genome != this){
|
||||||
\GENOME_DTOR
|
\GENOME_DTOR
|
||||||
\COPY_CTOR
|
\COPY_CTOR
|
||||||
if (genome.invalid()) { // copying an invalid genome
|
if (genome.invalid()) { // copying an invalid genome
|
||||||
fitness(FitT()); // put a valid value (i.e. non NAN)
|
fitness(FitT()); // put a valid value (i.e. non NAN)
|
||||||
invalidate(); // but INVALIDATE the genome
|
invalidate(); // but INVALIDATE the genome
|
||||||
|
|
@ -356,8 +356,8 @@ public:
|
||||||
fitness(genome.fitness());
|
fitness(genome.fitness());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const EASEAGenome & genome) const {
|
bool operator==(const EASEAGenome & genome) const {
|
||||||
\EQUAL
|
\EQUAL
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -372,7 +372,7 @@ public:
|
||||||
// First write the fitness
|
// First write the fitness
|
||||||
EO<FitT>::printOn(os);
|
EO<FitT>::printOn(os);
|
||||||
os << ' ';
|
os << ' ';
|
||||||
// START Code of default output
|
// START Code of default output
|
||||||
|
|
||||||
/** HINTS
|
/** HINTS
|
||||||
* in EO we systematically write the sizes of things before the things
|
* in EO we systematically write the sizes of things before the things
|
||||||
|
|
@ -383,7 +383,7 @@ public:
|
||||||
// END Code of default output
|
// END Code of default output
|
||||||
}
|
}
|
||||||
|
|
||||||
/** reading...
|
/** reading...
|
||||||
* of course, your readFrom must be able to read what printOn writes!!!
|
* of course, your readFrom must be able to read what printOn writes!!!
|
||||||
*/
|
*/
|
||||||
void readFrom(istream& is)
|
void readFrom(istream& is)
|
||||||
|
|
@ -412,11 +412,11 @@ public:
|
||||||
// (The above line is useful in Emacs-like editors)
|
// (The above line is useful in Emacs-like editors)
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
// EASEAEvalFunc.h
|
// EASEAEvalFunc.h
|
||||||
//
|
//
|
||||||
// C++ file generated by AESAE-EO v0.7
|
// C++ file generated by AESAE-EO v0.7
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
@ -424,7 +424,7 @@ public:
|
||||||
Evaluator in EO: a functor that computes the fitness of an EO
|
Evaluator in EO: a functor that computes the fitness of an EO
|
||||||
=============================================================
|
=============================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _EASEAEvalFunc_h
|
#ifndef _EASEAEvalFunc_h
|
||||||
#define _EASEAEvalFunc_h
|
#define _EASEAEvalFunc_h
|
||||||
|
|
||||||
|
|
@ -435,7 +435,7 @@ Evaluator in EO: a functor that computes the fitness of an EO
|
||||||
// include the base definition of eoEvalFunc
|
// include the base definition of eoEvalFunc
|
||||||
#include "eoEvalFunc.h"
|
#include "eoEvalFunc.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Always write a comment in this format before class definition
|
Always write a comment in this format before class definition
|
||||||
if you want the class to be documented by Doxygen
|
if you want the class to be documented by Doxygen
|
||||||
*/
|
*/
|
||||||
|
|
@ -446,7 +446,7 @@ public:
|
||||||
/// Ctor - no requirement
|
/// Ctor - no requirement
|
||||||
// START eventually add or modify the anyVariable argument
|
// START eventually add or modify the anyVariable argument
|
||||||
EASEAEvalFunc()
|
EASEAEvalFunc()
|
||||||
// EASEAEvalFunc( varType _anyVariable) : anyVariable(_anyVariable)
|
// EASEAEvalFunc( varType _anyVariable) : anyVariable(_anyVariable)
|
||||||
// END eventually add or modify the anyVariable argument
|
// END eventually add or modify the anyVariable argument
|
||||||
{
|
{
|
||||||
// START Code of Ctor of an EASEAEvalFunc object
|
// START Code of Ctor of an EASEAEvalFunc object
|
||||||
|
|
@ -456,7 +456,7 @@ public:
|
||||||
/** Actually compute the fitness
|
/** Actually compute the fitness
|
||||||
*
|
*
|
||||||
* @param EOT & _eo the EO object to evaluate
|
* @param EOT & _eo the EO object to evaluate
|
||||||
* it should stay templatized to be usable
|
* it should stay templatized to be usable
|
||||||
* with any fitness type
|
* with any fitness type
|
||||||
*/
|
*/
|
||||||
void operator()(EOT & genome)
|
void operator()(EOT & genome)
|
||||||
|
|
@ -484,11 +484,11 @@ private:
|
||||||
// (The above line is useful in Emacs-like editors)
|
// (The above line is useful in Emacs-like editors)
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
// EASEAInit.h
|
// EASEAInit.h
|
||||||
//
|
//
|
||||||
// C++ file generated by AESAE-EO v0.7
|
// C++ file generated by AESAE-EO v0.7
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
@ -503,12 +503,12 @@ objects initialization in EO
|
||||||
// include the base definition of eoInit
|
// include the base definition of eoInit
|
||||||
#include <eoInit.h>
|
#include <eoInit.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always write a comment in this format before class definition
|
* Always write a comment in this format before class definition
|
||||||
* if you want the class to be documented by Doxygen
|
* if you want the class to be documented by Doxygen
|
||||||
*
|
*
|
||||||
* There is NO ASSUMPTION on the class GenoypeT.
|
* There is NO ASSUMPTION on the class GenoypeT.
|
||||||
* In particular, it does not need to derive from EO (e.g. to initialize
|
* In particular, it does not need to derive from EO (e.g. to initialize
|
||||||
* atoms of an eoVector you will need an eoInit<AtomType>)
|
* atoms of an eoVector you will need an eoInit<AtomType>)
|
||||||
*/
|
*/
|
||||||
template <class GenotypeT>
|
template <class GenotypeT>
|
||||||
|
|
@ -517,7 +517,7 @@ public:
|
||||||
/// Ctor - no requirement
|
/// Ctor - no requirement
|
||||||
// START eventually add or modify the anyVariable argument
|
// START eventually add or modify the anyVariable argument
|
||||||
EASEAInit()
|
EASEAInit()
|
||||||
// EASEAInit( varType & _anyVariable) : anyVariable(_anyVariable)
|
// EASEAInit( varType & _anyVariable) : anyVariable(_anyVariable)
|
||||||
// END eventually add or modify the anyVariable argument
|
// END eventually add or modify the anyVariable argument
|
||||||
{
|
{
|
||||||
// START Code of Ctor of an EASEAInit object
|
// START Code of Ctor of an EASEAInit object
|
||||||
|
|
@ -552,11 +552,11 @@ private:
|
||||||
// (The above line is useful in Emacs-like editors)
|
// (The above line is useful in Emacs-like editors)
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
// EASEAMutation.h
|
// EASEAMutation.h
|
||||||
//
|
//
|
||||||
// C++ file generated by AESAE-EO v0.7
|
// C++ file generated by AESAE-EO v0.7
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
@ -571,14 +571,14 @@ simple mutation operators
|
||||||
|
|
||||||
#include <eoOp.h>
|
#include <eoOp.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always write a comment in this format before class definition
|
* Always write a comment in this format before class definition
|
||||||
* if you want the class to be documented by Doxygen
|
* if you want the class to be documented by Doxygen
|
||||||
*
|
*
|
||||||
* THere is NO ASSUMPTION on the class GenoypeT.
|
* THere is NO ASSUMPTION on the class GenoypeT.
|
||||||
* In particular, it does not need to derive from EO
|
* In particular, it does not need to derive from EO
|
||||||
*/
|
*/
|
||||||
template<class GenotypeT>
|
template<class GenotypeT>
|
||||||
class EASEAMutation: public eoMonOp<GenotypeT>
|
class EASEAMutation: public eoMonOp<GenotypeT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -587,7 +587,7 @@ public:
|
||||||
*/
|
*/
|
||||||
// START eventually add or modify the anyVariable argument
|
// START eventually add or modify the anyVariable argument
|
||||||
EASEAMutation()
|
EASEAMutation()
|
||||||
// EASEAMutation( varType _anyVariable) : anyVariable(_anyVariable)
|
// EASEAMutation( varType _anyVariable) : anyVariable(_anyVariable)
|
||||||
// END eventually add or modify the anyVariable argument
|
// END eventually add or modify the anyVariable argument
|
||||||
{
|
{
|
||||||
// START Code of Ctor of an EASEAMutation object
|
// START Code of Ctor of an EASEAMutation object
|
||||||
|
|
@ -601,7 +601,7 @@ public:
|
||||||
* modifies the parent
|
* modifies the parent
|
||||||
* @param _genotype The parent genotype (will be modified)
|
* @param _genotype The parent genotype (will be modified)
|
||||||
*/
|
*/
|
||||||
bool operator()(GenotypeT & _genotype)
|
bool operator()(GenotypeT & _genotype)
|
||||||
{
|
{
|
||||||
// START code for mutation of the _genotype object
|
// START code for mutation of the _genotype object
|
||||||
\INSERT_MUTATOR
|
\INSERT_MUTATOR
|
||||||
|
|
@ -620,11 +620,11 @@ private:
|
||||||
// (The above line is useful in Emacs-like editors)
|
// (The above line is useful in Emacs-like editors)
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
// EASEAQuadCrossover.h
|
// EASEAQuadCrossover.h
|
||||||
//
|
//
|
||||||
// C++ file generated by AESAE-EO v0.7
|
// C++ file generated by AESAE-EO v0.7
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
@ -640,14 +640,14 @@ Quadratic crossover operators modify both genotypes
|
||||||
|
|
||||||
#include <eoOp.h>
|
#include <eoOp.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always write a comment in this format before class definition
|
* Always write a comment in this format before class definition
|
||||||
* if you want the class to be documented by Doxygen
|
* if you want the class to be documented by Doxygen
|
||||||
*
|
*
|
||||||
* THere is NO ASSUMPTION on the class GenoypeT.
|
* THere is NO ASSUMPTION on the class GenoypeT.
|
||||||
* In particular, it does not need to derive from EO
|
* In particular, it does not need to derive from EO
|
||||||
*/
|
*/
|
||||||
template<class GenotypeT>
|
template<class GenotypeT>
|
||||||
class EASEAQuadCrossover: public eoQuadOp<GenotypeT>
|
class EASEAQuadCrossover: public eoQuadOp<GenotypeT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -656,7 +656,7 @@ public:
|
||||||
*/
|
*/
|
||||||
// START eventually add or modify the anyVariable argument
|
// START eventually add or modify the anyVariable argument
|
||||||
EASEAQuadCrossover()
|
EASEAQuadCrossover()
|
||||||
// EASEAQuadCrossover( varType _anyVariable) : anyVariable(_anyVariable)
|
// EASEAQuadCrossover( varType _anyVariable) : anyVariable(_anyVariable)
|
||||||
// END eventually add or modify the anyVariable argument
|
// END eventually add or modify the anyVariable argument
|
||||||
{
|
{
|
||||||
// START Code of Ctor of an EASEAQuadCrossover object
|
// START Code of Ctor of an EASEAQuadCrossover object
|
||||||
|
|
@ -669,11 +669,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* eoQuad crossover - modifies both genotypes
|
* eoQuad crossover - modifies both genotypes
|
||||||
*/
|
*/
|
||||||
bool operator()(GenotypeT& child1, GenotypeT & child2)
|
bool operator()(GenotypeT& child1, GenotypeT & child2)
|
||||||
{
|
{
|
||||||
GenotypeT parent1(child1);
|
GenotypeT parent1(child1);
|
||||||
GenotypeT parent2(child2);
|
GenotypeT parent2(child2);
|
||||||
|
|
||||||
// START code for crossover of child1 and child2 objects
|
// START code for crossover of child1 and child2 objects
|
||||||
\INSERT_CROSSOVER
|
\INSERT_CROSSOVER
|
||||||
return (parent1!=child1)||(parent2!=child2);
|
return (parent1!=child1)||(parent2!=child2);
|
||||||
|
|
@ -693,11 +693,11 @@ private:
|
||||||
// (The above line is useful in Emacs-like editors)
|
// (The above line is useful in Emacs-like editors)
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
// EASEA_make_continue.h
|
// EASEA_make_continue.h
|
||||||
//
|
//
|
||||||
// C++ file generated by AESAE-EO v0.7
|
// C++ file generated by AESAE-EO v0.7
|
||||||
//
|
//
|
||||||
//*************************************
|
//*************************************
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
@ -838,11 +838,11 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
\START_EO_PARAM_TPL#*************************************
|
\START_EO_PARAM_TPL#*************************************
|
||||||
#
|
#
|
||||||
# EASEA.prm
|
# EASEA.prm
|
||||||
#
|
#
|
||||||
# Parameter file generated by AESAE-EO v0.7
|
# Parameter file generated by AESAE-EO v0.7
|
||||||
#
|
#
|
||||||
#*************************************
|
#*************************************
|
||||||
###### General ######
|
###### General ######
|
||||||
# --help=0 # -h : Prints this message
|
# --help=0 # -h : Prints this message
|
||||||
|
|
@ -901,11 +901,11 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
|
||||||
--pMut=\MUT_PROB # -M : Probability of Mutation
|
--pMut=\MUT_PROB # -M : Probability of Mutation
|
||||||
|
|
||||||
\START_EO_MAKEFILE_TPL#*************************************
|
\START_EO_MAKEFILE_TPL#*************************************
|
||||||
#
|
#
|
||||||
# EASEA.mak
|
# EASEA.mak
|
||||||
#
|
#
|
||||||
# Makefile generated by AESAE-EO v0.7
|
# Makefile generated by AESAE-EO v0.7
|
||||||
#
|
#
|
||||||
#*************************************
|
#*************************************
|
||||||
|
|
||||||
# sample makefile for building an EA evolving a new genotype
|
# sample makefile for building an EA evolving a new genotype
|
||||||
|
|
@ -929,7 +929,7 @@ SOURCES = EASEA.cpp \
|
||||||
ALL = EASEA
|
ALL = EASEA
|
||||||
|
|
||||||
EASEA : $(SOURCES)
|
EASEA : $(SOURCES)
|
||||||
c++ -g -I. -I$(DIR_EO)/src -o $@ EASEA.cpp $(LIB_EO) -lm
|
c++ -g -I. -I$(DIR_EO)/src -o $@ EASEA.cpp $(LIB_EO) -lm
|
||||||
|
|
||||||
all : $(ALL)
|
all : $(ALL)
|
||||||
|
|
||||||
|
|
|
||||||
16
eo/tutorial/Templates/Makefile.am.src-tmpl
Normal file
16
eo/tutorial/Templates/Makefile.am.src-tmpl
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
bin_PROGRAMS = MyStruct
|
||||||
|
|
||||||
|
MyStruct_SOURCES = MyStructEA.cpp \
|
||||||
|
eoMyStruct.h \
|
||||||
|
eoMyStructEvalFunc.h \
|
||||||
|
eoMyStructInit.h \
|
||||||
|
eoMyStructMutation.h \
|
||||||
|
eoMyStructQuadCrossover.h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dnl Local Variables:
|
||||||
|
dnl coding: iso-8859-1
|
||||||
|
dnl mode: makefile-automake
|
||||||
|
dnl fill-column: 80
|
||||||
|
dnl End:
|
||||||
8
eo/tutorial/Templates/Makefile.am.top-tmpl
Normal file
8
eo/tutorial/Templates/Makefile.am.top-tmpl
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
SUBDIRS = src
|
||||||
|
|
||||||
|
|
||||||
|
dnl Local Variables:
|
||||||
|
dnl coding: iso-8859-1
|
||||||
|
dnl mode: makefile-automake
|
||||||
|
dnl fill-column: 80
|
||||||
|
dnl End:
|
||||||
|
|
@ -17,7 +17,7 @@ main file BitEA in tutorial/Lesson4 dir.
|
||||||
Or you can wait until we do it :-)
|
Or you can wait until we do it :-)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Miscilaneous include and declaration
|
// Miscilaneous include and declaration
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -29,17 +29,17 @@ using namespace std;
|
||||||
// include here whatever specific files for your representation
|
// include here whatever specific files for your representation
|
||||||
// Basically, this should include at least the following
|
// Basically, this should include at least the following
|
||||||
|
|
||||||
/** definition of representation:
|
/** definition of representation:
|
||||||
* class eoMyStruct MUST derive from EO<FitT> for some fitness
|
* class eoMyStruct MUST derive from EO<FitT> for some fitness
|
||||||
*/
|
*/
|
||||||
#include "eoMyStruct.h"
|
#include "eoMyStruct.h"
|
||||||
|
|
||||||
/** definition of initilizqtion:
|
/** definition of initilizqtion:
|
||||||
* class eoMyStructInit MUST derive from eoInit<eoMyStruct>
|
* class eoMyStructInit MUST derive from eoInit<eoMyStruct>
|
||||||
*/
|
*/
|
||||||
#include "eoMyStructInit.h"
|
#include "eoMyStructInit.h"
|
||||||
|
|
||||||
/** definition of evaluation:
|
/** definition of evaluation:
|
||||||
* class eoMyStructEvalFunc MUST derive from eoEvalFunc<eoMyStruct>
|
* class eoMyStructEvalFunc MUST derive from eoEvalFunc<eoMyStruct>
|
||||||
* and should test for validity before doing any computation
|
* and should test for validity before doing any computation
|
||||||
* see tutorial/Templates/evalFunc.tmpl
|
* see tutorial/Templates/evalFunc.tmpl
|
||||||
|
|
@ -51,19 +51,19 @@ using namespace std;
|
||||||
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||||
// START fitness type: double or eoMaximizingFitness if you are maximizing
|
// START fitness type: double or eoMaximizingFitness if you are maximizing
|
||||||
// eoMinimizingFitness if you are minimizing
|
// eoMinimizingFitness if you are minimizing
|
||||||
typedef eoMinimizingFitness MyFitT ; // type of fitness
|
typedef eoMinimizingFitness MyFitT ; // type of fitness
|
||||||
// END fitness type
|
// END fitness type
|
||||||
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||||
|
|
||||||
// Then define your EO objects using that fitness type
|
// Then define your EO objects using that fitness type
|
||||||
typedef eoMyStruct<MyFitT> Indi; // ***MUST*** derive from EO
|
typedef eoMyStruct<MyFitT> Indi; // ***MUST*** derive from EO
|
||||||
|
|
||||||
// create an initializer
|
// create an initializer
|
||||||
#include "make_genotype_MyStruct.h"
|
#include "make_genotype_MyStruct.h"
|
||||||
eoInit<Indi> & make_genotype(eoParser& _parser, eoState&_state, Indi _eo)
|
eoInit<Indi> & make_genotype(eoParser& _parser, eoState&_state, Indi _eo)
|
||||||
{
|
{
|
||||||
return do_make_genotype(_parser, _state, _eo);
|
return do_make_genotype(_parser, _state, _eo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and the variation operaotrs
|
// and the variation operaotrs
|
||||||
#include "make_op_MyStruct.h"
|
#include "make_op_MyStruct.h"
|
||||||
|
|
@ -75,38 +75,38 @@ eoGenOp<Indi>& make_op(eoParser& _parser, eoState& _state, eoInit<Indi>& _init)
|
||||||
// Use existing modules to define representation independent routines
|
// Use existing modules to define representation independent routines
|
||||||
// These are parser-based definitions of objects
|
// These are parser-based definitions of objects
|
||||||
|
|
||||||
// how to initialize the population
|
// how to initialize the population
|
||||||
// it IS representation independent if an eoInit is given
|
// it IS representation independent if an eoInit is given
|
||||||
#include <do/make_pop.h>
|
#include <make_pop.h>
|
||||||
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init)
|
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init)
|
||||||
{
|
{
|
||||||
return do_make_pop(_parser, _state, _init);
|
return do_make_pop(_parser, _state, _init);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the stopping criterion
|
// the stopping criterion
|
||||||
#include <do/make_continue.h>
|
#include <make_continue.h>
|
||||||
eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval)
|
eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval)
|
||||||
{
|
{
|
||||||
return do_make_continue(_parser, _state, _eval);
|
return do_make_continue(_parser, _state, _eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
// outputs (stats, population dumps, ...)
|
// outputs (stats, population dumps, ...)
|
||||||
#include <do/make_checkpoint.h>
|
#include <make_checkpoint.h>
|
||||||
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue)
|
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue)
|
||||||
{
|
{
|
||||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// evolution engine (selection and replacement)
|
// evolution engine (selection and replacement)
|
||||||
#include <do/make_algo_scalar.h>
|
#include <make_algo_scalar.h>
|
||||||
eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op)
|
eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op)
|
||||||
{
|
{
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple call to the algo. stays there for consistency reasons
|
// simple call to the algo. stays there for consistency reasons
|
||||||
// no template for that one
|
// no template for that one
|
||||||
#include <do/make_run.h>
|
#include <make_run.h>
|
||||||
// the instanciating fitnesses
|
// the instanciating fitnesses
|
||||||
#include <eoScalarFitness.h>
|
#include <eoScalarFitness.h>
|
||||||
void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop)
|
void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop)
|
||||||
|
|
@ -141,7 +141,7 @@ int main(int argc, char* argv[])
|
||||||
eoGenOp<Indi>& op = make_op(parser, state, init);
|
eoGenOp<Indi>& op = make_op(parser, state, init);
|
||||||
|
|
||||||
|
|
||||||
//// Now the representation-independent things
|
//// Now the representation-independent things
|
||||||
//
|
//
|
||||||
// YOU SHOULD NOT NEED TO MODIFY ANYTHING BEYOND THIS POINT
|
// YOU SHOULD NOT NEED TO MODIFY ANYTHING BEYOND THIS POINT
|
||||||
// unless you want to add specific statistics to the checkpoint
|
// unless you want to add specific statistics to the checkpoint
|
||||||
|
|
|
||||||
|
|
@ -73,28 +73,28 @@ typedef eoMyStruct<MyFitT> Indi; // ***MUST*** derive from EO
|
||||||
|
|
||||||
// how to initialize the population
|
// how to initialize the population
|
||||||
// it IS representation independent if an eoInit is given
|
// it IS representation independent if an eoInit is given
|
||||||
#include <do/make_pop.h>
|
#include <make_pop.h>
|
||||||
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init)
|
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init)
|
||||||
{
|
{
|
||||||
return do_make_pop(_parser, _state, _init);
|
return do_make_pop(_parser, _state, _init);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the stopping criterion
|
// the stopping criterion
|
||||||
#include <do/make_continue.h>
|
#include <make_continue.h>
|
||||||
eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval)
|
eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval)
|
||||||
{
|
{
|
||||||
return do_make_continue(_parser, _state, _eval);
|
return do_make_continue(_parser, _state, _eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
// outputs (stats, population dumps, ...)
|
// outputs (stats, population dumps, ...)
|
||||||
#include <do/make_checkpoint.h>
|
#include <make_checkpoint.h>
|
||||||
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue)
|
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue)
|
||||||
{
|
{
|
||||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// evolution engine (selection and replacement)
|
// evolution engine (selection and replacement)
|
||||||
#include <do/make_algo_scalar.h>
|
#include <make_algo_scalar.h>
|
||||||
eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op, eoDistance<Indi> *_dist = NULL)
|
eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op, eoDistance<Indi> *_dist = NULL)
|
||||||
{
|
{
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op, _dist);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op, _dist);
|
||||||
|
|
@ -102,7 +102,7 @@ eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<I
|
||||||
|
|
||||||
// simple call to the algo. stays there for consistency reasons
|
// simple call to the algo. stays there for consistency reasons
|
||||||
// no template for that one
|
// no template for that one
|
||||||
#include <do/make_run.h>
|
#include <make_run.h>
|
||||||
// the instanciating fitnesses
|
// the instanciating fitnesses
|
||||||
#include <eoScalarFitness.h>
|
#include <eoScalarFitness.h>
|
||||||
void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop)
|
void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop)
|
||||||
|
|
|
||||||
|
|
@ -1,149 +1,15 @@
|
||||||
Quick NOTE: This version of README is obsolete (May 25, 2004)
|
This Templates directory contains template files of an EO project and
|
||||||
In particular, a simpler version of the algorithm can be generated
|
a script createEOproject.sh to create a complete new EO project.
|
||||||
using the script
|
|
||||||
createSimple
|
|
||||||
|
|
||||||
with the same syntax. It is also more powerful, allowing for instance
|
The template requires a complete installation of EO.
|
||||||
to create you own statistics on the population, saving it in a file
|
|
||||||
and/or plotting on on-line during the run (see eoStat.tmpl).
|
|
||||||
More details some day, when I have some time ...
|
|
||||||
|
|
||||||
============= Old README (most is still accurate, though) ==========
|
In particular, the C++ compiler must find the EO include files and the
|
||||||
|
linker must find the EO libraries. Most probably, that means that you
|
||||||
|
have to set the variables CPLUS_INCLUDE_PATH and LIBRARY_PATH, i.e.
|
||||||
|
for a standard installation and using tcsh:
|
||||||
|
|
||||||
This directory contains sample files that should make it easy to
|
setenv CPLUS_INCLUDE_PATH /usr/local/include/eo:"$CPLUS_INCLUDE_PATH"
|
||||||
create an EO algorithm to evolve any type of structure
|
setenv LIBRARY_PATH /usr/local/lib:"$LIBRARY_PATH"
|
||||||
(EO comes with two examples, bitstrings and vector of real variables,
|
|
||||||
so you'll need this as soon as you want to evolve something else).
|
|
||||||
|
|
||||||
At the moment, only algorithms involving a scalar fitness (double)
|
|
||||||
are implemented (see test dir for Pareto optimization of multiple-
|
|
||||||
objective fitness - or be patient :-)
|
|
||||||
|
|
||||||
This file will help you to build the same algorithm than the ones
|
See README.manual for more details.
|
||||||
in the Lesson4 of the tutorial, but with YOUR genotype instead of
|
|
||||||
bitstrings or vector<double>. More details in Lesson5 of the tutorial.
|
|
||||||
|
|
||||||
It is assumed in the following that you have read the first part of
|
|
||||||
the tutorial (Lessons 1 to 4).
|
|
||||||
|
|
||||||
Creating the algorithm for your genotype
|
|
||||||
----------------------------------------
|
|
||||||
In what follows, we will suppose that you want to evolve some data
|
|
||||||
structure, and that you have enough programming skills to be able to
|
|
||||||
write C code for its random initilialization, its crossover, its
|
|
||||||
mutation and the computation of its fitness.
|
|
||||||
|
|
||||||
The helper script * create.sh * will create for you the files you need
|
|
||||||
from the samples in tutorial/Templates dir, and all you'll have to do
|
|
||||||
is to include the actual code where indicated in those files (between
|
|
||||||
keywords START and END).
|
|
||||||
|
|
||||||
First, let's choose a name: let's call the new EO class eoAppli.
|
|
||||||
All newly created classes will be named eoAppliXXX (in the file
|
|
||||||
eoAppliXXX)
|
|
||||||
|
|
||||||
1- cd to the tutorial dir
|
|
||||||
|
|
||||||
2- create the directory for your application (let's assume you call it
|
|
||||||
APPLICATION): type in
|
|
||||||
|
|
||||||
mkdir APPLICATION
|
|
||||||
|
|
||||||
3- go to the Templates dir
|
|
||||||
|
|
||||||
cd Templates
|
|
||||||
|
|
||||||
and run the helper script create.sh with the following arguments
|
|
||||||
|
|
||||||
./create.sh Appli ../APPLICATION
|
|
||||||
|
|
||||||
4- cd to the APPLICATION dir (cd ../APPLICATION).
|
|
||||||
You should see there the following files:
|
|
||||||
AppliEA.cpp the main file, includes all other, to be compiled
|
|
||||||
Makefile with default target eoAppliEA
|
|
||||||
eoAppli.h class eoAppli<FitT>, FitT = template fitness
|
|
||||||
eoAppliEvalFunc.h class for the computation of fotness
|
|
||||||
eoAppliInit.h class for genotype initlialization
|
|
||||||
eoAppliMutation.h class for mutation
|
|
||||||
eoAppliQuadCrossover.h class for (quadratic) crossover
|
|
||||||
make_genotype_Appli.h helper function that create the initializer
|
|
||||||
make_op_Appli.h helper function that creates the variatin operators
|
|
||||||
|
|
||||||
Note: You can go directly to step 6 and 7: you'll get a lot of
|
|
||||||
warnings, but will be able to run an EA that does nothing!
|
|
||||||
|
|
||||||
5- Edit those files to suit your needs. The minimal addition you'll need
|
|
||||||
to make are
|
|
||||||
in eoAppli.h define your genotype
|
|
||||||
in eoAppliInit.h define the initialization of one genotype
|
|
||||||
in eoAppliMutation.h define the mutation of one genotype
|
|
||||||
in eoAppliQuadCrossover.h define the crossover of 2 genotypes
|
|
||||||
|
|
||||||
HINT: look for keywords START and END and modify code in between.
|
|
||||||
|
|
||||||
6- Compile eoAppliEA.cpp. If your APPLICATION dir is in the tutorial
|
|
||||||
dir, you don't need to modify Makefile. Just type in
|
|
||||||
|
|
||||||
% make
|
|
||||||
|
|
||||||
7- Run the resulting program:
|
|
||||||
|
|
||||||
% eoAppliEA
|
|
||||||
|
|
||||||
The default output is one line per generation with the generation
|
|
||||||
number, the number of evaluations performed, the best and average
|
|
||||||
fitnesses in the population.
|
|
||||||
The algorithm stops by default after 100 generations.
|
|
||||||
|
|
||||||
8- Customize the parameters: copy eoAppliEA.status into
|
|
||||||
e.g. eoAppliEA.param, edit eoAppliEA.param (uncomment the lines you
|
|
||||||
want to become active), and run
|
|
||||||
|
|
||||||
% eoAppliEA @eoAppliEA.param
|
|
||||||
|
|
||||||
(see the Lesson 5 of the tutorial for more details now).
|
|
||||||
|
|
||||||
HINTS
|
|
||||||
-----
|
|
||||||
|
|
||||||
1- If some new classes you create require some user parameter, you can
|
|
||||||
either read them in the file where they are created (e.g.
|
|
||||||
make_op_Appli.h for variation operators), or pass the eoParser to the
|
|
||||||
constructor of the class, and read the parameter from the parser.
|
|
||||||
|
|
||||||
2- If you stick to privacy for the data in your EO class, you will
|
|
||||||
probably need to write accessors to those data, as well as some public
|
|
||||||
methods to modify them, as soon as some other methods need them too.
|
|
||||||
|
|
||||||
3- The sample make_op_Appli.h supposes that you ony have one crossover
|
|
||||||
and one mutation operator. However, the code for multiple operators is
|
|
||||||
there: you can have for instance 2 crossover operators, and choose
|
|
||||||
among them according to relative weights (proportional choice) - same
|
|
||||||
for mutation. Look at the operator section in eoAppliEA.cpp In
|
|
||||||
particular, the user parameters cross1Rate and mut1Rate are totally
|
|
||||||
useless for a single operator.
|
|
||||||
|
|
||||||
To add another operator, you have to create another class by mimicking
|
|
||||||
what has been done for the first operator.
|
|
||||||
For instance, let's suppose you want to create another mutation.
|
|
||||||
|
|
||||||
* duplicate the code for eoAppliMutation class
|
|
||||||
* in the second version, change the class name (eoAppliMutation) into
|
|
||||||
another name (let's say eoAppliBetterMutation) - you must change the
|
|
||||||
name in the class declaration, in the constructor and in the
|
|
||||||
className() method.
|
|
||||||
* in the new eoAppliBetterMutation class, change the code for the
|
|
||||||
operator() - and eventually the code for the constructor.
|
|
||||||
* in the make_op_Appli.h file, in the mutation section, uncomment the
|
|
||||||
lines
|
|
||||||
mut = new eoAppliSecondMutation<Indi>(varType _anyVariable);
|
|
||||||
_state.storeFunctor(mut);
|
|
||||||
double mut2Rate = _parser.createParam(1.0, "mut2Rate", "Relative rate for mutation 2", '2', "Variation Operators").value();
|
|
||||||
propMutation.add(*mut, mut2Rate);
|
|
||||||
|
|
||||||
and change the name of the class from eoAppliSecondMutation to your
|
|
||||||
name eoAppliBetterMutation (you can also change the keyword from
|
|
||||||
mut2Rate to something more meaningful like BetterMutationRate).
|
|
||||||
You're done!
|
|
||||||
|
|
||||||
In case of problem: Marc.Schoenauer@inria.fr
|
|
||||||
|
|
|
||||||
143
eo/tutorial/Templates/README.manual
Normal file
143
eo/tutorial/Templates/README.manual
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
This is the old template-directory README. Most of this information is
|
||||||
|
still accurate and it contains more details than the new README.
|
||||||
|
However, see there first for the creation of new projects.
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
This directory contains sample files that should make it easy to
|
||||||
|
create an EO algorithm to evolve any type of structure
|
||||||
|
(EO comes with two examples, bitstrings and vector of real variables,
|
||||||
|
so you'll need this as soon as you want to evolve something else).
|
||||||
|
|
||||||
|
At the moment, only algorithms involving a scalar fitness (double)
|
||||||
|
are implemented (see test dir for Pareto optimization of multiple-
|
||||||
|
objective fitness - or be patient :-)
|
||||||
|
|
||||||
|
This file will help you to build the same algorithm than the ones
|
||||||
|
in the Lesson4 of the tutorial, but with YOUR genotype instead of
|
||||||
|
bitstrings or vector<double>. More details in Lesson5 of the tutorial.
|
||||||
|
|
||||||
|
It is assumed in the following that you have read the first part of
|
||||||
|
the tutorial (Lessons 1 to 4).
|
||||||
|
|
||||||
|
Creating the algorithm for your genotype
|
||||||
|
----------------------------------------
|
||||||
|
In what follows, we will suppose that you want to evolve some data
|
||||||
|
structure, and that you have enough programming skills to be able to
|
||||||
|
write C code for its random initilialization, its crossover, its
|
||||||
|
mutation and the computation of its fitness.
|
||||||
|
|
||||||
|
The helper script * create.sh * will create for you the files you need
|
||||||
|
from the samples in tutorial/Templates dir, and all you'll have to do
|
||||||
|
is to include the actual code where indicated in those files (between
|
||||||
|
keywords START and END).
|
||||||
|
|
||||||
|
First, let's choose a name: let's call the new EO class eoAppli.
|
||||||
|
All newly created classes will be named eoAppliXXX (in the file
|
||||||
|
eoAppliXXX)
|
||||||
|
|
||||||
|
1- cd to the tutorial dir
|
||||||
|
|
||||||
|
2- create the directory for your application (let's assume you call it
|
||||||
|
APPLICATION): type in
|
||||||
|
|
||||||
|
mkdir APPLICATION
|
||||||
|
|
||||||
|
3- go to the Templates dir
|
||||||
|
|
||||||
|
cd Templates
|
||||||
|
|
||||||
|
and run the helper script create.sh with the following arguments
|
||||||
|
|
||||||
|
./create.sh Appli ../APPLICATION
|
||||||
|
|
||||||
|
4- cd to the APPLICATION dir (cd ../APPLICATION).
|
||||||
|
You should see there the following files:
|
||||||
|
AppliEA.cpp the main file, includes all other, to be compiled
|
||||||
|
Makefile with default target eoAppliEA
|
||||||
|
eoAppli.h class eoAppli<FitT>, FitT = template fitness
|
||||||
|
eoAppliEvalFunc.h class for the computation of fotness
|
||||||
|
eoAppliInit.h class for genotype initlialization
|
||||||
|
eoAppliMutation.h class for mutation
|
||||||
|
eoAppliQuadCrossover.h class for (quadratic) crossover
|
||||||
|
make_genotype_Appli.h helper function that create the initializer
|
||||||
|
make_op_Appli.h helper function that creates the variatin operators
|
||||||
|
|
||||||
|
Note: You can go directly to step 6 and 7: you'll get a lot of
|
||||||
|
warnings, but will be able to run an EA that does nothing!
|
||||||
|
|
||||||
|
5- Edit those files to suit your needs. The minimal addition you'll need
|
||||||
|
to make are
|
||||||
|
in eoAppli.h define your genotype
|
||||||
|
in eoAppliInit.h define the initialization of one genotype
|
||||||
|
in eoAppliMutation.h define the mutation of one genotype
|
||||||
|
in eoAppliQuadCrossover.h define the crossover of 2 genotypes
|
||||||
|
|
||||||
|
HINT: look for keywords START and END and modify code in between.
|
||||||
|
|
||||||
|
6- Compile eoAppliEA.cpp. If your APPLICATION dir is in the tutorial
|
||||||
|
dir, you don't need to modify Makefile. Just type in
|
||||||
|
|
||||||
|
% make
|
||||||
|
|
||||||
|
7- Run the resulting program:
|
||||||
|
|
||||||
|
% eoAppliEA
|
||||||
|
|
||||||
|
The default output is one line per generation with the generation
|
||||||
|
number, the number of evaluations performed, the best and average
|
||||||
|
fitnesses in the population.
|
||||||
|
The algorithm stops by default after 100 generations.
|
||||||
|
|
||||||
|
8- Customize the parameters: copy eoAppliEA.status into
|
||||||
|
e.g. eoAppliEA.param, edit eoAppliEA.param (uncomment the lines you
|
||||||
|
want to become active), and run
|
||||||
|
|
||||||
|
% eoAppliEA @eoAppliEA.param
|
||||||
|
|
||||||
|
(see the Lesson 5 of the tutorial for more details now).
|
||||||
|
|
||||||
|
HINTS
|
||||||
|
-----
|
||||||
|
|
||||||
|
1- If some new classes you create require some user parameter, you can
|
||||||
|
either read them in the file where they are created (e.g.
|
||||||
|
make_op_Appli.h for variation operators), or pass the eoParser to the
|
||||||
|
constructor of the class, and read the parameter from the parser.
|
||||||
|
|
||||||
|
2- If you stick to privacy for the data in your EO class, you will
|
||||||
|
probably need to write accessors to those data, as well as some public
|
||||||
|
methods to modify them, as soon as some other methods need them too.
|
||||||
|
|
||||||
|
3- The sample make_op_Appli.h supposes that you ony have one crossover
|
||||||
|
and one mutation operator. However, the code for multiple operators is
|
||||||
|
there: you can have for instance 2 crossover operators, and choose
|
||||||
|
among them according to relative weights (proportional choice) - same
|
||||||
|
for mutation. Look at the operator section in eoAppliEA.cpp In
|
||||||
|
particular, the user parameters cross1Rate and mut1Rate are totally
|
||||||
|
useless for a single operator.
|
||||||
|
|
||||||
|
To add another operator, you have to create another class by mimicking
|
||||||
|
what has been done for the first operator.
|
||||||
|
For instance, let's suppose you want to create another mutation.
|
||||||
|
|
||||||
|
* duplicate the code for eoAppliMutation class
|
||||||
|
* in the second version, change the class name (eoAppliMutation) into
|
||||||
|
another name (let's say eoAppliBetterMutation) - you must change the
|
||||||
|
name in the class declaration, in the constructor and in the
|
||||||
|
className() method.
|
||||||
|
* in the new eoAppliBetterMutation class, change the code for the
|
||||||
|
operator() - and eventually the code for the constructor.
|
||||||
|
* in the make_op_Appli.h file, in the mutation section, uncomment the
|
||||||
|
lines
|
||||||
|
mut = new eoAppliSecondMutation<Indi>(varType _anyVariable);
|
||||||
|
_state.storeFunctor(mut);
|
||||||
|
double mut2Rate = _parser.createParam(1.0, "mut2Rate", "Relative rate for mutation 2", '2', "Variation Operators").value();
|
||||||
|
propMutation.add(*mut, mut2Rate);
|
||||||
|
|
||||||
|
and change the name of the class from eoAppliSecondMutation to your
|
||||||
|
name eoAppliBetterMutation (you can also change the keyword from
|
||||||
|
mut2Rate to something more meaningful like BetterMutationRate).
|
||||||
|
You're done!
|
||||||
|
|
||||||
|
In case of problem: Marc.Schoenauer@inria.fr
|
||||||
10
eo/tutorial/Templates/README.tmpl
Normal file
10
eo/tutorial/Templates/README.tmpl
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
This is an autogenerated EO project
|
||||||
|
|
||||||
|
Fill in the marked code-snippets in the files in src/ and you have a
|
||||||
|
complete EA project.
|
||||||
|
|
||||||
|
The project has a complete build-infrastructure based on
|
||||||
|
automake/autoconf. You can simply run "make" in this directory to have
|
||||||
|
the program compiled. The executable build will be in src/.
|
||||||
|
|
||||||
|
Enjoy!
|
||||||
39
eo/tutorial/Templates/configure.ac.tmpl
Normal file
39
eo/tutorial/Templates/configure.ac.tmpl
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
# EO template autogeneration configure.ac template
|
||||||
|
#
|
||||||
|
# Copyright (C) 2006 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||||
|
#
|
||||||
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
AC_INIT(MyStruct, 0.1)
|
||||||
|
AC_CONFIG_SRCDIR(src/eoMyStruct.h)
|
||||||
|
AM_INIT_AUTOMAKE
|
||||||
|
AC_CONFIG_HEADERS(config.h)
|
||||||
|
|
||||||
|
dnl Checks for programs.
|
||||||
|
AC_PROG_CC
|
||||||
|
AC_PROG_CXX
|
||||||
|
AC_ISC_POSIX
|
||||||
|
|
||||||
|
dnl Checks for header files.
|
||||||
|
AC_STDC_HEADERS
|
||||||
|
AC_LANG(C++)
|
||||||
|
AC_CHECK_HEADERS([eo], [], [AC_ERROR(Evolving Objects headers are required)])
|
||||||
|
|
||||||
|
dnl Checks for libraries.
|
||||||
|
AC_LANG(C++)
|
||||||
|
AC_CHECK_LIB([eoutils], [main], [],
|
||||||
|
AC_MSG_ERROR([Evolving Objects utility library is required.]))
|
||||||
|
AC_CHECK_LIB([eo], [main], [],
|
||||||
|
AC_MSG_ERROR([Evolving Objects library is required.]))
|
||||||
|
AC_CHECK_LIB([es], [main], [],
|
||||||
|
AC_MSG_ERROR([EO Evolutionary strategies library is required.]))
|
||||||
|
|
||||||
|
dnl Checks for library functions.
|
||||||
|
|
||||||
|
AC_OUTPUT([Makefile src/Makefile])
|
||||||
|
|
||||||
|
|
||||||
|
dnl Local Variables:
|
||||||
|
dnl coding: iso-8859-1
|
||||||
|
dnl mode: autoconf
|
||||||
|
dnl fill-column: 80
|
||||||
|
dnl End:
|
||||||
79
eo/tutorial/Templates/createEOproject.sh
Executable file
79
eo/tutorial/Templates/createEOproject.sh
Executable file
|
|
@ -0,0 +1,79 @@
|
||||||
|
#! /bin/tcsh -f
|
||||||
|
#
|
||||||
|
# Script to create a completely new EO project from templates
|
||||||
|
#
|
||||||
|
# Originally by Marc Schoenauer
|
||||||
|
# Copyright (C) 2006 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||||
|
|
||||||
|
if ($PWD:t != Templates) then
|
||||||
|
echo "You must start this shell script from the EO Template directory"
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ($#argv < 1) then
|
||||||
|
echo "Usage: $0 ApplicationName [TargetDirName]"
|
||||||
|
echo " This will create ../TargetDirName if necessary (default dir name = ApplicationName),"
|
||||||
|
echo " and will also put all the files there that are strictly necessary to compile and run"
|
||||||
|
echo " your application."
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
|
||||||
|
# we're going to do something
|
||||||
|
echo " "
|
||||||
|
if ($#argv == 1) then
|
||||||
|
set TargetDir = ../$1
|
||||||
|
else
|
||||||
|
set TargetDir = ../$2
|
||||||
|
endif
|
||||||
|
if ( -d $TargetDir ) then
|
||||||
|
echo "Warning: The target directory does exist already."
|
||||||
|
echo -n "Overwrite (yes/no)? "
|
||||||
|
set REP = $<
|
||||||
|
if ($REP != "yes") then
|
||||||
|
echo "Stopping, nothing done!"
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
else if ( -e $TargetDir ) then
|
||||||
|
echo "Warning: $TargetDir exist but isn't a directory."
|
||||||
|
echo "Stopping, nothing done!"
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
mkdir -p $TargetDir/src
|
||||||
|
|
||||||
|
|
||||||
|
# creating files
|
||||||
|
echo "Creating source files for application $1 in $TargetDir/src"
|
||||||
|
sed s/MyStruct/$1/g eoMyStruct.tmpl > $TargetDir/src/eo$1.h
|
||||||
|
sed s/MyStruct/$1/g init.tmpl > $TargetDir/src/eo$1Init.h
|
||||||
|
sed s/MyStruct/$1/g stat.tmpl > $TargetDir/src/eo$1Stat.h
|
||||||
|
sed s/MyStruct/$1/g evalFunc.tmpl > $TargetDir/src/eo$1EvalFunc.h
|
||||||
|
sed s/MyStruct/$1/g mutation.tmpl > $TargetDir/src/eo$1Mutation.h
|
||||||
|
sed s/MyStruct/$1/g quadCrossover.tmpl > $TargetDir/src/eo$1QuadCrossover.h
|
||||||
|
sed s/MyStruct/$1/g MyStructSEA.cpp > $TargetDir/src/$1EA.cpp
|
||||||
|
|
||||||
|
echo "Creating build-support files for application $1 in $TargetDir"
|
||||||
|
sed s/MyStruct/$1/g configure.ac.tmpl > $TargetDir/configure.ac
|
||||||
|
sed s/MyStruct/$1/g Makefile.am.top-tmpl > $TargetDir/Makefile.am
|
||||||
|
sed s/MyStruct/$1/g Makefile.am.src-tmpl > $TargetDir/src/Makefile.am
|
||||||
|
sed s/MyStruct/$1/g README.tmpl > $TargetDir/README
|
||||||
|
touch $TargetDir/AUTHORS
|
||||||
|
touch $TargetDir/ChangeLog
|
||||||
|
touch $TargetDir/NEWS
|
||||||
|
|
||||||
|
echo "Successfully created project $1 in $TargetDir!"
|
||||||
|
echo "Start building the new project"
|
||||||
|
|
||||||
|
|
||||||
|
# building new project
|
||||||
|
cd $TargetDir
|
||||||
|
aclocal || exit
|
||||||
|
autoheader || exit
|
||||||
|
automake --add-missing --copy --gnu || exit
|
||||||
|
autoconf || exit
|
||||||
|
./configure || exit
|
||||||
|
make || exit
|
||||||
|
|
||||||
|
|
||||||
|
# done
|
||||||
|
echo "Project $1 successfully build in $TargetDir!"
|
||||||
|
echo "Implement your code and enjoy."
|
||||||
|
|
@ -17,7 +17,7 @@ and src/es (for real vectors).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Miscilaneous include and declaration
|
// Miscilaneous include and declaration
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ using namespace std;
|
||||||
// include here whatever specific files for your representation
|
// include here whatever specific files for your representation
|
||||||
// Basically, this should include at least the following
|
// Basically, this should include at least the following
|
||||||
|
|
||||||
/** definition of representation:
|
/** definition of representation:
|
||||||
* class eoMyStruct MUST derive from EO<FitT> for some fitness
|
* class eoMyStruct MUST derive from EO<FitT> for some fitness
|
||||||
*/
|
*/
|
||||||
#include "eoMyStruct.h"
|
#include "eoMyStruct.h"
|
||||||
|
|
@ -43,12 +43,12 @@ using namespace std;
|
||||||
// eoInit<eoMyStruct<double>> & make_genotype(eoParser& _parser, eoState&_state, eoMyStruct<double> _eo)
|
// eoInit<eoMyStruct<double>> & make_genotype(eoParser& _parser, eoState&_state, eoMyStruct<double> _eo)
|
||||||
// {
|
// {
|
||||||
// return do_make_genotype(_parser, _state, _eo);
|
// return do_make_genotype(_parser, _state, _eo);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// eoInit<eoMyStruct<eoMinimizingFitness>> & make_genotype(eoParser& _parser, eoState&_state, eoMyStruct<eoMinimizingFitness> _eo)
|
// eoInit<eoMyStruct<eoMinimizingFitness>> & make_genotype(eoParser& _parser, eoState&_state, eoMyStruct<eoMinimizingFitness> _eo)
|
||||||
// {
|
// {
|
||||||
// return do_make_genotype(_parser, _state, _eo);
|
// return do_make_genotype(_parser, _state, _eo);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// same thing for the variation operaotrs
|
// same thing for the variation operaotrs
|
||||||
//---------------------------------------
|
//---------------------------------------
|
||||||
|
|
@ -65,9 +65,9 @@ using namespace std;
|
||||||
|
|
||||||
// The following modules use ***representation independent*** routines
|
// The following modules use ***representation independent*** routines
|
||||||
|
|
||||||
// how to initialize the population
|
// how to initialize the population
|
||||||
// it IS representation independent if an eoInit is given
|
// it IS representation independent if an eoInit is given
|
||||||
#include <do/make_pop.h>
|
#include <make_pop.h>
|
||||||
eoPop<eoMyStruct<double> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoMyStruct<double> > & _init)
|
eoPop<eoMyStruct<double> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoMyStruct<double> > & _init)
|
||||||
{
|
{
|
||||||
return do_make_pop(_parser, _state, _init);
|
return do_make_pop(_parser, _state, _init);
|
||||||
|
|
@ -79,7 +79,7 @@ eoPop<eoMyStruct<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _
|
||||||
}
|
}
|
||||||
|
|
||||||
// the stopping criterion
|
// the stopping criterion
|
||||||
#include <do/make_continue.h>
|
#include <make_continue.h>
|
||||||
eoContinue<eoMyStruct<double> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoMyStruct<double> > & _eval)
|
eoContinue<eoMyStruct<double> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoMyStruct<double> > & _eval)
|
||||||
{
|
{
|
||||||
return do_make_continue(_parser, _state, _eval);
|
return do_make_continue(_parser, _state, _eval);
|
||||||
|
|
@ -91,19 +91,19 @@ eoContinue<eoMyStruct<eoMinimizingFitness> >& make_continue(eoParser& _parser, e
|
||||||
}
|
}
|
||||||
|
|
||||||
// outputs (stats, population dumps, ...)
|
// outputs (stats, population dumps, ...)
|
||||||
#include <do/make_checkpoint.h>
|
#include <make_checkpoint.h>
|
||||||
eoCheckPoint<eoMyStruct<double> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoMyStruct<double> >& _eval, eoContinue<eoMyStruct<double> >& _continue)
|
eoCheckPoint<eoMyStruct<double> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoMyStruct<double> >& _eval, eoContinue<eoMyStruct<double> >& _continue)
|
||||||
{
|
{
|
||||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||||
}
|
}
|
||||||
|
|
||||||
eoCheckPoint<eoMyStruct<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoMyStruct<eoMinimizingFitness> >& _eval, eoContinue<eoMyStruct<eoMinimizingFitness> >& _continue)
|
eoCheckPoint<eoMyStruct<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoMyStruct<eoMinimizingFitness> >& _eval, eoContinue<eoMyStruct<eoMinimizingFitness> >& _continue)
|
||||||
{
|
{
|
||||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// evolution engine (selection and replacement)
|
// evolution engine (selection and replacement)
|
||||||
#include <do/make_algo_scalar.h>
|
#include <make_algo_scalar.h>
|
||||||
eoAlgo<eoMyStruct<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoMyStruct<double> >& _eval, eoContinue<eoMyStruct<double> >& _continue, eoGenOp<eoMyStruct<double> >& _op)
|
eoAlgo<eoMyStruct<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoMyStruct<double> >& _eval, eoContinue<eoMyStruct<double> >& _continue, eoGenOp<eoMyStruct<double> >& _op)
|
||||||
{
|
{
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||||
|
|
@ -114,9 +114,9 @@ eoAlgo<eoMyStruct<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, e
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple call to the algo. stays there for consistency reasons
|
// simple call to the algo. stays there for consistency reasons
|
||||||
// no template for that one
|
// no template for that one
|
||||||
#include <do/make_run.h>
|
#include <make_run.h>
|
||||||
void run_ea(eoAlgo<eoMyStruct<double> >& _ga, eoPop<eoMyStruct<double> >& _pop)
|
void run_ea(eoAlgo<eoMyStruct<double> >& _ga, eoPop<eoMyStruct<double> >& _pop)
|
||||||
{
|
{
|
||||||
do_run(_ga, _pop);
|
do_run(_ga, _pop);
|
||||||
|
|
|
||||||
Reference in a new issue