Lecture 12 - 13 Genetic Algorithm-I
Lecture 12 - 13 Genetic Algorithm-I
Genetic Algorithm I
FAST-NU, Lahore
1
GENETIC ALGORITHM
Introduction
2
GENETIC ALGORITHM
Introduction
Introduction
4
GENETIC ALGORITHM
Basic Algorithm
begin
set time t = 0;
initialise population P(t) = {x1t, x2t, …, xnt} of solutions;
while the termination condition is not met do
begin
evaluate fitness of each member of P(t);
select some members of P(t) for creating offspring;
produce offspring by genetic operators;
replace some members with the new offspring;
set time t = t + 1;
end
end
5
GENETIC ALGORITHM
6
GENETIC ALGORITHM
Chromosome
7
GENETIC ALGORITHM
9
GENETIC ALGORITHM
10
GENETIC ALGORITHM
Two parameters sugar and flour (in kgs). The range for both
is 0 to 9 kgs. Therefore a chromosome will comprise of two
genes called sugar and flour
5 1 Chromosome # 01
2 4 Chromosome # 02
11
GENETIC ALGORITHM
12
GENETIC ALGORITHM
13
GENETIC ALGORITHM
2. Population Size
16
Initial Population
17
GENETIC ALGORITHM
3. Fitness Function
18
GENETIC ALGORITHM
Fitness Function
19
GENETIC ALGORITHM
Fitness Function
Two parameters sugar and flour (in kgs). The range for both
is 0 to 9 kgs. Therefore a chromosome will comprise of two
genes called sugar and flour
5 1
2 4
Example
21
GENETIC ALGORITHM
Example
22
GENETIC ALGORITHM
Fitness Function
23
GENETIC ALGORITHM
24
GENETIC ALGORITHM
Reproduction Operators
25
GENETIC ALGORITHM
26
GENETIC ALGORITHM
The operator splits them and forms two children whose initial
segment comes from one parent and whose tail comes from
the other
Resulting Strings
11#0#0#1 #110101#
27
GENETIC ALGORITHM
5 1 5 4
2 4 2 1
28
GENETIC ALGORITHM
29
GENETIC ALGORITHM
1000010 1000001
1110001 1110010
30
GENETIC ALGORITHM
Uniform crossover
The value of each gene of an offspring’s chromosome is
randomly taken from either parent
This is equivalent to multiple point crossover
1000010
1110001 1010010
31
GENETIC ALGORITHM
32
GENETIC ALGORITHM
33
GENETIC ALGORITHM
34
GENETIC ALGORITHM
For real valued genes, the value is selected randomly from the
alleles
If the rate is too low, new traits will appear too slowly in the
population. If the rate is too high, each generation will be
unrelated to the previous generation
35
GENETIC ALGORITHM
A) 01101 169
B) 11000 576
C) 01000 64
D) 10011 361
If we analyze the strings which have high fitness value, we have observe that they
both have a 1 in the 1st column, whereas the low fitness strings have a 0. In
the second column we have a 1 in B and 0 in D, and 1 in the low fitness
strings. We wonder that if 1 in the 2nd column is associated with low fitness, so
we may improve the score of B by putting a 0 in place of 1 in the 2 nd column
36
GENETIC ALGORITHM
Example#1
37
GENETIC ALGORITHM
Example
38
GENETIC ALGORITHM
Example
Selection of F & G
39
GENETIC ALGORITHM
Example
Selection of I and J
40
GENETIC ALGORITHM
Example
41
Chromosome Encoding for Simplified Time Table
Rules Representation
Rules Representation
Rules Representation
Example:
If (Outlook = Overcast or Rain) and Wind = strong
then PlayTennis = No
Another rule
If Wind = Strong then PlayTennis = Yes
Rules Representation
46
GENETIC ALGORITHM
If a1 = T and a2 = F then c = T
If a2 = T then c = F
47
GENETIC ALGORITHM
References
48