This commit is contained in:
LPTK 2013-06-13 15:37:47 +02:00
commit a1ce594a38
2 changed files with 3 additions and 15 deletions

View file

@ -68,11 +68,6 @@ public :
nbSolutionsEncountered = currentAvg = currentVar = 0;
firstTime = false;
}
/*else if (firstTime)
{
value() = 0.0;
firstTime = false;
}*/
operator()(_sol);
}
@ -85,13 +80,9 @@ public :
double x = _sol.fitness();
double oldAvg = currentAvg;
currentAvg = oldAvg + (x - oldAvg)/nbSolutionsEncountered;
if (nbSolutionsEncountered > 1) // <- not really necessary
{
//value() = (value()/nbSolutionsEncountered + _sol.fitness())/(nbSolutionsEncountered+1);
double oldVar = currentVar;
currentVar = oldVar + (x - oldAvg) * (x - currentAvg);
value() = currentVar/nbSolutionsEncountered;
}
double oldVar = currentVar;
currentVar = oldVar + (x - oldAvg) * (x - currentAvg);
value() = currentVar/nbSolutionsEncountered;
}
/**

View file

@ -19,7 +19,6 @@ double objective_function(const EOT & sol)
for ( size_t i = 0; i < sol.size(); ++i )
{
//std::cout << sol[i] << std::endl;
sum += sol[i] * sol[i];
}
@ -28,7 +27,6 @@ double objective_function(const EOT & sol)
int main(int ac, char** av)
{
//moNeighborhoodStat<Neighbor> nhStat
moFitnessVarianceStat<EOT> stat;
eoEvalFuncPtr< EOT, double > eval( objective_function );
EOT solution(2, 5);
@ -38,7 +36,6 @@ int main(int ac, char** av)
solution.invalidate();
eval(solution);
stat(solution);
//assert(stat.value() == 1);
std::cout << "var: " << stat.value() << std::endl;
assert(stat.value() == 625);
}