[galib] population.touch(), and best-of-generation statistics.

James McDermott jamesmichaelmcdermott at gmail.com
Fri Feb 24 09:45:55 EST 2006

Hi list,
I have a GALib program where the objective function uses userData.Sometimes, between generations, I need to be able to change somevalues in userData, and of course after doing that I need to touch()the population (so that individuals are re-evaluated, using the newuserData, next time):
  GAPopulation pop = ga.population();  ga.initialize();
  for (int i = 0; i < n; i++) {      ga.step();      if (some_condition) {          update_user_data();          pop.touch();      }      cout << "best individual: " << objective_function(pop.best()) << endl;  }

Now this works ok - it runs and the fitnesses reported are correct.But for some reason the values saved by the statistics object arewrong - they seem as if the population was never re-evaluated.
Has anyone seen anything like this? I've tried things likestats.update(pop) and pop.evaluate(gaTrue), but neither helps.
Side question: why can't I write:
instead of:
GAPopulation pop = ga.population(); pop.touch();
Could this be connected to the problem?

More information about the galib mailing list