什么是np完全问题?为什么它在计算机科学中如此重要?


当前回答

我们需要把算法和问题分开。我们编写算法来解决问题,它们以某种方式扩展。虽然这是一种简化,但如果缩放足够好,我们就用“P”来标记算法,如果缩放不够好,就用“NP”来标记算法。

了解我们试图解决的问题,而不是我们用来解决它们的算法,是有帮助的。所以我们说,所有具有良好伸缩算法的问题都是"在P内"的。而那些有一个糟糕的缩放算法的是“NP”。

That means that lots of simple problems are "in NP" too, because we can write bad algorithms to solve easy problems. It would be good to know which problems in NP are the really tricky ones, but we don't just want to say "it's the ones we haven't found a good algorithm for". After all, I could come up with a problem (call it X) that I think needs a super-amazing algorithm. I tell the world that the best algorithm I could come up with to solve X scales badly, and so I think that X is a really tough problem. But tomorrow, maybe somebody cleverer than me invents an algorithm which solves X and is in P. So this isn't a very good definition of hard problems.

尽管如此,NP中仍有许多问题,没有人知道一个好的算法。因此,如果我能证明X是一个特定的问题:一个解决X的好算法也可以用某种迂回的方式,为NP中的所有其他问题提供一个好算法。现在人们可能更相信X是一个棘手的问题。在这种情况下,我们称X为np完全。

其他回答

这是一类问题,我们必须模拟每一种可能性,以确保我们有最优解。

对于一些np完全问题,有很多好的启发式方法,但它们充其量只是一个有根据的猜测。

NP-Complete指的是非常具体的东西,你必须小心,否则你会弄错定义。首先,NP问题是一个是/否问题

对于答案为"是"的问题的每个实例都有多项式时间证明,即答案为"是",或者(等价地) 存在一种多项式时间算法(可能使用随机变量),如果问题实例的答案是“是”,那么它有非零概率回答“是”,如果答案是“否”,则它会在100%的时间内回答“否”。换句话说,该算法的假阴性率必须小于100%,并且没有假阳性。

问题X是np完全的,如果

X在NP中,并且 对于NP中的任何问题Y,都有一个从Y到X的“约简”:一个多项式时间算法,将Y的任何实例转换为X的实例,当且仅当X实例的答案是“是”时,Y实例的答案是“是”。

如果X是NP完全的,并且存在一个确定性的多项式时间算法,可以正确地解决X的所有实例(0%假阳性,0%假阴性),那么NP中的任何问题都可以在确定性多项式时间中解决(通过归约到X)。

So far, nobody has come up with such a deterministic polynomial-time algorithm, but nobody has proven one doesn't exist (there's a million bucks for anyone who can do either: the is the P = NP problem). That doesn't mean that you can't solve a particular instance of an NP-Complete (or NP-Hard) problem. It just means you can't have something that will work reliably on all instances of a problem the same way you could reliably sort a list of integers. You might very well be able to come up with an algorithm that will work very well on all practical instances of a NP-Hard problem.

I have heard an explanation, that is:" NP-Completeness is probably one of the more enigmatic ideas in the study of algorithms. "NP" stands for "nondeterministic polynomial time," and is the name for what is called a complexity class to which problems can belong. The important thing about the NP complexity class is that problems within that class can be verified by a polynomial time algorithm. As an example, consider the problem of counting stuff. Suppose there are a bunch of apples on a table. The problem is "How many apples are there?" You are provided with a possible answer, 8. You can verify this answer in polynomial time by using the algorithm of, duh, counting the apples. Counting the apples happens in O(n) (that's Big-oh notation) time, because it takes one step to count each apple. For n apples, you need n steps. This problem is in the NP complexity class.

如果一个问题可以证明它既NP-Hard,又在多项式时间内可验证,那么它就被归类为NP-complete。在不深入讨论NP-Hard的情况下,只要说明某些问题的多项式时间解还没有找到就足够了。也就是说,它需要n!(n !)步来解它们。然而,如果给你一个np完全问题的解,你可以在多项式时间内验证它。

np完全问题的一个经典例子是旅行商问题。”

作者:ApoxyButt 来自:http://www.everything2.com/title/NP-complete

上面NP完全问题的定义是正确的,但我想我可能会对它们的哲学重要性进行抒情,因为还没有人解决这个问题。

几乎你遇到的所有复杂问题都是NP完全的。这门课有一些非常基础的东西,从计算上看和容易解决的问题是不同的。它们有自己的味道,而且不难辨认。这基本上意味着任何适度复杂的算法都不可能精确地解决——调度、优化、包装、覆盖等。

But not all is lost if a problem you'll encounter is NP Complete. There is a vast and very technical field where people study approximation algorithms, which will give you guarantees for being close to the solution of an NP complete problem. Some of these are incredibly strong guarantees -- for example, for 3sat, you can get a 7/8 guarantee through a really obvious algorithm. Even better, in reality, there are some very strong heuristics, which excel at giving great answers (but no guarantees!) for these problems.

请注意,两个非常著名的问题——图同构和因式分解——不知道是P或NP。

什么是NP?

NP是所有决策问题(答案是或否的问题)的集合,其中“是”答案可以通过确定性图灵机在多项式时间(O(nk),其中n是问题大小,k是常数)验证。有时用多项式时间来定义快或快。

P是什么?

P是由确定性图灵机在多项式时间内解决的所有决策问题的集合。由于它们可以在多项式时间内求解,因此也可以在多项式时间内验证。因此P是NP的子集。

什么是np完全?

NP中的问题x也属于NP完全,当且仅当NP中的所有其他问题都可以快速地(即。在多项式时间内)转换成x。

换句话说:

x在NP中,并且 NP中的每个问题都可约为x

所以,NP完全问题的有趣之处在于,如果任何一个NP完全问题可以快速解决,那么所有NP问题都可以快速解决。

另见帖子“P=NP”是什么?为什么这是一个如此著名的问题?

什么是NP-Hard?

NP- hard是指至少和NP中最难的问题一样难的问题。注意,np完全问题也是np难的。然而,并非所有NP难问题都是NP问题(甚至是决策问题),尽管有NP作为前缀。NP-hard中的NP并不意味着非确定性多项式时间。是的,这令人困惑,但它的用法根深蒂固,不太可能改变。