...

View Full Version : Help working with classes



FrogCity
09-11-2011, 10:35 PM
I am working on a genetic algorithm to minimize the spherical function. http://www.cs.cmu.edu/afs/cs/project/jair/pub/volume24/ortizboyer05a-html/node6.html#tabla:DefFunc

I have a class for each gene which is an array of size 30 with an associated fitness score.

I am having trouble passing the class to my crossover function which selects the best fitness scores and mixes their genetics.

Here is my code so far http://codepad.org/RWrPSXiE

oracleguy
09-12-2011, 12:12 AM
You can't call functions outside of any functions, move your call to srand into the main function before your for loop.

You could also change your program so that the constructor on your Geotype randomizes the array.

#2 This line: fitnessScore(Genotype individual); should be fitnessScore(individual); You don't need to specify the type again.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum