TSP Where Vertices Can be Visited Multiple Times

烂漫一生 提交于 2019-12-14 02:14:49

问题


I am looking to solve a problem where I have a weighted directed graph and I must start at the origin, visit all vertices at least once and return to the origin in the shortest path possible. Essentially this would be a classic example of TSP, except I DO NOT have the constraint that each vertex can only be visited once. In my case any vertex excluding the origin can be visited any number of times along the path, if this makes the path shorter. So for example in a graph containing the vertices V1, V2, V3 a path like this would be valid, given that it is the shortest path:

ORIGIN -> V1 -> V2 -> V1 -> V3 -> V1 -> ORIGIN

As a result, I am a bit stuck on what approach to take in order to solve this, as a classic dynamic programming algorithm approach which is usually used to solve TSP problems in exponential time is not suitable.


回答1:


The typical approach is to create a distance matrix that gives the shortest-path distance between any two nodes. So d(i,j) = shortest path (following the edges of the network) from i to j. This can be done using Dijkstra's algorithm.

Now just solve a classical TSP with distances d(i,j). Your TSP doesn't "know" that the actual route followed might involve visiting a node multiple times. At the same time, it will ensure that the vehicle stops at every node.

Now, as for efficiency: As @Codor points out, TSP is NP-hard and so is your variant of it, so you are not going to find a provably optimal, polynomial-time algorithm. However, there are still many, many good algorithms (both heuristic and exact) for TSP, and most of them should be suitable for your problem. (In general, DP is not the way to go for TSP.)




回答2:


To answer the question in part, the problem described in the question does not admit a polynomial-time algorithm unless P=NP by the following argument. Clearly, the proposed problem includes instances which are Euclidean. However, no optimal solution to a Euclidean instance has repeated nodes, as such a solution can be improved by deleting additional nodes, using the triangle inequality. However, according to the Wikipedia article on TSP, Euclidean TSP is still NP-hard. This means that any polynomial-time algorithm for the problem in the question would be able to solve the Euclidean TSP to optimality on polynomial time, which is impossible unless P=NP.



来源:https://stackoverflow.com/questions/39833023/tsp-where-vertices-can-be-visited-multiple-times

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!