Genetic-Algorithms
Genetic-Algorithms
Algorithms
Introduction
Genotype:
– Particular set of genes in a genome
Phenotype:
– Physical characteristic of the genotype (smart,
beautiful, healthy, etc.)
Genotype and Phenotype
GA Requirements
A typical genetic algorithm requires two things to be defined:
a genetic representation of the solution domain, and
a fitness function to evaluate the solution domain.
Two individuals are then chosen randomly based on these probabilities and
produce offspring.
General Algorithm for GA
Roulette Wheel’s Selection Pseudo Code:
for all members of population
sum += fitness of this individual
end for
for all members of population
probability = sum of probabilities + (fitness / sum)
sum of probabilities += probability
end for
loop until new population is full
do this twice
number = Random between 0 and 1
for all members of population
if number > probability but less than next probability then
you have been selected
end for
end
create offspring
end loop
General Algorithm for GA
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 child, and the process
continues until a new population of solutions of appropriate
size is generated.
General Algorithm for GA
These processes ultimately result in the next generation population of
chromosomes that is different from the initial generation.
Generally the average fitness will have increased by this procedure for the
population, since only the best organisms from the first generation are
selected for breeding, along with a small proportion of less fit solutions,
for reasons already mentioned above.
Crossover
the most common type is single point crossover. In
single point crossover, you choose a locus at which you
swap the remaining alleles from on parent to the other.
This is complex and is best understood visually.
As you can see, the children take one section of the
chromosome from each parent.
The point at which the chromosome is broken depends
on the randomly selected crossover point.
This particular method is called single point crossover
because only one crossover point exists. Sometimes
only child 1 or child 2 is created, but oftentimes both
offspring are created and put into the new population.
Crossover does not always occur, however. Sometimes,
based on a set probability, no crossover occurs and the
parents are copied directly to the new population. The
probability of crossover occurring is usually 60% to 70%.
Crossover
Mutation
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
Checkboard example Cont’d
f(x) = 2 · (n-1) ·n
Checkboard example Cont’d
• Fitnesscurves for different cross-over rules:
170 170
160 160
Fitness
150 150
140 140
130 130
0 100 200 300 400 500 0 200 400 600 800
170 170
160 160
Fitness
150 150
140 140
130 130
0 200 400 600 800 0 500 1000 1500
Generations Generations
THANK YOU