A Deterministic Polynomial-time Approximation Scheme for Counting Knapsack Solutions

Daniel Stefankovic, Santosh S. Vempala, Eric Vigoda

Abstract

The counting version of the 0/1 knapsack problem is a fundamental challenge in computational complexity, classified as #P-complete. While randomized approximation schemes (FPRAS) have existed for some time, this paper presents the first deterministic Fully Polynomial-time Approximation Scheme (FPTAS) for the problem. By inverting the standard dynamic programming approach and employing a geometric discretization of the solution space, the authors achieve a $(1 \pm \epsilon)$ approximation with a running time of $O(n^3 \epsilon^{-1} \log(n/\epsilon))$. Notably, this deterministic approach scales more efficiently with the error parameter $\epsilon$ than previous randomized methods.

Introduction

In the classic 0/1 knapsack problem, we are given $n$ items with non-negative integer weights $w_1, \dots, w_n$ and a total capacity $C$. The goal of the counting version is to determine the number of distinct subsets of items whose total weight does not exceed $C$.

While the decision version of knapsack is NP-hard, the counting version is significantly more difficult, falling into the #P-complete complexity class. Historically, researchers have addressed this difficulty using randomized algorithms, such as Markov Chain Monte Carlo (MCMC) methods or dynamic programming combined with rejection sampling. However, the search for a deterministic algorithm that is both efficient (polynomial in $n$ and $1/\epsilon$) and provides guaranteed relative error remained a significant open problem until this work.

Algorithmic Framework

The core innovation of this paper lies in a fundamental restructuring of the standard dynamic programming (DP) approach used for knapsack problems. The authors introduce two primary techniques: Inverse DP Indexing and Geometric Discretization.

1. Inverse DP Indexing

In a standard DP approach for the knapsack problem, one typically tracks the number of solutions for every possible capacity from $1$ to $C$. If the capacity $C$ is large, this table becomes computationally intractable. The authors "flip" this logic by defining a function $\tau(i, a)$, which represents the minimum capacity required to yield at least $a$ solutions using a subset of the first $i$ items.

2. Geometric Discretization

Because the number of solutions $a$ can grow exponentially (up to $2^n$), it is impossible to store every possible value of $a$ in a DP table. To maintain a polynomial table size, the authors discretize the "number of solutions" axis using a geometric progression $Q^j$, where $Q = 1 + \frac{\epsilon}{n+1}$. This ensures that the relative error remains bounded while the number of entries in the table remains polynomial in $n$ and $1/\epsilon$.

3. Recurrence and Optimization

The algorithm computes $\tau$ by considering two cases for the $i$-th item: either it is included in the subset or it is not. The authors derive a recurrence relation to find the minimum capacity for a target number of solutions. Because the function $\tau$ is monotonic, they utilize binary search to find the optimal split of solutions between the two cases, reducing the complexity of each DP step from linear to logarithmic.

Key Results and Complexity

The resulting algorithm is a deterministic FPTAS that outputs a value $Z'$ such that $(1-\epsilon)Z \le Z' \le Z$, where $Z$ is the true number of solutions.

Complexity Analysis: The algorithm runs in $O(n^3 \epsilon^{-1} \log(n/\epsilon))$ time. This represents a major theoretical milestone for several reasons:

  • Superior Scaling: Most randomized counting algorithms (like MCMC) have a running time that depends on $\epsilon^{-2}$. This deterministic approach achieves a dependence on $\epsilon^{-1}$, making it significantly faster for high-precision approximations where $\epsilon$ is very small.
  • Deterministic vs. Randomized: The paper provides a rare example of an FPTAS for a #P-complete problem that does not require sampling. This contributes to the broader conjecture in complexity theory that $P = BPP$, suggesting that efficient randomized algorithms often have deterministic counterparts.

Discussion and Limitations

While the paper marks a breakthrough in theoretical computer science, there are several areas for further exploration:

  • Scope of Constraints: The current work focuses specifically on the 0/1 knapsack problem. While the authors suggest the results could extend to real-valued inputs, the specific model of computation for such an extension is not fully detailed.
  • Generalization: The "inverse DP" technique is highly tailored to the structure of the knapsack recurrence. It remains to be seen if this geometric discretization can be applied to other #P-complete problems, such as counting independent sets or graph colorings, without a significant increase in computational complexity.
  • Practical Implementation: As a theoretical paper, it does not provide empirical benchmarks. While the $\epsilon^{-1}$ scaling is theoretically superior, the constant factors involved in the algorithm compared to established MCMC methods in practical applications remain unquantified.

Conclusion

By reimagining the state space of the knapsack problem, the authors have provided the first deterministic FPTAS for a classic #P-complete counting problem. Their approach demonstrates that for certain structured counting problems, randomness is not a requirement for efficiency, and that geometric discretization is a powerful tool for maintaining precision in approximate dynamic programming.

Summary updated

BibTeX
@article{stefankovic2012deterministic,
  author = {Daniel Stefankovic and Santosh S. Vempala and Eric Vigoda},
  title = {{A Deterministic Polynomial-time Approximation Scheme for Counting Knapsack Solutions}},
  journal = {SIAM Journal on Computing},
  year = {2012},
  doi = {10.1137/11083976x},
}
Figure