当染色体中的基因不是唯一的时候,如何在GA中应用顺序交叉?

时间:2016-11-14 12:03:03

标签: genetic-algorithm

在遗传算法(GA)中,顺序交叉(OX)通常适用于具有独特基因的染色体。根据这个paper,使用这些指令将OX应用于看起来像{3,1,2,1,1}的染色体:

(a) Randomly choose two cut-off points in the string.

(b) Copy the elements of the first parent that are found between the two
    cutoff points in the first offspring.

(c) Copy the elements that still have not been included in the first offspring
    as follows:

    (c.1) Start from the second cutoff point of the second parent.

    (c.2) Copy the elements not included in the first offspring, respecting
          the order in which the elements appear in the second parent.

    (c.3) Once the list of the second parent is finished, continue with the
          first elements (as in a circular arrangement).

(d) The second offspring is created in a similar way (steps b and c), inverting
    the role of the parents.

本文讨论的问题是广义最小生成树问题(GMSTP),其中图被划分为顶点簇,并且MST需要仅由每个簇的一个顶点构造。在本文中,染色体中的每个元素代表一个簇,元素的每个值都是簇的选定节点,以构建GMST。

OX保留了亲本2中基因的顺序。当使用GA解决旅行商问题(TSP)时,染色体的每个值代表一个节点(一个城市)。但是,当谈到GMSTP时,它对我来说很模糊,因为集群的顺序总是一样的。

[编辑]

OX示例:

Parent1 = { 1 2 3 4 5 6 7 8 9 }
Parent2 = { 3 2 8 1 4 9 6 5 7 }

after 2 random cut-off points

Parent1: { 1 2 | 3 4 5 6 | 7 8 9 }
Parent2: { 3 2 | 8 1 4 9 | 6 5 7 }

Copy genes between the two cut-off points of the 1st parent
Child1:  { x x | 3 4 5 6 | x x x }

Copy the rest of genes of the 2nd parent starting from the 2nd cut-off point,
excluding genes already in the child as well as preserving order 
Child1:  { 1 9 | 3 4 5 6 | 7 2 8 }

(Do the same for Child2 swapping the parents)

现在,尝试在这组基因上应用OX:

Parent1: { 3 1 2 1 1 }
Parent2: { 3 2 2 1 4 }

I do not see a way of doing that, however, researchers said they used OX here.

1 个答案:

答案 0 :(得分:1)

在这样的染色体上实施OX的一种方法是正常进行,如果遇到缺失的元素,则复制原始元素(来自第一作者对我问题的回答)。

使用新指令解决问题中的示例如下:

Parent1 = { 3 1 2 1 1 }
Parent2 = { 3 2 2 1 4 }

after 2 random cut-off points

Parent1: { 3 | 1 2 | 1 1 }
Parent2: { 3 | 2 2 | 1 4 }

Copy genes between the two cut-off points of the 1st parent
Child1:  { x | 1 2 | x x }

Copy the rest of genes of the 2nd parent starting from the 2nd cut-off point,
excluding genes already in the child as well as preserving order 
Child1:  { x | 1 2 | 4 3 }

Copy original values to the missing elements
child1:  { 3 | 1 2 | 4 3 }

The same for Child2 swapping the rules of the parents
child2:  { 3 | 2 2 | 1 3 }