From e4b735b17f18e05baa7b3cb34f5380d4be1a1fb4 Mon Sep 17 00:00:00 2001 From: evomarc Date: Tue, 28 Nov 2000 15:35:09 +0000 Subject: [PATCH] Added a comment to stdout upon termination - so we know why we stop in case of multiple criteria --- eo/src/eoFitContinue.h | 11 +++++++++-- eo/src/eoGenContinue.h | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) 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