Reputation: 104
I have seen other SO questions asked about rank selection for genetic algorithms, but I am still confused. I haven't really seen an answer to this, or maybe I just didn't understand it: When using the rank selection, what is the population being ranked on? I had seen some answers say it's fitness, others say it's not. If it is possible to get a snippet of code so I can better understand this would be greatly appreciated. If there are any other questions, I can answer them to provide clarity. Thank you
EDIT: The case I am trying to solve is that I have a string I need the program to get right (I know what it is and have hard-coded it)
Upvotes: 0
Views: 356
Reputation: 77860
That code snippet, the fitness function, is entirely dependent on the application. It really defines the selection process. Imagine a simple program for playing five-card draw (poker). Each candidate is an algorithm that decides which cards to replace.
The fitness function might work like this: (1) remove the specified cards. (2) repeat 100 trials: replace the cards and compute the strength of the resulting hand. (3) return the average of the 100 trials.
That average stands as the fitness measure by which the algorithms are ranked.
Does that clear things up a little?
FOLLOW-UP
This means that you have to choose a similarity metric. You'll want something that is distinct for an exact match and degrades gracefully as you get farther from the right answer. A simple search will find the popular ones.
Upvotes: 1