Efficient and Not-So-Efficient Algorithms Problem spaces tend to be big: NP-Complete Problems A graph on n vertices can have up to n n − 2 spanning trees. A graph on n vertices can have Θ ( 2 n ) many paths between verts s and t . Jim Royer Etc. The Good News In our previous work, out of problems with Θ ( 2 n ) (or worse) many choices, we have November 6, 2018 found the right answer in time O ( n k ) for some k . The Bad News Not all problems are so nice. Uncredited diagrams are from DPV or homemade. NP-Completeness November 6, 2018 1 / 24 NP-Completeness November 6, 2018 2 / 24 Search Problems Propositional Logic The formulas of propositional logic are given by the grammar: Search problems are those of the form: P :: = Var | ¬ P | P ∧ P | P ∨ P Given: ... Var :: = the syntactic category of variables Find: ... (usually within a large search space) A truth assignment is a function I : Variables → { False , True } . I , a truth assignment, determines the value of a formula by: Satisfiability (as a search problem) Given: A boolean formula in conjunctive normal form (CNF). I [[ x ]] = True iff I ( x ) = True ( x a variable) Find: A satisfying assignment for it (if it has one). I [[ ¬ p ]] = True iff I [[ p ]] = False I [[ p ∧ q ]] = True iff I [[ p ]] = I [[ q ]] = True . I [[ p ∨ q ]] = True iff I [[ p ]] = True I [[ q ]] = True . or We need to define some terms. A satisfying assignment for a formula p is an I with I [[ p ]] = True . The only known algorithms for SAT run in exponential time. NP-Completeness November 6, 2018 3 / 24 NP-Completeness November 6, 2018 4 / 24
Conjunctive Normal Form Back to Search Problems, 1 Instead of writing ¬ x we write x . Elements of a Search Problem A variable x and the negation of a variable x are called literals . I : an instance of the problem A clause is a disjunction of literals. S : a possible solution for I E.g.: ( x ∨ y ∨ z ) . C : (Instances) × (Pot. Solutions) → { True , False } A conjunctive normal form formula is a conjunction of clauses. C ( I , S ) = the result of checking if S solves I E.g.: ( x ∨ y ∨ z ) ∧ ( x ∨ y ) ∧ ( y ∨ z ) ∧ ( z ∨ x ) ∧ ( x ∨ y ∧ z ) An efficient checking algorithm for C is an algorithm for C that, on input ( I , S ) runs in O ( | I | k ) -time for some k . (Implies that | S | cannot be too large.) Satisfiability (as a search problem) Given: A boolean formula in conjunctive normal form (CNF). For SAT: Find: A satisfying assignment for it (if it has one). An instance : a CNF formula ( x ∨ y ) ∧ ( y ∨ x ) A pot. solution : a truth assignment x �→ True , y �→ True Note the differences with the boolean circuit evaluation problem. eff. checker : boolean circuit evaluation If a CNF formula has n variables, there are 2 n possible assignments. NP-Completeness November 6, 2018 5 / 24 NP-Completeness November 6, 2018 6 / 24 Back to Search Problems, 2 Traveling Salesman Elements of a Search Problem Traveling Salesman (TS) as a search problem Given: n vertices and all n · ( n − 1 ) /2-many distances between them, b a budget (number) I : an instance of the problem Find: An ordering of 1, . . . , n : π ( 1 ) , π ( 2 ) , . . . , π ( n ) (a tour) so that S : a possible solution for I d π ( 1 ) , π ( 2 ) + d π ( 2 ) , π ( 3 ) + · · · + d π ( n ) , π ( 1 ) ≤ b . C : (Instances) × (Pot. Solutions) → { True , False } C ( I , S ) = the result of checking if S solves I Traveling Salesman (TS) as an optimization problem An efficient checking algorithm for C is an algorithm for C that, on input ( I , S ) runs in Given: n vertices and all n · ( n − 1 ) /2-many distances between them. O ( | I | k ) -time for some k . (Implies that | S | cannot be too large.) Find: An ordering of 1, . . . , n : π ( 1 ) , π ( 2 ) , . . . , π ( n ) so that the tour’s cost d π ( 1 ) , π ( 2 ) + d π ( 2 ) , π ( 3 ) + · · · + d π ( n ) , π ( 1 ) is minimal. Variations of SAT Horn Clause SAT Easy (Chapter 5) The two problems are equivalent: The only known algorithms for these 2SAT Easy problems are exponential time. A solution to the optimization problem, 3SAT Hard, it seems solves the search problem. (Why?) TS is a restriction of the Minimal Spanning Tree problem in which the MST Given a way to solve the search problem, Definition is allowed no branches. you can construct a solution to the n SAT is the restricted version of SAT in which each clause as at most n literals. opt. problem via binary search. (How?) NP-Completeness November 6, 2018 7 / 24 NP-Completeness November 6, 2018 8 / 24
Euler and Hamiltonian Paths, 1 Euler and Hamiltonian Paths, 2 Definition Definition A path in an undirected graph is an Euler path when it uses each edge of the graph exactly A path in an undirected graph is a Rudrata path (or more usually a Hamiltonian path ) when once. (The path may pass through a vertex many times.) it uses each vertex of the graph exactly once. If the path is a cycle, then it is called an Euler Tour or an Euler Circuit . If the path is a cycle, then it is called a Rudrata Cycle or Hamiltonian Cycle . Theorem (Euler) G has an Euler path ⇐ ⇒ G is connected and has at most two vertices of odd degree. Image from: http://en.wikipedia.org/wiki/Hamiltonian_path There is a nice poly-time algorithm for the Euler Path Search problem. (See http://en.wikipedia.org/wiki/Eulerian_path .) All known algorithms for the Hamiltonian Path Search Problem are exponential-time. No Euler Path Euler Tour: A B ... K NP-Completeness November 6, 2018 9 / 24 NP-Completeness November 6, 2018 10 / 24 Images from: http://en.wikipedia.org/wiki/Eulerian_path Cuts and bisections Integer Linear Programming Integer Linear Programming (ILP) Definition c T · � x ≤ � A cut in a graph is a set of edges which, if removed, disconnect the � b and objective function � Given: constraints A x and goal: g graph. c T · � x ≤ � x ≥ g . Find: A vector of integers � x satisfying A � b and � A minimum cut is a cut of smallest size. — or equivalently — Minimum Cut Problem x ≤ � Given: constraints A � b Given: An undirected graph G and a budget b (a number), x satisfying A ′ � x ≤ � b ′ . Find: A vector of integers � Find: A cut of G of at most b edges. c T · � ( � x ≥ g is incorporated into the constraints.) Balanced Cut Problem Zero-One Equations (ZOE) Given: An undirected graph G = ( V , E ) and a budget b (a number), Find: A partition of V : S and T with | S | , | T | ≥ | V | /3 such that the number of edges between S and x ≤ � Given: constraints A � b T is at most b . x satisfying A ′ � x ≤ � b ′ . Find: A vector of 0’s and 1’s � You can use Ford-Fulkerson to solve Min-Cut in poly-time. ILP and ZOE show up in lots of optimization work. The only known algorithms for Balanced-Cut are exponential time. The only known algorithms for ILP and ZOE are exponential time. Balanced-Cuts are important in clustering. (See DPV.) NP-Completeness November 6, 2018 11 / 24 NP-Completeness November 6, 2018 12 / 24 Image from: http://en.wikipedia.org/wiki/Cut_(graph_theory)
Three-dimensional matching Independent set, vertex cover, and clique, 1 Definition Suppose G = ( V , E ) is an undirected graph and U ⊆ V . Chet Alice U is independent when for each u , v ∈ U , ( u , v ) / ∈ E . (a) 3D Matching Bob Beatrice U is a vertex cover when each edge of E has at least one endpoint in U . (b) Al Carol Given: R ⊆ A × B × C where | A | = | B | = | C | = n . U is a clique when for each distinct u , v ∈ U , ( u , v ) ∈ E . Find: A subset M ⊆ R of n many triples such that (c) if ( a , b , c ) and ( a ′ , b ′ , c ′ ) are distinct elements of M , then a � = a ′ , b � = b ′ , and c � = c ′ . Armadillo Bobcat Canary 2D matching is poly-time (via Ford-Fulkerson). The only known algorithms for 3D Matching are exponential time. The blue vertices are a The red vertices are a The red vertices are a max-sized independent set min-sized vertex cover for max-sized clique for the for the graph. the graph. graph. The images are from Wikipedia. NP-Completeness November 6, 2018 13 / 24 NP-Completeness November 6, 2018 14 / 24 Independent set, vertex cover, and clique, 2 Longest Path, Knapsack, Subset Sum The Longest Path Problem Definition Suppose G = ( V , E ) is an undirected graph and U ⊆ V . Given: A undirected graph G . Find: A longest simple path in G . U is independent when for each u , v ∈ U , ( u , v ) / ∈ E . (a) (Simple path ≡ a path with no repeated vertices.) U is a vertex cover when each edge of E has at least one endpoint in U . (b) Knapsack U is a clique when for each distinct u , v ∈ U , ( u , v ) ∈ E . (c) Given: Weights w 1 , . . . , w n , values v 1 , . . . , v n , Total Capacity: W , and Goal: G (all positive integers). Independent Set Vertex Cover Problem Clique Problem Find: A selection of items with total weight ≤ W and total value ≥ G . Problem Given: G and b . Given: G and b . Find: A vertex cover for G of Subset Sum Given: G and b . Find: A clique in G of size size ≤ b . ≥ b . Find: An independent set for Given: A multiset of integers M and goal G . G of size ≥ b . Find: An { x 1 , . . . , x k } ⊆ M such that G = x 1 + · · · + x k . The only known algorithms for these problems are exponential time. The only known algorithms for these problems are exponential time. But didn’t we have an LP solution to Knapsack? Yes, but . . . NP-Completeness November 6, 2018 15 / 24 NP-Completeness November 6, 2018 16 / 24
Recommend
More recommend