c# - 轮盘赌选择程序

标签 c# c#-4.0 genetic-algorithm genetic-programming

有没有可能像下面的伪代码一样,不用求概率就用适应度值来评价种群中的每个个体

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/

相关文章:

c# - 我可以在这里将引用类型视为值类型吗,还是需要克隆?

c# - 在 C# 中使用 Revit API 提示用户回答 bool 选择

c# - 属性 Get v 方法的性能

c# - Correct Concurrent Collection 存储定时非循环结构

.net - 的确,对于长时间运行的进程,最好手动执行线程而不是线程池?

c#-4.0 - "Can not directly save a child object"

c# - GA 适应度函数的时间复杂度

c# - 如何使用 sharpsvn 检查 subversion URL 是文件还是目录

genetic-algorithm - 在稳态遗传算法中应用变异

java - 使用轮盘赌选择的遗传算法