1 / 15

NP-Complete Problems

NP-Complete Problems. Running Time v.s. Input Size. Concern with problems whose complexity may be described by exponential functions. Tractable problems v.s. intractable problems. Decision Problems. Optimization problems can be formulated as decision problems.

sylvia
Download Presentation

NP-Complete Problems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NP-Complete Problems

  2. Running Time v.s. Input Size • Concern with problems whose complexity may be described by exponential functions. • Tractable problems v.s. intractable problems

  3. Decision Problems • Optimization problems can be formulated as decision problems. • A decision problem is a question that has two possible answers, yes and no. • A problem instance is the combination of the problem and a specific input. • The instance description part defines the information expected in the input. • The question part state the actual yes-or-no question; the question contains variables defined in the instance description. • A precise statement of the input is important • Instance: an undirected graph G = (V, E). Question: Does G contain a clique of k vertices? (A clique is a complete subgraph: every pair of vertices in the subgraph has an edge between them) • Instance: an undirected graph G = (V, E) and an integer k. Question: Does G contain a clique of k vertices?

  4. Example Decision Problems • Bin packing Suppose we have an unlimted number of bins each of capacity one, and n objects with sizes s1, …, sn where 0 ≤ si ≤ 1. • Optimization problem: Determine the smallest number of bins into which the objects can be packed. • Decision problem: Given, in addition to the inputs described, an integer k, do the objects fit in k bins? • Knapsack Suppose we have a knapsack of capacity C (a positive integer) and n objects with sizes s1, …, sn and “profits” p1, …, pn. • Optimization problem: Find the largest total profit of any subset of the objects that fits in the knapsack. • Decision problem: Given k, is there a subset of the objects that fits in the knapsack and has total profit at least k?

  5. Example Decision Problems • Subset sum The input is a positive integer C and n objects whose sizes are positive integers s1, …, sn • Optimization problem: Among subsets of the objects with sum at most C, what is the largest subset sum? • Decision problem: Is there a subset of the objects whose sizes add up to exactly C? • Satisfiability Given a Boolean expression S involving only Boolean variables and values in conjunctive normal form (CNF) • Decision problem: Can we find an assignment of Boolean values to the variables such that S is evaluated to the value of 1? Some concepts • A Boolean variable is a variable that may be assigned the value 1 or 0. • A literal is a Boolean variable or the negation of a Boolean variable. • A clause is a sequence of literals separated by the Boolean or operator (). • A Boolean formula is in conjunctive normal form (CNF) if it consists of a sequence of clauses separated by the Boolean and operator ().

  6. The Class P • Polynomially bounded An algorithm is said to be polynomially bounded if its worst-case complexity is bounded by a polynomial function of the input size. • A problem is said to be polynomially bounded if there is a polynomially bounded algorithm for it. • The class P P is the class of decision problems that are polynomially bounded. • The problems in P may not be “tractable” in practice, but those not in P are intractable.

  7. The Class NP • Nondeterministic algorithm A nondeterministic algorithm has two phases and output step: • The nondeterministic “guessing” phase: guess a “proposed solution” s (called certificate) • The deterministic “verifying” phase: A deterministic (i.e., ordinary) subroutine begins execution. In addition to the decision problems’ input, the subroutine may use s. Eventually it returns a value true or false  or it may get in an infinite loop and never halt. (Think of the verifying phase as checking s to see if it is a solution for the decision problem’s input, i.e., if it justifies a yes answer for the decision problem’s input.) • The output step. If the verifying phase returned true, the algorithm outputs yes. Otherwise, there is no output. • A nondeterministic algorithm is said to be polynomially bounded if there is a polynomial p such that for each input of size n for which the answer is yes, there is some execution of the algorithm that produces a yes output in at most p(n) time. • NP is the class of decision problems for which there is a polynomially bounded nondeterministic algorithm.

  8. 1 4 2 5 3 The Class NP • Nondeterministic graph coloring Given an undirected graph G = (V, E) with n vertices and an integer k, is G colorable with k colors such that each edge connecting two vertices with different colors? • Guess a “proposed solution” s • The deterministic “verifying” phase • Check that each vertex is assigned a color • Totally there are at most k different colors • Scan the list of edges in the graph and check that the two vertices incident upon one edge have different colors. • The output step. If the verifying phase returned true, the algorithm outputs yes. Otherwise, there is no output.

  9. The Class NP • Nondeterministic vertex covering Given an undirected graph G = (V, E) with n vertices and an integer k, is there a subset S of k vertices in G such that for each edge (u, v), either uS or vS? • Generate all subsets of k vertices of G; • Non-deterministically select a subset S of k vertices from G; • For every vertex v in G, check whether v is adjacent to someone in S. • P  NP • NP = P ? P  NP NP P

  10. NP-Hard/NP-Complete • NP-complete problems are most “die-hard” problems in the class of NP. • Polynomial reductions Let T be a function from the input set for a decision problem P into the input set for a decision problem Q. T is a polynomial reduction from P to Q if all of the following hold: • T can be computed in polynomially bounded time. • For every instance x of P, the answer to x is yes if and only if the answer to instance T(x) of Q is yes. • Problem P is polynomially reducible to Q if there exists a polynomial reduction from P to Q. Polynomial reduction (encoding) P Q decoding

  11. NP-Hard/NP-Complete encoding • Polynomial reductions are transitive. • NP-hard: A problem X is called an NP-hard problem if every problem in NP is polynomially reducible to X. encoding encoding C A B decoding decoding decoding X NP

  12. NP-Hard/NP-Complete • NP-Complete: A problem X is NP-complete if the followings are true: • X is in NP (there is a non-deterministic polynomial time algorithm for X), and • X is NP-hard (for every problem in NP, there is a polynomial reduction to X). • Cook’s theorem (1971): The first NP-complete Problem The satisfiability problem (SAT) is NP-complete NP X

  13. Proving NP-Completeness • Steps for proving a problem X is NP-complete. • Problem X is in NP • Find an NP-complete problem Y, and a polynomial reduction from Y to X • A good reduction R must do • Maps any instance of Y to some instances of X • The answer to Y is yes if and only if the answer to X is yes. • R should take polynomial time deterministically. R X Y

  14. Examples • The clique problem Instance: an undirected graph G = (V, E) and an integer k. Question: Does G contain a clique of k vertices (A clique is a complete subgraph: every pair of vertices in the subgraph has an edge between them)? • Show the clique problem is NP-complete • Proof • Find a non-deterministic polynomial algorithm for the clique problem • Find a problem which is NP-complete (SAT), and a polynomial reduction. SAT: Instance: Given a CNF F = C1C2…Ck, where Ci = xi1xi2…xiki Question: Is F satisfiable? The reduction: Create a graph G = (V, E), V = {vij | xij  Ci} • The vertices from the same clause are not connected by edges • vij and vlk are not connected if • Connect everything else The reduction must make sense: There is a k-clique in G if and only if SAT is satisfiable.

  15. Examples • Proof (cont.) The reduction must make sense: There is a k-clique in G if and only if SAT is satisfiable. “” If there is a k-clique in G, then F is satisfiable. For each vertex vij in the k-clique, let its corresponding literal xij or be 1 (true). And set all other boolean variable to be 0 (false). • No conflict assignment • For each clause, there are at most one literal in the k-clique • There are k clauses in F “” If F is satisfiable, then there is a k-clique. For each clause Ci = xi1xi2…xiki, if xij = 1, then vij is taken. • vij corresponding xijis taken, vlkcorresponding will not be taken, where

More Related