TU/e Algorithms (2IL15) – Lecture 11 1 Approximation Algorithms.

Slides:



Advertisements
Similar presentations
Design and Analysis of Algorithms Approximation algorithms for NP-complete problems Haidong Xue Summer 2012, at GSU.
Advertisements

1 Approximation Algorithm Instructor: YE, Deshi
Approximation Algorithms for TSP
1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell ( )
End Topics Approximate Vertex Cover Approximate TSP Tour Computation of FFT P, NP, NP Complete, NP hard.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Combinatorial Algorithms
Lecture 21 Approximation Algorithms Introduction.
Complexity 16-1 Complexity Andrei Bulatov Non-Approximability.
Approximation Algorithms
Approximation Algorithms: Combinatorial Approaches Lecture 13: March 2.
1 Optimization problems such as MAXSAT, MIN NODE COVER, MAX INDEPENDENT SET, MAX CLIQUE, MIN SET COVER, TSP, KNAPSACK, BINPACKING do not have a polynomial.
Approximation Algorithms1. 2 Outline and Reading Approximation Algorithms for NP-Complete Problems (§13.4) Approximation ratios Polynomial-Time Approximation.
Approximation Algorithms Lecture for CS 302. What is a NP problem? Given an instance of the problem, V, and a ‘certificate’, C, we can verify V is in.
1 Approximation Algorithms CSC401 – Analysis of Algorithms Lecture Notes 18 Approximation Algorithms Objectives: Typical NP-complete problems Approximation.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2006 Lecture 7 Monday, 4/3/06 Approximation Algorithms.
Vertex cover problem S  V such that for every {u,v}  E u  S or v  S (or both)
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2009 Lecture 7 Tuesday, 4/7/09 Approximation Algorithms.
An introduction to Approximation Algorithms Presented By Iman Sadeghi.
Approximation Algorithms Motivation and Definitions TSP Vertex Cover Scheduling.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
1 The TSP : NP-Completeness Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell.
1 Approximation Algorithm Instructor: yedeshi
APPROXIMATION ALGORITHMS VERTEX COVER – MAX CUT PROBLEMS
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
Advanced Algorithm Design and Analysis (Lecture 13) SW5 fall 2004 Simonas Šaltenis E1-215b
Great Theoretical Ideas in Computer Science.
Approximation Algorithms
1 Combinatorial Algorithms Parametric Pruning. 2 Metric k-center Given a complete undirected graph G = (V, E) with nonnegative edge costs satisfying the.
Approximation Algorithms
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
Princeton University COS 423 Theory of Algorithms Spring 2001 Kevin Wayne Approximation Algorithms These lecture slides are adapted from CLRS.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Unit 9: Coping with NP-Completeness
WK15. Vertex Cover and Approximation Algorithm By Lin, Jr-Shiun Choi, Jae Sung.
Approximation Algorithms for TSP Tsvi Kopelowitz 1.
1 Approximation algorithms Algorithms and Networks 2015/2016 Hans L. Bodlaender Johan M. M. van Rooij TexPoint fonts used in EMF. Read the TexPoint manual.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
CSC 413/513: Intro to Algorithms
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
TU/e Algorithms (2IL15) – Lecture 9 1 NP-Completeness NOT AND OR AND NOT AND.
Approximation Algorithms by bounding the OPT Instructor Neelima Gupta
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2010 Lecture 7 Tuesday, 4/6/10 Approximation Algorithms 1.
Approximation algorithms
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
The Theory of NP-Completeness
More NP-Complete and NP-hard Problems
Richard Anderson Lecture 26 NP-Completeness
Optimization problems such as
An introduction to Approximation Algorithms Presented By Iman Sadeghi
Approximation Algorithms
Richard Anderson Lecture 26 NP-Completeness
Hamiltonian Cycle and TSP
Hamiltonian Cycle and TSP
Approximation algorithms
Algorithms for hard problems
Approximation Algorithms
Computability and Complexity
Approximation Algorithms for TSP
Minimum Spanning Trees
CHAPTER 35 Approximation Algorithms
Richard Anderson Lecture 28 NP-Completeness
Coverage Approximation Algorithms
Approximation Algorithms
Minimum Spanning Trees
Instructor: Aaron Roth
Lecture 24 Vertex Cover and Hamiltonian Cycle
Presentation transcript:

TU/e Algorithms (2IL15) – Lecture 11 1 Approximation Algorithms

TU/e Algorithms (2IL15) – Lecture 11 2 NP-complete problems: problems A in NP such that B ≤ P A for any B in NP Examples: Circuit-Sat, SATISFIABILITY, 3-SAT, CLIQUE, VertexCover, Subset Sum, Hamiltonian Cycle, … NP-complete problems cannot be solved in polynomial time, unless P = NP What to do when you want to solve an NP-complete (optimization) problem ?  still use exact algorithm: algorithm guaranteed to compute optimal solution  will not be polynomial-time, but perhaps fast enough for some instances  heuristic: algorithm without guarantees on the quality of the solution  approximation algorithm: algorithm that computes solution whose quality is guaranteed to be within a certain factor from OPT

TU/e Algorithms (2IL15) – Lecture 11 3 Approximation algorithms: terminology Consider minimization problem OPT(I) = value of optimal solution for problem instance I ALG(I) = value of solution computed by algorithm ALG for problem instance I ALG is ρ–approximation algorithm if ALG(I) ≤ ρ ∙ OPT(I) for all inputs I Note: ρ can be a function of input size n (e.g.: O(log n)-approximation) Example: Vertex Cover if ALG computes, for any graph G, a cover with at most twice the minimum number of nodes in any vertex cover for G, then ALG is 2-approximation approximation factor

TU/e Algorithms (2IL15) – Lecture 11 4 Approximation algorithms: terminology (cont’d) Consider minimization problem OPT(I) = value of optimal solution for problem instance I ALG(I) = value of solution computed by algorithm ALG ALG is ρ–approximation algorithm if ALG(I) ≤ ρ ∙ OPT(I) for all inputs I Example: CLIQUE if ALG computes, for any graph G, a clique with at least half the maximum number of nodes in any clique in G, then ALG is 2-approximation. NB In the literature, one often talks about (1/ρ)-approximation instead of ρ-approximation for maximization problems. In example, ALG would be (1/2)-approximation algorithm. ALG(I) ≥ (1/ρ) ∙ OPT(I) maximization

TU/e Algorithms (2IL15) – Lecture 11 5 For ρ-approximation algorithm ALG (for minimization problem) we must  describe algorithm …  … and analyze running time …  … and prove that ALG(I) ≤ ρ ∙ OPT(I) for all inputs I How can we prove that ALG(I) ≤ ρ ∙ OPT(I) if we don’t know OPT ?! we need to prove a lower bound on OPT(I) Example: OPT(I) ≥ 100 ALG(I) ≤ 2 OPT(I) ALG(I) ≤ 200 for maximization problems we need upper bound

TU/e Algorithms (2IL15) – Lecture 11 6 Example 1: Vertex Cover

TU/e Algorithms (2IL15) – Lecture 11 7 G = (V,E) is undirected graph vertex cover in G: subset C V such that for each edge (u,v) in E we have u in C or v in C (or both) Vertex Cover (optimization version) Input: undirected graph G = (V,E) Problem: compute vertex cover for G with minimum number of vertices Vertex Cover is NP-hard. ∩

TU/e Algorithms (2IL15) – Lecture 11 8 An approximation algorithm for Vertex Cover: first attempt Approx(?)-Vertex-Cover (G)  C ← empty set; E* ← E // E* = set of edges not covered by C  while E* not empty  do take edge (u,v) in E*  C ← C U {u }  remove from E* all edges that have u as an endpoint  return C

TU/e Algorithms (2IL15) – Lecture 11 9 Does Approx(?)_Vertex-Cover have good approximation ratio? No: if we pick the wrong vertices, approximation ratio can be |V|−1 Second attempt: greedy  always pick vertex that covers largest number of uncovered edges  gives O(log |V|)-approximation algorithm: better, but still not so good

TU/e Algorithms (2IL15) – Lecture An approximation algorithm for Vertex Cover: third attempt Approx(?)-Vertex-Cover (G)  C ← empty set; E* ← E // E* = set of edges not covered by C  while E* not empty  do take edge (u,v) in E*  C ← C U {u }  remove from E* all edges that have u as an endpoint  return C {u,v} and/or v

TU/e Algorithms (2IL15) – Lecture Approx-Vertex-Cover (G)  C ← empty set; E* ← E // E* = set of edges not covered by C  while E* not empty  do take edge (u,v) in E*  C ← C U {u,v}  remove from E* all edges that have u and/or v as an endpoint  return C Proving approximation ratio, step 1: try to get lower bound on OPT two edges are non-adjacent if they do not have an endpoint in common Lemma. Let N E be any set of non-adjacent edges. Then OPT ≥ |N |. U

TU/e Algorithms (2IL15) – Lecture Approx-Vertex-Cover (G)  C ← empty set; E* ← E // E* = set of edges not covered by C  while E* not empty  do take edge (u,v) in E*  C ← C U {u,v}  remove from E* all edges that have u and/or v as an endpoint  return C Theorem. Approx-Vertex-Cover is 2-approximation algorithm and can be implemented to run in O( |V | + |E | ) time. Proof (of approximation ratio). Consider any input graph G. Let N be set of edges selected in step 3 during the algorithm.  N is set of non-adjacent edges, so OPT(G) ≥ |N |  |C | = 2 |N | Hence, ALG(G) = |C| = 2 |N | ≤ 2 OPT(G). // N ← N U { (u,v) } // N ← empty set

TU/e Algorithms (2IL15) – Lecture Theorem. Approx-Vertex-Cover is 2-approximation algorithm and can be implemented to run in O( |V | + |E | ) time. Can we do better? (1.5)-approximation, or (1.1)-approximation, or … ?) Slightly better algorithm is known: approximation ratio 2 − Theorem. No polynomial-time (1.3606)-approximation algorithm exists for Vertex Cover unless P = NP. but some other problems can be approximated much better … 1 Θ(log |V| )

TU/e Algorithms (2IL15) – Lecture Example 2: TSP

TU/e Algorithms (2IL15) – Lecture MST versus TSP Min Spanning Tree Input: weighted graph Output: minimum-weight tree connecting all nodes greedy: O( |E| + |V | log |V | ) Traveling Salesman (TSP) Input: complete weighted graph (non-negative edge weights) Output: minimum-weight tour connecting all nodes NP-complete what about approximation algorithm ?

TU/e Algorithms (2IL15) – Lecture Lemma. MST is lower bound: for any graph G, we have TSP(G) ≥ MST(G). Triangle inequality: weight(u,w) ≤ weight(u,v) + weight(v,w) for any three vertices u,v,w A simple 2-approximation for TSP with triangle inequality u v w Approx-TSP 1.Compute MST on G. 2.Double each edge of MST to get a cycle. 3.Take shortcuts to get a tour visiting every vertex exactly once.

TU/e Algorithms (2IL15) – Lecture Hardness of approximation of TSP without triangle inequality Theorem. Let ρ ≥ 1 be any constant. Then there cannot be a polynomial-time ρ-approximation algorithm for general TSP, unless P = NP. G*: old edges weight 0 new edges: weight 1 G has Hamiltonian cycle iff G* has tour of length 0  ρ-approx algorithm computes tour T with length(T) ≤ ρ∙ OPT = 0 G: 1 ρ∙|V| + 1 and such a tour can only use edges of length 1 |V| ρ∙|V| even for positive edge weights

TU/e Algorithms (2IL15) – Lecture Polynomial-time approximation schemes Consider minimization problem. A polynomial-time approximation scheme (PTAS) is an algorithm ALG with two parameters, an input instance I and a number ε > 0, such that:  ALG(I, ε) ≤ (1+ ε) ∙ OPT(I) (so it’s (1+ ε)-approximation algorithm)  running time of ALG is polynomial in n for any constant ε>0. Example of possible running times: O(n 2 / ε 5 ), O(2 1/ε n log n), O( n 3/ε ), etc. FPTAS = fully polynomial-time approximation scheme = PTAS with running time not only polynomial in n, but also in 1/ε FPTAS not FPTAS

TU/e Algorithms (2IL15) – Lecture Polynomial-time approximation schemes Consider minimization problem. A polynomial-time approximation scheme (PTAS) is an algorithm ALG with two parameters, an input instance I and a number ε > 0, such that:  ALG(I, ε) ≤ (1+ ε) ∙ OPT(I) (so it’s (1+ ε)-approximation algorithm)  running time of ALG is polynomial in n for any constant ε>0. Example of possible running times: O(n 2 / ε 5 ), O(2 1/ε n log n), O( n 3/ε ), etc. FPTAS = fully polynomial-time approximation scheme = PTAS with running time not only polynomial in n, but also in 1/ε maximization ≥ 1/(1+ε) FPTAS not FPTAS

TU/e Algorithms (2IL15) – Lecture Subset Sum (optimization version) “Find maximum load for a truck, under the condition that the load does not exceed a given weight limit for the truck.” Input: multi-set X of non-negative integers, non-negative integer t Problem: compute subset S that maximizes ∑ x in S x under the condition that ∑ x in S x ≤ t ? Example: X = { 3, 5, 7, 10, 16, 23, 41 } t = 50 S = { 3, 5, 41} gives sum 49, which is optimal For simplicity we will only compute value of optimal solution, not solution itself.

TU/e Algorithms (2IL15) – Lecture An exponential-time exact algorithm for Subset Sum Use backtracking: generate all subset sums that are at most t Exact-Subset-Sum (X, t )  L ← Generate-Subset-Sums (X, t)  return the maximum sum in L

TU/e Algorithms (2IL15) – Lecture Generating subset sums  X = { x 1, x 2, …, x n }  choices: do we take x 1 into subset ? do we take x 2 into subset ? ETC Define L i = { all possible sums you can make with x 1,…,x i } Example: X = 2, 7, 5 L 0 = { 0 } L 1 = { 0 } U {0+2} = {0, 2} // for each sum in L 0, we can add x 1 to it or not L 2 = {0, 2} U {0+7, 2+7} = {0, 2, 7, 9} L 3 = {0,2,7,9} U {0+5, 2+5, 7+5, 9+5} = {0, 2, 5, 7, 9, 12, 14}

TU/e Algorithms (2IL15) – Lecture Generating subset sums  X = { x 1, x 2, …, x n }  choices: do we take x 1 into subset ? do we take x 2 into subset ? ETC Generate-Subsets ( X,t )  L 0 ← { 0 }  for i ←1 to n  do Copy L i-1 to list M i-1  Add x i to each number in M i-1 and remove numbers larger than t  L i ← L i-1 U M i-1  Remove duplicates from L i  return L n running time: Ω (size of list L n ) = Ω( 2 n )

TU/e Algorithms (2IL15) – Lecture Turning the exponential-time exact algorithm into an FPTAS Speeding up the algorithm: don’t keep all numbers in L i ( trim L i ) L i = 0, 104, 134, 135, 145, 149, 204, 207, 224, 300 if numbers y and z in L i are almost the same, then throw away one of them when exactly can we afford to do this ? which one ? if we keep only one of them, we make only a small mistake safer to keep the smaller number, let’s say z throw away y when 1 ≤ y / z ≤ 1 + δ for a suitable parameter δ

TU/e Algorithms (2IL15) – Lecture Trim ( L, δ ) // L is a sorted list with elements z 0, z 1, z 2, …, z m (in order) NB z 0 = 0  last ← z 1  for j ← 2 to m  do if z j / last ≤ 1+δ  then remove z j from L // trim  else last ← z j // don’t trim Generate-Trimmed-Subsets ( X,t )  L 0 ← empty set  for i ←1 to n  do Copy L i-1 to list M i-1  Add x i to each number in M i-1 and remove numbers larger than t  L i ← L i-1 U M i-1  Remove duplicates from L i  return L n Trim (L i, δ )

TU/e Algorithms (2IL15) – Lecture Lemma. The size of any list L i is O( (1/δ) ∙ log t ) ) Proof. Let L = z 0, z 1, z 2, …, z m (in order). Then z j / z j-1 ≥ 1+δ, so z m ≥ (1+δ) ∙ z m-1 ≥ (1+δ) 2 ∙ z m-2 ≥ … ≥ (1+δ) m-1 ∙ z 1 ≥ (1+δ) m-1 Hence, (1+δ) m-1 ≤ z m ≤ t, so (m -1) ∙ log (1+δ) ≤ log t Conclusion: m = O( (1/δ) ∙ log t ) ) since log(1+ δ) ≈ δ for small δ

TU/e Algorithms (2IL15) – Lecture Lemma. If we choose δ = ε/(2n), then approximation ratio is 1+ ε. Proof. L i = list we maintain U i = list we would maintain if we would never do any trimming Claim: For any y in U i there is z in L i such that z ≤ y ≤ (1+δ) i ∙ z Proof of Claim. By induction. OPT = value of optimal solution. Then OPT is max number in U n, so there is z in L i with z ≥ ( 1 / (1+δ) n ) ∙ OPT = ( 1 / (1+ ε/(2n)) n ) ∙ OPT ≥ ( 1 / (1+ ε) ) ∙ OPT

TU/e Algorithms (2IL15) – Lecture Lemma. If we choose δ = ε/(2n), then approximation ratio is 1+ ε. Lemma. The size of any list L i is O( (1/δ) ∙ log t ) ). Plug in δ = ε/(2n): size of L i is O( (n/ε) ∙ log t ) ) Need log t bits to represent t  size of L i polynomial in input size and 1/ε Running time is O ( Σ i |L i | )  running time polynomial in input size and 1/ε Theorem. There is an FPTAS for the Subset Sum optimization problem.

TU/e Algorithms (2IL15) – Lecture Summary  ρ-approximation algorithm: algorithm for which computed solution is within factor ρ from OPT  to prove approximation ratio we usually need lower bound on OPT (or, for maximization, upper bound)  PTAS = polynomial-time approximation scheme = algorithm with two parameters, input instance and ε > 0, such that –approximation ratio is1+ ε –running time is polynomial in n for constant ε  FPTAS = PTAS whose running time is polynomial in 1/ ε  some problems are even hard to approximate