[galib] Ellitism

Robert Burbidge rvb at aber.ac.uk
Tue Mar 17 11:56:25 EDT 2009


On 17 Mar 2009, at 15:35, Zyed Bouzarkouna wrote:

> I was wondering why to apply elitism, GALib choooses the fittest  
> chromosome to go automatically to next gen in 2 offspring.
> I don't see why the fittest is put twice in the next generation?

Hi Zyed,

I assume you are using a simple GA as elitism doesn't make sense for a  
steady state or incremental GA. The relevant code snippet is:

 >>>>>>>>
void
GASimpleGA::step()
{
...
// If we are supposed to be elitist, carry the best individual from  
the old
// population into the current population.  Be sure to check whether  
we are
// supposed to minimize or maximize.

   if(minimaxi() == GAGeneticAlgorithm::MAXIMIZE) {
     if(el && oldPop->best().score() > pop->best().score())
       oldPop->replace(pop->replace(&(oldPop->best()),  
GAPopulation::WORST),
		      GAPopulation::BEST);
   }
   else {
     if(el && oldPop->best().score() < pop->best().score())
       oldPop->replace(pop->replace(&(oldPop->best()),  
GAPopulation::WORST),
		      GAPopulation::BEST);
   }
...
}
<<<<<<<<<<

We can see that the best individual from the old population replaces  
the worst individual in the current population, provided that it is  
better than the best individual in the current population. This only  
results in one copy of the best in the current population.

It is of course possible to obtain more than one copy of the best  
through selection if it happens that it is not crossed over or  
mutated. Try running with pcross = 1.0 and you should only see (at  
most) one copy of the best in the next generation with elitism (except  
for the hopefully rare case where the crossover has no effect).

Rgds,
Robert



More information about the galib mailing list