如何在Python中对列表中的二进制值执行变异操作
假设我有下面给出的染色体。我想对其进行突变操作。 我想将两个基因从0更改为零。但是我必须随机选择这两个基因。如何在染色体上执行它:1?
Chromosome:1=['0001010010011001111100111101101110111001011011111010011011000110100010100011011100011000101100111011110000011101100000000010110001010100011100001001001110101111']
Suppose I have a chromosome given below. I want to perform a mutation operation on it.
I want to change two genes from 0 to 1 or 1 to zero. But I have to select these two genes at random. How can i perform it on chromosome:1?
Chromosome:1=['0001010010011001111100111101101110111001011011111010011011000110100010100011011100011000101100111011110000011101100000000010110001010100011100001001001110101111']
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
示例
从随机
标准库的包装>参数k = 2
以选择 unique 随机位置绳子,然后进行一些切片。Use
sample
from therandom
package of the standard library with parameterk=2
to select unique random positions in the string, then make some slice.