轮盘选择算法 [英] Roulette wheel selection algorithm

查看:86
本文介绍了轮盘选择算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能提供一些轮盘选择功能的伪代码?我将如何实现这一点:我真的不明白如何阅读这个数学符号.我想要通用算法.

Can anyone provide some pseudo code for a roulette selection function? How would I implement this: I don't really understand how to read this math notation.I want General algorithm to this.

推荐答案

其他答案似乎假设您正在尝试实施轮盘游戏.我认为您是在询问进化算法中的轮盘选择.

The other answers seem to be assuming that you are trying to implement a roulette game. I think that you are asking about roulette wheel selection in evolutionary algorithms.

这是一些实现轮盘选择的 Java 代码.

假设您有 10 个项目可供选择,并且您通过生成 0 到 1 之间的随机数进行选择.您将范围 0 到 1 划分为十个不重叠的部分,每个部分与十个项目之一的适应度成正比.例如,这可能如下所示:

Assume you have 10 items to choose from and you choose by generating a random number between 0 and 1. You divide the range 0 to 1 up into ten non-overlapping segments, each proportional to the fitness of one of the ten items. For example, this might look like this:

0 - 0.3 is item 1
0.3 - 0.4 is item 2
0.4 - 0.5 is item 3
0.5 - 0.57 is item 4
0.57 - 0.63 is item 5
0.63 - 0.68 is item 6
0.68 - 0.8 is item 7
0.8 - 0.85 is item 8
0.85 - 0.98 is item 9
0.98 - 1 is item 10

这是您的轮盘赌.您在 0 和 1 之间的随机数是您的自旋.如果随机数为 0.46,则选择的项为第 3 项.如果为 0.92,则为第 9 项.

This is your roulette wheel. Your random number between 0 and 1 is your spin. If the random number is 0.46, then the chosen item is item 3. If it's 0.92, then it's item 9.

这篇关于轮盘选择算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆