Travelling Salesman Problem�
Travelling Salesman Problem states-
Amity School of Engineering & Technology
Problem-�
Amity School of Engineering & Technology
Solution-�
Step-01:
Write the initial cost matrix and reduce it-
Amity School of Engineering & Technology
Rules
Amity School of Engineering & Technology
Row Reduction-
Consider the rows of above matrix one by one.
If the row already contains an entry ‘0’, then-
If the row does not contains an entry ‘0’, then-
Amity School of Engineering & Technology
Following this, we have-
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Column Reduction-
If the column already contains an entry ‘0’, then-
If the column does not contains an entry ‘0’, then-
Amity School of Engineering & Technology
Following this, we have-
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Cost(1)
= Sum of all reduction elements
= 4 + 5 + 6 + 2 + 1
= 18
Amity School of Engineering & Technology
Step-02:
Amity School of Engineering & Technology
Now,
We reduce this matrix.
Then, we find out the cost of node-02.
Amity School of Engineering & Technology
Row Reduction-
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Column Reduction-
Amity School of Engineering & Technology
Finally, the matrix is completely reduced.
Amity School of Engineering & Technology
Cost(2)
= Cost(1) + Sum of reduction elements + M[A,B]
= 18 + (13 + 5) + 0
= 36
Amity School of Engineering & Technology
Choosing To Go To Vertex-C: Node-3 (Path A → C)
Amity School of Engineering & Technology
Now,
We reduce this matrix.
Then, we find out the cost of node-03.
Amity School of Engineering & Technology
Row Reduction-
Amity School of Engineering & Technology
Column Reduction-
Amity School of Engineering & Technology
Choosing To Go To Vertex-D: Node-4 (Path A → D)
Amity School of Engineering & Technology
Now,
We reduce this matrix.
Then, we find out the cost of node-04.
Amity School of Engineering & Technology
Row Reduction-
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Column Reduction-
Thus, the matrix is already column-reduced.
Finally, the matrix is completely reduced.
Amity School of Engineering & Technology
Now, we calculate the cost of node-4.
Cost(4)
= Cost(1) + Sum of reduction elements + M[A,D]
= 18 + 5 + 3
= 26
Amity School of Engineering & Technology
Thus, we have-
Amity School of Engineering & Technology
Step-03:
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Now,
We reduce this matrix.
Then, we find out the cost of node-5.
Amity School of Engineering & Technology
Row Reduction-
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Column Reduction-
Amity School of Engineering & Technology
Now, we calculate the cost of node-5.
Cost(5)
= cost(3) + Sum of reduction elements + M[C,B]
= 25 + (13 + 8) + ∞
= ∞
Amity School of Engineering & Technology
Choosing To Go To Vertex-D: Node-6 (Path A → C → D)
Amity School of Engineering & Technology
Now,
We reduce this matrix.
Then, we find out the cost of node-6.
Amity School of Engineering & Technology
Row Reduction-
Amity School of Engineering & Technology
Column Reduction-
Amity School of Engineering & Technology
Now, we calculate the cost of node-6.
Cost(6)
= cost(3) + Sum of reduction elements + M[C,D]
= 25 + 0 + 0
= 25
Amity School of Engineering & Technology
Thus, we have-
Amity School of Engineering & Technology
Step-04:
Amity School of Engineering & Technology
Choosing To Go To Vertex-B: Node-7 (Path A → C → D → B)
Amity School of Engineering & Technology
Now,
We reduce this matrix.
Then, we find out the cost of node-7.
Amity School of Engineering & Technology
Row Reduction-
Amity School of Engineering & Technology
Column Reduction-
Thus, the matrix is already column reduced.
Finally, the matrix is completely reduced.
Amity School of Engineering & Technology
Now, we calculate the cost of node-7.
Cost(7)
= cost(6) + Sum of reduction elements + M[D,B]
= 25 + 0 + 0
= 25
Thus,
Optimal path is: A → C → D → B → A
Cost of Optimal path = 25 units
Amity School of Engineering & Technology