Knapsack and Subset Sum with Small Items

Adam Polak, Lars Rohwedder, Karol Wegrzycki

Abstract

This paper presents a significant breakthrough in solving the classic Knapsack and Subset Sum problems by focusing on instances where item sizes ($s$) or values ($v$) are small. By cleverly combining proximity arguments from integer programming with additive combinatorics and fast convolution techniques, the authors achieve running times that are independent of the knapsack capacity $t$, providing the first $O(n + \text{poly}(s))$ algorithms for these fundamental NP-hard problems.

Introduction

Knapsack and Subset Sum are cornerstones of combinatorial optimization. While NP-hard, they are solvable in "pseudopolynomial" time—most famously via Bellman’s dynamic programming in $O(Nt)$ time, where $N$ is the total number of items and $t$ is the capacity.

However, when the capacity $t$ is very large, Bellman’s approach becomes impractical. Researchers have long sought algorithms whose complexity depends on the maximum item size $s$ or maximum value $v$ instead of $t$. Previous attempts often resulted in runtimes like $O(\text{poly}(n) \cdot \text{poly}(s))$, where $n$ is the number of distinct items. This research addresses the challenge: Can we solve these problems in time that is linear in the number of distinct items $n$ and polynomial in the maximum item size $s$, even when items have large multiplicities?

Methodology

The authors utilize a "toolbox" of advanced algorithmic techniques to bypass the capacity dependency:

  1. Proximity Arguments: They prove that an optimal solution is "close" to a greedy "maximal prefix solution" (which simply picks the most efficient items first). Specifically, they show an optimal solution exists that differs from the greedy one by only $O(s)$ items. This drastically narrows the search space.
  2. Fast Structured (min, +)-Convolution: For Knapsack, the problem is reduced to a series of convolutions. While general (min, +)-convolution is computationally expensive, the authors exploit the "inverse-Monge" structure of their specific sub-problems. This allows them to use the SMAWK algorithm to find row maxima in linear time, leading to the $O(n + s^3)$ result.
  3. Additive Combinatorics: For Subset Sum, the authors use results from additive combinatorics which state that if a set of integers is "dense" enough, their subset sums will eventually form a long arithmetic progression. They introduce a "Robust Split" technique to partition the problem into a "bundled" part (handled by these combinatorial methods) and a "remainder" part.
  4. Binary Multiplicity Encoding: The algorithms are designed to handle instances where each item $i$ comes with a multiplicity $u_i$ (encoded in binary). This means the input can represent a massive number of items succinctly, and the algorithms remain efficient.

Key Results

The paper establishes new upper bounds for the deterministic time complexity of these problems, significantly improving upon the state-of-the-art as summarized in the following tables.

Comparison of algorithmic complexities for the 0-1 Knapsack problem and its variants.
  • Knapsack: The problem can be solved in $O(n + s^3)$ and $O(n + v^3)$ time. This is a major improvement because it is linear in $n$ and completely independent of the capacity $t$.
  • Subset Sum: The problem can be solved in randomized $\tilde{O}(n + s^{5/3})$ time.
Comparison of algorithmic complexities for the 0-1 Subset Sum problem.
  • Multiplicity Handling: These bounds hold even when the total number of items $N$ is much larger than the number of distinct items $n$, thanks to the binary multiplicity encoding.

Discussion and Future Work

A notable limitation is that these algorithms provide an answer for only a single target value $t$. Traditional DP algorithms often provide answers for all possible capacities from $0$ to $t$ simultaneously. The authors argue this is unavoidable if one wants a runtime independent of $t$.

Furthermore, for Knapsack, there is still a gap between the known lower bound of $O(n + s^{2-o(1)})$ and the authors' $O(n + s^3)$ upper bound. Closing this gap (e.g., finding an $O(n + s^2)$ algorithm) remains an open challenge. Finally, the $s^{5/3}$ result for Subset Sum is randomized; finding a deterministic algorithm with a similar bound is a potential area for future research.

Summary updated

BibTeX
@inproceedings{polak2021knapsack,
  author = {Adam Polak and Lars Rohwedder and Karol Wegrzycki},
  title = {{Knapsack and Subset Sum with Small Items}},
  booktitle = {ICALP},
  year = {2021},
  doi = {10.4230/lipics.icalp.2021.106},
}
Figure