Lecture 13 March 7, 2017

Similar documents
Lecture 11 October 7, 2013

a 1 a 2 a 3 a 4 v i c i c(a 1, a 3 ) = 3

Knapsack. Bag/knapsack of integer capacity B n items item i has size s i and profit/weight w i

Lec. 2: Approximation Algorithms for NP-hard Problems (Part II)

1 The Knapsack Problem

Approximation Algorithms

Lecture 4. 1 FPTAS - Fully Polynomial Time Approximation Scheme

SDP Relaxations for MAXCUT

princeton univ. F 17 cos 521: Advanced Algorithm Design Lecture 6: Provable Approximation via Linear Programming

Lecture 8: The Goemans-Williamson MAXCUT algorithm

Lecture 16: Constraint Satisfaction Problems

Topic: Sampling, Medians of Means method and DNF counting Date: October 6, 2004 Scribe: Florin Oprea

Essential facts about NP-completeness:

Lecture 6,7 (Sept 27 and 29, 2011 ): Bin Packing, MAX-SAT

6.854J / J Advanced Algorithms Fall 2008

An Algorithmist s Toolkit September 24, Lecture 5

Lecture Notes CS:5360 Randomized Algorithms Lecture 20 and 21: Nov 6th and 8th, 2018 Scribe: Qianhang Sun

P, NP, NP-Complete, and NPhard

Lecture 21: Counting and Sampling Problems

CS 151 Complexity Theory Spring Solution Set 5

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

Asymptotic Polynomial-Time Approximation (APTAS) and Randomized Approximation Algorithms

Lecture 24 Nov. 20, 2014

NP Completeness and Approximation Algorithms

Provable Approximation via Linear Programming

Lecture 20: LP Relaxation and Approximation Algorithms. 1 Introduction. 2 Vertex Cover problem. CSCI-B609: A Theorist s Toolkit, Fall 2016 Nov 8

Lecture 4: An FPTAS for Knapsack, and K-Center

Homework 4 Solutions

On the efficient approximability of constraint satisfaction problems

This means that we can assume each list ) is

Convex and Semidefinite Programming for Approximation

Solutions to Exercises

Lecture 21 (Oct. 24): Max Cut SDP Gap and Max 2-SAT

Lecture 10. Semidefinite Programs and the Max-Cut Problem Max Cut

U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 8 Luca Trevisan September 19, 2017

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

P,NP, NP-Hard and NP-Complete

Foundations of Machine Learning and Data Science. Lecturer: Avrim Blum Lecture 9: October 7, 2015

Approximate Counting and Markov Chain Monte Carlo

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam

Design and Analysis of Algorithms

Approximation Algorithms and Hardness of Approximation. IPM, Jan Mohammad R. Salavatipour Department of Computing Science University of Alberta

Lecture 18: More NP-Complete Problems

Overview. 1 Introduction. 2 Preliminary Background. 3 Unique Game. 4 Unique Games Conjecture. 5 Inapproximability Results. 6 Unique Game Algorithms

8 Knapsack Problem 8.1 (Knapsack)

Lecture 17 (Nov 3, 2011 ): Approximation via rounding SDP: Max-Cut

How hard is it to find a good solution?

Approximation Algorithms

2 P vs. NP and Diagonalization

NP-Hardness reductions

PCP Theorem and Hardness of Approximation

Lecture 4. 1 Estimating the number of connected components and minimum spanning tree

Approximation Basics

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

The Monte Carlo Method

NP-Complete Reductions 2

Lecture Semidefinite Programming and Graph Partitioning

Convex relaxation. In example below, we have N = 6, and the cut we are considering

CSCI3390-Second Test with Solutions

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

An Introduction to Randomized algorithms

Approximation algorithm for Max Cut with unit weights

NP-Complete Problems. More reductions

Optimization of Submodular Functions Tutorial - lecture I

Finding Large Induced Subgraphs

CS261: A Second Course in Algorithms Lecture #18: Five Essential Tools for the Analysis of Randomized Algorithms

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

(x 1 +x 2 )(x 1 x 2 )+(x 2 +x 3 )(x 2 x 3 )+(x 3 +x 1 )(x 3 x 1 ).

Notes for Lecture 2. Statement of the PCP Theorem and Constraint Satisfaction

1 T 1 = where 1 is the all-ones vector. For the upper bound, let v 1 be the eigenvector corresponding. u:(u,v) E v 1(u)

Introduction to Semidefinite Programming I: Basic properties a

The Knapsack Problem. 28. April /44

SAT, NP, NP-Completeness

More Approximation Algorithms

Lecture 6: Greedy Algorithms I

NP-Complete Reductions 1

Computability and Complexity Theory

CS294: PCP and Hardness of Approximation January 25, Notes for Lecture 3

Lecture 15: A Brief Look at PCP

NP-Completeness. NP-Completeness 1

Randomized Algorithms

Complexity Classes IV

NETS 412: Algorithmic Game Theory March 28 and 30, Lecture Approximation in Mechanism Design. X(v) = arg max v i (a)

Solutions to Sample Problems for Midterm

CSE 421 NP-Completeness

The Complexity of Optimization Problems

Lecture 18: P & NP. Revised, May 1, CLRS, pp

Convex relaxation. In example below, we have N = 6, and the cut we are considering

COSC 341: Lecture 25 Coping with NP-hardness (2)

BCCS: Computational methods for complex systems Wednesday, 16 June Lecture 3

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

More NP-Complete Problems

CS151 Complexity Theory. Lecture 15 May 22, 2017

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

1 Primals and Duals: Zero Sum Games

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan August 30, Notes for Lecture 1

Graduate Algorithms CS F-21 NP & Approximation Algorithms

Lecture 5: Efficient PAC Learning. 1 Consistent Learning: a Bound on Sample Complexity

Transcription:

CS 224: Advanced Algorithms Spring 2017 Prof. Jelani Nelson Lecture 13 March 7, 2017 Scribe: Hongyao Ma Today PTAS/FPTAS/FPRAS examples PTAS: knapsack FPTAS: knapsack FPRAS: DNF counting Approximation algorithms via Semidefinite Programming (SDP) 1 PTAS Knapsack The Knapsack Problem Given weight W of knapsack and weights/values of n items: w 1,..., w m, v 1,..., v n. Assume that the capacity W, w i s and v i s are integers. Assume w i W, w.l.o.g., since we can ignore all items with weights larger than the capacity. max s.t. n x i v i n x i w i W x i {0, 1}, i For PTAS, we want to achieve (1 ɛ)opt in time O(f(ɛ)n g(ɛ) ). 1.1 Greedy Algorithms Greedy Algorithm Sort items in the order: v 1 /w 1 v 2 /w 2 v n /w n. Can prove that this is optimal for fractional knapsack problem, but: Let v 1 = 1.001, w 1 = 1, v 2 = W, w 2 = W, we can see that for this instance, this is no better than a W -approximation. How can we improve the performance of the greedy algorithm? 1

Modified Greedy (ModGreedy) 1. Run greedy to get solution S 1 2. Let S 2 = {item with the largest value} 3. Return whichever of S 1, S 2 that has more value Claim 1. ModGreedy achieves value OPT/2, i.e. it s a 2-approximation Lemma 2. If greedy takes items 1, 2,..., k 1 in the fractional solution, we know k v i OPT, Proof. Since the kth item might not be taken in full in the optimal fractional solution, and that the optimal solution of the integral solution is no better tha the optimal solution of the LP relaxation, k v i OPT frac (LP ) OPT Proof of Claim 1. We know from the lemma, (v 1 + + v k 1 ) + v k OPT We know that one of k 1 v i and v k is at least OPT/2, therefore ModGreedy achieves at least maximum of the two (v(s 1 ) k 1 v i, and v(s 2 ) v max v k ), which is at least OPT/2. 1.2 PTAS for Knapsack ModGreedy gives us a 2-approximation. Now we try to improve the approximation ratio. First, observe that Greedy achieves at least OPT - v max, since k 1 v i OPT v k OPT v max. If no item has value larger than ɛ OPT, we know that the Greedy algorithm is a (1 ɛ) approximation. Also observe that the optimal set contains at most 1/ɛ items with value ɛopt otherwise the value of the optimal solution would exceed OPT. Denote S [n] as the set taken by the optimal solution, and let H S be the set of items with value ɛ OPT. We now from the above argument that H 1/ɛ. 2

Known OPT Assume that we know OPT, we can run the following algorithm: 1. Try all possibilities for sets H s.t. H 1/ɛ 2. While trying some particular H: throw out any item with value ɛopt run greed to get set G 3. return the H G with best value ever found When the guessed H correctly, we know that the loss from running greedy to get set G is at most ɛ OPT, since the size of the elements that are not thrown away is bounded by ɛ OPT. Therefore we get v(h G) OPT ɛopt = (1 ɛ)opt. Without OPT How to get around not knowing OPT? 1. Guess OPT up to a factor of 2. There are at most log( n 1 v i) possibilities, or 2. Use ModGreedy to get a 2-approximation of OPT first, or 3. Try all n thresholds Runtime The run time of the algorithms proposed above is (n + 1) 1/ɛ poly(n), since the number of sets with size at most k is at most (n + 1) k (k times I can either pick one of the n elements or pick an (n + 1)st null element, which does enumerate all size at most k sets, with overcounting), and the cost of trying different thresholds and to run the greedy on the rest is poly(n). 2 FPTAS Knapsack FPTAS achieves (1 ɛ)opt in time poly(n, 1/ɛ). The FPTAS dominates the PTAS for the knapsack problem, but there exists problems for which PTAS exists but no FPTAS exists. Existence of FPTAS Why can t we always hope for a FPTAS? Consider vertex cover as an example, where the goal is to cover all edges using fewest number of vertices. For vertex cover, even the decision problem is hard. If we have an FPTAS, take ɛ < 1/2n, we would get an objective at most (1 + ɛ)opt OPT + 1/2 since OPT is an integer, this would give us what OPT is. This means that if we have an FPTAS, we will be able to solve the vertex cover problem optimally, which would imply P = NP. Dynamic Programming for Kanpsack We know that we can already solve knapsack exactly in time O(nV ) using dynamic programming. Let f(i, v) = min{ total weight of items, using only items 1,..., i to achieve value b}, 3

and if value v is not possible using items from {1,..., i}, set f(i, v) to be infinity. We then take the set that achieves maximum b s.t. f(n, b) W. This is pseudo polynomial time since describing V needs only log V bits. FPTAS for Knapsack We will achieve O(n 3 /ɛ) time today, and the best known is O(n lg 1/ɛ + 1/ɛ 4 ) by Lawler in Math. Oper. Res. 79[2]. The idea is that the DP solution is not too bad if V is small, so let us transform the problem into one with a smaller V, hoping not to lose too much during the process. Approach: 1. Set α = n/(ɛ v max ), and for all i, set v i = αv i. 2. Solve the problem with v i using the O(nV ) algorithm. Runtime and Approximation Ratio Since the new total value V = n v i n max{v i } n 2, we know that the total run time is O(nV ) = O ( n 3 /ɛ ). What is left to prove is that the solution to the transformed problem is a (1 ɛ) approximation to the original problem. First, we know that the OPT v max since the optimal solution of the transformed problem can take at least the most valuable item. Moreover, since the v i s are upper bounded by n/ɛ and the total number of items is n, we get: n ɛ OPT n2 ɛ. Note we can assume 1/ɛ is an integer so that indeed n ɛ = n ɛ (if not, round ε down so that 1/ε is an integer, which changes ε by at most a factor of 2 and thus changes our final runtime by a constant factor) Now observe that the error comes from the floors, o.w. the solution would have been accurate. The amount of val(s) lost due to rounding is at most the size of S: S n ɛopt. We have the following lemma: Lemma 3. Let v(s) = i S v i and v (S) = i S v i, we have αv(s) S v i(s) αv(s). Now we will show that if A is the optimal set for the ransformed problem, and A is the actual optimal solution for the original problem, v(a) (1 ɛ)v(a ). How do we prove this? Since A is the optimal solution of the transformed problem, its value is at least as much as A in the transformed problem. Also consider A n, we get v(a) 1 α v (A) 1 α v (A ) 1 α (αv(a ) A ) v(a ) ɛ v max OPT ɛopt. 4

3 FPRAS DNF Counting FPRAS Recall that a FPRAS achieves a (1 ± ɛ) approximation in time poly(n, 1/ɛ) with probability at least 2/3. As we have seen in the problem sets, we can repeatedly do this for multiple times, and then take the median. The median only fails only if more than half of the trails fails. Here, we are going to do a counting problem instead of an optimization problem: counting solutions to DNF [1]. Counting Problems Approximate DNF Counting is known to be #P-Complete. 1. In a counting problem, we would like to know how many sets that satisfy this or not. This class of problems is harder than NP-hard problems, since if we can count, we are able to be able to solve the original problem like SAT. Sometimes the counting problem is hard, but the original problem is still easy. DNF Formula (Disjunctive Normal Form) C 1 C 2 C m C = (x i1 x i2... ) x {0, 1} n Approximate DNF counting would like to count the number of x out of the 2 n possible assignments s.t. a DNF formula is satisfied. The decision problem is easy as long as there doesn t exits a little x and its negation, the clause is satisfiable. The counting problem, however, is hard. Recall that a CNF formula is of the form (... ) (... ).... Let a CNF formula be we know that the negation of φ is a DNF: φ = C 1 C 2 C m, φ = C 1 C 2 C m Knowing CNF is hard implies DNF is hard, since if we can count the number of solutions to φ (say N), we are able to count the number of solutions to φ would be 2 n N, thus this implies a solution to counting of CNF. 2 3.1 Karp, Luby, Madras, J. Alg. 89 [3] Let n be the number of variables and m be the number of clauses. First, observe that randomly sample from the 2 n possible assignments to estimate the fraction p of satisfying assignments is not a good idea. This is because p can be very small, for which case we would need too many samples (thus won t be fast!) to get an good estimate of p. One such example is φ = x 1 x 2 x n, for which p = 1/2 n. 1 The name came from counting, thus # 2 For those who believe BPP (the randomized version of P)=P, they may also believe that there exists a deterministic algorithm for DNF counting. However, algorithms that are known so far are randomized. 5

Approach The idea is to reduce the size of the set from which we are sampling, in which case the fraction would not be too small. Let S i be the set of satisfying assignments to C i. The size of each such set is S i = 2 n # of literals in C i Let B = m S i. We would like to estimate the size of B. Let B be the set of pairs {(i, x) : x S i }, we know B = i S i. We want to estimate p = B / B up to 1 ± ɛ, then output p B. Bijection between subset of B to B Note that the elements in B and the elements in B are different stuff (assignments vs. pairs.) What to do? Treat b B as being in B if b = (i, x) and C i is the first clause x satisfies. This gives a natural bijection, and each satisfying assignment is only counted once. Now, p cannot be so small: p 1/m, since each satisfying assignment appears at most m times. We just need to argue that the empirical estimation of p is close to the true probability. Analysis Sample T times from B, and estimate p as the fraction of samples that were in B (the subset that we put in correspondence with B.) Let X i be the indicator random variable { 1, if the ith smaple belongs to B X i = 0, otherwise We bound the probability by Chernoff bound: [ ] T P X i µ > ɛµ e cɛ2 p T which is smaller than δ if we pick T C lg(1/δ)m/ɛ 2. Sampling from B How do we randomly draw an element from B? Note that B = S i. Step 1. Pick i with probability S i /( j S j ) Step 2. Pick random x S i the variables that appear in the clause has to be fixed, and those that do not appear in the clause can be picked uniformly at random. 6

4 Semidefinite Programming We are going to design approximation algorithm for MaxCut via SDP in the next lecture. MaxCut given an undirected graph G = (V, E), find a cut with the maximum of edges crossing it: find S V, S s.t. E(S, V \S) is maximized. MaxCut is known to be an NP-hard problem, but have a trivial 2-approximation: pick a random set S V. Since each edge is cut with probability half, and OPT cannot be larger than E, E(# edges cut) = e E P[e is cut] = E 2 OPT 2. 0.878-approx for MaxCut in polynomial time, where 0.878 = inf θ [0,π] { 2 π Goemans, Williamson 95 } [4] propose algorithm achieving 0.878OPT. Somehow this number is the truth. θ 1 cos θ Semidefinite Programming (SDP) In linear programming, x is a vector. In SDP, x is a matrix: min tr(c X) s.t. tr(a i X = b i), i = 1,..., m, X 0. The trace of a matrix is defined as: tr(a B) = i,j A i,jb i,j the objective doesn t look too much different from that in LP, so how is this more matrixy? What s more important is the constraint X 0, i.e. X is positive semi-definite (PSD). A matrix X is PSD means z R n, z Xz 0 We will see next time that LP is a special case of this (when everything is diagonal). We can also express the PSD constraints as z, tr(x (zz )) 0 i.e. infinitely many linear constraints. Just as we can relax ILP to LP, we can relax quadratic programs to SDPs, solve them, then round to get solutions to the quadratic program with provably good approximation ratios. References [1] Richard Karp, Michael Luby, Neal Madras. Monte-carlo approximation algorithms for enumeration problems. J. Algorithms, 10(3):429 448, 1989. [2] Eugene Lawler. Fast Approximation Algorithms for Knapsack Problems. Math. Oper. Res., 4(4):339 356, 1979. 7

[3] Richard Karp, Michael Luby, and Neal Madras. Monte-Carlo Approximation Algorithms for Enumeration Problems. J. Algorithms, 10(3):429 448, 1989. [4] Michel X. Goemans and David P. Williamson Improved Approximation Algorithms for Maximum Cut and Satisfiability Problems Using Semidefinite Programming J. ACM, 42(6):1115 1145, 1995. 8