Skip to content

Approximately Counting Knapsack Solutions in Almost Linear Time

Lin Chen, Biyou Ma, Yuchen Mao, Guochuan Zhang

cs.DS

Abstract

Given integer weights w1,…,wn∈[1,T]w_1,\ldots,w_n\in[1,T], we approximate the number ZZ of subsets whose total weight is at most the capacity TT. For every fixed δ>0δ>0 we give a randomized algorithm that estimates ZZ to relative error ε\varepsilon with probability at least 2/32/3 in Oδ(n+ε−(1+δ))O_δ(n+\varepsilon^{-(1+δ)}) time on the standard word RAM with words of Θ(log⁡(n/ε)+log⁡T)Θ(\log(n/\varepsilon)+\log T) bits. This improves the time bound O~(nε−2)\widetilde{O}(n\varepsilon^{-2}) by Jin, Park, and Saha. Instead of estimating the core threshold probabilities by sampling, we compute them under an exponentially tilted product law by Fourier analysis; this suffices when the total weight is polynomial. For arbitrary weights we use a discrete inverse Littlewood--Offord theorem to show that, after an inward rounding that preserves almost all feasible sets, all but a small power of n+ε−1n+\varepsilon^{-1} of the items selected under the tilted law lie, in expectation, in a progression of bounded rank. We find such a progression by sampling and lattice reduction, count the weights in it with the Fourier machinery, and add back the remaining weights through a degree-truncated inclusion--exclusion whose correction terms are estimated by sampling.

Create a lesson