Keywords: NP Problme; NP-hard Problem; NP-complete Problem; P Problem
[Why write this article] talking about algorithms in zero order
[Here are the symbols and formulas used in this series of articles.] Here we are talking about algorithm (outside of this article) symbol tagging and basic mathematical formulas.
First, let's explain what is the NP problem, what is the NP hard problem, and what is the NP complete problem.
The following figure shows a clear representation of the relationships between them.
P Problem: this should be the easiest to understand, that is, a Problem can be solved at the Polynominal time, of course, for any input size.
NP Problem: for a type of Problem, we may not have a known quick method to obtain the answer to the Problem. However, if you give us a candidate answer, we can verify that this candidate answer is the answer to a known question within the polynominal time, which is called NP problem. Therefore, it is clear that P Problem is a subset of NP problem.
NP-hard Problem: for this type of Problem, their features are "at least as hard as the hardest problems in NP Problem ", the NP-hard problem is at least as difficult as the NP problem.
NP-complete Problem: for this type of Problem, they satisfy two properties. One is to verify whether a candidate answer is a real solution within the polynomial time, another feature is that we can convert the input of any NP problem in the polynomial time to make it a NP-complete problem.
Therefore, for the NP-hard problem, we can divide them into two parts. In part, we can use the polynomial time to verify whether a candidate answer is a real answer. This part constitutes a NP-complete set.
We often say that NP = p or np! = P, in fact, at present, we do not know whether all the problems in the NP Problem set can be solved within the Polynomial time. Of course, the interesting point is that if we can solve any problem in the NP-complete set within the polynomial time, all NP problems can be solved within the polynomial time. The reason is that we can see the nature of the NP-complete mentioned above, because any NP problem can convert its input within the polynomial time, make it a NP-complete problem, so ....
This section describes some of the definitions mentioned above and describes several typical NP-complete problems.
Vertex CoverHttp://en.wikipedia.org/wiki/Vertex_Cover
Informally, for a graph G (V, E), we select a subset V' in V so that all the edges in E get one point in V. Vertex Cover: vertices in V' cover each edge (because at least one side of each edge is in V') to give you a G (V, E) and a k, ask if there is a Vertex Cover (demo-problem) with k size in the entire G)
Formally, a vertex cover of a graphGIs a setCOf vertices such that each edgeGIs incident to at least one vertex inC. The setCIs saidCoverThe edgesG. The following figure shows examples of vertex covers in two graphs (the setCIs marked with red ).
3-CNF-SATHttp://en.wikipedia.org/wiki/3SAT#3-satisfiability
For example, each bracket is called a clause, and the X1, X2, and X3 are called Words in discrete mathematics. The values are True or False. Each bracket is a combination, and the parentheses are an analysis. This problem is: can a group of Xi values be found for such an expression to make the expression True. Given the expression, is there some assignmentTRUEAndFALSEValues to the variables that will make the entire expression true?
Integer Linear ProgrammingHttp://en.wikipedia.org/wiki/Linear_program#Integer_unknowns
Of course, this is the most obvious, that is, all the variables in LP must be integers. The Linear Programming issue will be explained in a specific article later. O (distinct _ distinct) O ~
Next let's take a look at some of the problems we often encounter.
Prove that a problem is an NP problem. Prove a result to you. You can verify its correctness within the polynomial time.
Prove that a problem is NP-hard. To prove a problem is NP-hard, a technique we often use is the reduction function, which is usually expressed by the symbol <=, for example, P <= Q, which indicatesP is distinct cible to Q or Q is the function from P or P is strongly CED to Q. P can be reduced to Q. P can be reduced to Q.The signature symbol here can be regarded as less than or equal to the difficulty level, meaning that question Q is at least as difficult as question P. When we want to prove that a problem is NP-hard, we usually need to find an NPC problem (instead of the NP-complete problem ), this NPC problem is reduced to NP-hard, that is, the NPC <= NP-hard.
It proves that the problem is NPC. To prove the NPC, we need to take two steps. The first step is to prove that the question is NP, which is to verify the answer (I feel this sentence is too bad ). Step 2: prove that this problem is NP-hard. Of course, the second step is the key to the problem, but the first step must also be mentioned in the proof.
How to prove a problem is NP-hard is the key to the above proof, that is, how to contract.
Here, we will take the following steps,
1. Convert the input of NPC to the input of NP-hard, that is, the input of each NPC is actually an NP-hard input.
2. Convert the output of NP-hard to the output of the NPC. This shows that an output of NP-hard is provided, and I can give you an output of the NPC.
Note: The above two transformations must be completed within the polynomial time.
The following example demonstrates the reduction method above.
In this example, we use 3SAT to prove that Vertex Cover is NP-hard. That is, 3SAT <= Vertex Cover
This indicates that we know that the 3SAT problem is NP-complete, and how to normalize the 3SAT problem to Vertex Cover.
First, we need to establish our correspondence between these two problems through input. Assume that my 3SAT is
We construct our Graph according to the following method, corresponding to each variable Xi. we construct the points Xi and ~ Xi. For each clause, we construct three vertices. These three vertices have edges directly to each other. Suppose these three vertices are called A, B, and C. At the same time, we also need to establish the links between A, B, and C and the clause: assume that our clause is (X1 V ~ X2 V ~ X3) We will connect X1 and ,~ X2 and B are connected ,~ X3 and C are connected. Note that each clause has a fully connected triangle. They share the Six Variable points (X1 ,~ X1, X2 ,~ X2, X3 ,~ X3) as shown in.
One thing to note is that for every clause in E, We correspond to a triangle in the rectangle (that is, the part that I enclose in the rectangle ), at the same time, all clause share the above six points, that is, the number of 2 * variables so many points are shared.
Through this figure, we have established the relationship between 3SAT and Vertex Cover. This is usually the most difficult and creative part of such proof issues.
The following describes how to perform conversion. This is usually a very trival part.
1) if I have a solution that can satisfy 3SAT, then I will be able to find the solution that satisfies Veterx Cover. For example, if 3SAT is satisfied, every clause must be satisfied ~ X2 V ~ X3) for example, if this formula is satisfied, a variable must be set to true, which can be X1 or ~ X2 or ~ X3. If X1 is true, in the corresponding vertex cover, we select X1 from the above six points, and for the three points in the triangle below, we chose the other two points connected to X1. For each clause, we can do this and cover all the edges in the graph. That is, we have a vertex cover that meets the requirements.
2) if I have a solution that satisfies Vertex Cover, then I will be able to find the corresponding solution that meets 3SAT. Because we need to cover this figure, we need to cover at least two points in the triangle, and at least one pair of pair in the above will be covered, so for a vertex cover with a size of n + 2 m (n is the number of variables, and m is the number of clause), we can find a satisfying 3SAT. (obviously, because each clause is connected to a pair of pair points above. Still not clear can see this link http://users.eecs.northwestern.edu /~ Fortnow/classes/w08/EECS395/lecture11.pdf)
And then ,... We're done.
In this example, we use 3SAT to prove that ILP is NP-hard. That is, 3SAT <= ILP
First, we should look for ing. This ing does not involve graphs and should be easier to construct and understand.
Let's talk about the above 3SAT example. For each clause, we correspond to a constraint in ILP. For example, E contains four variables, X1, X2, X3, and X4. Our ILP also has the same four variables, in addition, we require that they can only take 0 or 1. For a clause, such as (X1 V ~ X2 V ~ X3). The corresponding constraint is "X1 + (1-X2) + (1-X3)> = 1". Obviously, the variable 0 in ILP corresponds to false in 3SAT, in ILP, select 1 for the variable corresponding to the variable in 3SAT and select true for the ing.
Obviously, the input/output conversion trival of these two problems is not good. If a clause meets the requirements, the constraint in the corresponding ILP must also meet the requirements. Stealing laziness ~ O (distinct _ distinct) O ~
Pass.
This type of NP proof problem is still very difficult. It can only be said that it is very hard to exercise your mind. Whether it is useful or not depends on your definition of "useful". If you are benevolent, You can see wisdom.
========================================================== ========================================================== ==========
This work is licensed using the "knowledge sharing" signature 2.5 mainland China license agreement. This blog uses the "knowledge sharing" signature 2.5 mainland China License Agreement for permission. This blog is copyrighted by the author. You are welcome to reprint it without the author's consent.Do not randomly delete any content in the articleAnd on the Article PageThe original text connection is given clearlyOtherwise, you are entitled to pursue legal liability. If you have any questions or authorization negotiation, please leave a message for me.