某些适应度为0时的适应度比例选择
Fitness Proportionate Selection when some fitnesses are 0
我有一个问题,关于如何处理在获得适应度比例概率时为 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,但是当获得这些成员的概率时,它与最后一个保持相同的概率非零成员。有没有办法可以将非零概率与零概率分开?我在想,即使我根据最高适应度排序,最后一个非零成员的概率也会与零概率相同。
考虑这个例子:
individual fitness(i) probability(i) partial_sum(i)
1 10 10/20 = 0.50 0.50
2 3 3/20 = 0.15 0.5+0.15 = 0.65
3 2 2/20 = 0.10 0.5+0.15+0.1 = 0.75
4 0 0/20 = 0.00 0.5+0.15+0.1+0.0 = 0.75
5 5 5/20 = 0.25 0.5+0.15+0.1+0.0+0.25 = 1.00
------
Sum 20
现在如果 number = Random between [0;1[
我们将选择个人 i
如果:
individual condition
1 0.00 <= number < partial_sum(1) = 0.50
2 0.50 = partial_sum(1) <= number < partial_sum(2) = 0.65
3 0.65 = partial_sum(2) <= number < partial_sum(3) = 0.75
4 0.75 = partial_sum(3) <= number < partial_sum(4) = 0.75
5 0.75 = partial_sum(4) <= number < partial_sum(5) = 1.00
如果一个个体具有适应度0
(例如I4),则由于其选择条件(例如I4 具有关联条件 0.75 <= number < 0.75
).
我有一个问题,关于如何处理在获得适应度比例概率时为 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,但是当获得这些成员的概率时,它与最后一个保持相同的概率非零成员。有没有办法可以将非零概率与零概率分开?我在想,即使我根据最高适应度排序,最后一个非零成员的概率也会与零概率相同。
考虑这个例子:
individual fitness(i) probability(i) partial_sum(i)
1 10 10/20 = 0.50 0.50
2 3 3/20 = 0.15 0.5+0.15 = 0.65
3 2 2/20 = 0.10 0.5+0.15+0.1 = 0.75
4 0 0/20 = 0.00 0.5+0.15+0.1+0.0 = 0.75
5 5 5/20 = 0.25 0.5+0.15+0.1+0.0+0.25 = 1.00
------
Sum 20
现在如果 number = Random between [0;1[
我们将选择个人 i
如果:
individual condition
1 0.00 <= number < partial_sum(1) = 0.50
2 0.50 = partial_sum(1) <= number < partial_sum(2) = 0.65
3 0.65 = partial_sum(2) <= number < partial_sum(3) = 0.75
4 0.75 = partial_sum(3) <= number < partial_sum(4) = 0.75
5 0.75 = partial_sum(4) <= number < partial_sum(5) = 1.00
如果一个个体具有适应度0
(例如I4),则由于其选择条件(例如I4 具有关联条件 0.75 <= number < 0.75
).