Web Analytics Made Easy -
StatCounter Help working with classes - CodingForum

Announcement

Collapse
No announcement yet.

Help working with classes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help working with classes

    I am working on a genetic algorithm to minimize the spherical function. http://www.cs.cmu.edu/afs/cs/project...#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
    Last edited by FrogCity; Sep 11, 2011, 04:43 PM. Reason: subscribe

  • #2
    You can't call functions outside of any functions, move your call to srand into the main function before your for loop.

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


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

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎