Classifying the Expected Waste of Best Fit Bin Packing under U{j,k}

Question

Items arrive one at a time and go into bins of capacity kk. Best Fit puts each item into the fullest open bin that still has room, and opens a new bin otherwise. It is the default online bin-packing rule.

Let item sizes be i.i.d. uniform on {1,…,j}\{1, \dots, j\}, i.e. the distribution U{j,k}U\{j,k\}. For j≤k−2j \le k-2 the items can be packed almost perfectly, so the optimal waste (unused space) stays O(1)O(1). The question is:

For which (j,k)(j, k) does Best Fit also keep the waste bounded, and for which does it waste a constant fraction, Θ(n)\Theta(n), of the space after nn items?

History

  • 1991. Coffman, Courcoubetis, Garey, Johnson, McGeoch, Shor, Weber and Yannakakis introduce U{j,k}U\{j,k\} and prove that the waste is bounded when k≥j(j+3)/2k \ge j(j+3)/2 [1]. Simulations suggest Best Fit wastes linearly for many other pairs.
  • 1993. Coffman, Johnson, Shor and Weber prove linear waste for U{8,11}U\{8,11\} and U{9,12}U\{9,12\} with LP-generated Lyapunov functions (about 24 hours each), settling every k≤11k \le 11 [2]. Their table leaves pairs with k≤14k \le 14 open: “All the still-open problems listed in the table appear to require solutions to LP’s that are far too big for us to store, much less solve.”
  • 1998. Kenyon, Rabani and Sinclair prove bounded waste for j=k−2j = k-2 [3].
  • 2002. Kenyon and Mitzenmacher prove linear waste for 0.66≤j/k<2/30.66 \le j/k < 2/3 when kk is “sufficiently large” [4]. They note that U{8,11}U\{8,11\} and U{9,12}U\{9,12\} are still the only explicit pairs with proven linear waste.

Since then, the explicit classification seems not to have moved. As far as we could find, seven non-trivial pairs with k≤14k \le 14 remained open, as did almost every pair with k≥15k \ge 15.

Results

  1. Solved the 7 open cases from 1993. Linear: U{9,13}U\{9,13\}, U{10,13}U\{10,13\}, U{10,14}U\{10,14\}, U{11,14}U\{11,14\}. Bounded: U{8,12}U\{8,12\}, U{8,13}U\{8,13\}, U{9,14}U\{9,14\}.
  2. Complete classification for k≤25k \le 25. 144 newly settled pairs: 78 linear, 66 bounded. In this range, for j≤k−2j \le k-2, only O(1)O(1) and Θ(n)\Theta(n) occur. Coffman et al. asked in 2002 whether anything in between is possible [5].
  3. Complete rows. For every j≤12j \le 12 and every kk, Best Fit has linear waste exactly when j≥8j \ge 8 and j+3≤k≤Kjj+3 \le k \le K_j, where K8,…,K12=11,13,17,20,24K_8, \dots, K_{12} = 11, 13, 17, 20, 24.
  4. Waste rates. For the linear cases with k≤14k \le 14, the long-run waste per item (liminf and limsup) is bracketed rigorously, e.g. U{9,13}U\{9,13\}: [0.01087,0.01123][0.01087, 0.01123] (simulation: 0.011090.01109), about 0.22% more bins than optimal.
  5. Where the waste goes. In 26 linear cases, bins with two or more free units provably stay O(1)O(1): all linear waste sits in bins with exactly one unit free.
Classification of Best Fit under U{j,k} for k ≤ 25

An empirical k\sqrt{k} law (simulation, not proof). For each jj, we bisected on kk in simulation to find the largest kk with linear waste. For jj up to 40 the boundary fits j∗≈2.52kj^* \approx 2.52\sqrt{k} (residual <0.25< 0.25), and it agrees exactly with the certified rows j≤12j \le 12. The proven bounded region, k≥j(j+3)/2k \ge j(j+3)/2, corresponds to j≲1.41kj \lesssim 1.41\sqrt{k}. The theorem has the right order but is off by a factor of about 3 in kk.

The linear-waste region

Methods

The chain. The state is the vector xx of gap counts: xgx_g is the number of open bins with gg units free. Best Fit’s move depends only on which xgx_g are positive. Two invariants mean that only small gaps can have many bins:

  • any two open bins have gaps summing to less than kk;
  • at most one open bin has a gap larger than jj.

The certificate. We look for a Lyapunov function of the form

V(x)=∑gcgxg+ψ(min⁡(x,M)),V(x) = \sum_g c_g x_g + \psi\bigl(\min(x, M)\bigr),

that is, a linear part plus an arbitrary correction on counts truncated at levels MM. The expected one-step change of VV depends only on the finite “pattern” min⁡(x,M+1)\min(x, M+1). So finitely many checks cover the infinite state space.

  • If the drift is at least γ>0\gamma > 0 on every reachable pattern, the waste grows linearly.
  • If all cg>0c_g > 0 and the drift is at most −γ-\gamma whenever some count exceeds its truncation level, the waste is bounded (Hajek’s drift theorem [6]).

The search. For a fixed linear part cc, the best ψ\psi solves a linear program. That LP is the Bellman inequality of an average-reward Markov decision process, in which an adversary chooses which truncated counts are “really” large. So instead of solving huge LPs, which was the 1993 bottleneck, we:

  • run value iteration (multi-threaded C++);
  • optimise cc by a cutting-plane method, warm-started from neighbouring cases.

The largest certificate has 15.7 million patterns. U{8,11}U\{8,11\}, the 24-hour computation of 1993, now takes seconds.

Reproduce

git clone https://github.com/CHHC-L/bestfit-ujk
cd bestfit-ujk
make && make test
# might be slow:
make verify

Code, certificates and proofs (notes/method.md): github.com/CHHC-L/bestfit-ujk

Note

Most of the code was written by Claude Opus 5.5.

References

  1. E. G. Coffman Jr., C. Courcoubetis, M. R. Garey, D. S. Johnson, L. A. McGeoch, P. W. Shor, R. R. Weber, M. Yannakakis. Fundamental discrepancies between average-case analyses under discrete and continuous distributions: a bin packing case study. STOC, 1991.
  2. E. G. Coffman Jr., D. S. Johnson, P. W. Shor, R. R. Weber. Markov chains, computer proofs, and average-case analysis of Best Fit bin packing. STOC, 1993.
  3. C. Kenyon, Y. Rabani, A. Sinclair. Biased random walks, Lyapunov functions, and stochastic analysis of Best Fit bin packing. J. Algorithms 27, 1998.
  4. C. Kenyon, M. Mitzenmacher. Linear waste of Best Fit bin packing on skewed distributions. Random Structures & Algorithms 20, 2002.
  5. E. G. Coffman Jr. et al. Perfect packing theorems and the average-case behavior of optimal and online bin packing. SIAM Review 44, 2002.
  6. B. Hajek. Hitting-time and occupation-time bounds implied by drift analysis with applications. Adv. Appl. Prob. 14, 1982.