Assignment 02 Genetic Algorithm
Assignment 02 Genetic Algorithm
Assignment 2
Genetic Algorithm
A.
C 10 3
D 40 8
E 15 7
F 25 4
G 4 5
H 7 2
Maximum weight = 12
The above problem is a 0/1 Knapsack problem. You have to carry the different objects in your bag
in a way such that the reward is maximized without exceeding the weight limit. You can carry an
object exactly once but you always have to carry the object labelled “H”. Assuming you are asked
to use Genetic Algorithm for this problem, answer the following questions
1. Encode the problem and create an initial population of 4 different chromosomes [1.5 marks]
2. Explain what would be an appropriate fitness function for this problem. Use the fitness
function and perform natural selection to choose the 2 fittest chromosomes. [1.5 marks]
3. Using the selected chromosomes perform a single point crossover to get 2 offspring [1
marks]
4. Perform mutation and check the fitness of the final offspring. Explain your work. [1 marks]
B.
This is a map of 7 cities (A, B, C, D, E, F, and G) which are connected with each other via different
paths. Your job is to visit every city just once covering the minimum distance possible. You have
to find the optimal combination of cities using Genetic Algorithm. You can start at any point and
end at any point but keep in mind that every city must be visited.
1. Encode the problem and create an initial population of 4 different chromosomes. [1.5
marks]
2. Using an appropriate fitness function, perform natural selection to choose the 2 fittest
chromosomes. [1 marks]
3. Perform single point crossover from the 3rd index of your selected chromosomes to get 2
offspring. Are they eligible as a solution? If not, explain with reason. [1.5 marks]
4. Would the usual method of mutation work here? Explain your opinion. [1 marks]