Genetic Algorithms A Step by Step Tutorial
Genetic Algorithms A Step by Step Tutorial
Genetic Algorithms
A step by step tutorial
Max Moorkamp
Outline
3 Advanced topics
Multi-objective optimization
A geophysical example
Advantages:
No derivatives needed
Easy to parallelize
Can escape local minima
Works on a wide range of problems
Disadvantages:
Need much more function evaluations than linearized methods
No guaranteed convergence even to local minimum
Have to discretize parameter space
Mutation
Outline
3 Advanced topics
Multi-objective optimization
A geophysical example
5-bit x1 x2 10-bit x1 x2
Basevalue -1 0 Basevalue -1 0
Stepsize 0.0625 0.1 Stepsize 0.0002 0.003
Generating a population
Assigning probabilities
Based on the objective function value, a probability is assigned to
make it into the next generation P(pj ) = f (O(xi )). In our example
1
P(pj ) = P (max {O(xi )} − O(xi ))
i max {O(xi )} − O(xi )
P
In our case: i max {O(xi )} − O(xi ) = 12.45 this gives:
6.64 − 6.64
P(p1 ) = = 0.
12.45
6.64 − 1.69
P(p2 ) = = 0.40
12.45
6.64 − 3.08
P(p3 ) = = 0.28
12.45
6.64 − 2.70
P(p4 ) = = 0.32
12.45
Now we can generate a new population of the same size.
Max Moorkamp Genetic Algorithms
General remarks and comparison with other method
Genetic algorithms step-by-step A hand-calculated example
Advanced topics Some experiments on simple problems
Summary
Selection
Crossover
(000111) (000001)
3
−→
(110001) (110111)
Mutation
(000111) → (010111)
Outline
3 Advanced topics
Multi-objective optimization
A geophysical example
Statistics of GA performance
4.5
400
Best member
Mean performance
4.4
200 25799.3 starting value
Function Value
4.3
0
GAResult
4.2
-200
4.1
-400
0 1 2 3 4
Generation 0 500 1000 1500 2000
Index
Performance of the GA
Generation 0 Generation 1 Generation 2
150000
6000
6000
+
100000
4000
4000
y
y
+ +
+
50000
2000
2000
+ +
+ + +
++ + + ++++ 0
++ + ++ +
0
0
x x x
6000
6000
4000
4000
4000
y
y
2000
2000
2000
+
++ + ++
++ + ++ ++++ +
0
0
−10 −5 0 5 10 −10 −5 0 5 10 −10 −5 0 5 10
x x x
Histogram of x
700
2000 runs, N=20, g=6
600
4
500
2
400
Frequency
0
300
-2
200
100
-4
-6
0
A hard problem
150
15
100
y
10
Frequency
5
50
0
−10 −5 0 5 10 15 20
0
x
−2 0 2 4
ga
The algorithm fails to find the exact minimum, but identifies the
general region
More iterations do not improve the mean/median performance, but
decrease diversity in the population
In this case the parameter T has no big influence on the result
Outline
3 Advanced topics
Multi-objective optimization
A geophysical example
Multi-objective optimization
Multi-objective optimization means that we try to minimize several
functions simultaneously.
O1 (xi )
O2 (xi )
O(xi ) =
..
.
OM (xi )
Rank 1
Rank 2
Rank 3
0,06 Rank 4
Model Roughness
0,04
0,02
0
10 20 30 40
MT RMS
α=1
α=2
0,8 α=3
α=4
α = 0.5
0,6
0,4
0,2
0
0 10 20 30 40
Rank
Outline
3 Advanced topics
Multi-objective optimization
A geophysical example
3 3
2 2
0 10 20 30 40 50 60 70 0 20 40 60
140 140
120 120
Resistivity
100
Resistivity
100
80 80
60
60
40
40
20
20
0
0 10 20 30 40 50 60 70 0 20 40 60
Depth [km] Depth [km]
Data fit
Synthetic Input model
1000
ρa [Ωm]
100
10
0,01 1 100 10000
90
75
60
Phase
45
30
Input Data
15
Inversion
0
0,01 1 100 10000
Period [s]
Best models
No Regularization
1000
Iteration 0
Iteration 20
Max Misfit
Iteration 40 100 Min Misfit
Iteration 60 Median Misfit
Iteration 80 Min Roughness
Iteration 100 10 Median Roughness
Rec. Func. Misfit
0,1
0,01
0,0001 0,001
Original Model
1000 Inversion Result
ρa [Ωm]
100
ρa [Ωm]
10
0 1 100 10000
90
100
75
60
Phase
45
30
15
Original data
0 Inversion result 10
0,01 1 100 10000 1 10 100
Period [s] Depth [km]
Inversion Fit
Receiver function data Receiver function model comparison
5
Inversion result
4,5 Original model
0,04
3,5
Amplitude
Vs [km/s]
0,02
3
2,5
0 2
1,5
0 100 200 300 400 500 1 10 100
Time [s] Depth [km]
Summary
D. E. Goldberg
Genetic algorithms in search, optimization & machine learning
Addison Wesley, 1990.
K. Deb
A Fast and Elitist Multiobjective Genetic Algorithm: NSGA-II
IEEE Transactions on Evolutionary Computation, Vol. 6, No.
2, April 2002
Kanpur Genetic Algorithm Laboratory
NSGA-II and general information
http://www.iitk.ac.in/kangal/index.shtml
M. Wall
GALib programming library in C++
http://lancet.mit.edu/ga
Max Moorkamp Genetic Algorithms