Mutation, Crossover not working on GARealGenome

Naveeed Ahmad noni_4444 at hotmail.com
Thu Apr 18 16:57:22 EDT 2002


Dear Markku,
Thanks for the information...gene function does infact return the 
values..BUT NOW I FACE AN EQUALLY CONFUSING PROBLEM...now all the values in 
the genes are initialized to the lower limit of the allele set which i had 
used to initialize the genome.
Here is the code

GARealAlleleSet alleles(-10.0,10.0);
/********************************************
NOTE THAT LOWER LIMIT OF ALLELE SET IS -10.0
*********************************************/
GARealGenome genome1(33,alleles,Objective);

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);

GASteadyStateGA ga1(genome1);
ga1.parameters(params);
ga1.evolve();

//code for the objective function

float Objective(GAGenome& g)
{
	GARealGenome & genome=(GARealGenome&)g;
	float* currentgenome=new float[33];
	for(int i=0;i<33;i++)
	{
		currentgenome[i]=0;
	}
	for(i=0;i<33;i++)
	{

		currentgenome[i]=(float&)genome.gene(i);
/******************************************************
HERE IS THE PROBLEM. ALL THE VALUES OF CURRENT GENOME ARE
SET TO -10 I.E., THE LOWER LIMIT OF THE ALLELE SET
NOW WHAT COULD BE THE POSSIBLE REASON.
*******************************************************/
	}
	float score=0.0;
	int check=getScore(currentgenome,score);//to calculate score
	delete []currentgenome;
	return score;

}
/*******************************************************
I AM ALSO GETTING A MESSAGE.COULD IT BE THE POSSIBLE CAUSE OF
ERROR
********************************************************/

GAAlleleSet::allele(unsigned int):
  this method has not been defined.

I would really appreciate if anyone could reply to me at the earliest ....i 
am really standing on my toes...

Naveed Ahmad
FAST NUCES
LAHORE





>From: Markku Laukkanen Reply-To: galib at mit.edu To: Naveeed Ahmad CC: 
>galib at mit.edu Subject: Re: Mutation, Crossover not working on GARealGenome 
>Date: Thu, 18 Apr 2002 10:14:20 +0300 (EET DST)
>
>
>
> > 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; > }
>
>userData function always returns the same value for all genes. This is a 
>pointer into user defined data, which the user wants to use with the genome 
>(e.g. pointer into this object of the implementation of the problem 
>solver);
>
>You have to use the genome.gene(x) functions to retrieve the right data..
>
>PKY
>
>
> > > 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 > > 
>_______________________________________________ > galib mailing list > 
>galib at mit.edu > http://lancet.mit.edu/mailman/listinfo/galib >
>
>_______________________________________________ galib mailing list 
>galib at mit.edu http://lancet.mit.edu/mailman/listinfo/galib

_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com




More information about the galib mailing list