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

tsp dynamic programming

The Travelling Salesman Problem (TSP) is a complex computational problem that can be approached using brute-force or dynamic programming methods. The dynamic programming approach is more efficient, allowing for the calculation of the shortest path visiting each city exactly once, while still lacking a polynomial time algorithm. The algorithm defines sub-problems based on the cities visited and the current city, facilitating the determination of the optimal next city to visit.

Uploaded by

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

tsp dynamic programming

The Travelling Salesman Problem (TSP) is a complex computational problem that can be approached using brute-force or dynamic programming methods. The dynamic programming approach is more efficient, allowing for the calculation of the shortest path visiting each city exactly once, while still lacking a polynomial time algorithm. The algorithm defines sub-problems based on the cities visited and the current city, facilitating the determination of the optimal next city to visit.

Uploaded by

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

Travelling salesman problem is the most notorious computational

problem. We can use brute-force approach to evaluate every


possible tour and select the best one. For n number of vertices in a
graph, there are (n−1)! number of possibilities. Thus, maintaining a
higher complexity.

However, instead of using brute-force, using the dynamic


programming approach will obtain the solution in lesser time,
though there is no polynomial time algorithm.

Travelling Salesman Dynamic Programming


Algorithm
Let us consider a graph G = (V,E), where V is a set of cities and E is
a set of weighted edges. An edge e(u, v) represents that
vertices u and v are connected. Distance between
vertex u and v is d(u, v), which should be non-negative.

Suppose we have started at city 1 and after visiting some cities now
we are in city j. Hence, this is a partial tour. We certainly need to
know j, since this will determine which cities are most convenient to
visit next. We also need to know all the cities visited so far, so that
we don't repeat any of them. Hence, this is an appropriate sub-
problem.

For a subset of cities S ϵ� {1,2,3,...,n} that includes 1,


and j ϵ� S, let C(S, j) be the length of the shortest path visiting
each node in S exactly once, starting at 1 and ending at j.

When |S|> 1 , we define 𝑪C(S,1)= ∝∝ since the path cannot start


and end at 1.

Now, let express C(S, j) in terms of smaller sub-problems. We need


to start at 1 and end at j. We should select the next city in such a
way that

C(S,j)=minC(S−{j},i)+d(i,j)whereiϵS and i≠j

You might also like