Академический Документы
Профессиональный Документы
Культура Документы
"A man who dares to waste an hour of life has not discovered the value of life"
Genetic Algorithms
Based on survival of the fittest
Developed extensively by John Holland in mid 70s
Based on a population based approach
Can be run on parallel machines
Only the evaluation function has domain knowledge
Can be implemented as three modules; the evaluation
module, the population module and the reproduction
module.
Solutions (individuals) often coded as bit strings
Algorithm uses terms from genetics; population,
chromosome and gene
GA Algorithm
Initialise a population of chromosomes
Evaluate each chromosome (individual) in the population
Create new chromosomes by mating chromosomes in the
current population (using crossover and mutation)
Delete members of the existing population to make way for
the new members
Evaluate the new members and insert them into the
population
Chromosome
Fitness
Running Total
Random Number
Chromsome Chosen
1
12
12
18
15
30
234
156
45
#N/A
4
17
62
136
12
15
20
65
201
213
228
248
263
10
210
10
31
15
174
219
255
143
94
10
Notes
Press F9 to regenerate random numbers
Notice how C6 tends to dominate due to its dominant fitness
GA Fitness Techniques
Fitness-Is-Evaluation : Simply have the fitness of the
chromosome equal to its evaluation
Windowing : Takes the lowest evaluation and assigns each
chromosome a fitness equal to the amount it exceeds this
minimum.
Linear Normalization : The chromosomes are sorted by
decreasing evaluation value. Then the chromosomes are
assigned a fitness value that starts with a constant value and
decreases linearly. The initial value and the decrement are
parameters to the techniques
Population Size
Elitism
Uniform Crossover in
Genetic Algorithms
Graham Kendall
Graham Kendall
gxk@cs.nott.ac.uk
gxk@cs.nott.ac.uk
http://cs.nott.ac.uk/~gxk
http://cs.nott.ac.uk/~gxk
Partially Matched
Crossover (PMX) in
Genetic Algorithms
Graham Kendall
gxk@cs.nott.ac.uk
http://cs.nott.ac.uk/~gxk
GA Example
Crossover probability, PC = 1.0
Mutation probability, PM = 0.0
Maximise f(x) = x3 - 60 * x2 + 900 * x +100
0 <= x >= 31
x can be represented using five binary digits
f(x) = x^3 - 60x^2 + 900x + 100
Max : x = 10
4500
4000
3500
3000
2500
2000
1500
1000
500
37
35
33
31
29
27
25
23
21
19
17
15
13
11
0
5
100
941
1668
2287
2804
3225
3556
3803
3972
4069
4100
4071
3988
3857
3684
3475
3236
2973
2692
2399
2100
1801
1508
1227
964
725
516
343
212
129
100
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
GA Example
Generate random individuals
Chromosome
P1
P2
P3
P4
Binary String
11100
01111
10111
00100
TOTAL
AVERAGE
f(x)
28
15
23
4
212
3475
1227
2804
7718
1929.50
GA Example
Choose Parents, using roulette wheel
selection
Crossover point is chosen randomly
Roulette Wheel
4116
1915
Parent Chosen
P3
P2
Crossover Point
N/A
1
GA Example - Crossover
P3
P2
1
0
0
1
1
1
1
1
1
1
P4
P2
0
0
0
1
1
1
0
1
0
1
C1
C2
1
0
1
0
1
1
1
1
1
1
C3
C4
0
0
0
1
1
1
1
0
1
0
Chromosome
P1
P2
P3
P4
Binary String
11111
00111
00111
01100
TOTAL
AVERAGE
f(x)
31
7
7
12
131
3803
3803
3998
11735
2933.75
GA Example - Question?
Assume the initial population was 17, 21, 4 and 28.
Using the same GA methods we used above (PC =
1.0, PM = 0.0), what chance is there of finding the
global optimum?
The answer is in the handout - but try it first
GA Example - Mutation
A method of ensuring premature convergence does
not occur
Usually set to a small value
Dynamic mutation and crossover rates
C1
C2
Schema
Another Schema
Length = 6
Order = 3
GA - Schema Theorem
Using a technique where we choose parents relative to
their fitness (e.g. roulette wheel selection), fitter
schema should find their way from one generation to
another
Intuitively, if a schema is fitter than average then it
should not only survive to the next generation but
should also increase its presence in the population
If is the number of instances of any particular
schema S within the population at time t, then at t+1
we would expect
(S, t +1) > (S)
to hold for above average fitness schemata
f (S )
( S , t 1) ( S , t )n
fi
f (S )
( S , t 1) ( S , t )
favg
favg is the average fitness of the population
( favg cfavg )
( S , t 1) ( S , t )
favg
= (S, t)(1 + c)
Setting t=0
(S, t) =
PNC
PCl ( S )
1
n 1
l(s) = 4 and n = 11
Assume PC = 1
The probability of the schema being disrupted
by a crossover operation is 1- 1 x 4 / 10 = 0.6
We can easily confirm this by seeing that there
are six crossover positions, of a possible ten (we
assume we do not pick crossover points at the
outside) that will not disrupt the schema
PNC 1
PCl ( S )
n 1
PNC
PCl ( S )
1
(1 P[ S , t ])
n 1
PC = 1
l(s) = 4
n = 11
P[S, t] = 1 (i.e. the other parents schema is the same as
the initial parent therefore we would expect the
schema to appear in the next population)
PC l ( S )
PNC 1
(1 P[ S , t ])
=1
n 1
PCl ( S )
(1 P[ S , t ])
P[S, t] = 0 PNC 1
n 1
= 0.6
Schema Theory
Assume PM = 0.01 then the probability of the above schema
surviving is
Probability of schema
Number of
surviving mutation
schema present
at t
Probability of schema
surviving crossover
f (S )
PCl ( S )
( S , t 1) ( S , t )
1
(
1
P
[
S
,
t
])
K(S)P
M
favg
n 1
1.00
Probability of Mutation - P M
Length of Schema - l(S)
Order of Schema - O(S)
Length of Chromosome - n
Probability of Schema's being the same
Fitness Ratio - f(S) / f avg
Instances of S at time t
Constant - c
0.01
4.00
5.00
100.00
0.00
9.88
10.00
3.00
Reproduction Formulae
Expected Instances of Schema at t+1
98.75
10.00
40.00
160.00
640.00
2560.00
10240.00
Crossover Formulae
Probability of non-disruption of schema
0.96
Mutation Formulae
Probability of non-disruption of schema
Approximation
0.95
0.95
Coding Schemes
The classic approach is to use bit strings and there are still
some people who argue that unless you use bit strings then
you have moved away from a GA
Coding Schemes
Decimal
Binary
0
1
2
3
4
5
6
7
000
001
010
011
100
101
110
111
Gray Code
000
001
011
010
110
111
101
100
Gray codes have the property that adjacent integers only differ in one bit
position. Take, for example, decimal 3. To move to decimal 4, using binary
representation, we have to change all three bits. Using the gray code only
one bit changes
Coding Schemes
Coding Schemes
A Gray code representation seems to improve a mutation
operator's chances of making incremental improvements.
Why?
In a binary-coded string of length N, a single mutation in
the most significant bit (MSB) alters the number by 2N-1
In a Gray-coded string, fewer mutations lead to a change
this large
1
= 51
2N-1 = 32
= 19
Coding Schemes
The use of Gray codes does pay a price for this feature. The
"fewer mutations" which lead to large changes, lead to much
larger changes
In the Gray code illustrated above, for example, a single
mutation of the left-most bit changes a zero to a seven and
vice-versa, while the largest change a single mutation can
make to a corresponding binary-coded individual is always
four
However most mutations will make only small changes, while
the occasional mutation that effects a truly big change may
allow exploration of a new area of the search space
Coding Schemes
G5BAIM
Artificial Intelligence Methods
Graham Kendall
End of Genetic Algorithms