11 EC Encoding
11 EC Encoding
11 EC Encoding
Debasis Samanta
13.03.2023
Start
Define parameters
Parameter representation
Create population
Initialize population
Apply cost
function to each of
the population
No
Converge ? Evaluate the fitness
Selection
Yes
Select Mate
Stop
Crossover
Reproduction
Mutation
Inversion
1 Encoding
2 Convergence test
3 Mating pool
4 Fitness Evaluation
5 Crossover
6 Mutation
7 Inversion
1 Encoding
2 Convergence test
3 Mating pool
4 Fitness Evaluation
5 Crossover
6 Mutation
7 Inversion
Different GAs
Simple Genetic Algorithm (SGA)
Steady State Genetic Algorithm (SSGA)
Messy Genetic Algorithm (MGA)
Encoding Schemes
Binary encoding
Real value encoding
Order encoding
Tree encoding
For example:
Encoding Scheme
Tree encoding
Phenotype
a b c 1 0 1 2 9 6 7 $ α β..................
Chromosome
Debasis Samanta (IIT Kharagpur) Soft Computing Applications 13.03.2023 8 / 47
Individual Representation: Phenotype and
Genotype
Note :
A: 0 1 1 0 0 1 0 1 0 1 0 1 0 1 1 1 1 0 Individual 1
B: 0 0 1 0 1 0 1 1 1 0 1 0 1 0 1 0 0 0 Individual 2
There are n items, each item has its own cost (ci ) and weight (wi ).
Maximize :
P
i ci ∗ wi ∗ xi
Subject to
P
xi ∗ wi ≤ W
where xi ∈ [0 · · · 1]
The encoding for the 0-1 Knapsack, problem, in general, for n items
set would look as follows.
Genotype :
1 2 3 4 ..... n-1 n
.....
Phenotype :
0 1 0 1 1 0 1 0 1 0 1 0 1. . . . . .1 0 1
A binary string of n-bits
Example 2:
Minimize :
2
f (x) = x2 + 125
x
where 0 ≤ x ≤ 15 and x is any discrete integer value.
Genotype :
Phenotype :
01101
A binary string of 5-bits
x y
Phenotype :
01101 11001
Two binary string of 5-bits each
Limitations:
1 Needs an effort to convert into binary from
2 Accuarcy depends on the binary reprresentation
Advantages:
1 Since operations with binary representation is faster, it provide a
faster implementations of all GA operators and hence the execution
of GAs.
2 Any optimization problem has it binary-coded GA implementation
Genotype :
x y
Phenotype :
5.28 -475.36
Real-value representation
where XL ≤ x ≤ XU
Equivalently,
ε = XU2−Xn
L
Note:If ε = 0.5, then 4.05 or 4.49 ≡ 4 and 4.50 or 4.99 ≡ 4.5 and so
on.
1 Example 1:
1 ≤ x ≤ 16, n = 6. What is the accuracy?
16−1 15
ε= 26
= 64 = 0.249 ≈ 0.25
2 Example 2:
What is the obtainable accuracy, for the binary representation for a
variable X in the range range 20.1 ≤ X ≤ 45.6 with 8-bits?
3 Example 3:
In the above case, what is the binary representation of X = 34.35?
Example:
TSP
- Visit all the cities
- One city once only
- Starting and ending city is the same
d A B C D E 6
2 4
A 0 2 6 4
B 2 0 7 5
5 D
C 7 0 3 1 B
E
D 6 3 0 3
7
E 4 5 1 0
d= Distance matrix C
Minimizing
Pn−2
cost = i=0 d(ci , ci+1 ) + d(cn−1 , c0 )
Subject to
P = [c0 , c1 , c2 , · · · , cn−1 , c0 ]
where ci ∈ X ;
Here, P is an ordered collection of cities and ci ̸= cj such that
∀i, j = 0, 1, · · · , n − 1
Note: P represents a possible tour with the starting cities as c0 .
and
X = x1 , x2 , · · · , xn , set of n number of cities,
d(xi , xj ) is the distance between any two cities xi and xj .
Debasis Samanta (IIT Kharagpur) Soft Computing Applications 13.03.2023 29 / 47
Tree Encoding
A D A B E G C F (In-order)
(TL R TR)
B C
A B D C E G F (Pre-order)
D E F (R TL TR)
D B G E E C A (Post-order)
G
(TL TR R)
C2
C1
C3
C1
C2
C9 C5
C5
C6
C7 C4
C4 C8
C6 C8
C7
C9
C10 C3
Wire = f1 (B, N)
4 H
Desirable floor plan aspect ratio ρ such that 1ρ ≤ W ≤ ρ, where H
and W are the height and width of the floor plan, respectively.
Area = f2 (B, N, ρ)
5 Timing information.
Delay = f3 (B, N, ρ)
Objectives :
We are to find a floor plan, which would
1 Minimize floor plan area.
2 Minimize wire length.
3 Minimize circuit delay.
3 4 5
1 1
4 5 6 7
2 2
6 7 3
H H
3
1
2 1 H 3
4 5
2 V V
6 7
6 7 4 5
Note 1:
The operators H and V expressed in polish notation carry the following
meanings:
ijH → Block bj is on top of the block bi .
ijV → Block bi is on the left of block bj .
Note 4:
Post order traversal of a binary tree is equivalent to polish notation
+ -
abc÷+ ab+c-
a ÷ + c
b c
a b
Note 5:
There is only one way to performing a post order traversal of a binary
tree.
H H
3
1
2 1 H 3
4 5
2 V V
6 7
6 7 4 5
Polish notation : 2 1 H 6 7 V 4 5 V H 3 H V
H
V2
2
3 1 V
H3 2
V4
3
4 5
2
H1 H 2
1 4
V 3
Floor Plan
4 5
Binary tree
Polish notation : 4 5 V 3 H 2 V 1 H
H H
2 1 V
H
?
6 7
V 3
4 5
2 1 H 6 7 V 4 5 V 3 H H V
H H 3
1
2 1 V
H 4 5
6 7 2
V 3 6 7
4 5
2 1 H 6 7 V 4 5 V 3 H H V
Problem :
Problem :