diff --git a/eo/src/eoFitContinue.h b/eo/src/eoFitContinue.h index 42d7ae5e..276e0b7c 100644 --- a/eo/src/eoFitContinue.h +++ b/eo/src/eoFitContinue.h @@ -47,8 +47,15 @@ public: * reached. Assumes pop is not sorted! */ virtual bool operator() ( const eoPop& _pop ) { - return (_pop.nth_element_fitness(0) < maximum); - } + FitnessType bestCurrentFitness = _pop.nth_element_fitness(0); + if (bestCurrentFitness >= maximum) + { + cout << "STOP in eoFitContinue: Best fitness has reached " << + bestCurrentFitness << "\n"; + return false; + } + return true; + } private: FitnessType maximum; diff --git a/eo/src/eoGenContinue.h b/eo/src/eoGenContinue.h index a0fcc77f..6458f62f 100644 --- a/eo/src/eoGenContinue.h +++ b/eo/src/eoGenContinue.h @@ -52,7 +52,12 @@ public: virtual bool operator() ( const eoPop& _vEO ) { thisGeneration++; // cout << " [" << thisGeneration << "] "; - return (thisGeneration < repTotalGenerations) ; // for the postincrement + if (thisGeneration >= repTotalGenerations) + { + cout << "STOP in eoGenContinue: Reached maximum number of generations\n"; + return false; + } + return true; } /** Sets the number of generations to reach