This question answers pseudocode for roulette wheel selection. But it's for maximization problem. But my problem is to minimize the value of fitness function. That means, individuals with low fitness get higher probability for being selected than individual with high fitness. How can I implement that?
Thanks in advance.
Rank selection is easy to implement when you already know on roulette wheel selection. Instead of using the fitness as probability for getting selected you use the rank. So for a population of N solutions the best solution gets rank N, the second best rank N-1, etc. The worst individual has rank 1.
A better approach to selection is to give every individual a chance of being selected to breed but to make fitter candidates more likely to be chosen than weaker individuals. This is achieved by making an individual's survival probability a function of its fitness score.
Use the same algorithm but make the proportion of each individual = maxfitness - fitness
Change the fitness to fitness_new = 1 / fitness_old and you have maximization problem again. If fitness_old = 0 is possible, add 1 to the denominator to avoid division by zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With