我有一个关于在获得适应度成比例概率时如何处理为 0 的适应度(适应度'?)的问题。如果成员的容器首先按最高适应度排序,则执行类似于以下的代码:
for all members of population
sum += fitness of this individual
end for
for all members of population
probability = sum of probabilities + (fitness / sum)
sum of probabilities += probability
end for
loop until new population is full
do this twice
number = Random between 0 and 1
for all members of population
if number > probability but less than next probability then you have been selected
end for
end
create offspring
end loop
当我使用随机生成的成员手动进行一次迭代时,我看到的问题是我有一些成员的适应度为 0,但是当获得这些成员的概率时,它保持与最后一个非零成员相同的概率。有没有办法可以将非零概率与零概率分开?我在想,即使我根据最高适应度进行排序,最后一个非零成员的概率与零概率相同。