Worst-Case Performance Bounds for Simple One-Dimensional Packing Algorithms 1: First-Fit and Best-Fit Have Asymptotic Worst-Case Ratio 17/10Research Paper
Motivation
Bin packing asks for the fewest unit-capacity bins that hold a given list of item sizes. It is one of the first problems studied through the worst-case analysis of approximation algorithms, and it models storage allocation, paging and file placement on tracks, as well as cutting-stock problems in operations research. Deciding the optimum exactly is NP-hard, so the practical question is how badly simple rules can do. The two simplest on-line rules, First-Fit and Best-Fit, are still the baseline against which every later bin-packing heuristic is measured.
Timeline:
- 1972. Garey, Graham and Ullman announce that First-Fit uses at most about times the optimal number of bins (Proc. 4th ACM STOC, 1972); Johnson's thesis (MIT, 1973) develops the analysis.
- 1974. Johnson, Demers, Ullman, Garey and Graham prove and for every list, and give lists with for every optimum , so the asymptotic worst-case ratio of both rules is exactly (SIAM J. Comput. 3(4)). This paper is the source of the mission.
- 1976–2014. The additive constant is lowered: Garey, Graham, Johnson and Yao (1976) show , and Dósa and Sgall prove the tight bound (STACS 2013) and the same bound for Best-Fit (ICALP 2014).
Setting
A list is a finite sequence of real numbers in ; values may repeat. A bin has capacity , and its level is the sum of the numbers in it. The optimum is the minimum number of bins into which the elements of can be placed so that no bin contains numbers whose sum exceeds .
Both rules place in this order into bins , each initially at level , and never move an element once placed.
- First-Fit (FF) places into the bin of least index whose level satisfies .
- Best-Fit (BF) places into a bin whose level satisfies and is as large as possible, taking the least index among ties.
and are the numbers of nonempty bins at the end. The worst-case ratio at optimum is
The analysis also uses a weighting function , piecewise linear with on , on , on and on , and the coarseness of a bin of a completed packing: the largest over the bins of smaller index, and for the first bin.
Formalization targets
Goal: the asymptotic ratio (Corollary of Section 2, p. 306)
The goal fixes only the asymptotic ratio and leaves the additive constants free, so it is the statement that survives the later improvements of the constants.
Milestones, in the order the proof uses them
- Claim 2.2.1 (p. 304): a bin with total size at most has .
- Claim 2.2.2 (p. 305): in an FF or BF packing, every element placed into a bin before the bin was more than half full exceeds the bin's coarseness.
- Claim 2.2.3 (p. 305): a bin of coarseness whose level exceeds has weight at least .
- Claim 2.2.4 (p. 306): a bin of coarseness with weight , , either holds a single element at most or has level at most .
- Theorem 2.2 (p. 304): and for every list.
- Theorem 2.1 (p. 301): for every there is a list with and .
A companion item, not a milestone, records the explicit list of Fig. 3 (p. 307) with and .
Significance
The result fixes the worst-case behaviour of the two simplest bin-packing heuristics: neither ever uses more than about more bins than an optimal packing, and both can be forced to. The weighting-function technique introduced for this bound became the standard method for analysing bin-packing heuristics, including First-Fit Decreasing, Harmonic-type algorithms and on-line lower bounds, and the constant is the reference point for later on-line algorithms.
The theorem is proved, and its constants have since been sharpened. No machine-checked proof of any of these results is known. This mission produces a Lean model of on-line bin packing (the optimum, the First-Fit and Best-Fit runs with their placement history, and the worst-case ratio) that the other missions of this paper and later bin-packing formalizations can reuse. It also produces formal proofs of the weighting-function bounds, of the upper bound and of the lower-bound construction.
Difficulty
The first idea, charging each bin its level, gives only : at most one bin is at most half full. The ratio comes from bins that are more than half full but far from full, and a bound on the total size of the elements cannot see them. No property of the final packing alone suffices: the bins that are far from full can only be controlled through the order in which the rule opened and filled them, so the argument depends on the dynamics of the run. On the lower-bound side, the natural periodic list (sizes near , p. 301) gives only the ratio ; reaching needs a list on which both rules waste space in every medium bin, for every , while is still known exactly.
Formalization scope
A list is L : List ℝ with the hypothesis IsList L (every element in ), and every statement assumes it. is optBins L, the least b : ℕ for which some assignment Fin L.length → Fin b has every bin sum at most . A run is a fold over the list that keeps only the nonempty bins, in index order, each with its contents in placement order. A new bin is opened at the end exactly when no nonempty bin fits, which is the paper's "least " over infinitely many initially empty bins, since elements are positive. The fit test is the non-strict , and Best-Fit breaks ties by least index. The placement history (the bin chosen for each element and that bin's level just before) is read off the run on the prefix of the list. Indices are -based. Coarseness is computed in the completed packing. is a function ℝ → ℝ and is only ever applied to elements of . and are suprema in the extended nonnegative reals , and the limit is taken there.
A real-valued supremum would be on an empty or unbounded family, and the limit statement would then say nothing about the algorithms. The extended-real supremum rules this trivialization out. Every claim is stated for the concrete First-Fit run and the concrete Best-Fit run, not for an abstract rule with the properties used in the proof.
Claim 2.2.4 is printed with alternative (i) " and ", which is false: First-Fit on gives a counterexample. The mission states it with , which is what the paper's proof establishes and what the main proof uses. The milestone text keeps the printed version.
The model definitions are reusable for any on-line bin-packing rule, since the run is parameterized by the choice rule. Contributions welcome: proofs of the milestones, general lemmas about the runs (levels stay at most , at most one bin is at most half full, the history determines the final packing), and the computation of for the explicit lists of Theorem 2.1 and Fig. 3.
Selected references
- D. S. Johnson, A. Demers, J. D. Ullman, M. R. Garey, R. L. Graham, Worst-Case Performance Bounds for Simple One-Dimensional Packing Algorithms, SIAM Journal on Computing 3(4):299–325, 1974. https://doi.org/10.1137/0203025
- M. R. Garey, R. L. Graham, J. D. Ullman, Worst-case analysis of memory allocation algorithms, Proc. 4th ACM STOC, 1972.
- D. S. Johnson, Near-Optimal Bin Packing Algorithms, PhD thesis, MIT, 1973.
- M. R. Garey, R. L. Graham, D. S. Johnson, A. C. Yao, Resource constrained scheduling as generalized bin packing, J. Combinatorial Theory Ser. A 21, 1976.
- G. Dósa, J. Sgall, First Fit bin packing: A tight analysis, STACS 2013, LIPIcs 20:538–549. https://doi.org/10.4230/LIPIcs.STACS.2013.538
- G. Dósa, J. Sgall, Optimal analysis of Best Fit bin packing, ICALP 2014, LNCS 8572.