0% found this document useful (0 votes)
72 views

Travelling Salesman Problem Dynamic Programming

The document describes the travelling salesman problem and its solution using dynamic programming. It defines a journey J(k,S) as starting at node k, passing through nodes in set S at most once, and terminating at node 1. It calculates the costs of all possible journeys, starting with direct paths to node 1, then paths with one node in S, then two nodes, and finally three nodes to find the overall minimum cost tour. The minimum cost tours for the sample graph are listed as 1-2-4-3-1, 1-3-2-4-1, 1-4-2-3-1, or 1-3-4-2-1.

Uploaded by

theresa.painter
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views

Travelling Salesman Problem Dynamic Programming

The document describes the travelling salesman problem and its solution using dynamic programming. It defines a journey J(k,S) as starting at node k, passing through nodes in set S at most once, and terminating at node 1. It calculates the costs of all possible journeys, starting with direct paths to node 1, then paths with one node in S, then two nodes, and finally three nodes to find the overall minimum cost tour. The minimum cost tours for the sample graph are listed as 1-2-4-3-1, 1-3-2-4-1, 1-4-2-3-1, or 1-3-4-2-1.

Uploaded by

theresa.painter
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

TRAVELLING SALESMAN PROBLEM

DYNAMIC PROGRAMMING
SOLUTION

SAMPLE GRAPH
COST(k,l) = 10(k+l)

30

3
50

30

70

50
2

60

THE TRAVELLING SALESMAN PROBLEM


In a complete weighted graph find a tour of minimum cost.
Let a journey be defined as follows. A journey J(k,S) starts at a node k, passes
through all the nodes in S at most once and terminates at node 1. S is a subset of the
nodes of the graph excluding node 1.
S is the null set
J(2,) = 30, J(3,) = 40, J(4,) = 50---direct paths to node 1.
S has one element
J(2, {3}) = cost(2,3) + J(3, ) = 50 + 30 = 80
J(2, {4}) = cost(2,4) + J(4, ) = 60 + 40 = 100
J(3, {2}) = cost(3,2) + J(3, ) = 50 + 30 = 80
J(3, {4}) = cost(3,4) + J(4, ) = 70 + 40 = 110
J(4, {2}) = cost(4,2) + J(2, ) = 60 + 20 = 80

J(4, {3}) = cost(4,3) + J(3, ) = 70 + 30 = 100


S has two elements
J(2, {3,4}) = min{cost(2,3) + J(3, {4}), cost(2,4) + J(4, {3})}= min(50 + 110, 60 + 100)
= min(160,160) = 160
J(3, {2,4})=min{ cost(3,2) + J(2,{4}), cost(3,4) + J(4, {3})}= min(50 + 100, 70 + 100)
=min(150,170)=150
J(4, {2,3})=min{ cost(4,2) + J(2, {3}), cost(4,3) + J(3, {2})} = min(60 + 80, 70 + 80)
=min(140, 150) = 140
S has three elements
J(1, {2,3,4}) = min{ cost(1,2) + J(2, {3,4}), cost(1,3) + J(3, {2,4}),
cost(1,4) + J(4,{2,3})}
= min{ 30 + 160, 40 + 150, 50 + 140}
= min(190,190,190)
= 190

THE MINIMUM COST TOURS ARE THUS

1-2-4-3-1 OR 1-3-2-4-1 OR 1-4-2-3-1


OR 1-3-4-2-1
SAMPLE GRAPH
COST(k,l) = 10(k+l)

30

3
50

30

70

50
2

60

You might also like