Adding Evolution Strategies:

src/es/eoEsGlobalXover.h and src/es/eoEsLocalXover.h for crossover
src/es/make_XXX_es.h for user-input
test/t-eoEsAll.cpp to test

However, an old bug appeared: className was not const in eoGenOp (and derived classes)
so I had to change that throughtout the hierarchy
This commit is contained in:
evomarc 2001-05-02 10:42:32 +00:00
commit 10064ad967
28 changed files with 471 additions and 180 deletions

View file

@ -14,19 +14,13 @@ CXXFLAGS = -g -Wall
###############################################################################
check_PROGRAMS = t-eoParetoFitness t-eoPareto t-eofitness t-eoRandom t-eobin t-eoStateAndParser t-eoCheckpointing t-eoSSGA \
t-eoExternalEO t-eoSymreg t-eo t-eoReplacement t-eoSelect t-eoGenOp t-eoGA t-eoReal t-eoVector
t-eoExternalEO t-eoSymreg t-eo t-eoReplacement t-eoSelect t-eoGenOp t-eoGA t-eoReal t-eoVector t-eoESAll
TESTS=run_tests t-eoVector t-eoRandom t-eoSSGA t-eoPareto t-eoParetoFitness
# removing temporarily t-eoESFull
# noinst_PROGRAMS = t-eofitness t-eobin t-eoStateAndParser t-eoCheckpointing t-eoExternalEO t-eoESFull t-eoSymreg t-eo t-eoReplacement t-eoSelect t-eoGenOp t-eoGA t-eoReal
###############################################################################
#t_eoESFull_SOURCES = t-eoESFull.cpp real_value.h
#t_eoESFull_DEPENDENCIES = $(DEPS)
#t_eoESFull_LDFLAGS = -lm
#t_eoESFull_LDADD = $(LDADDS)
###############################################################################
t_eoRandom_SOURCES = t-eoRandom.cpp
t_eoRandom_DEPENDENCIES = $(DEPS)
t_eoRandom_LDADD = $(LDADDS)
@ -122,6 +116,12 @@ t_eoReal_LDADD = $(top_builddir)/src/es/libes.a $(LDADDS)
###############################################################################
t_eoESAll_SOURCES = t-eoESAll.cpp real_value.h
t_eoESAll_DEPENDENCIES = $(DEPS) $(top_builddir)/src/es/libes.a
t_eoESAll_LDFLAGS = -lm
t_eoESAll_LDADD = $(top_builddir)/src/es/libes.a $(LDADDS)
###############################################################################
t_eoSSGA_SOURCES = t-eoSSGA.cpp binary_value.h
t_eoSSGA_DEPENDENCIES = $(DEPS) $(top_builddir)/src/ga/libga.a
t_eoSSGA_LDFLAGS = -lm

View file

@ -36,7 +36,6 @@ int main(int argc, char* argv[])
// initialize the population - and evaluate
// yes, this is representation indepedent once you have an eoInit
eoPop<EOT>& pop = make_pop(parser, state, init);
apply(eval, pop);
// stopping criteria
eoContinue<EOT> & term = make_continue(parser, state, eval);
@ -52,6 +51,9 @@ int main(int argc, char* argv[])
//// GO
///////
// evaluate intial population AFTER help and status in case it takes time
apply(eval, pop);
// print it out
cout << "Initial Population\n";
pop.sortedPrintOn(cout);
cout << endl;

View file

@ -59,7 +59,7 @@ class monop : public eoMonOp<EOT>
_eo.fitness(_eo.fitness()+pSize);
return false;
}
string className() {return sig;}
string className() const {return sig;}
private:
string sig;
};
@ -74,13 +74,13 @@ class binop: public eoBinOp<EOT>
_eo1.fitness(_eo1.fitness()+f);
return false;
}
string className() {return "binop";}
string className() const {return "binop";}
};
class quadop: public eoQuadOp<EOT>
{
public :
string className() {return "quadop";}
string className() const {return "quadop";}
bool operator()(EOT& a, EOT& b)
{
EOT oi = a;
@ -98,7 +98,7 @@ class quadop: public eoQuadOp<EOT>
class quadClone: public eoQuadOp<EOT>
{
public :
string className() {return "quadclone";}
string className() const {return "quadclone";}
bool operator()(EOT& , EOT& ) {return false;}
};
@ -120,7 +120,7 @@ class one2threeOp : public eoGenOp<EOT> // :-)
eo.s = "v(" + eo.s + ", 0)"; // only now change the thing
// oh right, and invalidate fitnesses
}
virtual string className() {return "one2threeOp";}
virtual string className() const {return "one2threeOp";}
};
@ -136,7 +136,7 @@ class two2oneOp : public eoGenOp<EOT> // :-)
eo.s = "221(" + eo.s + ", " + eo2.s + ")";
// oh right, and invalidate fitnesses
}
virtual string className() {return "two2oneOp";}
virtual string className() const {return "two2oneOp";}
};
class three2threeOp : public eoGenOp<EOT> // :-)
@ -159,7 +159,7 @@ class three2threeOp : public eoGenOp<EOT> // :-)
// oh right, and invalidate fitnesses
cout << "les enfants: a=" << eo1 << " et b=" << eo2 << " et c=" << eo3 << endl;
}
virtual string className() {return "three2threeOp";}
virtual string className() const {return "three2threeOp";}
};

View file

@ -26,7 +26,7 @@ int main(int argc, char* argv[])
eoEvalFuncCounter<EOT> eval(mainEval);
// the genotype - through a genotype initializer
eoInit<EOT>& init = make_genotype(parser, state, EOT());
eoRealInitBounded<EOT>& init = make_genotype(parser, state, EOT());
// Build the variation operator (any seq/prop construct)
eoGenOp<EOT>& op = make_op(parser, state, init);
@ -37,14 +37,13 @@ int main(int argc, char* argv[])
// initialize the population - and evaluate
// yes, this is representation indepedent once you have an eoInit
eoPop<EOT>& pop = make_pop(parser, state, init);
apply(eval, pop);
// stopping criteria
eoContinue<EOT> & term = make_continue(parser, state, eval);
// output
eoCheckPoint<EOT> & checkpoint = make_checkpoint(parser, state, eval, term);
// algorithm (need the operator!)
eoAlgo<EOT>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
eoAlgo<EOT>& ea = make_algo_scalar(parser, state, eval, checkpoint, op);
///// End of construction of the algorith
/////////////////////////////////////////
@ -53,11 +52,14 @@ int main(int argc, char* argv[])
//// GO
///////
// evaluate intial population AFTER help and status in case it takes time
apply(eval, pop);
// print it out
cout << "Initial Population\n";
pop.sortedPrintOn(cout);
cout << endl;
run_ea(ga, pop); // run the ga
run_ea(ea, pop); // run the ea
cout << "Final Population\n";
pop.sortedPrintOn(cout);