Complete GA Algorithms

Unifying all the single functions leads to one big function for the repeatedly application of the GA idea:

 //*************************************************************
// All Functions Unified
//
// 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)
// POP := a predefined population (can be done automatically)
// run := number of cycles

function[POP,FITNESS_ALLLOG]=gasimple(POP,l,p,n,run)
  
  FITNESS_ALLLOG=[]
  
for cyc = 1:run  
  
  [M]= mshow(POP,n,l+p);
  
  for j=1:n, v=POP(j,:),  [POP(j,l+1)]= vec2dec(v,l)
  end
 
  for i=1:n,[POP(i,l+2)]= fitness1(POP(i,l+1))
  end
 
  [FITNESS_ALL]=fitness(POP,l)
  FITNESS_ALLLOG(cyc)=FITNESS_ALL
  
  [MFITNESS]=maxfitness(POP,l)
  
  [POP,AFITNESS]=rfitness(POP,l,FITNESS_ALL)
  
  [POP]=newMember(POP,l,n)
  [POP]=newPop(POP,l,p,n)
  [POP]= crossoverPrep(POP,l,p,n)
  [POP]= crossover(POP,l,p,n)
  
end

clf(), xdel, plot2d([1:1:run], FITNESS_ALLLOG)

endfunction

The result for the sum of all fitness values for 10 consecutive runs is shown below:

 FITNESS_ALLLOG  =
 
    2603.  
    2571.  
    2571.  
    2571.  
    2595.  
    2579.  
    2583.  
    2631.  
    2748.  
    2748.

The graphical representation of these numbers can be seen in figure 3.2.

Figure 3.2: Development of maximal Fitness in 10 Cycles,Run 1
\includegraphics[width=4.5in]{ga1_run1c.eps}

Here some more examples without mutation allowing longer periods with run = 50. The Y-axis in the following diagrams shows the gained fitness value as percentage of the theoretical possible maximum. In special cases where one simulates the fitness with the aid of a pre-defined fitness function like $ y=x^2$ this is possible. This - a bit artificial - situation allows direct analysis of the 'real' behavior of the GA.

Figure 3.3: Development without Mutation in 50 Cycles,Run 1
\includegraphics[width=4.5in]{ga6_run1.eps}

Figure 3.4: Development without Mutation in 50 Cycles, Run 2
\includegraphics[width=4.5in]{ga6_run2.eps}

Figure 3.5: Development without Mutation in 50 Cycles, Run 3
\includegraphics[width=4.5in]{ga6_run3.eps}

Figure 3.6: Development without Mutation in 50 Cycles, Run 4
\includegraphics[width=4.5in]{ga6_run4.eps}

Figure 3.7: Development without Mutation in 50 Cycles,Run 5
\includegraphics[width=4.5in]{ga6_run5.eps}

One can easily observe the fact that the overall fitness value reaches quickly a certain upper level and then it is bound to this level. This can be understood as a hint that the available information in the gen pool can be limited with regard to the information needed to reach the theoretical maximum. If this hypothesis is true, then should the inclusion of a mutation operator change the gain in the overall fitness value significantly. This can be observed in the following diagrams.

These examples allow run periods with run = 80 with mutations every 10th cycle.

Figure 3.8: Development with Mutation in 80 Cycles,Run 1
\includegraphics[width=4.5in]{ga8_run1_r80_m10.eps}

Figure 3.9: Development with Mutation in 80 Cycles, Run 2
\includegraphics[width=4.5in]{ga8_run2_r80_m10.eps}

Figure 3.10: Development with Mutation in 80 Cycles, Run 3
\includegraphics[width=4.5in]{ga8_run3_r80_m10.eps}

Figure 3.11: Development with Mutation in 80 Cycles, Run 4
\includegraphics[width=4.5in]{ga8_run4_r80_m10.eps}

Figure 3.12: Development with Mutation in 80 Cycles,Run 5
\includegraphics[width=4.5in]{ga8_run5_r80_m10.eps}

If one compares the runs without mutation (cf. 3.3, 3.4, 3.5 and, 3.6, and 3.7) with those runs with mutations (cf. 3.8, 3.9,3.10,3.11,and 3.12), one can 'see' how the mutation-free runs reach some maximal level below the theoretical maximum and this level 'seems' to be a limit for the mutation-free runs. On the other side induce the diagrams with the mutation-active runs the impression that mutation can penetrate these mutation-free inherent levels.

This will be analyzed now.

Gerd Doeben-Henisch 2012-03-31