• No results found

5.3 Computation: Algorithm Setup

5.3.3 Genetic Operators

There are some existing operators for tree structures [56]. But those methods can not guarantee that the resulting tree structures are legal in the sense that every leaf of the tree represents one graph node, and every graph node appears once on the leaves of the tree representation. There are two approaches to deal with this problem. One is to insert a penalty in the fitness function for illegal structures, and the other is to design new operators which only produce legal genomes. It is not very clear how to integrate penalty into the fitness function in the first method, so the later method is used here. That is, it is necessary to design new genetic operators.

5.3.3.1 Crossover

The crossover operator includes five steps.

1. Randomly select two parents (T1, T2) by roulette wheel method. Two parents are shown in

Figure 5.4.

2. Uniformly randomly select two hidden nodes from the two parent trees, respectively, label the two subtrees under the selected nodes asDT1,DT2and the two leftover subtrees asLT1,LT2,

1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 M 2 1 3 2 0 4 6 7 5 11 8 12 N 1 N 4 N 3 N 2 9 10 3 2 11 5 8 N 3 1 2 3 0 4 5 6 7 8 M 1 M 3 M 2 LT 1 LT 2 CT 2 CT 1 DT 2 DT 1 T 1 T 2

Figure 5.5: Crossover step 2: select crossover points.

3. Keep subtrees LT1, LT2 unchanged, delete common leaves ofCT1 and CT2 from T1 andT2,

and delete the uncommon leaves fromCT1 andCT2, as shown in Figure 5.6.

4. Randomly select a hidden node from (T1-LT1) and add subtreeCT2. Do the same forT2and

CT1, as shown in Figure 5.7.

5. Clean fragments. The hidden nodes that have no child nodes will be removed. Those hidden nodes having only one child node will be removed, and its child node will be attached to its parent, as shown in Figure 5.8.

5.3.3.2 Mutation

There are four different mutation operators: swapping two leaves, swapping two subtrees, merging leaves, and splitting a large subtree.

1. Swapping two leaves: First, randomly select two leaves from different clusters and then ex- change them, as shown in Figure 5.9.

2. Swapping two subtrees: First, randomly select two subtrees, neither of which is a subtree of the other, and then exchange them, as shown in Figure 5.10.

3. Merging leaves: Randomly select a subtree, and merge the leaves according to the following cases:

• CASE 1: If the subtree has few single nodes (say 1 or 2), those single nodes will be merged into a randomly selected subtree under the subtree, as shown in Figure 5.11.

1 0 4 6 7 9 10 11 12 M 1 M 4 M 3 M 2 1 0 4 6 7 11 12 N 1 N 4 N 3 N 2 9 10 3 2 5 8 N 3 3 2 5 8 M 1 M 3 M 2 LT 1 LT 2 T 1 T 2 CT 2 CT 1

Figure 5.6: Crossover step 3: delete repeated leaves.

1 0 4 6 7 9 10 11 12 M 1 M 4 M 3 M 2 1 0 4 6 7 11 12 N 1 N 4 N 3 N 2 9 10 3 2 5 8 N 3 3 2 5 8 M 1 M 3 M 2 LT 1 LT 2 T 1 T 2 CT 1 CT 2

Figure 5.7: Crossover step 4: add subtrees.

1 0 4 6 7 9 10 11 12 M 1 M 4 M 3 M 2 1 0 4 6 7 11 12 N 1 N 4 N 2 9 10 3 2 5 8 N 3 3 2 5 8 M 1 M 3 M 2 LT 1 LT 2 T 1 T 2

1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 M 2 1 2 3 0 4 5 6 7 9 10 11 12 M 1 M 4 M 3 M 2 8

Figure 5.9: Mutation: swapping two leaves.

1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 M 2 1 2 3 0 8 4 5 6 7 M 1 M 2 M 3 M 4 9 10 11 12 Figure 5.10: Mutation: swapping two subtrees.

1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 M 2 1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 M 2

1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 M 2

Figure 5.12: Mutation: merging single nodes as a subtree.

1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 M 2 1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 M 2 M 5 M 5,

Figure 5.13: Mutation: merging two subtrees.

• CASE 2: If the subtree has many single nodes, all those nodes will be merged into a cluster under the subtree, as shown in Figure 5.12.

• CASE 3: If one submodule in the selected subtree has very few single nodes, the sub- module will be merged into another submodule with the least leaves among the remaining submodules, as shown in Figure 5.13.

4. Splitting a large subtree: If a tree has many subtrees, it will be split into two subtrees, as shown in Figure 5.14. 1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 M 2 M 5 13 14 15 M 6 1 2 3 0 4 5 6 7 8 9 10 11 12 M 1 M 4 M 3 M 2 M 5 13 14 15 M 6 M 7

Related documents