Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Rimsha Noor Mcs 3A 20-ARID-414 Quiz AI Submitted To Sir Imran

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Rimsha Noor

Mcs 3A
20-ARID-414
Quiz
AI
Submitted to
Sir Imran
Question:
Suppose a genetic algorithm uses chromosomes of the form x =
abcdefgh
with a fixed length of eight genes. Each gene can be any digit
between 0
and 9. Let the fitness of individual x be calculated as:
f(x) = (a + b) − (c + d) + (e + f) − (g + h) ,
BIS4435 3
and let the initial population consist of four individuals with the
following
chromosomes:
x1 = 6 5 4 1 3 5 3 2
x2 = 8 7 1 2 6 6 0 1
x3 = 2 3 9 2 1 2 8 5
x4 = 4 1 8 5 2 0 9 4
a) Evaluate the fitness of each individual, showing all your
workings, and
arrange them in order with the fittest first and the least fit
last.
Answer:
f(x1) = (6 + 5) − (4 + 1) + (3 + 5) − (3 + 2) = 9
f(x2) = (8 + 7) − (1 + 2) + (6 + 6) − (0 + 1) = 23
f(x3) = (2 + 3) − (9 + 2) + (1 + 2) − (8 + 5) = −16
f(x4) = (4 + 1) − (8 + 5) + (2 + 0) − (9 + 4) = −19
The order is x2, x1, x3 and x4.
b) Perform the following crossover operations:
i) Cross the fittest two individuals using one–point crossover
at the
middle point.
Answer:
One–point crossover on x2 and x1:
x2 = 8 7 1 2 6 6 0 1
x1 = 6 5 4 1 3 5 3 2

O1 = 8 7 1 2 3 5 3 2
O2 = 6 5 4 1 6 6 0 1
ii) Cross the second and third fittest individuals using a two–
point
crossover (points b and f).
Answer:
Two–point crossover on x1 and x3
x1 = 6 5 4 1 3 5 3 2
x3 = 2 3 9 2 1 2 8 5

O3 = 6 5 9 2 1 2 3 2
O4 = 2 3 4 1 3 5 8 5

You might also like