有没有可能像下面的伪代码一样,不用求概率就用适应度值来评价种群中的每个个体
For all members of population
sum += fitness ( member)
End for
Loop until new population is full
Do this twice
Number = Random between 0 and sum
Currentfitness = 0.0
For each member in population
Currentfitness += fitness (member)
if Number > Currentfitness then select member
End for
End
Create offspring
End loop
代码的以下部分是做什么的?
Do this twice
我真的很困惑轮盘赌是如何选择一对 parent 的。有什么帮助吗?提前致谢
最佳答案
Number 应该小于 Currentfitness,否则会严重偏向种群的第一个成员。
例子:
- 考虑权重 {1, 2, 7}
- 累计权重 {1, 3, 10}
- 总重量 10
- 使用 r.NextDouble(10.0) 在 0 到 10 之间随机选择 double
- 90% 的时间 1 是用给定的伪代码选择的。应该是 10%
关于c# - 轮盘赌选择程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10765660/