One more question
Vijay G Kovvali
vkovvali at mailcity.com
Wed Jun 21 14:05:24 EDT 2000
Thank you for the help you have been extending. I have one more question. I have the following code for which I am getting the same score value, and the same population over the generations. Checking it, I see that the Genome is setting the gene values to the minimum values from my GAAlleleSetArray. So, my genomes in each population and all the populations have the same value. What do I need to do to correct this problem?
Thanks,
Vijay
P.S. I am not using RealGenome since it is giving me lot of problems in linking
float Objective1(GAGenome& g);
void TForm1::RunGA()
{
int NoOfInts = 5;
GARandomSeed(100);
GAParameterList params;
GASimpleGA::registerDefaultParameters(params);
params.set(gaNscoreFilename, "bog.dat");
params.set(gaNflushFrequency, 50);
params.set(gaNpMutation, 0.01);
params.set(gaNpCrossover, 0.8);
params.set(gaNnGenerations, 50); // number of generations
params.set(gaNpopulationSize, 10); // population size
GAAlleleSetArray<float> MyBounds;
MyBounds.add(40, 120);
for(int i=0; i<NoOfInts*2; ++i)
{
MyBounds.add(0,1); //Values between 0 and 1
}
GA1DArrayAlleleGenome<float> MyGenome(MyBounds,Objective1);
GASimpleGA ga(MyGenome);
ga.parameters(params);
ga.evolve();
}
float Objective1(GAGenome& g)
{
GA1DArrayAlleleGenome<float> genome = (GA1DArrayAlleleGenome<float>&)g;
float value=0.0;
for(int i=0; i<genome.length(); i++)
{
value +=genome.gene(i);
}
return value;
}
Send FREE Greetings for Father's Day--or any day!
Click here: http://www.whowhere.lycos.com/redirects/fathers_day.rdct
More information about the galib
mailing list