对于遗传算法来说,表示二进制基因组的合理方法是什么?
我的上一个问题掩盖了我的经验不足,并且是基于一个假设。现在我聪明多了。 (将 1 和 0 放入字符串中?呸!我嘲笑这个建议!)
我的问题是,我应该如何编码我的基因组?
在纸面上,它们看起来像这样:
01010011010110010
17 位编码(在某些情况下单独,在某些情况下作为组)要测试的参数。
要求是:
- 需要可扩展。目前可能有 17 个,但随着选项的添加、删除或范围的修改,这个数量可能会增加/减少。
- 每个位都需要单独翻转,以代表点突变。
- 理想情况下,应该很容易获取两个基因组的最后 X% 并将它们交换(代表交叉)。
- 必须有一种以明文形式表示基因组的简单方法。这里强调的是便利性而不是人类可翻译性。 (想想 URL 缩短器。)
有人有什么好主意吗? (如果有用的话,我正在使用 C#。)
My previous question belied my inexperience and was based on an assumption. Now I am much wiser. (Put 1s and 0s in a string? Pah! I laugh at the suggestion!)
My question is then, how should I encode my genomes?
On paper, they look like this:
01010011010110010
17 bits that encode (in some cases singly and in some cases as groups) the parameters to be tested.
The requirements are:
- Needs to be scalable. There might be 17 at the moment, but this could grow/shrink as options are added, removed or have their range modified.
- Each bit needs to be individually flippable, to represent spot mutations.
- Ideally, it should be easy to take the last X% of two genomes and switch them over (representing crossover).
- There must be a straightforward way of representing the genome in plaintext. Here the emphasis is on convenience rather than human translatability. (Think URL shorteners.)
Anyone got any great ideas? (If it's useful, I'm using C#.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就像 Andrey 所说,BitArray 可能是您最好的答案,它满足您的所有要求。
1) 您可以使用构造函数设置位数
2) 它允许您设置(开或关)、或、与、异或、不在位上
3) 您可以循环最后的 x% 进行交叉
4) 有一个 ToString 应该允许您输出它。
Like Andrey said, BitArray is probably your best answer, it meets all your requirements.
1) you can set the number of bits with the constructor
2) it allows you Set (on or off),Or,And,Xor, Not on bits
3) you can loop over your last x% to do crossover
4) there is a ToString that should allow you to output it.
BitArray
BitArray