Week06_Assignment06_Solution
Week06_Assignment06_Solution
1. 5, range is 4.99 to 5.01. Given function is f (x) = (x − 4)2 and x ∈ [0, 31], ϵ = 1.0. Also, we have,
b−a
2n − 1 ≥
ϵ
31 −0
=⇒ 2n − 1 ≥
1
=⇒ 2n ≥32
=⇒ n ≥ 5
which gives n = 5.
3. (b). 2 and 7 are represented by 00010 and 00111, when we apply one-point crossover at the third
location we get,
2 :000|10
7 :001|11
O1 :000|11
O2 :001|10
00011 = 21 + 20
=⇒ 00011 = 3
00110 = 22 + 21
=⇒ 00110 = 6
5. (d). 2 and 11 are represented by 00010 and 01011, when we apply one-point crossover at the second
location we get,
2 :00|010
11 :01|011
O3 :00|011
O4 :01|010
00011 = 21 + 20
=⇒ 00011 = 3
01010 = 23 + 21
=⇒ 00110 = 10
7. (d). Given the fitness function f (x) which is equal to numbers of ones in the bit string x, so for the
given population we have,
4+3+4+5
8. (b). We know that the average value is given by, Average = 4 =4
So, we get
Fitness value
Population Fitness value Expected count = Average
4
0000 1111 4 4 =1
3
0001 1001 3 4
4
0010 1011 4 4 =1
5
0011 1110 5 4
Sum = 4 + 3 + 4 + 5
=⇒ Sum = 16
01100101 = 26 + 25 + 22 + 20
=⇒ 01100101 = 101
Let X = 101 ∈
/ [0, 25.5], so we will use a formula to make X lie inside the given interval, given by
n b−a o
x=a+ X
2n − 1
Here, we have 8 bits =⇒ n = 8 and the given interval is [0, 25.5] =⇒ b = 25.5 and a=0. Then the
above formula becomes,
n 25.5 − 0 o
x=0+ × 101
28 − 1
n 25.5 o
x= × 101
255
=⇒ x = 10.1