简体   繁体   English

Dijkstra 算法是否适用于旅行商问题?

[英]Can Dijkstra's algorithm be applicable to the Travelling Salesman Problem?

This is a general query.这是一般查询。 Dijkstra's algorithm is able to find the shortest distances between each of the nodes while the TSP problem says to start and end on the same node by traveling each node at least once with the shortest path. Dijkstra 的算法能够找到每个节点之间的最短距离,而 TSP 问题说通过以最短路径至少遍历每个节点一次来在同一节点上开始和结束。 Is there any way I can solve it using Dijkstra's algorithm approach because I am unable to implement the complex approach using dynamic programming?有什么办法可以使用 Dijkstra 的算法方法解决它,因为我无法使用动态编程来实现复杂的方法?

Dijkstra's algorithm can be used but it doesn't help (a lot).可以使用 Dijkstra 的算法,但它没有帮助(很多)。 First you need to see that the graph you "need to use" to find a solution is not the input graph G=<V,E> but a graph which is derived from the input graph.首先,您需要看到您“需要使用”来找到解决方案的图形不是输入图形G=<V,E>而是从输入图形派生的图形。 Which can be Gd=<Vd,Ed> where Vd is a ordered subset of V and Ed is a pair from Vd , where an edge '([v1,..,vn],[v1,..,vn,vm]) in Ed exists if (vn,vm)\\in E .可以是Gd=<Vd,Ed>其中VdV的有序子集, Ed是来自Vd一对,其中边为 '([v1,..,vn],[v1,..,vn,vm] ) 在Ed存在如果(vn,vm)\\in E Now the cost of an edge in Gd correspond to the cost in G .现在Gd边的成本对应于G的成本。 A node is a goal state when it contains all nodes from G当一个节点包含来自G所有节点时,它就是一个目标状态

Brute-force Depth/Bredth/Iterative would work.蛮力深度/Bredth/迭代会起作用。 How about dijkstra.迪杰斯特拉怎么样。 You need to have你需要有

a consistent heuristic which estimate is always less than or equal to the estimated distance from any neighboring vertex to the goal, plus the step cost of reaching that neighbor.一致的启发式,其估计值始终小于或等于从任何相邻顶点到目标的估计距离,加上到达该邻居的步骤成本。

Obviously, the constant zero is such a heuristic.显然,常量零就是这样一种启发式方法。 Can you get a better heuristic?你能得到更好的启发式方法吗? Not really due to the NP nature of TSP.并不是真的由于 TSP 的 NP 性质。 Interestingly in real world problems you can sometimes find in-consistent heuristics, which still produce good results.有趣的是,在现实世界中的问题中,您有时会发现不一致的启发式方法,但仍然可以产生良好的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM