Crossover and Mutation

To understand the importance of the mutation operator interacting with the crossover operator one has to consider the contributions of each of these operators more concretely. The implementation of the crossover operator used in the algorithm is given below.

//***************************************************
// Apply a crossover operation onto two adjacent strings at intersection x
// The strings are assumed to be randomly paired in the area at position 1
//
// p := number of parameters between strings left and right (actually  p=5)
// l := length of strings ( actually l=5)
// n := number of elements in POP (actually n=4)

function[POP]= crossover(POP,l,p,n)
  
  // Take a first row
  r=1 
  while(r < n)
    
   // printf('crossover r = %d\n',j)
   
   // Select randomly a point in this row
   
   x = round(l * rand()), if(x == 0) then x=1,end,
   
        // printf('crossover x = %d\n',x)
         
         for i=x:l, m=POP(r+1,i)
           POP(r+1,i) = POP(r,i)
           POP(r,i) = m
         end
         
         r=r+2
    end

endfunction

According to this code the crossover operator takes two strings $ s, s'$ embedded in the population $ POP$ in a row indicated by the index $ r$ in $ POP(r,...)$ and reaching from column $ 1$ to column $ 5$ represented by the index $ i$.

Within a first string $ s$ a random point $ x$ is selected as point of reference $ \langle
-,-,x,-,-\rangle$.

Then will all values of the strings $ s, s'$ from the selected point $ x$ until the end of the both strings $ l$ be exchanged. This is shown below:


$\displaystyle s$ $\displaystyle =$ $\displaystyle \langle 0,0,0,0,0\rangle : fitness = 0$ (3.9)
$\displaystyle s'$ $\displaystyle =$ $\displaystyle \langle 1,1,1,1,1\rangle : fitness = 31^2$ (3.10)
$\displaystyle x$ $\displaystyle =$ $\displaystyle 3$ (3.11)
$\displaystyle s$ $\displaystyle =$ $\displaystyle \langle 0,0,1,0,0\rangle : fitness = 4^2$ (3.12)
$\displaystyle s'$ $\displaystyle =$ $\displaystyle \langle 1,1,0,1,1 : fitness = 27^2\rangle$ (3.13)
$\displaystyle s$ $\displaystyle =$ $\displaystyle \langle 0,0,1,1,0\rangle$ (3.14)
$\displaystyle s'$ $\displaystyle =$ $\displaystyle \langle 1,1,0,0,1\rangle$ (3.15)
$\displaystyle s$ $\displaystyle =$ $\displaystyle \langle 0,0,1,1,1\rangle : fitness = 5^2$ (3.16)
$\displaystyle s'$ $\displaystyle =$ $\displaystyle \langle 1,1,0,0,0\rangle : fitness = 24^2$ (3.17)

In this example the overall number of zeros has not changed, not even there positions. If we would repeat the crossover-operation with different $ x$ values this would not change. The only difference would be the computed fitness value which depends from the position of the 'ones' in the string.

Using selection we could select the string with the highest fitness value twice and repeat the application of the crossover operator:


$\displaystyle s$ $\displaystyle =$ $\displaystyle \langle 1,1,0,0,0\rangle : fitness = 24^2$ (3.18)
$\displaystyle s'$ $\displaystyle =$ $\displaystyle \langle 1,1,0,0,0\rangle : fitness = 24^2$ (3.19)

As one can see directly the application of the crossover operator will not change the fitness of these strings. Because they are equal in shape no exchange can change this structure furthermore.

From this follows that the application of the crossover operator only makes sense as long as the involved strings are at least in one position different.

From this one can deduce the following hypothesis when to apply the mutation operator additionally to the crossover operator.

Hypothesis: If a population $ P$ has reached a 'sufficient' similarity between the information strings and the sum of all fitness values of these strings is 'sufficiently' below a known theoretical maximum, then one can apply mutation. This is nicely illustraed in the following examples.

The initial population $ p$ has 11 zeros and a population $ P'$ generatd only by crossover after 50 cycles still 8 zeros. The 'leading' zeros have been selected out by the fitness values.

  (P) POP  =
 
    0.    1.    1.    0.    1.    13.    169.    0.    0.    0.  
    1.    1.    0.    0.    0.    24.    576.    0.    0.    0.  
    0.    1.    0.    0.    0.    8.     64.     0.    0.    0.  
    1.    0.    0.    1.    1.    19.    361.    0.    0.    0.

 (P') POP  =

         column 1 to 9
 
    1.    1.    0.    0.    1.    28.    784.    0.2774239    1.1096957  
    1.    1.    0.    0.    0.    25.    625.    0.2211607    0.8846426  
    1.    1.    1.    0.    0.    24.    576.    0.2038217    0.8152866  
    1.    1.    1.    0.    1.    29.    841.    0.2975938    1.1903751

Figure 3.13: Development without Mutation in 50 Cycles
\includegraphics[width=4.5in]{ga9_run2_r50_m55.eps}

The population $ P'''$ is generated during a run of 80 cycles using crossover and every 10th cycle mutation. This population contains only 4 zeros and this population can be improved further.

 (P''') POP  =
         column 1 to 9
 
    1.    1.    1.    0.    0.    31.    961.    0.3085072    1.2340289  
    1.    1.    1.    1.    1.    23.    529.    0.1698234    0.6792937  
    1.    1.    1.    1.    1.    29.    841.    0.2699839    1.0799358  
    1.    0.    1.    0.    1.    28.    784.    0.2516854    1.0067416

Figure 3.14: Development with Mutation in 80 Cycles
\includegraphics[width=4.5in]{ga9_run1_r80_m10.eps}

Gerd Doeben-Henisch 2012-03-31