more generic eoSecondMomentStats: use EOT::Fitness instead of double

This commit is contained in:
Johann Dreo 2012-11-22 14:47:13 +01:00
commit 740275b31a

View file

@ -179,15 +179,13 @@ private :
Average fitness + Std. dev. of a population, fitness needs to be scalar. Average fitness + Std. dev. of a population, fitness needs to be scalar.
*/ */
template <class EOT> template <class EOT>
class eoSecondMomentStats : public eoStat<EOT, std::pair<double, double> > class eoSecondMomentStats : public eoStat<EOT, std::pair<typename EOT::Fitness, typename EOT::Fitness> >
{ {
public : public :
typedef typename EOT::Fitness FitT;
using eoStat<EOT, std::pair<double, double> >::value; using eoStat<EOT, std::pair<FitT, FitT> >::value;
typedef std::pair<FitT, FitT> SquarePair;
typedef typename EOT::Fitness fitness_type;
typedef std::pair<double, double> SquarePair;
eoSecondMomentStats(std::string _description = "Average & Stdev") eoSecondMomentStats(std::string _description = "Average & Stdev")
: eoStat<EOT, SquarePair>(std::make_pair(0.0,0.0), _description) : eoStat<EOT, SquarePair>(std::make_pair(0.0,0.0), _description)
@ -195,7 +193,7 @@ public :
static SquarePair sumOfSquares(SquarePair _sq, const EOT& _eo) static SquarePair sumOfSquares(SquarePair _sq, const EOT& _eo)
{ {
double fitness = _eo.fitness(); FitT fitness = _eo.fitness();
_sq.first += fitness; _sq.first += fitness;
_sq.second += fitness * fitness; _sq.second += fitness * fitness;