logo
Rubicite Genetic Algorith Framework Tutorial
Crossover Technique: PMX

PMX Crossover
PMX Crossover is a genetic algorithm operator. For some problems it offers better performance than most other crossover techniques. Basically, parent 1 donates a swath genetic material and the corresponding swath from the other parent is sprinkled about in the child. Once that is done, the remaining alleles are copied direct from parent 2.

  1. Randomly select a swath of alleles from parent 1 and copy them directly to the child. Note the indexes of the segment.

  2. Looking in the same segment positions in parent 2, select each value that hasn't already been copied to the child.

    1. For each of these values:

      1. Note the index of this value in Parent 2. Locate the value, V, from parent 1 in this same position.

      2. Locate this same value in parent 2.

      3. If the index of this value in Parent 2 is part of the original swath, go to step i. using this value.

      4. If the position isn't part of the original swath, insert Step A's value into the child in this position.

  3. Copy any remaining positions from parent 2 to the child.

PMX Example

Parent 1: 8 4 7 3 6 2 5 1 9 0
Parent 2: 0 1 2 3 4 5 6 7 8 9

Child 1:  _ _ _ 3 6 2 5 1 _ _

1. We copy a random swath of consecutive alleles from Parent 1 to the Child.

Parent 1: 8 4 7 3 6 2 5 1 9 0
Parent 2: 0 1 2 3 4 5 6 7 8 9

Child 1:  _ _ _ 3 6 2 5 1 _ _


2. '4' is the first value in the swath of Parent 2 that isn't in the child. We identify 6 as the value in the same position in Parent 1. We locate the value 6 in Parent 2 and notice that it is still in the swath. So, we go back to step 'i' using 6 as the value.

PMX Example

Parent 1: 8 4 7 3 6 2 5 1 9 0
Parent 2: 0 1 2 3 4 5 6 7 8 9

Child 1:  _ _ _ 3 6 2 5 1 _ _

3. Repeating Step i: Once again, we see that 5 is in the same position in Parent 1, and we locate 5 in Parent 2. It also is in the swath, so we repeat step 'i' once more with '5' as our value.

Parent 1: 8 4 7 3 6 2 5 1 9 0
Parent 2: 0 1 2 3 4 5 6 7 8 9

Child 1:  _ _ 4 3 6 2 5 1 _ _

4. Repeating Step i: We see that 2 is in the same position in Parent 1, and we locate 2 in Parent 2 in the 3rd position. Finally, we have obtained a position in the Child for the value 4 from Step 2.

Parent 1: 8 4 7 3 6 2 5 1 9 0
Parent 2: 0 1 2 3 4 5 6 7 8 9

Child 1:  _ 7 4 3 6 2 5 1 _ _

5. '7' is the next value in the swath in Parent 2 that isn't already included in the Child. So, we check the same index in Parent 1 and see a '1' in that position. Next, we check for '1' in Parent 2 and find it in the 2nd position. Since the 2nd position is not part of the swath, we've found a home for the value '7'.

Parent 1: 8 4 7 3 6 2 5 1 9 0
Parent 2: 0 1 2 3 4 5 6 7 8 9

Child 1:  0 7 4 3 6 2 5 1 8 9

6. Now the easy part, we've taken care of all swath values, so everything else from Parent 2 drops down to the child.

If we wish to create a 2nd child with the same set of parents, simply swap the parents and start over.

VB.NET 2008 Source Code


© 2008/2009 Rubicite Interactive Inc.