diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index c06188d5..ef013716 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -35,7 +35,10 @@ /** Base class for all statistics that need to be calculated - over the (unsorted) population (I guess it is not really necessary? MS) + over the (unsorted) population + (I guess it is not really necessary? MS. + Depends, there might be reasons to have a stat that is not an eoValueParam, + but maybe I'm just kidding myself, MK) */ template class eoStatBase : public eoUF&, void> @@ -97,7 +100,7 @@ public : eoAverageStat(std::string _description = "Average Fitness") : eoStat(fitness_type(), _description) {} #endif - static double sumFitness(double _sum, const EOT& _eot) + static fitness_type sumFitness(double _sum, const EOT& _eot) { _sum += _eot.fitness(); return _sum; @@ -135,7 +138,7 @@ private : template void doit(const eoPop& _pop, T) { - double v = std::accumulate(_pop.begin(), _pop.end(), 0.0, eoAverageStat::sumFitness); + fitness_type v = std::accumulate(_pop.begin(), _pop.end(), fitness_type(0.0), eoAverageStat::sumFitness); value() = v / _pop.size(); } @@ -149,6 +152,8 @@ template class eoSecondMomentStats : public eoStat > { public : + typedef typename EOT::Fitness fitness_type; + typedef std::pair SquarePair; eoSecondMomentStats(std::string _description = "Average & Stdev") : eoStat(std::make_pair(0.0,0.0), _description) {} @@ -245,6 +250,10 @@ private : /* Actually, you shouldn't need to sort the population to get the best fitness MS - 17/11/00 + But then again, if another stat needs sorted fitness anyway, getting the best + out would be very fast. + MK - 09/01/03 + template class eoBestFitnessStat : public eoStat {