diff --git a/eo/src/es/eoEsLocalXover.h b/eo/src/es/eoEsStandardXover.h similarity index 75% rename from eo/src/es/eoEsLocalXover.h rename to eo/src/es/eoEsStandardXover.h index bcf1c855..df7c2374 100644 --- a/eo/src/es/eoEsLocalXover.h +++ b/eo/src/es/eoEsStandardXover.h @@ -36,13 +36,14 @@ // needs a selector - here random #include -/** Local (i.e. std eoBinOp) crossover operator for ES genotypes. +/** Standard (i.e. eoBinOp) crossover operator for ES genotypes. * Uses some Atom crossovers to handle both the object variables * and the mutation strategy parameters - * It is an eoGenOp and not an eoBinOp for consistency with the global version + * It is an eoBinOp and has to be wrapped into an eoGenOp before being used + * like the global version */ template -class eoEsLocalXover: public eoGenOp +class eoEsStandardXover: public eoBinOp { public: typedef typename EOT::Fitness FitT; @@ -50,36 +51,25 @@ public: /** * (Default) Constructor. */ - eoEsLocalXover(eoBinOp & _crossObj, eoBinOp & _crossMut) : + eoEsStandardXover(eoBinOp & _crossObj, eoBinOp & _crossMut) : crossObj(_crossObj), crossMut(_crossMut) {} /// The class name. Used to display statistics - virtual string className() const { return "eoEsLocalXover"; } - - /// The TOTAL number of offspring (here = nb of parents modified in place) - unsigned max_production(void) { return 1; } + virtual string className() const { return "eoEsStandardXover"; } /** * modifies one parents in the populator * using a second parent - * - * @param _pop a POPULATOR (not a simple population) */ - void apply(eoPopulator& _plop) - { - // First, select as many parents as you will have offspring - EOT& parent1 = *_plop; // select the first parent - const EOT& parent2 = sel(_plop.source()); // and the second, randomly - + bool operator()(EOT& _eo1, const EOT& _eo2) + { // first, the object variables - for (unsigned i=0; i -#include - -/** -\ingroup EvolutionStrategies - -Crossover for Evolutionary strategie style representation, - supporting co-evolving standard deviations. - -Simply calls a crossover for the object variables, - and a crossover for teh StdDev -*/ - -template -class eoEsStdevXOver : public eoQuadOp -{ -public : - eoEsStdevXOver(eoQuadOp > & _objectXOver, - eoQuadOp > & _stdDevXOver) : - objectXOver(_objectXOver), stdDevXOver(_stdDevXOver) {} - - virtual std::string className(void) const { return "eoEsStdevXOver"; } - - bool operator()(EOT & _eo1, EOT & _eo2) - { - bool objectChanged = objectXOver(_eo1, _eo2); // as vector - bool stdDevChanged = stdDevXOver(_eo1.stdevs, _eo2.stdevs); - - return objectChanged; - } - -private: - eoQuadOp > & objectXOver; - eoQuadOp > & stdDevXOver; -}; - -/* A question: it seems it really makes no difference to have - as template the fitness (and use eoEsStdev where you need EOs) or - directly the EOT itself. But of course if the EOT you use does not have - a stdev public member the compiler will crash. - There is a difference, however, in the calling instruction, because in - on case you have to write eoEsStdevXOver whereas otherwise you - simply write eoEsStdevXOver (if Indi has been typedef'ed correctly). - So to keep everything (or almost :-) in the main program templatized - with the Indi i've kept here the EOT template. - -Are there arguments against that??? -MS - Marc.Schoenauer@polytechnique.fr -*/ - -#endif