我正在尝试实现轮盘赌选择。我找到了一些伪代码并且我已经实现了它,但是关于 0 适应度的基因组,我有些不明白。
我发现的伪代码是这个
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
我担心的是:假设我有 5 个基因组,它们的适应度如下
G1 = 11
G2 = 0
G3 = 0
G4 = 0
G5 = 0
根据上面的算法,肯定只有 G1 会被选中,这会杀死遗传多样性......我理解对了吗?