From 16e09360c9789fcf1309fc3ae64212d975db4b39 Mon Sep 17 00:00:00 2001 From: okoenig Date: Mon, 14 Jun 2004 11:24:37 +0000 Subject: [PATCH] Added a failed boolean to indicate if fitness evaluation succeeded ( useful if programs are involved, where fitness evaluation can fail for some indis) Avg Stats are now only evaluated of individuals if this bool is false! --- eo/src/utils/eoAssembledFitnessStat.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/eo/src/utils/eoAssembledFitnessStat.h b/eo/src/utils/eoAssembledFitnessStat.h index b468f564..6a064b1e 100644 --- a/eo/src/utils/eoAssembledFitnessStat.h +++ b/eo/src/utils/eoAssembledFitnessStat.h @@ -40,6 +40,7 @@ Average fitness values of a population, where the fitness is of type eoScalarAssembledFitness. Specify in the constructor, for which fitness term (index) the average should be evaluated. + Only values of object where the failed boolean = false is set are counted. */ #ifdef _MSC_VER template @@ -61,10 +62,15 @@ public : if ( whichFitnessTerm >= _pop[0].fitness().size() ) throw std::logic_error("Fitness term requested out of range"); - double result =0.0; - for (typename eoPop::const_iterator it = _pop.begin(); it != _pop.end(); ++it) - result+= it->fitness()[whichFitnessTerm]; - + double result =0.0; + unsigned count = 0; + for (typename eoPop::const_iterator it = _pop.begin(); it != _pop.end(); ++it){ + if ( it->fitness().failed == false ){ + result+= it->fitness()[whichFitnessTerm]; + ++count; + } + } + value().clear(); value() = result / _pop.size();