質問

I'm trying to implement roulette wheel selection. I found some pseudocode and I have implemented it however, there is something I dont understand regarding the genomes of 0 fitness.

the psudocode I found was this

for each genome in population:
    totalFitness = totalFitness + genome.fitness

x = random(0, totalFitness) 

currentCount = 0

for each genome in population:
    currentCount = currentCount + genome.fitness
    if currentCount >= x:
        parent = genome
        break

My concern is the following: say I have 5 genomes, which score the following fitness

G1 = 11
G2 = 0
G3 = 0
G4 = 0
G5 = 0

Based on the algorithm above, surely only G1 could ever be selected which would kill the genetic diversity.... Have I understood this right?

役に立ちましたか?

解決

Yes, you have understood correctly. If you want to have a better diversity you should give partial credit to the individuals, not just zero when they aren't very good.

One easy way to achieve this is by counting errors of the individual and then let the fitness be 1/(1+Errors). But just finding a way to give your individuals some points would solve your problem.

You may also want to look into scaling the fitness values. Now the chance of selection is proportional to the fitness.

他のヒント

You've understood correctly. As the above answer states, altering the fitness function so that 0 isn't a possibility is a good solution. Generally though, with this type of problem roulette wheel selection isn't the best choice.

If you're using a genetic algorithm where some of the population have a score of 0, but you still want to include them in the selection process, you should consider using a different selection method. Rank based roulette selection method would suit the problem a lot better. Not only would it give every genome a possibility of selection but it would also stop outliers from dominating the roulette wheel.

As with most implementations of genetic algorithms your choices are heavily influenced by the problem. Sometimes you'd want a genome with a fitness of 0 to be culled from the population, then you'd use roulette selection as above.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top