CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Similar documents
Approximation Algorithms

11. APPROXIMATION ALGORITHMS

11. APPROXIMATION ALGORITHMS

11. APPROXIMATION ALGORITHMS

Algorithm Design and Analysis

Outline. CS38 Introduction to Algorithms. Approximation Algorithms. Optimization Problems. Set Cover. Set cover 5/29/2014. coping with intractibility

Theorem 2.9: nearest addition algorithm

Copyright 2000, Kevin Wayne 1

Approximation Algorithms

Approximation Algorithms

10. EXTENDING TRACTABILITY

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

15-451/651: Design & Analysis of Algorithms November 4, 2015 Lecture #18 last changed: November 22, 2015

Design and Analysis of Algorithms

Approximation Algorithms

Introduction to Approximation Algorithms

11.1 Facility Location

Approximation Basics

Copyright 2000, Kevin Wayne 1

10. EXTENDING TRACTABILITY

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

Greedy Approximations

Approximation Algorithms: The Primal-Dual Method. My T. Thai

Stanford University CS261: Optimization Handout 1 Luca Trevisan January 4, 2011

Notes for Lecture 24

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

15-854: Approximations Algorithms Lecturer: Anupam Gupta Topic: Direct Rounding of LP Relaxations Date: 10/31/2005 Scribe: Varun Gupta

COMP Analysis of Algorithms & Data Structures

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

Mathematical and Algorithmic Foundations Linear Programming and Matchings

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

Approximation Algorithms

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

Outline. CS38 Introduction to Algorithms. Linear programming 5/21/2014. Linear programming. Lecture 15 May 20, 2014

Basic Approximation algorithms

1 Better Approximation of the Traveling Salesman

3 INTEGER LINEAR PROGRAMMING

CS 473: Algorithms. Ruta Mehta. Spring University of Illinois, Urbana-Champaign. Ruta (UIUC) CS473 1 Spring / 36

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Topic: Local Search: Max-Cut, Facility Location Date: 2/13/2007

1 Unweighted Set Cover

CS599: Convex and Combinatorial Optimization Fall 2013 Lecture 14: Combinatorial Problems as Linear Programs I. Instructor: Shaddin Dughmi

Algorithms for Euclidean TSP

/ Approximation Algorithms Lecturer: Michael Dinitz Topic: Linear Programming Date: 2/24/15 Scribe: Runze Tang

Lecture 7: Asymmetric K-Center

CS6841: Advanced Algorithms IIT Madras, Spring 2016 Lecture #1: Properties of LP Optimal Solutions + Machine Scheduling February 24, 2016

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

Slides on Approximation algorithms, part 2: Basic approximation algorithms

1. Lecture notes on bipartite matching

Lecture 7. s.t. e = (u,v) E x u + x v 1 (2) v V x v 0 (3)

CS521 \ Notes for the Final Exam

Approximation Algorithms

Graph Algorithms Matching

2 The Fractional Chromatic Gap

1 The Traveling Salesperson Problem (TSP)

CMPSCI611: Approximating SET-COVER Lecture 21

MVE165/MMG630, Applied Optimization Lecture 8 Integer linear programming algorithms. Ann-Brith Strömberg

6 Randomized rounding of semidefinite programs

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

Advanced Algorithms. On-line Algorithms

Iterative Methods in Combinatorial Optimization. R. Ravi Carnegie Bosch Professor Tepper School of Business Carnegie Mellon University

COT 6936: Topics in Algorithms! Giri Narasimhan. ECS 254A / EC 2443; Phone: x3748

Vertex Cover Approximations

Approximability Results for the p-center Problem

A List Heuristic for Vertex Cover

Steiner Trees and Forests

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

Lecture 8: The Traveling Salesman Problem

Chapter 10 Part 1: Reduction

Network Design Foundations Fall 2011 Lecture 10

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

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

Strategies for Replica Placement in Tree Networks

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

Integer Programming Theory

Fall CS598CC: Approximation Algorithms. Chandra Chekuri

Chapter 5 Graph Algorithms Algorithm Theory WS 2012/13 Fabian Kuhn

In this lecture, we ll look at applications of duality to three problems:

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

CS 580: Algorithm Design and Analysis

Greedy Algorithms 1 {K(S) K(S) C} For large values of d, brute force search is not feasible because there are 2 d {1,..., d}.

Polynomial-Time Approximation Algorithms

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Clustering: Centroid-Based Partitioning

6. Lecture notes on matroid intersection

Approximation Algorithms

Algorithms Dr. Haim Levkowitz

Lecture 2. 1 Introduction. 2 The Set Cover Problem. COMPSCI 632: Approximation Algorithms August 30, 2017

Greedy algorithms is another useful way for solving optimization problems.

Introduction to Mathematical Programming IE406. Lecture 20. Dr. Ted Ralphs

Discrete Optimization 2010 Lecture 5 Min-Cost Flows & Total Unimodularity

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

Chapter 16. Greedy Algorithms

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

February 19, Integer programming. Outline. Problem formulation. Branch-andbound

FINAL EXAM SOLUTIONS

Treewidth and graph minors

3 No-Wait Job Shops with Variable Processing Times

Chapter 6. Dynamic Programming

Transcription:

CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018

Chapter 11 Approximation Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved. 2

Approximation Algorithms Q. Suppose I need to solve an NP-hard problem. What should I do? A. Theory says you're unlikely to find a poly-time algorithm. Must sacrifice one of three desired features. Solve problem to optimality. Solve problem in poly-time. Solve arbitrary instances of the problem. -approximation algorithm. Guaranteed to run in poly-time. Guaranteed to solve arbitrary instance of the problem Guaranteed to find solution within ratio of true optimum. Challenge. Need to prove a solution's value is close to optimum, without even knowing what optimum value is! 3

11.1 Load Balancing

Load Balancing Input. m identical machines; n jobs, job j has processing time t j. Job j must run contiguously on one machine. A machine can process at most one job at a time. Def. Let J(i) be the subset of jobs assigned to machine i. The load of machine i is L i = j J(i) t j. Def. The makespan is the maximum load on any machine L = max i L i. Load balancing. Assign each job to a machine to minimize makespan. M=2 Machines. Subset Sum problem in disguise! Search problem is NP-Hard 5

Load Balancing: List Scheduling List-scheduling algorithm. Consider n jobs in some fixed order. Assign job j to machine whose load is smallest so far. play List-Scheduling(m, n, t 1,t 2,,t n ) { for i = 1 to m { L i 0 load on machine i J(i) } jobs assigned to machine i } for j = 1 to n { i = argmin k L k J(i) J(i) {j} L i L i + t j } return J(1),, J(m) machine i has smallest load assign job j to machine i update load of machine i Implementation. O(n log m) using a priority queue. 6

Load Balancing: List Scheduling Analysis Theorem. [Graham, 1966] Greedy algorithm is a 2-approximation. First worst-case analysis of an approximation algorithm. Need to compare resulting solution with optimal makespan L*. 7

Load Balancing: List Scheduling Analysis Theorem. Greedy algorithm is a 2-approximation. Pf. Consider load L i of bottleneck machine i. Let j be last job scheduled on machine i. When job j assigned to machine i, i had smallest load. Its load before assignment is L i -t L j i -t j L k for all 1 k m. blue jobs scheduled before j j 0 L i -t j L = L i 8

Load Balancing: List Scheduling Analysis Lemma 1 Now 9 Lemma 2

Load Balancing: List Scheduling Analysis Q. Is our analysis tight? A. Essentially yes. Ex: m machines, m(m-1) jobs length 1 jobs, one job of length m machine 2 idle machine 3 idle machine 4 idle machine 5 idle machine 6 idle machine 7 idle machine 8 idle machine 9 idle machine 10 idle list scheduling makespan = 19 10

Load Balancing: List Scheduling Analysis Q. Is our analysis tight? A. Essentially yes. Ex: m machines, m(m-1) jobs length 1 jobs, one job of length m 11 optimal makespan = 10

Load Balancing: LPT Rule Longest processing time (LPT). Sort n jobs in descending order of processing time, and then run list scheduling algorithm. LPT-List-Scheduling(m, n, t 1,t 2,,t n ) { Sort jobs so that t 1 t 2 t n for i = 1 to m { L i 0 J(i) } load on machine i jobs assigned to machine i } for j = 1 to n { i = argmin k L k J(i) J(i) {j} L i L i + t j } return J(1),, J(m) machine i has smallest load assign job j to machine i update load of machine i 12

Load Balancing: LPT Rule Observation. If at most m jobs, then list-scheduling is optimal. Pf. Each job put on its own machine. Lemma 3. If there are more than m jobs, L* 2t m+1. Pf. Consider first m+1 jobs t 1,, t m+1. Since the t i 's are in descending order, each takes at least t m+1 time. There are m+1 jobs and m machines, so by pigeonhole principle, at least one machine gets two jobs. Theorem. LPT rule is a 3/2 approximation algorithm. Pf. Same basic approach as for list scheduling. L i (L i t j ) L* t j 3 L *. 2 1 2 L* 13 Lemma 3 ( by observation, can assume number of jobs > m )

Load Balancing: LPT Rule Q. Is our 3/2 analysis tight? A. No. Theorem. [Graham, 1969] LPT rule is a 4/3-approximation. Pf. More sophisticated analysis of same algorithm. Q. Is Graham's 4/3 analysis tight? A. Essentially yes. Ex: m machines, n = 2m+1 jobs, 2 jobs of length m+1, m+2,, 2m-1 and one job of length m. 14

11.2 Center Selection

Center Selection Problem Input. Set of n sites s 1,, s n and integer k > 0. Center selection problem. Select k centers C so that maximum distance from a site to nearest center is minimized. k = 4 r(c) center site 16

Center Selection Problem Input. Set of n sites s 1,, s n and integer k > 0. Center selection problem. Select k centers C so that maximum distance from a site to nearest center is minimized. Notation. dist(x, y) = distance between x and y. dist(s i, C) = min c C dist(s i, c) = distance from s i to closest center. r(c) = max i dist(s i, C) = smallest covering radius. Goal. Find set of centers C that minimizes r(c), subject to C = k. Distance function properties. dist(x, x) = 0 (identity) dist(x, y) = dist(y, x) (symmetry) dist(x, y) dist(x, z) + dist(z, y) (triangle inequality) 17

Center Selection Example Ex: each site is a point in the plane, a center can be any point in the plane, dist(x, y) = Euclidean distance. Remark: search can be infinite! r(c) center site 18

Greedy Algorithm: A False Start Greedy algorithm. Put the first center at the best possible location for a single center, and then keep adding centers so as to reduce the covering radius each time by as much as possible. Remark: arbitrarily bad! greedy center 1 k = 2 centers center site 19

Center Selection: Greedy Algorithm Greedy algorithm. Repeatedly choose the next center to be the site farthest from any existing center. Greedy-Center-Selection(k, n, s 1,s 2,,s n ) { } C = repeat k times { Select a site s i with maximum dist(s i, C) Add s i to C } site farthest from any center return C Observation. Upon termination all centers in C are pairwise at least r(c) apart. Pf. By construction of algorithm. 20

Center Selection: Analysis of Greedy Algorithm Theorem. Let C* be an optimal set of centers. Then r(c) 2r(C*). Pf. (by contradiction) Assume r(c*) < ½ r(c). For each site c i in C, consider ball of radius ½ r(c) around it. Exactly one c i * in each ball; let c i be the site paired with c i *. Consider any site s and its closest center c i * in C*. dist(s, C) dist(s, c i ) dist(s, c i *) + dist(c i *, c i ) 2r(C*). Thus r(c) 2r(C*). -inequality r(c*) since c i * is closest center ½r(C) ½r(C) C* sites ½r(C) s c i c i * 21

Center Selection Theorem. Let C* be an optimal set of centers. Then r(c) 2r(C*). Theorem. Greedy algorithm is a 2-approximation for center selection problem. Remark. Greedy algorithm always places centers at sites, but is still within a factor of 2 of best solution that is allowed to place centers anywhere. e.g., points in the plane Question. Is there hope of a 3/2-approximation? 4/3? Theorem. Unless P = NP, there no -approximation for center-selection problem for any < 2. 22

11.4 The Pricing Method: Vertex Cover

Weighted Vertex Cover Definition. Given a graph G = (V, E), a vertex cover is a set S V such that each edge in E has at least one end in S. Weighted vertex cover. Given a graph G with vertex weights, find a vertex cover of minimum weight. 2 4 2 4 2 9 2 9 weight = 2 + 2 + 4 weight = 11 24

Pricing Method Pricing method. Each edge must be covered by some vertex. Edge e = (i, j) pays price p e 0 to use vertex i and j. Fairness. Edges incident to vertex i should pay w i in 2 4 total. for each vertex i : p e e (i, j) w i 2 9 Lemma. For any vertex cover S and any fair prices p e : e p e w(s). Pf. e E p e i S e ( i, j) p e i S w i w( S). each edge e covered by at least one node in S sum fairness inequalities for each node in S 25

Pricing Method Pricing method. Set prices and find vertex cover simultaneously. Weighted-Vertex-Cover-Approx(G, w) { foreach e in E p e = 0 e ( i, j) p e w i while ( edge i-j such that neither i nor j are tight) select such an edge e increase p e as much as possible until i or j tight } } S set of all tight nodes return S 26

Pricing Method price of edge a-b vertex weight Figure 11.8 27

Pricing Method: Analysis Theorem. Pricing method is a 2-approximation. Pf. Algorithm terminates since at least one new node becomes tight after each iteration of while loop. Let S = set of all tight nodes upon termination of algorithm. S is a vertex cover: if some edge i-j is uncovered, then neither i nor j is tight. But then while loop would not terminate. Let S* be optimal vertex cover. We show w(s) 2w(S*). w(s) w i i S i S p e e (i, j) i V p e e (i, j) 2 p e 2w(S*). e E all nodes in S are tight S V, prices 0 each edge counted twice fairness lemma 28

11.6 LP Rounding: Vertex Cover

Weighted Vertex Cover Weighted vertex cover. Given an undirected graph G = (V, E) with vertex weights w i 0, find a minimum weight subset of nodes S such that every edge is incident to at least one vertex in S. 10 A 6F 9 16 B 7G 10 6 3C H 9 23 D I 33 7 E 10 J 32 total weight = 55 30

Weighted Vertex Cover: IP Formulation Weighted vertex cover. Given an undirected graph G = (V, E) with vertex weights w i 0, find a minimum weight subset of nodes S such that every edge is incident to at least one vertex in S. Integer programming formulation. Model inclusion of each vertex i using a 0/1 variable x i. x i 0 if vertex i is not in vertex cover 1 if vertex i is in vertex cover Vertex covers in 1-1 correspondence with 0/1 assignments: S = {i V: x i = 1} Objective function: maximize i w i x i. Must take either i or j: x i + x j 1. 31

Weighted Vertex Cover: IP Formulation Weighted vertex cover. Integer programming formulation. (ILP) min w i x i i V s. t. x i x j 1 (i, j) E x i {0,1} i V Observation. If x* is optimal solution to (ILP), then S = {i V: x* i = 1} is a min weight vertex cover. 32

Integer Programming INTEGER-PROGRAMMING. Given integers a ij and b i, find integers x j that satisfy: max c t x s. t. Ax b x integral n a ij x j b i 1 i m j 1 x j 0 1 j n x j integral 1 j n Observation. Vertex cover formulation proves that integer programming is NP-hard search problem. even if all coefficients are 0/1 and at most two variables per inequality 33

Linear Programming Linear programming. Max/min linear objective function subject to linear inequalities. Input: integers c j, b i, a ij. Output: real numbers x j. (P) max c t x s. t. Ax b x 0 (P) max c j x j n j 1 n s. t. a ij x j b i 1 i m j 1 x j 0 1 j n Linear. No x 2, xy, arccos(x), x(1-x), etc. Simplex algorithm. [Dantzig 1947] Can solve LP in practice. Ellipsoid algorithm. [Khachian 1979] Can solve LP in poly-time. 34

LP Feasible Region LP geometry in 2D. x 1 = 0 x 2 = 0 2x 1 + x 2 = 6 x 1 + 2x 2 = 6 35

Weighted Vertex Cover: LP Relaxation Weighted vertex cover. Linear programming formulation. (LP) min w i x i i V s. t. x i x j 1 (i, j) E x i 0 i V Observation. Optimal value of (LP) is optimal value of (ILP). Pf. LP has fewer constraints. ½ ½ Note. LP is not equivalent to vertex cover. ½ Q. How can solving LP help us find a small vertex cover? A. Solve LP and round fractional values. 36

Weighted Vertex Cover Theorem. If x* is optimal solution to (LP), then S = {i V : x* i ½} is a vertex cover whose weight is at most twice the min possible weight. Pf. [S is a vertex cover] Consider an edge (i, j) E. Since x* i + x* j 1, either x* i ½or x* j ½ (i, j) covered. Pf. [S has desired cost] Let S* be optimal vertex cover. Then w i i S* * w i x i 1 w 2 i i S i S LP is a relaxation x* i ½ 37

Weighted Vertex Cover Theorem. 2-approximation algorithm for weighted vertex cover. Theorem. [Dinur-Safra 2001] If P NP, then no -approximation for < 1.3607, even with unit weights. 10 5-21 Open research problem. Close the gap. 38

* 11.7 Load Balancing Reloaded

Generalized Load Balancing Input. Set of m machines M; set of n jobs J. Job j must run contiguously on an authorized machine in M j M. Job j has processing time t j. Each machine can process at most one job at a time. Def. Let J(i) be the subset of jobs assigned to machine i. The load of machine i is L i = j J(i) t j. Def. The makespan is the maximum load on any machine = max i L i. Generalized load balancing. Assign each job to an authorized machine to minimize makespan. 40

Generalized Load Balancing: Integer Linear Program and Relaxation ILP formulation. x ij = time machine i spends processing job j. (IP) min L s. t. x ij t j for all j J i L for all i M j x ij x ij {0, t j } for all j J and i M j x ij 0 for all j J and i M j LP relaxation. (LP) min L s. t. x ij t j for all j J i L for all i M j x ij x ij 0 for all j J and i M j x ij 0 for all j J and i M j 41

Generalized Load Balancing: Lower Bounds Lemma 1. Let L be the optimal value to the LP. Then, the optimal makespan L* L. Pf. LP has fewer constraints than IP formulation. Lemma 2. The optimal makespan L* max j t j. Pf. Some machine must process the most time-consuming job. 42

Generalized Load Balancing: Structure of LP Solution Lemma 3. Let x be solution to LP. Let G(x) be the graph with an edge from machine i to job j if x ij > 0. Then G(x) is acyclic. Pf. (deferred) can transform x into another LP solution where G(x) is acyclic if LP solver doesn't return such an x x ij > 0 G(x) acyclic job machine G(x) cyclic 43

Generalized Load Balancing: Rounding Rounded solution. Find LP solution x where G(x) is a forest. Root forest G(x) at some arbitrary machine node r. If job j is a leaf node, assign j to its parent machine i. If job j is not a leaf node, assign j to one of its children. Lemma 4. Rounded solution only assigns jobs to authorized machines. Pf. If job j is assigned to machine i, then x ij > 0. LP solution can only assign positive value to authorized machines. job machine 44

Generalized Load Balancing: Analysis Lemma 5. If job j is a leaf node and machine i = parent(j), then x ij = t j. Pf. Since i is a leaf, x ij = 0 for all j parent(i). LP constraint guarantees i x ij = t j. Lemma 6. At most one non-leaf job is assigned to a machine. Pf. The only possible non-leaf job assigned to machine i is parent(i). job machine 45

Generalized Load Balancing: Analysis Theorem. Rounded solution is a 2-approximation. Pf. Let J(i) be the jobs assigned to machine i. By Lemma 6, the load L i on machine i has two components: leaf nodes Lemma 5 LP Lemma 1 (LP is a relaxation) t j j J(i) j is a leaf x ij x ij L L * j J(i) j is a leaf Lemma 2 j J optimal value of LP parent(i) t parent(i) L * Thus, the overall load L i 2L*. 46

Generalized Load Balancing: Flow Formulation Flow formulation of LP. x ij t j for all j J i x ij L for all i M j x ij 0 for all j J and i M j x ij 0 for all j J and i M j Observation. Solution to feasible flow problem with value L are in oneto-one correspondence with LP solutions of value L. 47

Generalized Load Balancing: Structure of Solution Lemma 3. Let (x, L) be solution to LP. Let G(x) be the graph with an edge from machine i to job j if x ij > 0. We can find another solution (x', L) such that G(x') is acyclic. Pf. Let C be a cycle in G(x). Augment flow along the cycle C. flow conservation maintained At least one edge from C is removed (and none are added). Repeat until G(x') is acyclic. 3 3 3 3 6 6 4 2 2 4 3 1 1 5 5 4 3 4 4 G(x) augment along C G(x') 48

Conclusions Running time. The bottleneck operation in our 2-approximation is solving one LP with mn + 1 variables. Remark. Can solve LP using flow techniques on a graph with m+n+1 nodes: given L, find feasible flow if it exists. Binary search to find L*. Extensions: unrelated parallel machines. [Lenstra-Shmoys-Tardos 1990] Job j takes t ij time if processed on machine i. 2-approximation algorithm via LP rounding. No 3/2-approximation algorithm unless P = NP. 49

11.8 Knapsack Problem

Polynomial Time Approximation Scheme PTAS. (1 + )-approximation algorithm for any constant > 0. Load balancing. [Hochbaum-Shmoys 1987] Euclidean TSP. [Arora 1996] Consequence. PTAS produces arbitrarily high quality solution, but trades off accuracy for time. This section. PTAS for knapsack problem via rounding and scaling. 51

Knapsack Problem Knapsack problem. Given n objects and a "knapsack." Item i has value v > 0 and weighs w i i > 0. Knapsack can carry weight up to W. Goal: fill knapsack so as to maximize total value. we'll assume w i W Ex: { 3, 4 } has value 40. Item Value Weight 1 1 1 W = 11 2 3 6 2 18 5 4 5 22 28 6 7 52

Knapsack is NP-Complete KNAPSACK: Given a finite set X, nonnegative weights w i, nonnegative values v i, a weight limit W, and a target value V, is there a subset S X such that: W i S SUBSET-SUM: Given a finite set X, nonnegative values u i, and an integer U, is there a subset S X whose elements sum to exactly U? w i V i S v i Claim. SUBSET-SUM P KNAPSACK. Pf. Given instance (u 1,, u n, U) of SUBSET-SUM, create KNAPSACK instance: v i w i u i V W U u i i S u i i S U U 53

Knapsack Problem: Dynamic Programming 1 Def. OPT(i, w) = max value subset of items 1,..., i with weight limit w. Case 1: OPT does not select item i. OPT selects best of 1,, i 1 using up to weight limit w Case 2: OPT selects item i. new weight limit = w w i OPT selects best of 1,, i 1 using up to weight limit w w i 0 if i 0 OPT(i, w) OPT(i 1, w) if w i w Running time. O(n W). W = weight limit. Not polynomial in input size! max OPT(i 1, w), v i OPT(i 1, w w i ) otherwise 54

Knapsack Problem: Dynamic Programming II Def. OPT(i, v) = min weight subset of items 1,, i that yields value exactly v. Case 1: OPT does not select item i. OPT selects best of 1,, i-1 that achieves exactly value v Case 2: OPT selects item i. consumes weight w i, new value needed = v v i OPT selects best of 1,, i-1 that achieves exactly value v 0 if v 0 if i 0, v > 0 OPT(i, v) OPT(i 1, v) if v i v min OPT(i 1, v), w i OPT(i 1, v v i ) otherwise V* n v max Running time. O(n V*) = O(n 2 v max ). V* = optimal value = maximum v such that OPT(n, v) W. Not polynomial in input size! 55

Knapsack: FPTAS Intuition for approximation algorithm. Round all values up to lie in smaller range. Run dynamic programming algorithm on rounded instance. Return optimal items in rounded instance. Item Value Weight Item Value Weight 1 934,221 1 1 1 1 2 5,956,342 2 2 6 2 3 17,810,013 5 3 18 5 4 21,217,800 6 4 22 6 5 27,343,199 7 5 28 7 W = 11 W = 11 original instance rounded instance 56

Knapsack: FPTAS Knapsack FPTAS. Round up all values: v i v i, v ˆ i v i v max = largest value in original instance = precision parameter = scaling factor = v max / n Observation. Optimal solution to problems with or are equivalent. v v Intuition. close to v so optimal solution using is nearly optimal; small and integral so dynamic programming algorithm is fast. v ˆ Running time. O(n 3 / ). Dynamic program II running time is O(n 2 v ˆ max ), where v ˆ max v max n v v ˆ 57

Knapsack: FPTAS Knapsack FPTAS. Round up all values: v i v i Theorem. If S is solution found by our algorithm and S* is any other feasible solution then(1 ) v i v i i S Pf. Let S* be any feasible solution satisfying weight constraint. i S* v i i S* v i i S* always round up v i i S (v i i S ) solve rounded instance optimally never round up by more than v i i S n S n DP alg can take v max (1 ) v i i S n = v max, v max i S v i 58

Extra Slides

Load Balancing on 2 Machines Claim. Load balancing is hard even if only 2 machines. Pf. NUMBER-PARTITIONING P LOAD-BALANCE. NP-complete by Exercise 8.26 a b c d e f g length of job f machine 1 machine 2 a d Machine 1 f b c Machine e2 g yes 0 Time L 60

Center Selection: Hardness of Approximation Theorem. Unless P = NP, there is no -approximation algorithm for metric k-center problem for any < 2. Pf. We show how we could use a (2 - ) approximation algorithm for k- center to solve DOMINATING-SET in poly-time. Let G = (V, E), k be an instance of DOMINATING-SET. see Exercise 8.29 Construct instance G' of k-center with sites V and distances d(u, v) = 2 if (u, v) E d(u, v) = 1 if (u, v) E Note that G' satisfies the triangle inequality. Claim: G has dominating set of size k iff there exists k centers C* with r(c*) = 1. Thus, if G has a dominating set of size k, a (2 - )-approximation algorithm on G' must find a solution C* with r(c*) = 1 since it cannot use any edge of distance 2. 61