Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 20

Optimization Problem with Simple

Genetic Algorithms

2000. 9. 27
Cho, Dong-Yeon
(dycho@scai.snu.ac.kr)
Function Optimization Problem
Example
max f ( x, y ) 21.5 x sin( 4x) y sin( 20y )
3.0 x 12.1
4.1 y 5.8
Representation Binary String
Code length
( xmax xmin ) 10 4 (12.1 (3.0)) 10 4 151000
217 151000 218 , l x 18
( ymax ymin ) 10 4 (5.8 4.1) 10 4 17000
214 17000 215 , l y 15
l l x l y 18 15 33

| 33bit |
00000101010010100110 1111011111 110
| 18bit || 15bit |
Mapping from a binary string to real number
xmax xmin
x xmin decimal ( substring x )
2l x 1

12.1 (3.0)
x 3.0 5417 2.687960
2 1
18

5.8 4.1
y 4.1 24318 15 5.361653
2 1
Framework of Simple GA
Generate Initial Population

Fitness Function
Evaluate Fitness

Yes
Termination Condition? Best Individual

No

Select Parents
Crossover, Mutation

Generate New Offspring


Initial Population
Initial population is randomly generated.
v1 [00000101010010100110 1111011111 110 ]
v2 [0011101011 1001100000 0010101001000]
v3 [1110001110 00001000010101001000110 ]
v4 [1001101101 0010110100 0000010111 001]
v5 [0000101111 0110001000 1110001101 000]
v6 [1111101010 1101100000 0010110011 001]
v7 [1101000100 1111100010 0110011101 101]
v8 [0010110101 0000110001 0110011001 100]
v9 [1111100010 1110110001 1101000111 101]
v10 [1111010011 10101010000010101101 010]
Fitness Evaluation
Procedure: Evaluation
Convert the chromosomes genotype to its phenotype.
This means converting binary string into relative real values.
Evaluate the objective function.
Convert the value of objective function into fitness.
For the maximization problem, the fitness is simply equal to
the value of objective function.
For the minimization problem, the fitness is the reciprocal of
the value of objective function.
f (v1 ) f (2.687969, 5.3761653) 19.805119
f (v2 ) f (0.474101, 4.170144) 17.370896
f (v3 ) f (10.419457, 4.661461) 9.590546
f (v4 ) f (6.159951, 4.109598) 29.406122
f (v5 ) f (2.301286, 4.477282) 15.686091
f (v6 ) f (11.788084, 4.174346) 11.900541
f (v7 ) f (9.342067, 5.121702) 17.958717
f (v8 ) f (0.330256, 4.694977) 19.763190
f (v9 ) f (11.671267, 4.873501) 26.401669
f (v10 ) f (11.446273, 4.171908) 10.252480
Selection
Fitness proportional (roulette wheel) selection
The roulette wheel can be constructed as follows.
Calculate the total fitness for the population.
pop _ size
F f (v )
k 1
k

Calculate selection probability pk for each chromosome vk.


f ( vk )
pk , k 1,2,..., pop _ size
F
Calculate cumulative probability qk for each chromosome vk.
k
qk p j , k 1,2,..., pop _ size
j 1
Procedure: Selection
Generate a random number r from the range [0,1].
If r q1, then select the first chromosome v1; else,
select the kth chromosome vk (2 k pop_size) such
that qk-1 < r qk.
pop _ size
F f (v ) 178.135372
k 1
k

pk qk
1 0.111180 0.111180
2 0.097515 0.208695
3 0.053839 0.262534
4 0.165077 0.427611
5 0.088057 0.515668
6 0.066806 0.582475
7 0.100815 0.683290
8 0.110945 0.794234
9 0.148211 0.942446
10 0.057554 1.000000
Genetic Operations
Crossover
One point crossover
Crossover rate pc
Procedure: Crossover
Select two parents.
Generate a random number rc from the range [0,1].
If rc < pc then perform undergo crossover.
Mutation
Mutation alters one or more genes with a probability
equal to the mutation rate pm.
v f [1001101101 0010110100 0000010111 001]
vm [0010110101 0000110001 0110011001 100]

vf [1001101101 0010110001 0110011001 100]


vm [0010110101 0000110100 0000010111 001]

v p [1001101101 0010110001 0110011001 100]

vp [1001101101 0010110001 0010011001 100]


Experiments
Various experimental setup
Termination condition: maximum_generation
2 pop_size (large, small) 5 parameter settings 10 runs
Parameter setting (pc, pm)
Elitism
The best chromosome of the previous population is just copied.
At least two test functions
Example function given here (*) - maximization
Rastrigins function minimization
Ackleys function minimization
Schwefels (sine root) function minimization
Test Functions
Rastrigins function
max f ( x, y ) 20 x 2 10 cos(2x) y 2 10 cos(2y )
5.12 x 5.12
5.12 y 5.12
Ackleys function

1 x2 y 2
max f ( x, y ) 20 exp exp cos(2x) cos(2y ) 20 e
5 2 2

32.768 x 32.768
32.768 y 32.768
Schwefels (sine root) function

max f ( x, y ) 418.9829 2 x sin x y sin y


500 x 500
500 y 500
Results
For each test function
Result table for the best solution and your analysis
Large (pop_size) Small (pop_size)
Average SD Best Worst Average SD Best Worst
Setting 1
Setting 2
Setting 3
Setting 4
Setting 5

fopt, (xopt, yopt), chromosomeopt among whole runs


Fitness curve for the run where the best solution was found.
References
Source Codes
Simple GA code
GA libraries
Web sites
Books
Genetic Algorithms and Engineering Design, Mitsuo
Gen and Runwei Cheng, pp. 1-15, John Wiley & Sons,
1997.

(10 25 , ):


Source code, file
Source comment
File e-mail diskette

:


.

You might also like