Presentation is loading. Please wait.

Presentation is loading. Please wait.

An FPTAS for Counting Integer Knapsack Solutions Made Easy

Similar presentations


Presentation on theme: "An FPTAS for Counting Integer Knapsack Solutions Made Easy"โ€” Presentation transcript:

1 An FPTAS for Counting Integer Knapsack Solutions Made Easy
Nir Halman Hebrew University of Jerusalem

2 The Integer Knapsack Problem
Input: n items. Item i has: weight wi , value vi and limit ui on #copies (U=max ui). Knapsack capacity C. Output: Max ๐‘–โ‰ค๐‘› ๐‘ฃ ๐‘– ๐‘ฅ ๐‘– s.t. ๐‘–โ‰ค๐‘› ๐‘ค ๐‘– ๐‘ฅ ๐‘– โ‰ค๐ถ; 0โ‰ค ๐‘ฅ ๐‘– โ‰ค ๐‘ข ๐‘– Admits an FPTAS [IK75,HS76] If all ui=1, called 0/1 knapsack Counting problem: How many feasible solutions exist? (v is obsolete) Theorem. An O( ๐‘› 3 log 3 ๐‘ˆlog๐ถ ๐œ– log ๐‘›log ๐‘ˆ ๐œ€ ) time FPTAS Improves over Gopalan et al. [FOCS11] by ๐‘‚ ( ๐‘› 2 ๐œ€ ) Other well-know counting problems: counting satisfying assignments of distinctive normal form (DNF) formulas (1st FPRAS by [KL85]), counting independent sets in graphs of max. degree ๏„โ‰ค5 (1st FPTAS by [We06]).

3 A naรฏve DP formulation Let ๐‘š ๐‘– (๐‘—)=max. #copies of item i (โ‰คui) using โ‰ค j space, ๐‘  ๐‘– ๐‘— =#feasible sols. using โ‰ค j space & items 1,โ€ฆ,i Recurrence: ๐‘  1 ๐‘— = ๐‘š 1 ๐‘— +1 ๐‘—=1,โ€ฆ,๐ถ ๐‘  ๐‘– ๐‘— = ๐‘˜=0 ๐‘š ๐‘– ๐‘— ๐‘  ๐‘–โˆ’1 ๐‘—โˆ’๐‘˜ ๐‘ค ๐‘– 2โ‰ค๐‘–โ‰ค๐‘›, ๐‘—=1,โ€ฆ,๐ถ Solution = ๐‘  ๐‘› ๐ถ Running time: i โ‰ค n items, space j โ‰ค C and summation of size โ‰ค U ๏ƒจ O(nUC) time, i.e., pseudopolynomial in both U and C

4 A second DP formulation
Idea: ๏€ข item i break integer decision i into โ‰ค log ui binary sub-decisions. If all ui were powers of 2 minus one, then easy: ๏€ขi Break item i into m bundles of weights ๐‘ค ๐‘– ,2 ๐‘ค ๐‘– ,โ€ฆ,((ui +1)/2-1) ๐‘ค ๐‘– and solve the corresponding 0/1 knapsack counting problem E.g., if ui=7 (=111 in binary encoding) and ๐‘ค ๐‘– =1:

5 A second DP formulation
Idea: ๏€ข item i break integer decision i into โ‰ค log ui binary sub-decisions. But when ui is not a power of 2 minus one, then the bundles are not necessarily โ€œindependentโ€: E.g., if ui=5 (=101 in binary encoding) and ๐‘ค ๐‘– =1: + - bit # from left Corresponding bundle 1 2 3 constraint non-binding constraint binding - + - + - + - + - 5 4 3 2 1

6 A second DP formulation
Idea: break integer decision i into at most ui binary sub-decisions, ๏€ข item i Let: msb(x,i)=place (from the right) of most significant โ€œ1โ€ bit of the ith least significant bits of x, if exists or -โˆž e.g., msb(5,2)=1 (5 in binary encoding is 101); msb(4,1)=-โˆž (4 in binary encoding is 100).

7 A second DP formulation โ€“ contโ€™
๐‘ง ๐‘–,๐‘™,0 ๐‘— = ๐‘ง ๐‘–,๐‘™โˆ’1,0 ๐‘— + ๐‘ง ๐‘–,๐‘™โˆ’1,0 ๐‘—โˆ’ 2 ๐‘™โˆ’1 ๐‘ค ๐‘– l=2,โ€ฆ (a) ๐‘ง ๐‘–,๐‘™,1 ๐‘— = ๐‘ง ๐‘–,๐‘™โˆ’1,0 ๐‘— + ๐‘ง ๐‘–,msb( ๐‘ข ๐‘– ,๐‘™โˆ’1),1 ๐‘—โˆ’ 2 ๐‘™โˆ’1 ๐‘ค ๐‘– l=2,โ€ฆ (b) ๐‘ง ๐‘–,1,๐‘Ÿ ๐‘— = ๐‘ง ๐‘–โˆ’1,โ””log+ ๐‘š ๐‘– ๐‘— โ”˜+1,1 ๐‘— + ๐‘ง ๐‘–โˆ’1,โ””log+ ๐‘š ๐‘–โˆ’1 ๐‘— โˆ’๐‘ค ๐‘– โ”˜+1,1 ๐‘—โˆ’ ๐‘ค ๐‘– (c) E.g., ui=5 (101 in binary encoding) and wi=1. ๐‘ง ๐‘–,3,0 ๐‘— considers placing a bundle of 4 and then recursively checks a bundle of 2 by using ๐‘ง ๐‘–,2,0 โˆ™ ๐‘ง ๐‘–,3,1 ๐‘— considers placing a bundle of 4 and then recursively checks a bundle of 1 (because msb(5,2)=1) by using ๐‘ง ๐‘–,1,0 โˆ™ The last index of z is an indicator for the constraint xi โ‰คui being potentially binding ๐‘ง ๐‘–,โˆ’โˆž,1 ๐‘— = ๐‘ง ๐‘–โˆ’1,โ””log+ ๐‘š ๐‘–โˆ’1 ๐‘— โ”˜+1,1 ๐‘— (d) ๐‘ง 1,๐‘™,๐‘Ÿ ๐‘— = ๐‘š 1 ๐‘— l=1,โ€ฆ (e) ๐‘ง ๐‘–,๐‘™,๐‘Ÿ ๐‘— = j<0 (f) where r=0,1, i=2,...,n and j=0,...,C Solution = ๐‘ง ๐‘›,โ””log+ ๐‘ข ๐‘› โ”˜+1,1 ๐ถ Running time: i โ‰ค n items, l โ‰ค log U sub-decisions, r=0,1 space j โ‰ค C, and summation of size โ‰ค 2๏ƒจ O(nClogU) time, i.e., pseudopolynomial in C only

8 An FPTAS Note: All functions ๐‘ง ๐‘–,๐‘™,๐‘Ÿ โˆ™ are univariate and monotone non-decreasing in their variable This is called a monotone dynamic program Thm[HKLOS14]: A monotone DP with depth T, |action space| โ‰คA, |state space|โ‰คS and bound M on max. value, admits an O( ๐‘‡ 2 ๐œ€ ๐ด log๐‘† log๐‘€ log ๐‘‡log๐‘€ ๐œ€ ) FPTAS ๏ƒจ Here T=nlogU, A=2, S=C, and M=Un ๏ƒจ O( ๐‘› 3 ๐œ€ log3๐‘ˆ log๐ถ log ๐‘›log๐‘ˆ ๐œ€ ) time

9 K-approximation functions
Assume function ฯ† is defined over integer domains and is non-negative, i.e., ฯ†:[0, U] ๏ƒ  R+ We say that ฯ†* is a K-approximation of ฯ† if ฯ†(x) โ‰ค ฯ†*(x) โ‰ค Kฯ†(x), ๏€ขx โˆˆ [0, U] We denote this by ฯ†* โ‰…K ฯ†

10 1. Calculus of K-apx. Functions
Let ฮฑ,ฮฒ โ‰ฅ 0, ฯ†i* โ‰…Ki ฯ†i , K1 โ‰ฅ K2, and i =1,2 Operation name Operation and apx. ratio summation ฮฑ+ฮฒฯ†1*+ฯ†2* โ‰…K1 ฮฑ+ฮฒฯ†1+ฯ†2 minimization min{ฯ†1*, ฯ†2*} โ‰…K1 min{ฯ†1, ฯ†2} composition ฯ†1*(ฯˆ) โ‰…K1 ฯ†1(ฯˆ) approximation ฯ†2* โ‰…K1 K2 ฯ†1 when ฯ†2= ฯ†1* ๐‘ง ๐‘–,๐‘™,0 ๐‘— = ๐‘ง ๐‘–,๐‘™โˆ’1,0 ๐‘— + ๐‘ง ๐‘–,๐‘™โˆ’1,0 ๐‘—โˆ’ 2 ๐‘™โˆ’1 ๐‘ค ๐‘– (๐‘Ž) ๐‘งโ€ฒ ๐‘–,๐‘™,0 ๐‘— = ๐‘งโˆ— ๐‘–,๐‘™โˆ’1,0 ๐‘— + ๐‘งโˆ— ๐‘–,๐‘™โˆ’1,0 ๐‘—โˆ’ 2 ๐‘™โˆ’1 ๐‘ค ๐‘– (๐‘Žโ€ฒ) Corollary: (summation of composition) Let z* in (aโ€™) be K1 -apx. functions of the original functions. Then ๐‘งโ€ฒ ๐‘–,๐‘™,0 ๐‘— โ‰…K1 ๐‘ง ๐‘–,๐‘™,0 ๐‘—

11 2. K-approximation Sets Definition: Let ฯ†:[0,...,S]โ†’ R+ be monotone. A K-apx. set of ฯ† is W๏ƒŒ [0,...,S] with 0,S๏ƒŽW and ratio ๏‚ฃ K between each two consecutive points in W Construction: ฯ†* is the apx. of ฯ† induced by W: ฯ† โ‰ฅK ๏‚ฃ K W ฯ†* Question: How small a K-apx. set of ฯ† can be, and how fast can it be constructed?

12 Approximating a Monotone Function: The Compress Operator
Answer: A monotone ฯ† admits a K-apx. function with |breakpoints| poly. of input size (= log S + log M) via binary search over both domain and range. We explicitly construct it via the compress procedure: g := Compress(ฯ† , K=1+๏ฅ ). g is a piecewise step function g โ‰…K ฯ† #pieces is O(logK M) = O( log M ฮต ) (using K<2๏‚ฎlogKโ‰ฅฮต) Running time is O( log M log S ฮต ), query time is O(log log M ฮต ), assuming pieces are stored as a list (x, ฯ†(x)) sorted by x

13 FPTAS formulation begin 1. K:= 1+๐œ– 1 2๐‘‡ .
2. Define ๐‘งโˆ— 1,๐‘™,๐‘Ÿ โˆ™ := ๐‘ง 1,๐‘™,๐‘Ÿ โˆ™ 3. for t=2 to depth T do 4. implement ๐‘งโ€ฒ ๐‘–,๐‘™,๐‘Ÿ โˆ™ oracle using DP and ๐‘งโˆ— ๐‘– โ€ฒ , ๐‘™ โ€ฒ ,๐‘Ÿ โˆ™ where either iโ€™<i or lโ€™<l 5. ๐‘งโˆ— ๐‘–,๐‘™,๐‘Ÿ โˆ™ :=compress( ๐‘งโ€ฒ ๐‘–,๐‘™,๐‘Ÿ โˆ™ ,K) 6. endfor end Corollary: (summation of composition) Let z* in (aโ€™) be K1 -apx. functions of the original functions. Then ๐‘งโ€ฒ ๐‘–,๐‘™,0 ๐‘— โ‰…K1 ๐‘ง ๐‘–,๐‘™,0 ๐‘—

14 Running Time and Error Analysis
begin 1. K:= 1+๐œ– 1 2๐‘‡ . 2. Define ๐‘งโˆ— 1,๐‘™,๐‘Ÿ โˆ™ := ๐‘ง 1,๐‘™,๐‘Ÿ โˆ™ 3. for t=2 to depth T do 4. implement ๐‘งโ€ฒ ๐‘–,๐‘™,๐‘Ÿ โˆ™ oracle using DP and ๐‘งโˆ— ๐‘– โ€ฒ , ๐‘™ โ€ฒ ,๐‘Ÿ โˆ™ where either iโ€™<i or lโ€™<l 5. ๐‘งโˆ— ๐‘–,๐‘™,๐‘Ÿ โˆ™ :=compress( ๐‘งโ€ฒ ๐‘–,๐‘™,๐‘Ÿ โˆ™ ,K) 6. endfor end each query = O(log logK M) O(logS logK M) queries to ๐‘งโ€ฒ ๐‘–,๐‘™,๐‘Ÿ โˆ™ Running time: O(TlogS logKM log logK M)=O( ๐‘‡ 2 ๐œ€ log๐‘† log๐‘€ log ๐‘‡ log๐‘€ ๐œ€ ) Apx. Ratio: By line 1 K2T=1+๏ฅ

15 Summary / Our Approach โ€ข Functional point of view
โ€ข Approximating functions via apx. sets โ€ข Propagation of errors via Calculus of approximation โ€ข Modular framework for deriving FPTASs โ€ข The notion of binding constraints is of independent interest

16 Bibliography: โ™ฆ [G+11] P. Gopalan, A. Klivans, R. Meka, D
Bibliography: โ™ฆ [G+11] P. Gopalan, A. Klivans, R. Meka, D. Stefankoviห‡c, S. Vempala, E. Vigoda, FPTAS for #Knapsack and Related Counting Problems, FOCS 2011 โ™ฆ[HKLOS14] N. Halman, D. Klabjan, C.L. Li, J. Orlin, D. Simchi-Levi, FPTASs for stochastic DPs, SIAM. Discrete Math โ™ฆ [HS76] E. Horowitz & S. Sahni, Exact and appoximate algs. for scheduling nonidentical processors, J. ACM, โ™ฆ [IK75] H. Ibarra & C. Kim, Fast approximation algor the knapsack and sum of subset problems, J. ACM, โ™ฆ [KL85] R. Karp & M. Luby, Monte Carlo algs. for the planar multiterminal network reliability problem, J. Complexity, 1985 โ™ฆ [We06] D. Weitz, Counting independent sets up to the tree threshold, STOC 2006

17 Thank you!

18 Relative Approximation
OPT โ€“ a minimization problem OPT(x) โ€“ value of problem on instance x A K-apx. alg. A(x) (K>1) returns A(x) โ‰ค K OPT(x) A PTAS (Polynomial Time Approximation Scheme) is a (1+ ฮต)-apx. that runs in poly(|x|) time, e.g., O(|x|3/ฮต ) An FPTAS (Fully Poly. Time Approximation Scheme) is a PTAS that runs in poly(|x|,1/ฮต) time, e.g., O((|x|/ฮต)2) FPTASs are considered as the โ€œHolly Grailโ€ among apx. algs. because one can get as close to opt(x) as one wants in poly. time

19 A Question Does a value oracle for a monotone function ฯ†:[0,...,S]โ†’R+ admits an efficient succinct K-approximation? ( Let M = ฯ†max . Input size = log S + log M) Def: a K-approximation ฯ†* is: succinct if stored in logarithmic space, e.g., O(log S log M) efficient if built in logarithmic time (# of oracle queries)


Download ppt "An FPTAS for Counting Integer Knapsack Solutions Made Easy"

Similar presentations


Ads by Google