通过适应度函数从群体中选择个体
我一直在研究一种算法,我需要从大小为 k 的群体中选择 n 个个体,其中 k 比 n 大得多。所有个体都有适应度值,因此选择时应优先考虑较高的适应度值。然而,我不想简单地选择最好的n个人,最差的人也应该有机会。 (自然选择)
所以,我决定找到种群内的最小和最大适应度值。因此,任何个体都有
p = (current - min) / (max - min)
的概率被选择,但我不能只是迭代所有这些,掷骰子并选择一个如果概率成立的话,因为那样我就结束了超过n个人。我可以打乱列表并从前面迭代,直到获得最多 n 个个体,但这可能会错过列表末尾的重要个体。
我还可以执行多次传递,直到剩余的种群数量达到 n。但这可能会更倾向于更好的选择,并收敛到我提到的朴素选择方法。
对这样的选择过程有何建议或参考?如果您可以参考的话,我可以阅读一些相关的统计方法。
谢谢。
I've been working on an algorithm, where I need to choose n individuals from a population of size k, where k is much bigger than n. All individuals have a fitness value, therefore the selection should favor higher fitness values. However, I don't want to simply choose best n individuals, the worse ones should have a chance also. (Natural selection)
So, I decided to find the min and max fitness values within population. So, any individual would have
p = (current - min) / (max - min)
probability to be chosen, but I can not just iterate over all of them, roll the dice and choose one if the probability holds, because then I end up with more than n individuals. I could shuffle the list and iterate from front, till I obtain up to n individuals, but that might miss great ones to the end of list.
I also could perform more than one passes, until the remaining population size reaches to n. But this might favor better ones a lot, and converge to the naive selection method I mentioned.
Any suggestion, or references to such a selection process? I could do some reading on relevant statistical methods if you can refer any.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用轮盘赌选择。基本思想是,您分配相对于概率大小的轮盘赌轮区域:
然后您只需旋转它
n
次来选择你想要的人。ruby 中的示例实现:
注意:如果您是 Ruby 黑客,您会发现使用更多 Rubyism 代码可能会更短,但我希望算法尽可能清晰。
Use Roulette-wheel selection. The basic idea is that you assign an area of the roulette-wheel relative to the probability size:
Then you simply spin it
n
times to select the individuals you want.Sample implementation in ruby:
Note: if you are a Ruby hacker, you see that the code could be much shorter with more Rubyisms, however I wanted the algorithm to be as clear as possible.