Small fixes in Condition checking.
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Sat, 4 Apr 2015 20:37:39 +0000 (22:37 +0200)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Sat, 4 Apr 2015 20:37:39 +0000 (22:37 +0200)
src/condition/condition.h

index be7c798a1a66163501088aa2c819c5baab4819a6..d9a1373c9cb4dc17667934105607b62fb17cac0d 100644 (file)
@@ -39,13 +39,17 @@ namespace genetic {
          * @return true if condition is satisfied and another generation can checked;
          *      false if condition is not satisfied and algorithm should stop.
          */
-        virtual bool check(Generation<_Chromosome> generation) {
-            if (currentGeneration >= maxNumberOfGenerations) {
-                return false;
-            }
+        virtual bool check(Generation<_Chromosome>) {
+            /* Initial population is never checked, as method is invoked after
+             * selection, crossover and mutation. It is safe to increment it now.
+             */
             currentGeneration++;
 
-            return true;
+            if (currentGeneration < maxNumberOfGenerations) {
+                return true;
+            }
+
+            return false;
         }
     };
 }