Forcing Evaluation

Matthew Wall mbwall at MIT.EDU
Mon Aug 12 12:55:22 EDT 2002


>Hi All,
>  I am using galib with a noisy objective function - it does not always
>return the same value for a specific genome.
>As I am using elitism my best genomes from each generation get 
>passed on from generation to generation without being re-evaluated. 
>I know this to be the case because the fitness of the best genome is 
>a  monotonously increasing step function - this being highly 
>unlikely considering how noisy my objective function is.  I would 
>like to force galib to re-evaluate my genome in each generation.
>
>I wrote the following population evaluator:
>
>void PopEvaluator(GAPopulation & p)
>{
>  for(int i=0; i<p.size(); i++)
>    p.individual(i).evaluate(gaTrue);
>}
>
>and set it using:
>
>GAPopulation& pop = const_cast<GAPopulation&>(ga.population());
>pop.evaluator(&PopEvaluator);

this is a very bad thing to do.  the ga returns a const population 
object because it does *not* want you to modify it.  you should do 
this instead:

   GAPopulation pop(genome);
   pop.evaluator(PopEvaluator);
   GASteadyStateGA ga(pop);
   ga.evolve();

some of the GA implementations use multiple populations, and by 
forcing you pop evaluator on the ga's population, you are assigning 
your evaluator to one of those populations (but evidently not to the 
one that is doing the work).

>I expected this to solve the problem as I force evaluation in the 
>population evaluator.  What happens is a bit surprising, my 
>evaluator is used only every other call to the population evaluator, 
>the other call goes to the default population evaluator which does 
>not force evaluation.



More information about the galib mailing list