Heuristics: Genetic Algorithm 2: Unterschied zwischen den Versionen

Aus Operations-Research-Wiki
Wechseln zu: Navigation, Suche
[unmarkierte Version][unmarkierte Version]
 
(23 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
 
__INHALTSVERZEICHNIS_ERZWINGEN__
 
__INHALTSVERZEICHNIS_ERZWINGEN__
==Introduction==
+
'''BACKGROUND INFORMATION'''
Genetic Algorithm are good at taking large, potentially huge search spaces and navigating them, looking for optimal combinations of things, solutions you might otherwise find in a lifetime (Salvatore Mangano, Computer Design, May 1995)
+
 
 +
 
 +
Generally genetic algorithms represent search heuristics that illustrates the process of natural evolution. Based on the functionality of natural selection
 +
and genetics genetic algorithms belong to the evolutionary algorithms. Moreover this kind of heuristics are allocated to the so called metaheuristic.
 +
In contrast to specific heuristics metaheuristics demonstrate more abstract procedures that use low-level heuristics in order to solve optimization problems.
 +
 
 +
 
 +
 
 +
 
 +
'''POTENTIAL FIELDS OF APPLICATION'''
 +
 
 +
 
 +
• Search problems
 +
 
 +
• Optimization problems
 +
 
 +
• Machine learning
 +
 
 +
• Adaptive rule-basis
 +
 
 +
 
 +
 
 +
The main purpose of the genetic algorithms is to generate useful solutions according to optimization and search problems, whereby their functionality is characterized by three essential features.
 +
 
 +
 
 +
 
 +
 
 +
'''FUNCTIONALITY'''
 +
 
 +
 
 +
The functionality of genetic algorithms can be differentiated into three major phases:
 +
 
 +
 
 +
•SELECTION: This phase refers to the so called individuals that are characterized by their own and exceptional genes as well as a special adjustment to the  environment. The extent of an individual’s adjustment to the environment can be in turn described as the so called fitness. During the first step a selection of a specified amount of elements from a beginning population occurs. Hereby the attention should be paid to the fact, that those elements which are characterized by a higher fitness even have a higher probability to be admitted.
 +
 
 +
 
 +
•MUTATION: In connection with the genetic algorithms the mutation phase illustrates the process of how new individuals are generated from a random change of the parental units. Moreover the mutation is able to find potential solutions which couldn’t be generated through only the recombination.
 +
 
 +
 
 +
•RECOMBINATION (CROSSOVER): The recombination leads to the creation of new gene and attribute combinations of elements from a now existing matepool. Thus a mixture of different attributes takes place.
 +
 
 +
 
 +
As a consequence of the above mentioned results the following strengths and weaknesses of genetic algorithms can be stated.
 +
 
 +
 
 +
 
 +
 
 +
'''STRENGHTS AND WEAKNESSES'''
 +
 
 +
 
 +
•Genetic algorithms are characterized by a good functionality according to the search of the global optimum, because the searching process takes place in the whole solution place.
 +
 
 +
•Furthermore Genetic algorithms can be extended by genetic operators. Thereby the quality of the solution or the speed can be optimated.
 +
 
 +
•Simple implementation for complex problems.
 +
 
 +
 
  
The solution that you get from a genetic algorithm is the result of the iteratively application of different stochastic operators.
 
  
  
Zeile 27: Zeile 82:
  
 
'''genotype''' =coded solution of a problem
 
'''genotype''' =coded solution of a problem
'''
+
 
phenotype''' =decoded solution of a problem
+
'''phenotype''' =decoded solution of a problem
  
  
Zeile 44: Zeile 99:
 
#'''END WHILE'''
 
#'''END WHILE'''
  
 +
==Examples==
  
 +
We want to visit 6 cities and every city just once.
  
==Example==
+
The distances between the cities are given in the following tableau.
  
The Maxone problem:
+
We want to minimize the distance of our tour.
 +
 
 +
 
 +
<math>\begin{array}{|c||c|c|c|c|c|c|}
 +
 
 +
\hline
 +
& 1 & 2 & 3 & 4 & 5 & 6\\
 +
\hline \hline
 +
1 & - & 4 & 2 & 10 & 8 & 7\\
 +
\hline
 +
2 &  & - & 5 & 7 & 9 & 2\\
 +
\hline
 +
3 &  &  & - & 3 & 5 & 9\\
 +
\hline
 +
4 &  &  &  & - & 1 & 5\\
 +
\hline
 +
5 &  &  &  &  & - & 4\\
 +
\hline
 +
6 &  &  &  &  &  & -\\
 +
\hline
 +
 
 +
\end{array}</math>
 +
 
 +
 
 +
We have an initial parents generation given by the following three route alternatives:
 +
 
 +
 
 +
<math>(1) \ \ 3-4-1-5-2-6</math>
 +
 
 +
<math>(2) \ \ 2-6-3-1-4-5</math>
 +
 
 +
<math>(3) \ \ 1-5-2-3-6-4</math>
 +
 
 +
 
 +
The reproduction rate of the parents´pool is 1/3. The reproduction rate of the children´s pool is 2/3.
 +
 
 +
The recombination takes place in the following (chosen randomly) order:
 +
 
 +
(1)->(2), (1)->(3), (3)->(2)
 +
 
 +
The algorithm stops after the second generation.
 +
 
 +
 
 +
a) '''Partially-Matched Crossover (PMX)'''
 +
 
 +
 
 +
The length of the sequence is given by 2.
 +
 
 +
 
 +
'''(1)->(2)'''
 +
 
 +
 
 +
<math> (1) \ \ 3-4-1-\color{red}5\color{black}-\color{red}2\color{black}-6</math>
 +
 
 +
<math> (2) \ \ 2-6-3-\color{green}1\color{black}-\color{green}4\color{black}-5</math>
 +
 
 +
<math> (4) \ \ \color{green}4\color{black}-6-3-\color{red}5\color{black}-\color{red}2\color{black}-\color{green}1 </math>
 +
 
 +
 
 +
The first recombination process [(1)->(2)] starts at gene 4 (randomly chosed). This means we cut out gene 4 and 5 of parent 1 (red marked).
 +
 
 +
So 5 becomes the 4th gene and 2 the 5h element of the child (red marked).
 +
 
 +
Now we have to take gene 4 and 5 of parent 2 (green marked).
 +
 
 +
The green marked 1 of parent 2 has to be placed under 5 of parent 2, because the green marked 1 of parent 2 stands below the 5 of parent 1.
 +
 
 +
The green marked 4 of parent 2 has to be placed under 2 of parent 2, because the green marked 4 of parent 2 stands below the 2 of parent 1.
 +
 
 +
At the end we have to fill up gene 2 and 3 of the child with gene 2 and 3 of parent 2 to get an new individual without a number twice.
 +
 
 +
 
 +
 
 +
'''(1)->(3)'''
 +
 
 +
 
 +
<math> (1) \ \ \color{red}3\color{black}-\color{red}4\color{black}-1-5-2-6</math>
 +
 
 +
<math> (3) \ \ \color{green}1\color{black}-\color{green}5\color{black}-2-3-6-4</math>
 +
 
 +
<math> (5) \ \ \color{red}3\color{black}-\color{red}4\color{black}-2-\color{green}1\color{black}-6-\color{green}5</math>
 +
 
 +
The second recombination process [(1)->(3)] starts at gene 1 (randomly chosed).
 +
 
 +
 
 +
'''(3)->(2)'''
 +
 
 +
<math> (3) \ \ 1-\color{red}5\color{black}-\color{red}2\color{black}-3-6-4</math>
 +
 
 +
<math> (2) \ \ 2-\color{green}6\color{black}-\color{green}3\color{black}-1-4-5</math>
 +
 
 +
<math> (6) \ \ \color{green}3\color{black}-\color{red}5\color{black}-\color{red}2\color{black}-1-4-\color{green}6</math>
 +
 
 +
 
 +
The third recombination process [(3)->(2)] starts at gene 2 (randomly chosed).
 +
 
 +
 
 +
Now we have to calculate the fitness of the parents and children.
 +
 
 +
 
 +
Parent (1) :  <math>f_1=3+10+8+9+2=32</math>
 +
 
 +
Parent (2) :  <math>f_2=2+9+2+10+1=24</math>
 +
 
 +
Parent (3) :  <math>f_3=8+9+5+9+5=36</math>
 +
 
 +
Child (4)  :  <math>f_4=5+9+5+9+4=32</math>
 +
 
 +
Child (5)  :  <math>f_5=3+9+4+7+4=27</math>
 +
 +
Child (6)  :  <math>f_6=5+9+4+10+5=33</math>
 +
 
 +
 
 +
The reproduction rate of the parents´ pool is 1/3. So we pick out parent 2, because we want to minimize the distance.
 +
 
 +
The reproduction rate of the childrens´ pool is 2/3. So we pick out Child 4 and 5.
 +
 
 +
So the '''second generation''' consists out of '''parent 2''' and '''child 4 and 5'''.
 +
 
 +
 
 +
 
 +
b) '''Order Crossover (OX)'''
 +
 
 +
The length of the sequence is given by 2.
 +
 
 +
 
 +
'''(1)->(2)'''
 +
 
 +
 
 +
<math> (1) \ \ 3-4-1-\color{red}5\color{black}-\color{red}2\color{black}-6</math>
 +
 
 +
<math> (2) \ \ 2-6-3-\color{green}1\color{black}-\color{green}4\color{black}-5</math>
 +
 
 +
<math> (4) \ \ \color{green}1\color{black}-6-3-\color{red}5\color{black}-\color{red}2\color{black}-\color{green}4 </math>
 +
 
 +
 
 +
The first recombination process [(1)->(2)] starts at gene 4 (randomly chosed). This means we cut out gene 4 and 5 of parent 1 (red marked).
 +
 
 +
So 5 becomes the 4th gene and 2 the 5h element of the child (red marked).
 +
 
 +
Now we have to take gene 4 and 5 of parent 2 (green marked).
 +
 
 +
The green marked 1 of parent 2 has to be placed under 2 of parent 2, because the green marked 1 of parent 2 stands below the 5 of parent 1.
 +
 
 +
The green marked 4 of parent 2 has to be placed under 5 of parent 2, because the green marked 4 of parent 2 stands below the 2 of parent 1.
 +
 
 +
At the end we have to fill up gene 2 and 3 of the child with gene 2 and 3 of parent 2 to get an new individual without a number twice.
 +
 
 +
 
 +
'''(1)->(3)'''
 +
 
 +
 
 +
<math> (1) \ \ \color{red}3\color{black}-\color{red}4\color{black}-1-5-2-6</math>
 +
 
 +
<math> (3) \ \ \color{green}1\color{black}-\color{green}5\color{black}-2-3-6-4</math>
 +
 
 +
<math> (5) \ \ \color{red}3\color{black}-\color{red}4\color{black}-2-\color{green}5\color{black}-6-\color{green}1</math>
 +
 
 +
The second recombination process [(1)->(3)] starts at gene 1 (randomly chosed).
 +
 
 +
 
 +
'''(3)->(2)'''
 +
 
 +
<math> (3) \ \ 1-\color{red}5\color{black}-\color{red}2\color{black}-3-6-4</math>
 +
 
 +
<math> (2) \ \ 2-\color{green}6\color{black}-\color{green}3\color{black}-1-4-5</math>
 +
 
 +
<math> (6) \ \ \color{green}6\color{black}-\color{red}5\color{black}-\color{red}2\color{black}-1-4-\color{green}3</math>
 +
 
 +
 
 +
The third recombination process [(3)->(2)] starts at gene 2 (randomly chosed).
 +
 
 +
 
 +
Now we have to '''calculate''' the '''fitness''' of the parents and children.
 +
 
 +
 
 +
Parent (1) :  <math>f_1=3+10+8+9+2=32</math>
 +
 
 +
Parent (2) :  <math>f_2=2+9+2+10+1=24</math>
 +
 
 +
Parent (3) :  <math>f_3=8+9+5+9+5=36</math>
 +
 
 +
Child (4)  :  <math>f_4=7+9+5+9+7=37</math>
 +
 
 +
Child (5)  :  <math>f_5=3+9+9+7+7=35</math>
 +
 +
Child (6)  :  <math>f_6=4+9+4+10+3=30</math>
 +
 
 +
 
 +
The reproduction rate of the parents´ pool is 1/3. So we pick out parent 2, because we want to minimize the distance.
 +
 
 +
The reproduction rate of the childrens´ pool is 2/3. So we pick out Child 5 and 6.
 +
 
 +
So the '''second generation''' consists out of '''parent 2''' and '''child 5 and 6'''.
 +
 
 +
 
 +
 
 +
 
 +
 
 +
'''The Maxone problem:'''
  
 
We want to maximize the number of ones in a string of L binary bits.
 
We want to maximize the number of ones in a string of L binary bits.
  
This may seem to trivial, cause we know already the answer, but however, we can think of it as maximazing the number of correct answers, each encoded by 1, ot difficult questions:
+
This may seem to trivial, cause we know already the answer, but however, we can think of it as maximazing the number of correct answers, each encoded by 1, to difficult questions:
  
 
Suppose l=10, n=6
 
Suppose l=10, n=6
Zeile 61: Zeile 317:
  
  
To get the initial population, we toss a fair coin 60 times:
+
To get the '''initial population''', we toss a fair coin 60 times:
  
  
Zeile 79: Zeile 335:
  
  
while f(s) is the fitness function
+
while f(s) is the '''fitness''' function
 
        
 
        
 
    
 
    
  
The new population after performing selection (suppose we apply a random generator and get this selection).
+
The new population after performing '''selection''' (suppose we apply a random generator and get this selection).
  
  
Zeile 99: Zeile 355:
  
  
We only perform a crossover for the pairs <math>(s_1',s_2')</math> and <math>(s_5',s_6')</math>
+
You can determine the probability for a crossover, for instance 0,6.
 +
 
 +
Thus we only perform a crossover for the pairs <math>(s_1',s_2')</math> and <math>(s_5',s_6')</math>
  
  
Zeile 105: Zeile 363:
  
  
Before crossover:
+
Before '''crossover''':
  
 
<math>s_1'=11\color{green}11010101 \color{black}\qquad s_5'=01000\color{green}10011</math>
 
<math>s_1'=11\color{green}11010101 \color{black}\qquad s_5'=01000\color{green}10011</math>
Zeile 113: Zeile 371:
  
  
After crossover:
+
After '''crossover''':
  
 
<math>s_1''=11\color{red}10110101 \color{black}\qquad s_5''=01000\color{red}11101</math>
 
<math>s_1''=11\color{red}10110101 \color{black}\qquad s_5''=01000\color{red}11101</math>
Zeile 120: Zeile 378:
  
  
Before applying random mutation:
+
Before applying random '''mutation''':
  
for each bit, that we are to copy to the new population, we allow a small probability of error, for instance 0,1
+
For each bit, that we are to copy to the new population, we allow a small probability of error, for instance 0,1.
  
  
Zeile 133: Zeile 391:
  
  
After applying mutation (random) with updated fitness-values:
+
After applying mutation (random) with updated '''fitness-values''':
  
 
<math>s_1'''=11101\color{red}0\color{black}0101 \qquad f(s_1''')=6</math>
 
<math>s_1'''=11101\color{red}0\color{black}0101 \qquad f(s_1''')=6</math>
Zeile 151: Zeile 409:
  
  
Improvement of 9 percent
+
'''Improvement of 9 percent''' (fitness from 34 to 37)
  
 
You could repeat the algorithm, until a stopping criterion is met.
 
You could repeat the algorithm, until a stopping criterion is met.
Zeile 160: Zeile 418:
  
 
Alfred Hermes, Heuristik: Genetischer Algorithmus am Beispiel des 0/1-Rucksackproblems: http://learntech.rwth-aachen.de/lehre/ss05/fdi/folien/VS11HTML/GenAlg.pdf (download: 24.06.13)
 
Alfred Hermes, Heuristik: Genetischer Algorithmus am Beispiel des 0/1-Rucksackproblems: http://learntech.rwth-aachen.de/lehre/ss05/fdi/folien/VS11HTML/GenAlg.pdf (download: 24.06.13)
 +
 +
Operations Research Tutorial

Aktuelle Version vom 30. Juni 2013, 12:40 Uhr

BACKGROUND INFORMATION


Generally genetic algorithms represent search heuristics that illustrates the process of natural evolution. Based on the functionality of natural selection and genetics genetic algorithms belong to the evolutionary algorithms. Moreover this kind of heuristics are allocated to the so called metaheuristic. In contrast to specific heuristics metaheuristics demonstrate more abstract procedures that use low-level heuristics in order to solve optimization problems.



POTENTIAL FIELDS OF APPLICATION


• Search problems

• Optimization problems

• Machine learning

• Adaptive rule-basis


The main purpose of the genetic algorithms is to generate useful solutions according to optimization and search problems, whereby their functionality is characterized by three essential features.



FUNCTIONALITY


The functionality of genetic algorithms can be differentiated into three major phases:


•SELECTION: This phase refers to the so called individuals that are characterized by their own and exceptional genes as well as a special adjustment to the environment. The extent of an individual’s adjustment to the environment can be in turn described as the so called fitness. During the first step a selection of a specified amount of elements from a beginning population occurs. Hereby the attention should be paid to the fact, that those elements which are characterized by a higher fitness even have a higher probability to be admitted.


•MUTATION: In connection with the genetic algorithms the mutation phase illustrates the process of how new individuals are generated from a random change of the parental units. Moreover the mutation is able to find potential solutions which couldn’t be generated through only the recombination.


•RECOMBINATION (CROSSOVER): The recombination leads to the creation of new gene and attribute combinations of elements from a now existing matepool. Thus a mixture of different attributes takes place.


As a consequence of the above mentioned results the following strengths and weaknesses of genetic algorithms can be stated.



STRENGHTS AND WEAKNESSES


•Genetic algorithms are characterized by a good functionality according to the search of the global optimum, because the searching process takes place in the whole solution place.

•Furthermore Genetic algorithms can be extended by genetic operators. Thereby the quality of the solution or the speed can be optimated.

•Simple implementation for complex problems.



For understanding GA and how they work, we have to introduce some new vacabulary:

individual =a strucuture, that represents a solution, consisting of genes

chromosome =equal to individual

gene =a bit of the binary representation of a solution

population =quantity of individuals, that became considered by an GA

parents =two chosen individuals of a population

crossing =combination of two genes from two chromosomes

mutation =modification of a chromosome

fitness =qualtity of a solution

generation =one iteration in the duration of the optimation

genotype =coded solution of a problem

phenotype =decoded solution of a problem


Basically the strucure of Genetic Algorithm is always the same presented below

  1. produce an initial population of indivuals
  2. evaluate the fitness of all individuals
  3. WHILE termination condition not met DO
    1. select fitter individuals for reproduction
    2. recombine between individuals
    3. mutate individuals
    4. evaluate the fitness of the modified individuals
    5. generate a new population
  4. END WHILE

Inhaltsverzeichnis

Examples

We want to visit 6 cities and every city just once.

The distances between the cities are given in the following tableau.

We want to minimize the distance of our tour.


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): \begin{array}{|c||c|c|c|c|c|c|} \hline & 1 & 2 & 3 & 4 & 5 & 6\\ \hline \hline 1 & - & 4 & 2 & 10 & 8 & 7\\ \hline 2 & & - & 5 & 7 & 9 & 2\\ \hline 3 & & & - & 3 & 5 & 9\\ \hline 4 & & & & - & 1 & 5\\ \hline 5 & & & & & - & 4\\ \hline 6 & & & & & & -\\ \hline \end{array}


We have an initial parents generation given by the following three route alternatives:


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (1) \ \ 3-4-1-5-2-6


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (2) \ \ 2-6-3-1-4-5


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (3) \ \ 1-5-2-3-6-4


The reproduction rate of the parents´pool is 1/3. The reproduction rate of the children´s pool is 2/3.

The recombination takes place in the following (chosen randomly) order:

(1)->(2), (1)->(3), (3)->(2)

The algorithm stops after the second generation.


a) Partially-Matched Crossover (PMX)


The length of the sequence is given by 2.


(1)->(2)


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (1) \ \ 3-4-1-\color{red}5\color{black}-\color{red}2\color{black}-6


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (2) \ \ 2-6-3-\color{green}1\color{black}-\color{green}4\color{black}-5


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (4) \ \ \color{green}4\color{black}-6-3-\color{red}5\color{black}-\color{red}2\color{black}-\color{green}1


The first recombination process [(1)->(2)] starts at gene 4 (randomly chosed). This means we cut out gene 4 and 5 of parent 1 (red marked).

So 5 becomes the 4th gene and 2 the 5h element of the child (red marked).

Now we have to take gene 4 and 5 of parent 2 (green marked).

The green marked 1 of parent 2 has to be placed under 5 of parent 2, because the green marked 1 of parent 2 stands below the 5 of parent 1.

The green marked 4 of parent 2 has to be placed under 2 of parent 2, because the green marked 4 of parent 2 stands below the 2 of parent 1.

At the end we have to fill up gene 2 and 3 of the child with gene 2 and 3 of parent 2 to get an new individual without a number twice.


(1)->(3)


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (1) \ \ \color{red}3\color{black}-\color{red}4\color{black}-1-5-2-6


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (3) \ \ \color{green}1\color{black}-\color{green}5\color{black}-2-3-6-4


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (5) \ \ \color{red}3\color{black}-\color{red}4\color{black}-2-\color{green}1\color{black}-6-\color{green}5


The second recombination process [(1)->(3)] starts at gene 1 (randomly chosed).


(3)->(2)

Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (3) \ \ 1-\color{red}5\color{black}-\color{red}2\color{black}-3-6-4


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (2) \ \ 2-\color{green}6\color{black}-\color{green}3\color{black}-1-4-5


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (6) \ \ \color{green}3\color{black}-\color{red}5\color{black}-\color{red}2\color{black}-1-4-\color{green}6


The third recombination process [(3)->(2)] starts at gene 2 (randomly chosed).


Now we have to calculate the fitness of the parents and children.


Parent (1) :

Parent (2) :

Parent (3) :

Child (4)  :

Child (5)  :

Child (6)  :


The reproduction rate of the parents´ pool is 1/3. So we pick out parent 2, because we want to minimize the distance.

The reproduction rate of the childrens´ pool is 2/3. So we pick out Child 4 and 5.

So the second generation consists out of parent 2 and child 4 and 5.


b) Order Crossover (OX)

The length of the sequence is given by 2.


(1)->(2)


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (1) \ \ 3-4-1-\color{red}5\color{black}-\color{red}2\color{black}-6


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (2) \ \ 2-6-3-\color{green}1\color{black}-\color{green}4\color{black}-5


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (4) \ \ \color{green}1\color{black}-6-3-\color{red}5\color{black}-\color{red}2\color{black}-\color{green}4


The first recombination process [(1)->(2)] starts at gene 4 (randomly chosed). This means we cut out gene 4 and 5 of parent 1 (red marked).

So 5 becomes the 4th gene and 2 the 5h element of the child (red marked).

Now we have to take gene 4 and 5 of parent 2 (green marked).

The green marked 1 of parent 2 has to be placed under 2 of parent 2, because the green marked 1 of parent 2 stands below the 5 of parent 1.

The green marked 4 of parent 2 has to be placed under 5 of parent 2, because the green marked 4 of parent 2 stands below the 2 of parent 1.

At the end we have to fill up gene 2 and 3 of the child with gene 2 and 3 of parent 2 to get an new individual without a number twice.


(1)->(3)


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (1) \ \ \color{red}3\color{black}-\color{red}4\color{black}-1-5-2-6


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (3) \ \ \color{green}1\color{black}-\color{green}5\color{black}-2-3-6-4


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (5) \ \ \color{red}3\color{black}-\color{red}4\color{black}-2-\color{green}5\color{black}-6-\color{green}1


The second recombination process [(1)->(3)] starts at gene 1 (randomly chosed).


(3)->(2)

Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (3) \ \ 1-\color{red}5\color{black}-\color{red}2\color{black}-3-6-4


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (2) \ \ 2-\color{green}6\color{black}-\color{green}3\color{black}-1-4-5


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): (6) \ \ \color{green}6\color{black}-\color{red}5\color{black}-\color{red}2\color{black}-1-4-\color{green}3


The third recombination process [(3)->(2)] starts at gene 2 (randomly chosed).


Now we have to calculate the fitness of the parents and children.


Parent (1) :

Parent (2) :

Parent (3) :

Child (4)  :

Child (5)  :

Child (6)  :


The reproduction rate of the parents´ pool is 1/3. So we pick out parent 2, because we want to minimize the distance.

The reproduction rate of the childrens´ pool is 2/3. So we pick out Child 5 and 6.

So the second generation consists out of parent 2 and child 5 and 6.



The Maxone problem:

We want to maximize the number of ones in a string of L binary bits.

This may seem to trivial, cause we know already the answer, but however, we can think of it as maximazing the number of correct answers, each encoded by 1, to difficult questions:

Suppose l=10, n=6

Cause everey individual is encoded as a string of l binary bit, we can write for one

1=0000000001 (10 bits)


To get the initial population, we toss a fair coin 60 times:


Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): \color{red}\sum_{i=1}^{6}f(s_i)=34


while f(s) is the fitness function


The new population after performing selection (suppose we apply a random generator and get this selection).



You can determine the probability for a crossover, for instance 0,6.

Thus we only perform a crossover for the pairs and


Crossover-points: 2 and 5


Before crossover:


After crossover:


Before applying random mutation:

For each bit, that we are to copy to the new population, we allow a small probability of error, for instance 0,1.



After applying mutation (random) with updated fitness-values:

Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): \sum_{i=1}^{6}f(s_i''')=37



Improvement of 9 percent (fitness from 34 to 37)

You could repeat the algorithm, until a stopping criterion is met.

References

Nobal Niraula, Genetic Algorithm: http://de.slideshare.net/kancho/genetic-algorithm-by-example (download: 24.06.13)

Alfred Hermes, Heuristik: Genetischer Algorithmus am Beispiel des 0/1-Rucksackproblems: http://learntech.rwth-aachen.de/lehre/ss05/fdi/folien/VS11HTML/GenAlg.pdf (download: 24.06.13)

Operations Research Tutorial