From: Rafał Długołęcki Date: Sat, 4 Apr 2015 20:37:39 +0000 (+0200) Subject: Small fixes in Condition checking. X-Git-Url: https://git.dlugolecki.net.pl/?p=genetic.git;a=commitdiff_plain;h=b81d71a34fc7b18764f2ab75e6e29949a811a532 Small fixes in Condition checking. --- diff --git a/src/condition/condition.h b/src/condition/condition.h index be7c798..d9a1373 100644 --- a/src/condition/condition.h +++ b/src/condition/condition.h @@ -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; } }; }