[galib] Need Help Please in the objective function structure

Oly Mo o_morad3 at yahoo.fr
Thu Sep 3 11:53:53 EDT 2009


Hello,
 
Would you please help me in the following requests:
 
 
1-In my program I have a for loop in each iteration I have to make a genetic algorithm run my problem is :how before starting the genetic algorithm run   I can send two arguments to the objective function, these arguments must be used in a formula to evaluate the real genome   one of them depend on the index of the loop.,,so how I have to declare  and invok my objective function to receive three arguments ,the first is the standard argument GAGenome&g then mytwo  arguments. A portion of the code  is below, I have gotten this code from example21 but I have added the loop cause I need to do a number of genetic algorithm run.
 
float Objective1(GAGenome& g)
 
int length = n;
 
 
GARealAlleleSet alleles1;
alleles1.add(0.0);
alleles1.add(1.0);
GARealGenome genome1(length, alleles1,Objective1);
 
GAParameterList params;
GASteadyStateGA::registerDefaultParameters(params);
params.set(gaNnGenerations, 500);
params.set(gaNpopulationSize, 110);
params.set(gaNscoreFrequency, 10);
params.set(gaNflushFrequency, 50);
params.set(gaNselectScores, (int)GAStatistics::AllScores);
params.parse(argc, argv, gaFalse);
 
 
for(j=0 ; j<size;j++)
{//Here the objective function should receive the two arguments one of them is the index of the loop
//Begin Genetic run
GASteadyStateGA ga1(genome1);
ga1.parameters(params);
ga1.set(gaNscoreFilename, "bog1.dat");
ga1.evolve(seed);
//End Genetic run
}
 
 
2-If I want  to receive the best solution of a genetic algorithm run is the following syntax correct?
 
genome1 = ga1.statistics().bestIndividual();
 
I am really very thankful if someone help me,
Best Regards


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/galib/attachments/20090903/3c29a575/attachment.htm


More information about the galib mailing list