简体   繁体   English

关于NP-hard和NP-Complete在旅行商问题上的困惑

[英]Confusion about NP-hard and NP-Complete in Traveling Salesman problems

Traveling Salesman Optimization(TSP-OPT) is a NP-hard problem and Traveling Salesman Search(TSP) is NP-complete. 旅行推销员优化(TSP-OPT)是NP难问题,旅行推销员搜索(TSP)是NP完全的。 However, TSP-OPT can be reduced to TSP since if TSP can be solved in polynomial time, then so can TSP-OPT(1). 但是,TSP-OPT可以简化为TSP,因为如果TSP可以在多项式时间内求解,那么TSP-OPT(1)也可以。 I thought for A to be reduced to B, B has to be as hard if not harder than A. As I can see in the below references, TSP-OPT can be reduced to TSP. 我认为A要降低到B,B必须要比A更难。如我在下面的参考文献中所见,TSP-OPT可以降低到TSP。 TSP-OPT is supposed to be harder than TSP. TSP-OPT应该比TSP更难。 I am confused... 我很困惑...

References: (1)Algorithm, Dasgupta, Papadimitriou, Vazirani Exercise 8.1 http://algorithmics.lsi.upc.edu/docs/Dasgupta-Papadimitriou-Vazirani.pdf https://cseweb.ucsd.edu/classes/sp08/cse101/hw/hw6soln.pdf 参考文献:(1)算法,Dasgupta,Papadimitriou,Vazirani练习8.1 http://algorithmics.lsi.upc.edu/docs/Dasgupta-Papadimitriou-Vazirani.pdf https://cseweb.ucsd.edu/classes/sp08/cse101 /hw/hw6soln.pdf

http://cs170.org/assets/disc/dis10-sol.pdf http://cs170.org/assets/disc/dis10-sol.pdf

I took a quick look at the references you gave, and I must admit there's one thing I really dislike in your textbook (1st pdf) : they address NP-completeness while barely mentioning decision problems . 我快速浏览了你提供的参考资料,我必须承认在你的教科书中我真的不喜欢一件事(第1版):他们解决了NP完全性,而几乎没有提到决策问题 The provided definition of an NP-complete problem also somewhat deviates from what I'd expect from a textbook. 所提出的NP完全问题的定义也有点偏离我对教科书的期望。 I assume that was a conscious decision to make the introduction more appealing... 我认为这是一个有意识的决定,使引言更具吸引力......

I'll provide a short answer, followed by a more detailed explanation about related notions. 我将提供一个简短的答案,然后是关于相关概念的更详细的解释。


Short version 简洁版本

Intuitively (and informally), a problem is in NP if it is easy to verify its solutions. 直觉(和非正式),如果很容易验证其解决方案,则问题在于NP

On the other hand, a problem is NP-hard if it is difficult to solve, or find a solution. 另一方面,如果难以解决或找到解决方案,则问题是NP难的

Now, a problem is NP-complete if it is both in NP, and NP-hard. 现在,如果NP和NP都是NP,那么问题就是NP完全。 Therefore you have two key, intuitive properties to NP-completeness. 因此,您有两个关键的,直观的NP完全性属性。 Easy to verify , but hard to find solutions. 易于验证 ,但很难找到解决方案。

Although they may seem similar, verifying and finding solutions are two different things. 尽管它们看似相似,但验证和寻找解决方案是两回事。 When you use reduction arguments, you're looking at whether you can find a solution. 当您使用减少参数时,您正在查看是否可以找到解决方案。 In that regard, both TSP and TSP-OPT are NP-hard, and it is difficult to find their solutions. 在这方面,TSP和TSP-OPT都是NP难的,很难找到他们的解决方案。 In fact, the third pdf provides a solution to excercise 8.1 of your textbook, which directly shows that TSP and TSP-OPT are equivalently hard to solve. 实际上,第三个pdf提供了练习8.1教科书的解决方案,这直接表明TSP和TSP-OPT等同于难以解决。

Now, one major distinction between TSP and TSP-OPT is that the former is (what your textbook call) a search problem, whereas the latter is an optimization problem. 现在,TSP和TSP-OPT之间的一个主要区别是前者是(教科书所称的)搜索问题,而后者是优化问题。 The notion of verifying the solution of a search problem makes sense, and in the case of TSP, it is easy to do, therefore it is NP-complete. 验证搜索问题的解决方案的概念是有意义的,并且在TSP的情况下,它很容易做到,因此它是NP完全的。 For optimization problems, the notion of verifying a solution becomes weird, because I can't think of any way to do that without first computing the size of an optimal solution, which is roughly equivalent to solving the problem itself. 对于优化问题,验证解决方案的概念变得奇怪,因为如果不首先计算最优解的大小,我就无法想到任何方法,这大致相当于解决问题本身。 Since we do not know an efficient way to verify a solution for TSP-OPT, we cannot say that it is in NP, thus we cannot say that it is NP-complete. 由于我们不知道验证TSP-OPT解决方案的有效方法,我们不能说它在NP中,因此我们不能说它是NP完全的。 (More on this topic in the detailed explanation.) (详细说明中有关此主题的更多信息。)


The tl;dr is that for TSP-OPT, it is both hard to verify and hard to find solutions, while for TSP it is easy to verify and hard to find solutions. tl; dr是针对TSP-OPT的,它既难以验证又难以找到解决方案,而对于TSP,它很容易验证并且很难找到解决方案。 Reductions arguments only help when it comes to finding solutions, so you need other arguments to distinguish them when it comes to verifying solutions. 减少参数只有在寻找解决方案时才有用,因此在验证解决方案时需要其他参数来区分它们。


More details 更多细节

One thing your textbook is very brief about is what a decision problem is. 您的教科书非常简短的一件事是决策问题是什么。 Formally, the notion of NP-completeness, NP-hardness, NP, P, etc, were developed in the context of decision problems, and not optimization or search problems. 形式上,NP完全性,NP-硬度,NP,P等的概念是在决策问题的背景下开发的,而不是优化或搜索问题。

Here's a quick example of the differences between these different types of problems. 以下是这些不同类型问题之间差异的快速示例。

A decision problem is a problem whose answer is either YES or NO . 决策问题是答案是“是还是“ 否”的问题

TSP decision problem TSP决策问题

Input: a graph G, a budget b 输入:图G,预算b

Output: Does G admit a tour of weight at most b ? 输出: G是否承认最多b的重量? (YES/NO) (YES / NO)

Here is the search version 这是搜索版本

TSP search problem TSP搜索问题

Input: a graph G, a budget b 输入:图G,预算b

Output: Find a tour of G of weight at most b, if it exists. 输出:如果存在,找到最多重量为G的G的游览。

And now the optimization version 而现在的优化版本

TSP optimization problem TSP优化问题

Input: a graph G 输入:图G

Output: Find a tour of G with minimum weight. 输出:找到最小重量的G之旅。

Out of context, the TSP problem could refer to any of these. 脱离背景,TSP问题可能涉及其中任何一个。 What I personally refer to as the TSP is the decision version. 我个人称之为TSP的是决策版。 Here your textbook use TSP for the search version, and TSP-OPT for the optimization version. 在这里,您的教科书使用TSP作为搜索版本,使用TSP-OPT作为优化版本。

The problem here is that those various problems are strictly distinct. 这里的问题是那些各种问题是严格区分的。 The decision version only ask for existence, while the search version asks for more, it needs one example of such a solution. 决策版只要求存在,而搜索版要求更多,它需要一个这样的解决方案的例子。 In practice, we often want to have the actual solution, so more practical approaches may omit to mention decision problems. 在实践中,我们经常希望得到实际的解决方案,因此更实际的方法可能省略提及决策问题。

Now what about it? 那现在怎么样? The definition of an NP-complete problem was meant for decision problems, so it technically does not apply directly to search or optimization problems. NP完全问题的定义是针对决策问题的,因此从技术上讲它不直接适用于搜索或优化问题。 But because the theory behind it is well defined and useful, it is handy to still apply the term NP-complete/NP-hard to search/optimization problem, so that you have an idea of how hard these problems are to solve. 但由于其背后的理论定义明确且有用,因此仍然可以将NP-complete / NP-hard一词应用于搜索/优化问题,这样您就可以了解这些问题需要解决的难度。 So when someone says the travelling salesman problem is NP-complete, formally it should be the decision problem version of the problem. 因此,当有人说旅行商问题是NP完全时,正式问题应该是决策问题版本。

Obviously, many notions can be extended so that they also cover search problems, and that is how it is presented in your textbook. 显然,许多概念可以扩展,以便它们也涵盖搜索问题,这就是它在教科书中的呈现方式。 The differences between decision, search, and optimization, are precisely what the exercises 8.1 and 8.2 try to cover in your textbook. 决策,搜索和优化之间的差异正是练习8.1和8.2试图在教科书中涵盖的内容。 Those exercises are probably meant to get you interested in the relationship between these different types of problems, and how they relate to one another. 这些练习可能是为了让你对这些不同类型的问题之间的关系以及它们如何相互关联感兴趣。

Short Version 简洁版本

The decision problem is NP-complete because you can both have a polynomial time verifier for the solution, as well as the fact that the hamiltonian cycle problem is reducible to TSP_DECIDE in polynomial time. 决策问题是NP完全的,因为你可以为解决方案都有一个多项式时间验证器,以及哈密顿循环问题在多项式时间内可以简化为TSP_DECIDE的事实。

However, the optimization problem is strictly NP-hard, because even though TSP_OPTIMIZE is reducible from the hamiltonian (HAM) cycle problem in polynomial time, you don't have a poly time verifier for a claimed hamiltonian cycle C, whether it is the shortest or not, because you simply have to enumerate all possibilities (which consumes the factorial order space & time). 然而,优化问题严格来说是NP难的,因为即使TSP_OPTIMIZE可以从多项式时间的哈密顿(HAM)循环问题中减少,你也没有一个多边形时间验证器用于声称的哈密顿循环C,它是否是最短的或不,因为您只需要枚举所有可能性(消耗阶乘顺序空间和时间)。

What the given reference define is, bottleneck TSP 给定的参考定义的是瓶颈TSP

The Bottleneck traveling salesman problem (bottleneck TSP) is a problem in discrete or combinatorial optimization. 瓶颈旅行推销员问题(瓶颈TSP)是离散或组合优化中的问题。 The problem is to find the Hamiltonian cycle in a weighted graph which minimizes the weight of the most weighty edge of the cycle. 问题是在加权图中找到哈密顿循环,这使得循环最重的边缘的权重最小化。

The problem is known to be NP-hard. 已知问题是NP难。 The decision problem version of this, "for a given length x is there a Hamiltonian cycle in a graph G with no edge longer than x?", is NP-complete. 这个决策问题的版本,“对于给定长度x,图G中的哈密顿循环没有边长于x?”,是NP完全的。 NP-completeness follows immediately by a reduction from the problem of finding a Hamiltonian cycle. NP-完全性立即由于发现哈密顿循环的问题而减少。

This problem can be solved by performing a binary search or sequential search for the smallest x such that the subgraph of edges of weight at most x has a Hamiltonian cycle. 该问题可以通过对最小x执行二元搜索或顺序搜索来解决,使得最多x的权重边的子图具有哈密顿循环。 This method leads to solutions whose running time is only a logarithmic factor larger than the time to find a Hamiltonian cycle . 该方法导致解决方案的运行时间仅是比找到哈密顿循环的时间更大的对数因子


Long Version 长版

The mistake is to say that the TSP is NP complete. 错误是说TSP是NP完整的。 Truth is that TSP is NP hard. 事实是TSP是NP难的。 Let me explain a bit: 让我解释一下:

The TSP is a problem defined by a set of cities and the distances between each city pair. TSP是由一组城市和每个城市对之间的距离定义的问题。 The problem is to find a circuit that goes through each city once and that ends where it starts. 问题是找到一个通过每个城市一次的电路,并在它开始的地方结束。 This in itself isn't difficult. 这本身并不困难。 What makes the problem interesting is to find the shortest circuit among all those that are possible. 使问题变得有趣的是在所有可能的那些中找到最短的电路。

Solving this problem is quite simple. 解决这个问题非常简单。 One merely need to compute the length of all possible circuits, then keep the shortest one. 人们只需要计算所有可能电路的长度,然后保持最短的电路。 Issue is that the number of such circuits grows very quickly with the number of cities. 问题是这些电路的数量随着城市数量的增长而迅速增长。 If there are n cities then this number is factorial of n-1 = (n-1)(n-2)...3.2. 如果有n个城市,那么这个数字是因子n-1 =(n-1)(n-2)... 3.2。

A problem is NP if one can easily (in polynomial time) check that a proposed solution is indeed a solution. 如果人们可以很容易地(在多项式时间内)检查提出的解决方案确实是一个解决方案,那么问题就是NP。

Here is the trick. 这是诀窍。

In order to check that a proposed tour is a solution of the TSP we need to check two things, namely 为了检查提议的巡回演出是TSP的解决方案,我们需要检查两件事,即

  1. That each city is is visited only once 每个城市只访问过一次
  2. That there is no shorter tour than the one we are checking 没有比我们检查的旅游更短的旅行

We didn't check the second condition! 我们没有检查第二个条件! The second condition is what makes the problem difficult to solve. 第二个条件是使问题难以解决的原因。 As of today, no one has found a way to check condition 2 in polynomial time. 截至今天,没有人找到在多项式时间内检查条件2的方法。 It means that the TSP isn't in NP, as far as we know. 据我们所知,这意味着TSP不在NP中。

Therefore, TSP isn't NP complete as far as we know. 因此,据我们所知,TSP不是NP完整的。 We can only say that TSP is NP hard. 我们只能说TSP是NP难的。

When they write that TSP is NP complete, they mean that the following decision problem (yes/no question) is NP complete: 当他们写TSP是NP完成时,他们意味着以下决策问题(是/否问题)是NP完成的:

TSP_DECISION : Given a number L, a set of cities, and distance between all city pairs, is there a tour visiting each city exactly once of length less than L? TSP_DECISION :给定一个数字L,一组城市,以及所有城市对之间的距离,是否有一个游览每个城市只有一次长度小于L?

This problem is indeed NP complete, as it is easy (polynomial time) to check that a given tour leads to a yes answer to TSPDECISION. 这个问题确实是NP完成的,因为很容易(多项式时间)检查给定的巡回导致TSPDECISION的答案是肯定的。

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

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