【发布时间】:2014-02-07 12:14:59
【问题描述】:
让我从我正在实施的遗传算法版本开始。对于我在这里犯的任何术语错误,我提前道歉。请随时纠正我。
我的问题的染色体是二维的。三行三十二列。本质上,等位基因(值)是该染色体包含的索引。
如何制定索引
染色体的每一行和每一列(一起)指的是一个基因。每个基因包含一个整数值 (0 - 30)。因此,单列(我相信称为 gnome)是指包含用户数据的四维数组的索引,适应度函数在该数组上运行。
This is how a chromosome would look like
11 22 33 14 27 15 16 ...
3 29 1 7 18 24 22 ...
29 9 16 10 14 21 3 ...
e.g. column 0 ==> data[11][3][29]
where
11 -> (0, 0); 0th row, 0th column
3 -> (1, 0); 1st row, 0th column
29 -> (2, 0); 2nd row, 0th column
为了完整性,适应度函数的工作原理如下:(对于单个染色体)
for first 10 iterations: (user 0 to 9)
for each column (genome)
consider gene value for first row as the first index of data array
consider gene value for the second row as the second index of data array
consider gene value for the third row as the third index of data array
so if the first column contains [11][3][29] user = 0
it refers to data[0][11][3][29]
SUM the data array value for all columns and save it
Do the same for all iterations (users)
for second 10 iterations: (user 10 to 19)
for each column (genome)
consider gene value for the SECOND row as the FIRST index of data array
consider gene value for the THIRD row as the SECOND index of data array
consider gene value for FIRST row as the THIRD index of data array
SUM the data array value for all columns and save it
Do the same for all iterations (users)
for third 10 iterations: (user 20 to 29)
for each column (genome)
consider gene value for the THIRD row as the FIRST index of data array
consider gene value for FIRST row as the SECOND index of data array
consider gene value for the SECOND row as the THIRD index of data array
SUM the data array value for all columns and save it
Do the same for all iterations (users)
Out of the 30 (sum) values calculated so far, assign the minimum value as fitness value
to this chromosome.
这里解释适应度函数的重点是解释我正在处理的优化问题。很抱歉我无法用数学符号来表述它。任何人都可以做到这一点,他/她的评论非常受欢迎。本质上它是最大化最小 X。其中 X 是指包含在数据数组中的数据。 (在为下一代选择最高适应度染色体的世代中进行最大化)
Q1) 我正在使用单个随机数生成器来计算交叉和变异概率。一般来说,使用单个生成器实现它是否正确?我问这个问题是因为我选择的交叉率是 0.7,而突变是 0.01。我的随机数生成器生成一个均匀分布的整数。数字介于 0 到 (2^31 - 1) 之间。如果随机函数生成的数字位于满足突变的边界之下,则相同的数字也满足交叉。这会影响进化过程吗?
注意:随机数生成的最大数字是 2147483647。该值的 1% 是 21474836。因此,只要数字小于 21474836,就表明该基因可以发生突变。这个数字也表明必须进行交叉。不应该有不同的生成器吗?
Q2)虽然我看到基因之间存在关系,但在计算适应度时是一列。但是在执行突变时,所有基因都应该被认为是相互独立的,或者基因组(列)的所有行都应该受到突变的影响。
说明 正如我在二进制字符串中了解到的,例如1000 位,其中每个位对应一个基因,突变率为 1% 意味着 100 位中的 1 位可能会被翻转。但是在我的情况下,我的染色体是 2D(3 行,32 列)。我应该考虑所有 96 个相互独立的基因还是只考虑 32 个基因。每当我需要翻转时,一起翻转列。二维染色体中的突变如何发挥作用?
Q3)我在这里的行之间真的有相关性吗?我有一点疑惑?
说明 我有 2D 染色体,其列值完全指向我必须用来计算该染色体适应度的数据。遗传算法操纵染色体,因为适应度由与该染色体相关的数据分配。我的问题是遗传算法应该如何处理二维染色体。列中的基因之间是否应该存在关系。我可以参考一些操纵二维染色体的论文/代码吗?
【问题讨论】:
标签: algorithm random genetic-algorithm