2

我有一个关于在获得适应度成比例概率时如何处理为 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,但是当获得这些成员的概率时,它保持与最后一个非零成员相同的概率。有没有办法可以将非零概率与零概率分开?我在想,即使我根据最高适应度进行排序,最后一个非零成员的概率与零概率相同。

4

1 回答 1

2

考虑这个例子:

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(例如 I 4 ),则由于其选择条件(例如 I 4具有相关条件) ,它不能被选中0.75 <= number < 0.75

于 2017-11-28T17:22:14.107 回答