0% found this document useful (0 votes)
81 views2 pages

Assignment 02 Genetic Algorithm

This document describes two optimization problems that can be solved using genetic algorithms: a 0/1 knapsack problem and a traveling salesperson problem. For the knapsack problem, the document asks the reader to encode the problem, define a fitness function, perform selection, crossover and mutation. For the traveling salesperson problem, similar steps are outlined to find the shortest route between cities using genetic algorithms.

Uploaded by

Ahsaan Habib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views2 pages

Assignment 02 Genetic Algorithm

This document describes two optimization problems that can be solved using genetic algorithms: a 0/1 knapsack problem and a traveling salesperson problem. For the knapsack problem, the document asks the reader to encode the problem, define a fitness function, perform selection, crossover and mutation. For the traveling salesperson problem, similar steps are outlined to find the shortest route between cities using genetic algorithms.

Uploaded by

Ahsaan Habib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE422 Artificial Intelligence

Assignment 2
Genetic Algorithm

A.

Object Reward Weight


A 20 1
B 5 2

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]

You might also like