[galib] Print Individuals in the population

Miguel Nicolau Miguel.Nicolau at ul.ie
Thu Oct 20 07:08:18 EDT 2005


Hi Edgar,

Edgar GL wrote:
> Hi,
>  
> I've a basic question. I changed example 1 which refers to genome of 2D. 
> I would like to see each individual in the population. For this I have 
> removed ga.evolve and i've wrote:
>    while(!ga.done())
>       {
>       ga.step();
>       if(ga.generation() % 1 == 0)
>         {
>        for (i = 0; i < popsize; i++)
>              cout << genome << "\n";
>         }
>     }
>  
> But I see the same individual, so  I guess I need to update the genome, 
> do u know how to do it?

Try using this in the body of your loop:


cout << ga.population().individual(i) << "\n";


Not sure if this is the best approach to it, but it should work.

All the best

Miguel


More information about the galib mailing list