简体   繁体   English

为什么TSP NP难以在汉密尔顿路径NP完全?

[英]Why is TSP NP-hard while the Hamiltonian path NP-complete?

Why aren't these 2 problems, namely TSP and Hamiltonian path problem , both NP-complete? 为什么这两个问题,即TSP哈密​​顿路径问题都不是NP完全?

They seem identical. 它们似乎相同。

For a problem X to be NP-complete , it has to satisfy: 对于问题X是NP完全的 ,它必须满足:

  1. X is in NP , given a solution to X, the solution can be verified in polynomial time. X在NP中 ,给定X的解,可以在多项式时间内验证解。
  2. X is in NP-hard , that is, every NP problem is reduceable to it in polynomial time (you can do this through a reduction from a known NP-hard problem (eg Hamiltonian Path)). X是NP难的 ,也就是说,每个NP问题在多项式时间内都可以减少(你可以通过减少已知的NP难问题(例如哈密顿路径)来实现)。

There are two versions of the The Travelling Salesman Problem (TSP) : 旅行商问题(TSP)有两个版本:

  1. The optimization version (probably the one you are looking at), namely, find the optimum solution to the TSP. 优化版本(可能是您正在查看的版本),即找到TSP的最佳解决方案。 This is not a decision problem, and hence cannot be in NP, but it is however in NP-hard which can be proven via a Hamiltonian Path reduction . 这不是一个决策问题,因此不能在NP中,但它在NP-hard中可以通过哈密​​顿路径减少来证明。 Therefore this isn't an NP complete problem. 因此,这不是NP完全问题。
  2. The decision version - given an integer K is there a path through every vertex in the graph of length < K? 决定版本 - 给定一个整数K是否有一条路径通过长度<K的图中的每个顶点? This is a decision (yes/no) problem, and a solution can be verified in polynomial time (just traverse the path and see if it touches every vertex) and so it is in NP, but it is also in NP-hard (by an identical proof as above). 这是一个决定(是/否)问题,并且可以在多项式时间内验证解决方案(只是遍历路径并查看它是否接触到每个顶点),因此它在NP中,但它也在NP-hard(通过与上述相同的证据)。 Since it satisfies both requirements for NP-completeness, it is an NP-complete problem. 由于它满足NP完全性的两个要求,因此它是NP完全问题。

The definitions of NP-hardness and NP-completeness are related but different. NP-硬度和NP-完整性的定义是相关的但不同。 Specifically, a problem is NP-hard if every problem in NP reduces to it in polynomial time, and a problem is NP-complete if it's both NP-hard and itself in NP. 具体来说,如果NP中的每个问题在多项式时间内都减少,那么问题就是NP难,如果它既是NP难的又是NP本身的问题就是NP完全问题。

The class NP consists of decision problems, problems that have a yes/no answer. NP类由决策问题,有/无答案的问题组成。 As a result, TSP cannot be in NP because the expected answer is a number rather than yes or no. 因此,TSP不能在NP中,因为预期的答案是数字而不是是或否。 Therefore, TSP can be NP-hard, but it can't be NP-complete. 因此,TSP可以是NP难的,但它不能是NP完全的。

On the other hand, the Hamiltonian path problem asks for a yes/no answer, and it happens to be in NP. 另一方面,汉密尔顿路径问题要求是/否答案,它恰好在NP中。 Therefore, since it's NP-hard as well, it's NP-complete. 因此,既然它也是NP难的,它就是NP完全的。

Now, you can take TSP and convert it to a decision problem by changing the question from "what's the cheapest path?" 现在,您可以通过更改“最便宜的路径是什么?”中的问题来将TSP转换为决策问题。 to "is there a path that costs X or less?," and that latter formulation is in NP and also happens to be NP-complete. “是否存在成本为X或更低的路径?”,后一种配方在NP中也恰好是NP完全的。

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

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