Efficient and Not-So-Efficient Algorithms Problem spaces tend to be big: NP-Complete Problems, Part I 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 April 1, 2019 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 April 1, 2019 1 / 27 NP-Completeness April 1, 2019 2 / 27 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 Var :: = the syntactic category of variables Given: ... 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 (in the worst case). NP-Completeness April 1, 2019 3 / 27 NP-Completeness April 1, 2019 4 / 27
Digression: DeMorgan’s Laws Digression: Distributive Laws A ∧ ( B ∨ C ) ⇐ ⇒ ( A ∧ B ) ∨ ( A ∧ C ) ¬ ( P ∨ Q ) ⇐ ⇒ ( ¬ P ) ∧ ( ¬ Q ) ⇒ ( A ∨ B ) ∧ ( A ∨ C ) ⋆ A ∨ ( B ∧ C ) ⇐ ¬ ( P ∧ Q ) ⇐ ⇒ ( ¬ P ) ∨ ( ¬ Q ) ⋆ Exercise for the reader. NP-Completeness April 1, 2019 5 / 27 NP-Completeness April 1, 2019 6 / 27 Conjunctive Normal Form Digression: Translating Boolean Formulas to CNF Instead of writing ¬ x we write x . A variable x and the negation of a variable x are called literals . A formula is in negation normal form (NNF) iff the only place a negation symbol A clause is a disjunction of literals. appears in F is in front of a variable. E.g.: ( x ∨ y ∨ z ) . Step 1 A conjunctive normal form formula is a conjunction of clauses. E.g.: ( x ∨ y ∨ z ) ∧ ( x ∨ y ) ∧ ( y ∨ z ) ∧ ( z ∨ x ) ∧ ( x ∨ y ∨ z ) Given a formula F translate it to an equivalent NNF formula using DeMorgan’s Laws. Satisfiability (as a search problem) Step 2 Given: A boolean formula in conjunctive normal form (CNF). Given a NNF formula F translate it to an equivalent CNF formula using the distributive Find: A satisfying assignment for it (if it has one). law A ∨ ( B ∧ C ) ⇐ ⇒ ( A ∨ B ) ∧ ( A ∨ C ) . Note the differences with the boolean circuit evaluation problem. If a CNF formula has n variables, there are 2 n possible assignments. NP-Completeness April 1, 2019 7 / 27 NP-Completeness April 1, 2019 8 / 27
Back to Search Problems, 1 Back to Search Problems, 2 Elements of a Search Problem Elements of a Search Problem I : an instance of the problem I : an instance of the problem S : a possible solution for I S : a possible solution for I C : (Instances) × (Pot. Solutions) → { True , False } C : (Instances) × (Potential Solutions) → { True , False } C ( I , S ) = the result of checking if S solves I C ( I , S ) = the result of checking if S solves I An efficient checking algorithm for C is an algorithm for C that, on input ( I , S ) runs in 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.) O ( | I | k ) -time for some k . (Implies that | S | cannot be too large.) Variations of SAT For SAT: Horn Clause SAT Easy (Chapter 5) 2SAT Easy An instance : a CNF formula ( x ∨ y ) ∧ ( y ∨ x ) 3SAT Hard, it seems A potential solution : a truth assignment x �→ True , y �→ True efficient checker : boolean circuit evaluation Definition n SAT is the restricted version of SAT in which each clause as at most n literals. NP-Completeness April 1, 2019 9 / 27 NP-Completeness April 1, 2019 10 / 27 Traveling Salesman Euler and Hamiltonian Paths, 1 Traveling Salesman (TS) as a search problem Definition Given: n vertices and all n · ( n − 1 ) /2-many distances between them, b a budget (number) A path in an undirected graph is an Euler path when it uses each edge of the graph exactly Find: An ordering of 1, . . . , n : π ( 1 ) , π ( 2 ) , . . . , π ( n ) (a tour) so that once. (The path may pass through a vertex many times.) d π ( 1 ) , π ( 2 ) + d π ( 2 ) , π ( 3 ) + · · · + d π ( n ) , π ( 1 ) ≤ b . If the path is a cycle, then it is called an Euler Tour or an Euler Circuit . Traveling Salesman (TS) as an optimization problem Theorem (Euler) Given: n vertices and all n · ( n − 1 ) /2-many distances between them. G has an Euler path ⇐ ⇒ G is connected and has at most two vertices of odd degree. 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. The two problems are equivalent: The only known algorithms for these problems are exponential time. A solution to the optimization problem, 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, is allowed no branches. you can construct a solution to the No Euler Path Euler Tour: A B ... K opt. problem via binary search. (How?) NP-Completeness April 1, 2019 11 / 27 NP-Completeness April 1, 2019 12 / 27 Images from: http://en.wikipedia.org/wiki/Eulerian_path
Euler and Hamiltonian Paths, 2 Cuts and bisections Definition Definition A cut in a graph is a set of edges which, if removed, disconnect the graph. A path in an undirected graph is a Rudrata path (or more usually a Hamiltonian path ) when A minimum cut is a cut of smallest size. it uses each vertex of the graph exactly once. Minimum Cut Problem If the path is a cycle, then it is called a Rudrata Cycle or Hamiltonian Cycle . Given: An undirected graph G and a budget b (a number), Find: A cut of G of at most b edges. Balanced Cut Problem 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 Image from: http://en.wikipedia.org/wiki/Hamiltonian_path T is at most b . There is a nice poly-time algorithm for the Euler Path Search problem. (See http://en.wikipedia.org/wiki/Eulerian_path .) You can use Ford-Fulkerson to solve Min-Cut in poly-time. All known algorithms for the Hamiltonian Path Search Problem are The only known algorithms for Balanced-Cut are exponential time. exponential-time. Balanced-Cuts are important in clustering. (See DPV.) NP-Completeness April 1, 2019 13 / 27 NP-Completeness April 1, 2019 14 / 27 Image from: http://en.wikipedia.org/wiki/Cut_(graph_theory) Integer Linear Programming Three-dimensional matching Integer Linear Programming (ILP) c T · � x ≤ � � b and objective function � Chet Alice Given: constraints A x and goal: g c T · � x ≤ � x ≥ g . Find: A vector of integers � x satisfying A � b and � Bob Beatrice 3D Matching — or equivalently — Al Carol Given: R ⊆ A × B × C where | A | = | B | = | C | = n . x ≤ � Given: constraints A � b Find: A subset M ⊆ R of n many triples such that x satisfying A ′ � x ≤ � b ′ . Find: A vector of integers � if ( a , b , c ) and ( a ′ , b ′ , c ′ ) are distinct elements of M , c T · � ( � x ≥ g is incorporated into the constraints.) then a � = a ′ , b � = b ′ , and c � = c ′ . Zero-One Equations (ZOE) Armadillo Bobcat Canary 2D matching is poly-time (via Ford-Fulkerson). x ≤ � Given: constraints A � b x satisfying A ′ � x ≤ � The only known algorithms for 3D Matching are exponential time. b ′ . Find: A vector of 0’s and 1’s � ILP and ZOE show up in lots of optimization work. The only known algorithms for ILP and ZOE are exponential time. NP-Completeness April 1, 2019 15 / 27 NP-Completeness April 1, 2019 16 / 27
Recommend
More recommend