[galib] initialising/restarting GA from a given population...

Johannes Zellner johannes at zellner.org
Wed Oct 19 13:07:44 EDT 2005


On Wed, Oct 19, 2005 at 02:38:10PM +0100, Demet Erbas wrote:
> Hi,
> 
> I have a question about initializing GA search. I want GA search start
> from the population that I provide externally. I did it very simply with
> genome.initializer as follows;
> 
>  
> 
> // this is defined in the main program
> 
> ifstream init("init.pop");
> 
> genome.initializer(Init);
> 
>  
> 
> // here is the initializer, it reads the initial population from the
> file called 'init.pop'
> 
> void
> 
> Init(GAGenome& g){
> 
> GARealGenome& genome = (GARealGenome &)g;
> 
>  
> 
> genome.read(init);
> 
>  
> 
> return;
> 
> }
> 
>  
> 
> This works fine, but I don't want GA evaluate this initial population. I
> want it to read the objective function values from the file as well as
> the individuals. How can I do this? Any suggestion?

you can set score and fitness in your read function with the GAGenome
member functions

    score(float);
    fitness(float);

The former will set the flag _evaluated to True, so no further
score evaluation will be done later. (Fitness will probably be
recalculated according to your scaling function).

-- 
Johannes


More information about the galib mailing list