more generic eoSecondMomentStats: use EOT::Fitness instead of double
This commit is contained in:
parent
8af6aa295e
commit
740275b31a
1 changed files with 5 additions and 7 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue