If you find the post useful,kindly acknowledge the above source and not this blog. This post has been reproduced here as a study material for my students. No commercial activity is involved.
Consider the given problem of the two bar pendulum
Consider the given problem of the two bar pendulum
The total potential for the two bar pendulum is written as
Õ= - P [(L1 Sin q1 + L2 Sin q2 )]- (W1 L1/2)Cos q1 – W2 [L2 Cos q2 + L1 Cos q1]
Putting the values for P, W1,W2, L1, L2 we get:
Õ(q1, q2)= -4Sinq1 - 6Cosq1-4 Sinq2- 2 Cos q2 …………….. (1)
where
0<=q1; q2<=90
The equilibrium configuration is the one which makes Õ a minimum.
Hence equation 1 gives the objective function. Let Õ(q1, q2)= f
Since the objective function f is negative, instead of minimizing it ,we maximize -f=f ’.
The max value of f=8 when q1, q2=0, hence the fitness function F is taken as
F=f’-7 = -f-7
Since there are 2 unknowns q1 , q2 in the problem, we use 4 bit binary string for each unknown.
Accuracy = XU-XL = 90/15 = 60
24-1
The binary coding and corresponding angles are given as follows:
S.No.
|
Binary Coding
|
Angle
|
1
|
0000
|
0
|
2
|
0001
|
6
|
3
|
0010
|
12
|
4
|
0011
|
18
|
5
|
0100
|
24
|
6
|
0101
|
30
|
7
|
0110
|
36
|
8
|
0111
|
42
|
9
|
1000
|
48
|
10
|
1001
|
54
|
11
|
1010
|
60
|
12
|
1011
|
66
|
13
|
1100
|
72
|
14
|
1101
|
78
|
15
|
1110
|
84
|
16
|
1111
|
90
|
Step 1 :
Randomly generate 8 populations with 8 bit strings as follows:
Population No.
|
Population
|
q1
|
q2
|
F=-f-7
|
1
|
0000 0000
|
0
|
0
|
8-7=1
|
2
|
0010 0001
|
12
|
6
|
2.1
|
3
|
0001 0101
|
6
|
30
|
3.11
|
4
|
0010 1000
|
12
|
48
|
4.01
|
5
|
0110 1010
|
36
|
60
|
4.66
|
6
|
1110 1000
|
84
|
48
|
1.91
|
7
|
1110 1101
|
84
|
78
|
1.93
|
8
|
0111 1100
|
42
|
72
|
4.55
|
The average fitness from the above table
Fav = (1+2.1+3.11+4.01+4.66+1.91+1.93+4.55)/8 =2.908
Step 2:
The average fitness from the above table
Fav = (1+2.1+3.11+4.01+4.66+1.91+1.93+4.55)/8 =2.908
Now we select the mating pool depending on F/Fav (rank selection). Two Populations with highest F/Fav will have 2 copies each in the mating pool while two populations with lowest F/Fav will die out. Others will get 1 copy each in the mating pool.
Population No.
|
Population
|
F=-f-7
|
F/Fav
|
Count
|
1
|
0000 0000
|
8-7=1
|
0.38
|
0
|
2
|
0010 0001
|
2.1
|
0.812
|
1
|
3
|
0001 0101
|
3.11
|
1.203
|
1
|
4
|
0010 1000
|
4.01
|
1.55
|
1
|
5
|
0110 1010
|
4.66
|
1.802
|
2
|
6
|
1110 1000
|
1.91
|
0.738
|
0
|
7
|
1110 1101
|
1.93
|
0.746
|
1
|
8
|
0111 1100
|
4.55
|
1.76
|
2
|
Mating pool:
Population No.
|
Population
|
F=-f-7
|
F/Fav
|
1
|
0010 0001
|
2.1
|
0.812
|
2
|
0001 0101
|
3.11
|
1.203
|
3
|
0010 1000
|
4.01
|
1.55
|
4
|
0110 1010
|
4.66
|
1.802
|
5
|
0110 1010
|
4.66
|
1.802
|
6
|
1110 1101
|
1.93
|
0.746
|
7
|
0111 1100
|
4.55
|
1.76
|
8
|
0111 1100
|
4.55
|
1.76
|
Step 3:
Crossover
It proceeds in 3 steps:
- Select two strings at random.
- Select crossover sites at random
- Swap bits between the crossover sites.
For the above mating pool:
Pop. No.
|
Population
|
Mate with
|
CS1
|
CS2
|
Population after crossover
|
1
|
0010 0001
|
5
|
2
|
6
|
0010 1001
|
2
|
0001 0101
|
6
|
1
|
5
|
0110 1101
|
3
|
0010 1000
|
7
|
4
|
8
|
0010 1100
|
4
|
0110 1010
|
8
|
4
|
6
|
0110 1110
|
5
|
0110 1010
|
1
|
2
|
6
|
0110 0010
|
6
|
1110 1101
|
2
|
1
|
5
|
1001 0101
|
7
|
0111 1100
|
3
|
4
|
8
|
0111 1000
|
8
|
0111 1100
|
4
|
4
|
6
|
0111 1000
|
Step 4: Mutation
Select bits with a small probability, here with a probability 0.031
i.e only 2 bits out of a total of 64 (8 populations X 8 bit wide) bits will be mutated.
Hence randomly select bit no.21 and bit no. 62. The bits of the crossed over populations in these locations are flipped.
Pop. No.
|
Population after crossover
|
Random bits for mutation
|
Population after Mutation = population for next generation
|
1
|
0010 1001
|
0010 1001
| |
2
|
0110 1101
|
0110 1101
| |
3
|
0010 1100
|
21
|
0010 0100
|
4
|
0110 1110
|
0110 1110
| |
5
|
0110 0010
|
0110 0010
| |
6
|
1001 0101
|
1001 0101
| |
7
|
0111 1000
|
0111 1000
| |
8
|
0111 1000
|
62
|
0111 1100
|
Now repeat the process on the next generation population.
Step 1:
Find q1 and q2 from the initial table
S.No.
|
Binary Coding
|
Angle
|
1
|
0000
|
0
|
2
|
0001
|
6
|
3
|
0010
|
12
|
4
|
0011
|
18
|
5
|
0100
|
24
|
6
|
0101
|
30
|
7
|
0110
|
36
|
8
|
0111
|
42
|
9
|
1000
|
48
|
10
|
1001
|
54
|
11
|
1010
|
60
|
12
|
1011
|
66
|
13
|
1100
|
72
|
14
|
1101
|
78
|
15
|
1110
|
84
|
16
|
1111
|
90
|
Population after Mutation = population for next (2nd ) generation
|
q1
|
q2
|
F =-f-7
|
0010 1001
|
12
|
54
|
4.11
|
0110 1101
|
36
|
78
|
4.53
|
0010 0100
|
12
|
24
|
3.15
|
0110 1110
|
36
|
84
|
4.4
|
0110 0010
|
36
|
12
|
3.00
|
1001 0101
|
54
|
30
|
3.49
|
0111 1000
|
42
|
48
|
4.44
|
0111 1100
|
42
|
72
|
4.55
|
Fav = (4.11+4.53+3.15+4.4+3+3.49+4.44+4.55)/8 = 3.95
The average fitness of the new set is better than the previous set(which was 2.9)
Step 2:
The average fitness from the above table
Fav = (4.11+4.53+3.15+4.4+3+3.49+4.44+4.55)/8 = 3.95
Now we select the mating pool depending on F/Fav (rank selection). Two Populations with highest F/Fav will have 2 copies each in the mating pool while two populations with lowest F/Fav will die out. Others will get 1 copy each in the mating pool.
Population (2nd ) generation
|
F =-f-7
|
F/Fav
|
Count
|
0010 1001
|
4.11
|
1.04
|
1
|
0110 1101
|
4.53
|
1.14
|
2
|
0010 0100
|
3.15
|
0.796
|
0
|
0110 1110
|
4.4
|
1.11
|
1
|
0110 0010
|
3.00
|
0.759
|
0
|
1001 0101
|
3.49
|
0.883
|
1
|
0111 1000
|
4.44
|
1.12
|
1
|
0111 1100
|
4.55
|
1.15
|
2
|
Mating pool:
Population (2nd ) generation
|
F =-f-7
|
F/Fav
|
0010 1001
|
4.11
|
1.04
|
0110 1101
|
4.53
|
1.14
|
0110 1101
|
4.53
|
1.14
|
0110 1110
|
4.4
|
1.11
|
0111 1100
|
4.55
|
1.15
|
1001 0101
|
3.49
|
0.883
|
0111 1000
|
4.44
|
1.12
|
0111 1100
|
4.55
|
1.15
|
Repeat Crossover and Mutation
Step 3:
Crossover
It proceeds in 3 steps:
- Select two strings at random.
- Select crossover sites at random
- Swap bits between the crossover sites.
For the above mating pool:
Pop. No.
|
Population (2nd generation)
|
Mate with
|
CS1
|
CS2
|
Population after crossover
|
1
|
0010 1001
|
5
|
2
|
6
|
0011 1100
|
2
|
0110 1101
|
6
|
1
|
5
|
0001 0101
|
3
|
0110 1101
|
7
|
4
|
8
|
0110 1000
|
4
|
0110 1110
|
8
|
4
|
6
|
0110 1110
|
5
|
0111 1100
|
1
|
2
|
6
|
0110 1000
|
6
|
1001 0101
|
2
|
1
|
5
|
1110 1101
|
7
|
0111 1000
|
3
|
4
|
8
|
0111 1101
|
8
|
0111 1100
|
4
|
4
|
6
|
0111 1100
|
Step 4: Mutation
Select bits with a small probability, here with a probability 0.031
i.e only 2 bits out of a total of 64 (8 populations X 8 bit wide) bits will be mutated.
Hence randomly select bit no.21 and bit no. 62. The bits of the crossed over populations in these locations are flipped.
Pop. No.
|
Population after crossover
|
Random bits for mutation
|
Pop. after Mutation = population for next (3rd )generation
|
1
|
0011 1100
|
0011 1100
| |
2
|
0001 0101
|
0001 0101
| |
3
|
0110 1000
|
21
|
0110 0000
|
4
|
0110 1110
|
0110 1110
| |
5
|
0110 1000
|
0110 1000
| |
6
|
1110 1101
|
1110 1101
| |
7
|
0111 1101
|
0111 1101
| |
8
|
0111 1100
|
62
|
0111 1000
|
Again repeat the process on this new population
Finally after many iterations you will get a value that is close to (34,66) which is the optimum value of angles for stabilizing the system under consideration
No comments:
Post a Comment