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; nbSolutionsEncountered = currentAvg = currentVar = 0;
firstTime = false; firstTime = false;
} }
/*else if (firstTime)
{
value() = 0.0;
firstTime = false;
}*/
operator()(_sol); operator()(_sol);
} }
@ -85,13 +80,9 @@ public :
double x = _sol.fitness(); double x = _sol.fitness();
double oldAvg = currentAvg; double oldAvg = currentAvg;
currentAvg = oldAvg + (x - oldAvg)/nbSolutionsEncountered; currentAvg = oldAvg + (x - oldAvg)/nbSolutionsEncountered;
if (nbSolutionsEncountered > 1) // <- not really necessary double oldVar = currentVar;
{ currentVar = oldVar + (x - oldAvg) * (x - currentAvg);
//value() = (value()/nbSolutionsEncountered + _sol.fitness())/(nbSolutionsEncountered+1); 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 ) for ( size_t i = 0; i < sol.size(); ++i )
{ {
//std::cout << sol[i] << std::endl;
sum += sol[i] * sol[i]; sum += sol[i] * sol[i];
} }
@ -28,7 +27,6 @@ double objective_function(const EOT & sol)
int main(int ac, char** av) int main(int ac, char** av)
{ {
//moNeighborhoodStat<Neighbor> nhStat
moFitnessVarianceStat<EOT> stat; moFitnessVarianceStat<EOT> stat;
eoEvalFuncPtr< EOT, double > eval( objective_function ); eoEvalFuncPtr< EOT, double > eval( objective_function );
EOT solution(2, 5); EOT solution(2, 5);
@ -38,7 +36,6 @@ int main(int ac, char** av)
solution.invalidate(); solution.invalidate();
eval(solution); eval(solution);
stat(solution); stat(solution);
//assert(stat.value() == 1);
std::cout << "var: " << stat.value() << std::endl; std::cout << "var: " << stat.value() << std::endl;
assert(stat.value() == 625); assert(stat.value() == 625);
} }