How to fix the start and end points in Travelling Salesmen Problem?

天大地大妈咪最大 提交于 2019-12-10 02:41:53

问题


I have a solver that solves normal symmetric TSP problems. The solution means the shortest path via all the nodes with no restriction on which nodes are the first and the last ones in the path.

Is there a way to transform the problem so that a specific node can be ensured as the start node, and another node as the end node?

One way would be to add an I - a very large distance - to all distances between these start/end nodes and all the others (adding I twice to the distance between start and end node), so the solver is tempted to visit them only once (thus making them as the start and the end of the path).

Are there any big disadvantages of this approach, or is there a better way to do this?


回答1:


You can add a dummy node, which connects to start and end node with edges with weight 0. Since the TSP must contain the dummy node, the final result must contain the sequence start - dummy node - end (there is no other way to reach the dummy node). Therefore, you can get the shortest Hamilton path with specified start and end node. This solution should work even if the edges in the graph are negative.



来源:https://stackoverflow.com/questions/14527815/how-to-fix-the-start-and-end-points-in-travelling-salesmen-problem

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