Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

Similar documents
Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

P and NP CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang

Theorem 2.9: nearest addition algorithm

P and NP CISC5835, Algorithms for Big Data CIS, Fordham Univ. Instructor: X. Zhang

NP-Complete Reductions 2

8.1 Polynomial-Time Reductions

Module 6 NP-Complete Problems and Heuristics

35 Approximation Algorithms

Module 6 NP-Complete Problems and Heuristics

NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

Coping with NP-Completeness

CMSC 451: Lecture 22 Approximation Algorithms: Vertex Cover and TSP Tuesday, Dec 5, 2017

COMP 355 Advanced Algorithms Approximation Algorithms: VC and TSP Chapter 11 (KT) Section (CLRS)

P and NP (Millenium problem)

8 NP-complete problem Hard problems: demo

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Module 6 P, NP, NP-Complete Problems and Approximation Algorithms

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

Module 6 NP-Complete Problems and Heuristics

NP-complete Reductions

NP-Completeness. Algorithms

Some Hardness Proofs

NP and computational intractability. Kleinberg and Tardos, chapter 8

Chapter 8. NP-complete problems

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

8.1 Polynomial-Time Reductions

Notes for Lecture 24

CS 4407 Algorithms. Lecture 8: Circumventing Intractability, using Approximation and other Techniques

Decision Problems. Observation: Many polynomial algorithms. Questions: Can we solve all problems in polynomial time? Answer: No, absolutely not.

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Approximation Algorithms

Chapter 10 Part 1: Reduction

Partha Sarathi Mandal

CS270 Combinatorial Algorithms & Data Structures Spring Lecture 19:

Greedy algorithms Or Do the right thing

APPROXIMATION ALGORITHMS FOR GEOMETRIC PROBLEMS

Prove, where is known to be NP-complete. The following problems are NP-Complete:

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

Complexity Classes and Polynomial-time Reductions

Example of a Demonstration that a Problem is NP-Complete by reduction from CNF-SAT

Matching 4/21/2016. Bipartite Matching. 3330: Algorithms. First Try. Maximum Matching. Key Questions. Existence of Perfect Matching

Copyright 2000, Kevin Wayne 1

Reductions. Linear Time Reductions. Desiderata. Reduction. Desiderata. Classify problems according to their computational requirements.

Computational problems. Lecture 2: Combinatorial search and optimisation problems. Computational problems. Examples. Example

CS 580: Algorithm Design and Analysis

3/7/2018. CS 580: Algorithm Design and Analysis. 8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability

val(y, I) α (9.0.2) α (9.0.3)

1 Minimum Spanning Trees (MST) b 2 3 a. 10 e h. j m

Steven Skiena. skiena

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem

Reductions and Satisfiability

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

NP-Complete Problems

Lecture 24: More Reductions (1997) Steven Skiena. skiena

Chapter 9 Graph Algorithms

W4231: Analysis of Algorithms

Introduction to Algorithms. Lecture 24. Prof. Patrick Jaillet

Examples of P vs NP: More Problems

Questions? You are given the complete graph of Facebook. What questions would you ask? (What questions could we hope to answer?)

Chapter 9 Graph Algorithms

More NP-complete Problems. CS255 Chris Pollett May 3, 2006.

CSE 100: B+ TREE, 2-3 TREE, NP- COMPLETNESS

Lecture 8: The Traveling Salesman Problem

CMPSCI611: The SUBSET-SUM Problem Lecture 18

1 Introduction. 1. Prove the problem lies in the class NP. 2. Find an NP-complete problem that reduces to it.

CSE 548: Analysis of Algorithms. Lecture 13 ( Approximation Algorithms )

1 Variations of the Traveling Salesman Problem

CS521 \ Notes for the Final Exam

Chapter 8. NP-complete problems

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Chapter 9 Graph Algorithms

Design and Analysis of Algorithms

1 Definition of Reduction

Chapter 8. NP-complete problems. Search problems. cient algorithms. Exponential search space

Approximation Algorithms

CSE 417 Branch & Bound (pt 4) Branch & Bound

Reference Sheet for CO142.2 Discrete Mathematics II

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost

9.1 Cook-Levin Theorem

Optimal tour along pubs in the UK

NP-Complete Problems

Traveling Salesman Problem. Algorithms and Networks 2014/2015 Hans L. Bodlaender Johan M. M. van Rooij

Notation Index. Probability notation. (there exists) (such that) Fn-4 B n (Bell numbers) CL-27 s t (equivalence relation) GT-5.

Assignment 5: Solutions

Travelling Salesman Problem. Algorithms and Networks 2015/2016 Hans L. Bodlaender Johan M. M. van Rooij

Graphs: Introduction. Ali Shokoufandeh, Department of Computer Science, Drexel University

NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT

ALGORITHMS EXAMINATION Department of Computer Science New York University December 17, 2007

Computability Theory

Vertex Cover Approximations

V1.0: Seth Gilbert, V1.1: Steven Halim August 30, Abstract. d(e), and we assume that the distance function is non-negative (i.e., d(x, y) 0).

1 The Traveling Salesperson Problem (TSP)

Approximation Algorithms

arxiv: v2 [cs.cc] 29 Mar 2010

Solutions for the Exam 6 January 2014

(p 300) Theorem 7.27 SAT is in P iff P=NP

Reductions. designing algorithms establishing lower bounds establishing intractability classifying problems. Bird s-eye view

1 The Traveling Salesman Problem

Introduction to Combinatorial Algorithms

Transcription:

: Coping with NP-Completeness Course contents: Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems Reading: Chapter 34 Chapter 35.1, 35.2 Y.-W. Chang 1 Complexity Classes Developed by S. Cook and R. Karp in early 1970. The class P: class of problems that can be solved in polynomial time in the size of input. Size of input: size of encoded binary strings (O(lg n) for integer n!!). Edmonds: Problems in P are considered tractable. Closed under addition, multiplication, composition, complement, etc. The class NP (Nondeterministic Polynomial): class of problems that can be verified in polynomial time in the size of input. P = NP? The class NP-complete (NPC): Any NPC problem can be solved in polynomial time All problems in NP can be solved in polynomial time. Y.-W. Chang 2 1

Asymptotic Functions Polynomial-time complexity: O(p(n)), where n is the input size and p(n) is a polynomial function of n, (p(n) = n O(1) ). Polynomial -time complexity!! Y.-W. Chang 3 Traveling Salesman Problem (TSP) Revisited Instance: a set of n cities, distance between each pair of cities, and a bound B. Question: is there a route that starts and ends at a given city, visits every city exactly once, and has total distance B? Can be solved or checked in polynomial time? Y.-W. Chang 4 2

Verification Algorithm and Class NP Verification algorithm: a 2-argument algorithm A, where one argument is an input string x and the other is a binary string y (called a certificate). A verifies x if there exists y s.t. A answers yes. Exp: Is TSP NP? Need to check a TSP solution in polynomial time. Guess a tour (certificate). Check if the tour visits every city exactly once. Check if the tour returns to the start. Check if total distance B. All can be done in O(n) time, so TSP NP. Y.-W. Chang 5 Complexity Classes NP and co-np Is class NP closed under complement? Class co-np: class of problems whose complement problems are in NP. co-np = {L: NP}. TSP-Complement: Instance: a set of n cities, distance between each pair of cities, and a bound B. Question: are all tours that start and end at a given city, visit every city exactly once, and have total distance > B? TSP-Complement NP? Equivalently, TSP co-np? Y.-W. Chang 6 3

Decision & Optimization Problems Decision problems: those having yes/no answers. MST: Given a graph G=(V, E) and a bound K, is there a spanning tree with a cost at most K? TSP: Given a set of cities, distance between each pair of cities, and a bound B, is there a route that starts and ends at a given city, visits every city exactly once, and has total distance at most B? Optimization problems: those finding a legal configuration such that its cost is minimum (or maximum). MST: Given a graph G=(V, E), find the cost of a minimum spanning tree of G. TSP: Given a set of cities and the distance between each pair of cities, find the distance of a minimum route starts and ends at a given city and visits every city exactly once. Y.-W. Chang 7 Decision vs. Optimization Problems Could apply binary search on a decision problem to obtain solutions to its optimization problem. NP-completeness is associated with decision problems. c.f., Optimal solutions/costs, optimal (exact) algorithms optimal exact in the theoretic computer science community. Y.-W. Chang 8 4

Polynomial-time Reduction Motivation: Let L 1 and L 2 be two decision problems. Suppose algorithm A 2 can solve L 2. Can we use A 2 to solve L 1? E.g., System of difference constraints (L 1 ) vs. SSSP (L 2 ) Polynomial-time reduction f from L 1 to L 2 : L 1 P L 2 f reduces any input for L 1 into an input for L 2 s.t. the reduced input is a yes input for L 2 iff the original input is a yes input for L 1. L 1 P L 2 if polynomial-time computable function f: {0, 1} * {0, 1} * s.t. x L 1 iff f(x) L 2, x {0, 1} *. L 2 is at least as hard as L 1. f is computable in polynomial time. no yes yes no Y.-W. Chang 9 Significance of Reduction Significance of L 1 P L 2 : polynomial-time algorithm for L 2 polynomial-time algorithm for L 1 (L 2 P L 1 P). polynomial-time algorithm for L 1 polynomialtime algorithm for L 2 (L 1 P L 2 P). P is transitive, i.e., L 1 P L 2 and L 2 P L 3 L 1 P L 3. L 1 : system of difference constraint vs. L 2 : SSSP L 1 : Bipartite cardinality matching vs. L 2 : maximum flow Y.-W. Chang 10 5

System of Difference Constraints P SSSP Example reduction from the system of difference constraints problem to the shortest path one. Constraint graph: Weighted, directed graph G=(V, E). V = { v 0, v 1,, v n } E = {(v i, v j ): x j - x i b k } {(v 0, v 1 ), (v 0, v 2 ),, (v 0, v n )} w(v i, v j ) = b k if x j - x i b k is a difference constraint. If G contains no negative-weight cycle, then x = ( (v 0, v 1 ), (v 0, v 2 ),, (v 0, v n )) is a feasible solution; no feasible solution, otherwise. (v 0, v j ) (v 0, v i ) + w(v i, v j ) x j x i b k Y.-W. Chang 11 Maximum Cardinality Bipartite Matching P Max Flow Example reduction from the matching problem to the max-flow one. Given a bipartite graph G = (V, E), V = L R, construct a unitcapacity flow network G' = (V', E'): V' = V {s, t} E '= {(s, u): u L} {(u, v): u L, v R, (u, v) E} {(v, t): v R}. The cardinality of a maximum matching in G = the value of a maximum flow in G' (i.e., M = f ). Y.-W. Chang 12 6

Polynomial Reduction: HC P TSP The Hamiltonian Circuit Problem (HC) Instance: an undirected graph G = (V, E). Question: is there a cycle in G that includes every vertex exactly once? TSP: The Traveling Salesman Problem Claim: HC P TSP. 1. Define a function f mapping any HC instance into a TSP instance, and show that f can be computed in polynomial time. 2. Prove that G has an HC iff the reduced instance has a TSP tour with distance B (x HC f(x) TSP). Hamiltonian nonhamiltonian Y.-W. Chang 13 HC P TSP: Step 1 1. Define a reduction function f for HC P TSP. Given an HC instance G = (V, E) with n vertices Create a set of n cities labeled with names in V. Assign distance between u and v Set bound B = n. f can be computed in O(V 2 ) time. look for the difference between the two problems to make the reduction!! Y.-W. Chang 14 7

HC P TSP: Step 2 2. G has an HC iff the reduced instance has a TSP with distance B. x HC f(x) TSP. Suppose the HC is h = <v 1, v 2,, v n, v 1 >. Then, h is also a tour in the transformed TSP instance. The distance of the tour h is n = B since there are n consecutive edges in E, and so has distance 1 in f(x). Thus, f(x) TSP (f(x) has a TSP tour with distance B). Y.-W. Chang 15 HC P TSP: Step 2 (cont d) 2. G has an HC iff the reduced instance has a TSP with distance B. f(x) TSP x HC. Suppose there is a TSP tour with distance n = B. Let it be <v 1, v 2,, v n, v 1 >.. Since distance of the tour n and there are n edges in the TSP tour, the tour contains only edges in E since all edge weights are equal to 1. Thus, <v 1, v 2,, v n, v 1 > is a Hamiltonian cycle (x HC). Y.-W. Chang 16 8

HP Application: Crosstalk Minimization Goal: Find a wire ordering s.t. the overall crosstalk is minimized. Construct a complete weighted graph G = (V, E, W): V wires, W coupling length between each pair of wires. The minimum weighted Hamiltonian path induces the minimum crosstalk. Overall crosstalk = 9 Overall crosstalk = 2 Minimum Hamiltonian path Y.-W. Chang 17 NP-Completeness A decision problem L (a language L {0, 1} * ) is NP-complete (NPC) if 1. L NP, and 2. L' P L for every L' NP. NP-hard: If L satisfies property 2, but not necessarily property 1, we say that L is NP-hard. Suppose L NPC. If L P, then there exists a polynomial-time algorithm for every L' NP (i.e., P = NP). If L P, then there exists no polynomial-time algorithm for any L' NPC (i.e., P NP).?? Tractable Polynomial-time solvable NP-complete problems Intractable Not polynomial-time solvable Y.-W. Chang 18 9

Proving NP-Completeness Five steps for proving that L is NP-complete: 1. Prove L NP. 2. Select a known NP-complete problem L'. 3. Construct a reduction f transforming every instance of L' to an instance of L. 4. Prove that x L' iff f(x) L for all x {0, 1} *. 5. Prove that f is a polynomial-time transformation. A known NP-complete problem L f reduce A problem L to be proved NP-complete Here we intend to show how difficult L is!! Cf. matching P maximum flow to show how easy matching is!! Y.-W. Chang 19 The Circuit-Satisfiability Problem (Circuit-SAT) The Circuit-Satisfiability Problem (Circuit-SAT): Instance: A combinational circuit C composed of AND, OR, and NOT gates. Question: Is there an assignment of Boolean values to the inputs that makes the output of C equal to 1? A circuit is satisfiable if there exists a set of Boolean input values that makes the output of the circuit to be 1. Circuit (a) is satisfiable since <x 1, x 2, x 3 > = <1, 1, 0> makes the output to be 1. Circuit-SAT is NP-complete. (Cook, ACM STOC'71) Circuit-SAT NP. L' NP, L' P Circuit-SAT. 1? Y.-W. Chang 20 10

Structure of NP-Completeness Proofs 3SAT Clique Independent-Set Vertex-Cover Hitting-Set Y.-W. Chang 21 The Satisfiability Problem (SAT) The Satisfiability Problem (SAT): Instance: A Boolean formula. Question: Is there an assignment of truth values to the variables that makes true? Truth assignment: set of values for the variables of. Satisfying assignment: a truth assignment that makes evaluate to 1. Exp: = ((x 1 x 2 ) (( x 1 x 3 ) x 4 )) x 2 Truth assignment: <x 1, x 2, x 3, x 4 > = <0, 0, 1, 1>, <0, 1, 0, 1>, etc. Satisfying assignment: <x 1, x 2, x 3, x 4 > = <0, 0, 1, 1>, etc. Satisfiable formula: a formula with a satisfying assignment. is a satisfiable formula. Y.-W. Chang 22 11

SAT is NP-Complete 1. SAT NP. 2. SAT is NP-hard: Prove that Circuit-SAT P SAT. For each wire x i in circuit C, the formula has a variable x i. The operation of a gate is expressed as a formula with associated variables, e.g., x 10 (x 7 x 8 x 9 ). = AND of the circuit-output variable with the conjunction ( ) of clauses describing the operation of each gate, e.g., = x 10 (x 4 x 3 ) (x 5 (x 1 x 2 )) (x 6 x 4 ) (x 7 (x 1 x 2 x 4 )) (x 8 (x 5 x 6 )) (x 9 (x 6 x 7 )) (x 10 (x 7 x 8 x 9 )) Circuit C is satisfiable formula is satisfiable. (Why?) Given a circuit C, it takes polynomial time to construct. Y.-W. Chang 23 3SAT is NP-Complete 3SAT: Satisfiability of boolean formulas in 3-conjunctive normal form (3-CNF). Each clause has exactly 3 distinct literals, e.g., = (x 1 x 1 x 2 ) (x 3 x 2 x 4 ) ( x 2 x 3 x 4 ) 3SAT NP (will omit this part for other proofs). 3SAT is NP-hard: SAT P 3SAT. 1. Construct a binary parse tree for input formula and introduce a variable y i for the output of each internal node. = ((x 1 x 2 ) (( x 1 x 3 ) x 4 )) x 2. Y.-W. Chang 24 12

3SAT is NP-Complete (cont'd) 2. Rewrite as the AND of the root variable and a conjunction of clauses describing the operation of each node. ' = y 1 (y 1 (y 2 x 2 )) (y 2 (y 3 y 4 )) (y 3 (x 1 x 2 )) (y 4 y 5 ) (y 5 (y 6 x 4 )) (y 6 ( x 1 x 3 )). 3. Convert each clause ' i into CNF. Construct the disjunctive normal form for ' i and then apply DeMorgan's law to get the CNF formula i. E.g., ' 1 = (y 1 (y 2 x 2 )) = (y 1 y 2 x 2 ) (y 1 y 2 x 2 ) (y 1 y 2 x 2 ) ( y 1 y 2 x 2 ) '' 1 = ( ' 1 ) = ( y 1 y 2 x 2 ) ( y 1 y 2 x 2 ) ( y 1 y 2 x 2 ) (y 1 y 2 x 2 ). Y.-W. Chang 25 3SAT is NP-Complete (cont'd) 4. Make each clause C i have exactly 3 distinct literals to get '''. C i has 3 distinct literals: do nothing. C i has 2 distinct literals: C i = (l 1 l 2 ) = (l 1 l 2 p) (l 1 l 2 p). C i has only 1 literal: C i = l = (l p q) (l p q) (l p q) (l p q). Claim: The 3-CNF formula ''' is satisfiable is satisfiable. All transformations can be done in polynomial time. Y.-W. Chang 26 13

Clique is NP-Complete A clique in G= (V, E) is a complete subgraph of G. The Clique Problem (Clique) Instance: a graph G = (V, E) and a positive integer k V. Question: is there a clique V V of size k? Clique NP. Clique is NP-hard: 3SAT P Clique. Key: Construct a graph G such that is satisfiable G has a clique of size k. Satisfying assignment: <x 1, x 2, x 3 > = <x, 0, 1> Y.-W. Chang 27 3SAT P Clique Let = C 1 C 2 C k be a Boolean formula in 3-CNF with k clauses. Each C r has exactly 3 distinct literals l 1r, l 2r, l 3r. For each C r = (l 1r l 2r l 3r ) in, introduce a triple of vertices v r 1, v r 2, v r 3 in V. Build an edge between v ir, v js if both of the following hold: v ir and v js are in different triples, and l ir is not the negation of l s j G can be computed from in polynomial time. Satisfying assignment: <x 1, x 2, x 3 > = <x, 0, 1> Y.-W. Chang 28 14

Is Satisfiable G Has a Clique of Size k is satisfiable G has a clique of size k. is satisfiable each C r contains at least one l ir = 1 and each such literal corresponds to a vertex v ir. Picking a true literal from each C r forms a set of V' of k vertices. For any two vertices v ir, v js V', r s, l ir = l js = 1 and thus l ir, l js cannot be complements. Thus, edge (v ir, v js ) E. Satisfying assignment: <x 1, x 2, x 3 > = <x, 0, 1> Y.-W. Chang 29 Is Satisfiable G Has a Clique of Size k G has a clique of size k is satisfiable. G has a clique V' of size k V' contains exactly one vertex per triple since no edges connect vertices in the same triple. Assign 1 to each l ir such that v ir V each C r is satisfied, and so is. Satisfying assignment: <x 1, x 2, x 3 > = <x, 0, 1> Y.-W. Chang 30 15

Vertex-Cover is NP-Complete A vertex cover of G = (V, E) is a subset V V such that if (w, v) E, then w V' or v V'. The Vertex-Cover Problem (Vertex-Cover) Instance: a graph G = (V, E) and a positive integer k V. Question: is there a subset V V of size k such that each edge in E has at least one vertex (endpoint) in V'? Vertex-Cover NP. Vertex-Cover is NP-hard: Clique P Vertex-Cover. Key: complement of G: = (V, Ē), Ē = {(w, v): (w, v) E}. Clique V = {u, v, x, y} Vertex cover V - V = {w, z} Y.-W. Chang 31 Vertex-Cover is NP-Complete (cont'd) G Has a Clique of Size k size V - k. Has a Vertex Cover of Suppose that G has a clique V V with V' = k. Let (w, v) be any edge in Ē (w, v) E at least one of w or v does not belong to V' So, w V - V' or v V - V edge (w, v) is covered by V - V'. Thus, V - V' forms a vertex cover of, and V - V' = V - k. Clique V = {u, v, x, y} Vertex cover V - V = {w, z} Y.-W. Chang 32 16

Vertex-Cover is NP-Complete (cont'd) Has a Vertex Cover of size V - k G Has a Clique of Size k. Suppose that has a vertex cover V V with V' = V - k. a, b V, if (a, b) Ē, then a V' or b V or both. So, a, b V, if a V' and b V', (a, b) E V - V' is a clique, and V - V' = k. Clique V-V = {u, v, x, y} Vertex cover V = {w, z} Y.-W. Chang 33 Clique, Independent-Set, Vertex-Cover An independent set of G = (V, E) is a subset V V such that G has no edge between any pair of vertices in V'. The Independent-Set Problem (Independent-Set) Instance: a graph G = (V, E) and a positive integer k V. Question: is there an independent set of size k? Theorem: The following are equivalent for G = (V, E) and a subset V of V: 1. V' is a clique of G. 2. V' is an independent set of. 3. V-V' is a vertex cover of. Corollary: Independent-Set is NP-complete. Clique V = {u, v, x, y} Independent set V = {u, v, x, y} Vertex cover V - V = {w, z} Y.-W. Chang 34 17

Hitting-Set is NP-Complete A hitting set for a collection C of subsets of a set S is a subset S S such that S' contains at least one element from each subset in C. S = {1, 2, 3, 4, 5, 6, 7, 8}, C = {{1}, {3, 5}, {4, 7, 8}, {5, 6}}, S' can be {1, 4, 5}, {1, 3, 4, 6}, etc. The Hitting-Set Problem (Hitting-Set) Instance: Collection C of subsets of a set S, positive integer k. Question: does S contain a hitting set for C of size k? Hitting-Set is NP-Complete. Restrict to Vertex-Cover by allowing only instances having c = 2 for all c C. Each set in C edge; element in S vertex cover. Proof by restriction is the simplest, and perhaps the most frequently used technique. Other examples: Bounded Degree Spanning Tree, Directed HC, Longest Simple Cycle, etc. Y.-W. Chang 35 Coping with NP-Complete/-Hard Problems Approximation algorithms: Guarantee to be a fixed percentage away from the optimum. Pseudo-polynomial time algorithms: E.g., dynamic programming for the 0-1 Knapsack problem. Probabilistic algorithms: Assume some probabilistic distribution of the instances. Randomized algorithms: Make use of a randomizer (random # generator) for operation. Restriction: Work on some special cases of the original problem. E.g., the maximum independent set problem in circle graphs. Exponential algorithms/branch and Bound/Exhaustive search: Feasible only when the problem size is small. Local search: Simulated annealing (hill climbing), genetic algorithms, etc. Heuristics: No formal guarantee of performance. Y.-W. Chang 36 18

Approximation Algorithms Approximation algorithm: An algorithm that returns near-optimal solutions. Ratio (Performance) bound (n): For any input size n, the cost C of the solution produced by an approximation algorithm (n) of the cost C * of an optimal solution: (n) 1. An optimal algorithm has ratio bound 1. Relative error bound (n): (n) (n) - 1. Y.-W. Chang 37 Greedy Vertex Cover Algorithm Revisited Greedy heuristic: cover as many edges as possible (vertex with the maximum degree) at each stage and then delete the covered edges. The greedy heuristic cannot always find an optimal solution! The vertex-cover problem is NP-complete. The greedy heuristic cannot guarantee a constant performance bound. A graph instance A vertex cover of size 5 by the greedy algorithm A vertex cover of size 4 Optimal solution!! Y.-W. Chang 38 19

The Vertex-Cover Problem Approx-Vertex-Cover(G) 1. C = 2. E' = E[G] 3. while E' 4. let (u, v) be an arbitrary edge of E' 5. C = C {u, v} 6. remove from E' every edge incident on either u or v 7. return C Time complexity: O(E). Y.-W. Chang 39 Approx-Vertex-Cover Has a Ratio Bound of 2 Let A denote the set of edges picked in line 4 C = 2 A. Since no two edges in A share an endpoint, no vertex in any cover is incident on more than one edge in A. Thus, A C * and C 2 C *. Recall: For a graph G= (V, E), V' is a minimum vertex cover V - V' is a maximum independent set. Is there any polynomial-time approximation with a constant ratio bound for the maximum independent set problem? Y.-W. Chang 40 20

Approximation Algorithm for TSP Approx-TSP-Tour(G) 1. select a vertex r V[G] to be a root vertex; 2. grow a minimum spanning tree T for G from root r using MST-Prim(G, d, r) 3. let L be the list of vertices visited in a preorder tree walk of T 4. return the HC H that visits the vertices in the order L Time complexity: O(V lg V). Run MST-Prim: T Preorder traversal of T Resulting TSP tour H from the preorder traversal of T Optimal TSP tour H* Y.-W. Chang 41 Approx-TSP-Tour with Triangle Inequality Inter-city distances satisfy triangle inequality if for all vertices u, v, w V, d(u, w) d(u, v) + d(v, w). Approx-TSP-Tour with triangle inequality has a ratio bound of 2. With triangle inequality: cost(h) 2 cost of MST. Let H * denote an optimal tour. H * is formed by some tree plus an edge cost of MST cost(h * ). Thus, cost(h) 2 cost(h * ). Run MST-Prim: T Preorder traversal of T Resulting TSP tour H from the preorder traversal of T Optimal TSP tour H* Y.-W. Chang 42 21

TSP without Triangle Inequality If P NP, there is no polynomial-time approximation algorithm with constant ratio bound for the general TSP. Suppose in contradiction that there is such an algorithm A with a constant. We will use A to solve HC in polynomial time. Algorithm for HC 1. Convert G = (V, E) into an instance I of TSP with cities V (resulting in a complete graph G' = (V, E')): 2. Run A on I. 3. If the reported cost V, then return Yes (i.e., G contains a tour that is an HC), else return No. Y.-W. Chang 43 Correctness If G has an HC: G contains a tour of cost V by picking edges in E, each with cost of 1. If G does not have an HC: any tour of G' must use some edge not in E, which has a total cost of ( V + 1) + ( V - 1) > V. A guarantees to return a tour of cost cost of an optimal tour A returns a cost V if G contains an HC; A returns a cost > V, otherwise. k k k k = V + 1 V Y.-W. Chang 44 22

Exhaustive Search vs. Branch and Bound TSP example Backtracking/exhaustive search Branch and bound Y.-W. Chang 45 Simulated Annealing Kirkpatrick, Gelatt, and Vecchi, Optimization by simulated annealing, Science, May 1983. Chen and Chang, Modern floorplanning based on fast simulated annealing, ISPD-05 (TCAD, April 2006). Y.-W. Chang 46 23

Simulated Annealing Basics Non-zero probability for up-hill moves. Probability depends on 1. magnitude of the up-hill movement 2. total search time C = cost(s') - Cost(S) T: Control parameter (temperature) Annealing schedule: T=T 0, T 1, T 2,, where T i = r i T 0, r < 1. Try a certain # of solutions for each temperature till frozen. 1 f(x) = e -x x Y.-W. Chang 47 Algorithmic Paradigms Nondeterministic Approaches Simulated annealing Genetic algorithm Ant colony Y.-W. Chang 48 24

Key Research Methodologies: CAR Criticality Abstraction Restriction Y.-W. Chang 49 Thank You!! Yao-Wen Chang ywchang@ntu.edu.tw Y.-W. Chang 50 25