WELCOME TO SINLEB.COM

Keep Internet Free
  The Pirate Party (PiratPartiet , Sweden)


BACK TO ALGORITHMS  |  GA Tutorial - Launch Example


Genetic Algorithms (GA) are a way of solving problems by mimicking the same processes mother nature uses; GA mimics the process of natural evolution.
In a genetic algorithm, a population (also called chromosomes), which encode candidate solutions (also called individuals, creatures, or phenotypes) to an optimization problem, evolves toward better solutions.
Traditionally, solutions are represented in binary as strings of 0s and 1s, but other encodings are also possible.

In other words: a genetic algorithm (GA) is a search (heuristic) .
They use the same combination of selection, recombination and mutation to evolve a solution to a problem.

Selection,in a genetic algorithm, is the stage of a genetic algorithm in which individual genomes are chosen from a population for later breeding (recombination or crossover).

In a binary number, a bit's value,depends on its position.
Like tens, hundreds, and thousands in a decimal number.
A bit's value grows by a power of two as it goes from right to left
As shown in the chart below.




Genetic algorithm



The population size depends on the nature of the problem, but typically contains several hundreds or thousands of possible solutions.
Traditionally, the population is generated randomly (covering the entire range of possible solutions ,the search space)
In this case we are going to select 5 creatures

Copy and save the binary code:

Num. of creature
Creature in Binary
Value of X
Value of f(x)
Tournament
Random Couple
Creature 1
1010
10
100
5
Creature 2
0000
0
0
3
Creature 3
1101
13
169
4
Creature 4
10010
18
324
1
Creature 5
0110
6
36
2


Best : Creature num. 4   (324)  |  Average f(x) 125.8   (629/5)



Selection

Tournament Selection

Creature 1 against Creature 5
1010 - 10 - f(x)=100 ... | ...0110 - 6 - f(x)=36 => Best Instance: creature 1 :=> 1010


Creature 2 against Creature 3
0000 - 0 - f(x)=0 ...|... 1101 - 13 - f(x)=169 => Best Instance: creature 3 :=> 1101


Creature 3 against creature 4
1101 - 13 - f(x)=169 ...|...10010 - 18 - f(x)=324 => Best Instance: creature 4 :=> 10010


Creature 4 against creature 1
10010 18 f(x)=324 ...|...1010 10 f(x)=100 => Best Instance: creature 4 :=> 10010


Creature 5 against creature 2
0110 - 6 - f(x)=36 ...|...0000 - 0 - f(x)=0 => Best Instance: creature 5 :=> 0110


Finally, the best couple is:creature 4 and creature 3


During each successive generation, a proportion of the existing population is selected to breed a new generation. Individual solutions are selected through a fitness-based process, where fitter solutions (as measured by a fitness function) are typically more likely to be selected. Certain selection methods rate the fitness of each solution and preferentially select the best solutions. Other methods rate only a random sample of the population, as this process may be very time-consuming.


Reproduction


The next step is to generate a second generation population of solutions from those selected through genetic operators: crossover (also called recombination), and/or mutation. For each new solution to be produced, a pair of "parent" solutions is selected for breeding from the pool selected previously. By producing a "child" solution using the above methods of crossover and mutation, a new solution is created which typically shares many of the characteristics of its "parents". New parents are selected for each new child, and the process continues until a new population of solutions of appropriate size is generated.



Sat, 19 May 2012 - 19:57 Server Time
Script Created by Sinleb.com