Mutation, Crossover not working on GARealGenome

Naveeed Ahmad noni_4444 at hotmail.com
Thu Apr 18 02:56:48 EDT 2002


Dear all,
i have already posted one message, got one reply but could not solve my 
problem.
The problem is that the population does not change, i.e., i think the cross 
over and mutation operator are not working. I am using GARealGenome to code 
the genome. I caught the problem in Objective function.Here is the code.
GARealAlleleSet alleles(-10,10);
  GARealGenome  genome(33,alleles,Objective,(void*)chrom1);
  genome.initializer(GARealGenome::UniformInitializer);
  genome.mutator(GARealGenome::FlipMutator);
  genome.crossover(GARealGenome::OnePointCrossover);
  GASimpleGA ga(genome);
  ga.populationSize(14);
  ga.nGenerations(14);
  ga.pMutation(0.9);
  ga.pCrossover(0.9);
  ga.evolve();
The code of the objective function is

float Objective(GAGenome& g)
{
GA1DArrayGenome & genome=(GA1DArrayGenome &)g;
float score=0.0;
float* currentgenome=(float*)((GAGenome&)genome).userData();
*****************************
/*HERE IS THE PROBLEM PROBLEM*/
/*We ALWAYS GET THE SAME currentgenome.....HOW IS IT POSSIBLE IF MUTATION 
AND CROSSOVER ARE WORKING*/
*****************************
score=getScore(currentgenome);       // getScore function calculated the 
score of the genome
  return score;
}

We have to submit the project soon....so we would be very thankful if you 
reply soon...

Naveed Ahmad
FAST NUCES
Lahore

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx




More information about the galib mailing list