QAM Assignment

5
Sahil Saini | PGP29391 | Section G Travelling Salesman Problem My initial cost matrix is shown below. Solving it as an Assignment problem in QM for windows, I get the following solution. City 1 City 2 City 3 City 4 City 5 City 6 City 1 Assign City 2 Assign City 3 Assign City 4 Assign City 5 Assign City 6 Assign Hence the path followed is 1-6-3-1 and 2-5-4-2. City 1 City 2 City 3 City 4 City 5 City 6 City 1 1000 3 8 9 3 1 City 2 4 1000 7 9 1 3 City 3 1 3 1000 1 5 9 City 4 7 2 3 1000 6 3 City 5 9 5 7 1 1000 2 City 6 5 2 1 3 6 1000 X6-3 = 0 1-6-3-1, 2-5-4-2 Z = 7 X1-6 = 0 X3-1 = 0

description

Decision tree analysis

Transcript of QAM Assignment

Page 1: QAM Assignment

Sahil Saini | PGP29391 | Section G

Travelling Salesman Problem

My initial cost matrix is shown below.

Solving it as an Assignment problem in QM for windows, I get the following solution.

City 1 City 2 City 3 City 4 City 5 City 6

City 1 Assign

City 2 Assign

City 3 Assign

City 4 Assign

City 5 Assign

City 6 Assign

Hence the path followed is 1-6-3-1 and 2-5-4-2.

City 1 City 2 City 3 City 4 City 5 City 6

City 1 1000 3 8 9 3 1

City 2 4 1000 7 9 1 3

City 3 1 3 1000 1 5 9

City 4 7 2 3 1000 6 3

City 5 9 5 7 1 1000 2

City 6 5 2 1 3 6 1000

X6-3 = 0

1-6-3-1, 2-5-4-2

Z = 7

X1-6 = 0 X3-1 = 0

Page 2: QAM Assignment

Sahil Saini | PGP29391 | Section G

1. Next we will solve the same cost matrix but this time add one more constraint i.e. we will not

allow the salesman to go from city 1 to city 6 by putting its cost very high.

Solving it as an Assignment problem in QM for windows, I get the following solution.

City 1 City 2 City 3 City 4 City 5 City 6

City 1 Assign

City 2 Assign

City 3 Assign

City 4 Assign

City 5 Assign

City 6 Assign

Hence the path followed is 1-2-5-4-6-3-1. Z value is 10.

2. Next we will solve the initial cost matrix but this time the constraint x6-3 =0 i.e. we will not allow

the salesman to go from city 6 to city 3 by putting its cost very high.

Solving it as an Assignment problem in QM for windows, I get the following solution.

City 1 City 2 City 3 City 4 City 5 City 6

City 1 1000 3 8 9 3 1000

City 2 4 1000 7 9 1 3

City 3 1 3 1000 1 5 9

City 4 7 2 3 1000 6 3

City 5 9 5 7 1 1000 2

City 6 5 2 1 3 6 1000

City 1 City 2 City 3 City 4 City 5 City 6

City 1 1000 3 8 9 3 1000

City 2 4 1000 7 9 1 3

City 3 1 3 1000 1 5 9

City 4 7 2 3 1000 6 3

City 5 9 5 7 1 1000 2

City 6 5 2 1 3 6 1000

City 1 City 2 City 3 City 4 City 5 City 6

City 1 1000 3 8 9 3 1

City 2 4 1000 7 9 1 3

City 3 1 3 1000 1 5 9

City 4 7 2 3 1000 6 3

City 5 9 5 7 1 1000 2

City 6 5 2 1000 3 6 1000

City 1 City 2 City 3 City 4 City 5 City 6

City 1 1000 3 8 9 3 1000

City 2 4 1000 7 9 1 3

City 3 1 3 1000 1 5 9

City 4 7 2 3 1000 6 3

City 5 9 5 7 1 1000 2

City 6 5 2 1 3 6 1000

Page 3: QAM Assignment

Sahil Saini | PGP29391 | Section G

City 1 City 2 City 3 City 4 City 5 City 6

City 1 Assign

City 2 Assign

City 3 Assign

City 4 Assign

City 5 Assign

City 6 Assign

Hence the path followed is 1-6-2-5-4-3-1. Z value is 9.

3. Next we will solve the initial cost matrix but this time the constraint x3-1 =0 i.e. we will not allow

the salesman to go from city 3 to city 1 by putting its cost very high.

Solving it as an Assignment problem in QM for windows, I get the following solution.

City 1 City 2 City 3 City 4 City 5 City 6

City 1 Assign

City 2 Assign

City 3 Assign

City 4 Assign

City 5 Assign

City 6 Assign

Hence the path followed is 1-5-6-3-4-2-1. Z value is 13.

City 1 City 2 City 3 City 4 City 5 City 6

City 1 1000 3 8 9 3 1

City 2 4 1000 7 9 1 3

City 3 1000 3 1000 1 5 9

City 4 7 2 3 1000 6 3

City 5 9 5 7 1 1000 2

City 6 5 2 1 3 6 1000

Page 4: QAM Assignment

Sahil Saini | PGP29391 | Section G

Hence, the optimal solution is 1-6-2-5-4-3-1 and the minimum cost for the travelling salesman is 9 units.

Nearest Neighbor Heuristic

These are the steps of the algorithm:

1. Stand on an arbitrary vertex as current vertex.

2. Find out the shortest edge connecting current vertex and an unvisited vertex V.

3. Set current vertex to V.

4. Mark V as visited.

5. If all the vertices in domain are visited, then terminate.

6. Go to step 2.

7. The sequence of the visited vertices is the output of the algorithm.

Hence this heuristic gives the following path.

X6-3 = 0

1-6-3-1, 2-5-4-2

Z = 7

X1-6 = 0

1-2-5-4-6-3-1

Z = 10 1-6-2-5-4-3-1

Z = 9

1-5-6-3-4-2-1

Z = 13

X3-1 = 0

Fathom Fathom Fathom

Page 5: QAM Assignment

Sahil Saini | PGP29391 | Section G

City 1 City 2 City 3 City 4 City 5 City 6

City 1 1000 3 8 9 3 1

City 2 4 1000 7 9 1 3

City 3 1 3 1000 1 5 9

City 4 7 2 3 1000 6 3

City 5 9 5 7 1 1000 2

City 6 5 2 1 3 6 1000

The path is 1-6-3-4-2-5 and the cost is 15 units.

Hence heuristic gives a correct path but does not necessarily give the optimal solution. In this case it

does not give the optimal solution which is 9 units.