diff --git a/eo/src/eoSequentialSelect.h b/eo/src/eoSequentialSelect.h index 1a1f02e4e..adf3cf452 100644 --- a/eo/src/eoSequentialSelect.h +++ b/eo/src/eoSequentialSelect.h @@ -51,7 +51,8 @@ always returns individuals from best to worst @ingroup Selectors */ -template class eoSequentialSelect: public eoSelectOne +template +class eoSequentialSelect: public eoSelectOne { public: /** Ctor: sets the current pter to numeric_limits::max() so init will take place first time @@ -60,7 +61,7 @@ template class eoSequentialSelect: public eoSelectOne eoSequentialSelect(bool _ordered = true) : ordered(_ordered), current(std::numeric_limits::max()) {} - void setup(const eoPop& _pop) + virtual void setup(const eoPop& _pop) { eoPters.resize(_pop.size()); if (ordered) // probably we could have a marker to avoid re-sorting @@ -86,6 +87,24 @@ private: }; +/** An eoSelectOne that returns the best individual each time it's called. + +@ingroup Selectors +*/ +template +class eoEliteSelect: public eoSequentialSelect +{ + public: + eoEliteSelect() : + eoSequentialSelect(true) + {} + + virtual const EOT& operator()(const eoPop& pop) + { + this->setup(pop); + return pop[0]; // the best one + } +}; /** All Individuals in order