First Fit uses at most 17/10 * OPT + 4/5 bins #
This file proves the 17/10 bound for First Fit (Cslib.Algorithms.Lean.BinPacking.firstFit)
with an explicit additive constant: against any packing Q of the same items,
10 * FF ≤ 17 * Q.length + 8 (ten_mul_length_firstFit_le), that is
FF ≤ 17/10 * OPT + 4/5 for the optimum OPT. As FF is an integer this implies
FF ≤ ⌈17/10 * OPT⌉ (length_firstFit_le_ceil), the bound of
Garey, Graham, Johnson and Yao as reported by
Dósa and Sgall, Section 1.1, and the earlier FF ≤ 17/10 * OPT + 2 of
Johnson, Demers, Ullman, Garey and Graham.
The proof is the amortized weighting argument of Dósa and Sgall, Section 1.2,
with sizes in ℕ and bin capacity C, all weights scaled by 10 * C. An item of size a has
weight 12 * a (the scaled size 6/5 * a) plus a bonus (firstFitBonus): 4 * C if
C < 2 * a, C if C ≤ 3 * a ≤ 3/2 * C, 6 * a - C if C < 6 * a < 2 * C, and 0 otherwise.
These are Dósa and Sgall's bonuses 0.4, 0.1, 3/5 * (a - 1/6) and 0.
- Upper bound. A bin of total size at most
Chas weight at most17 * C(sum_map_firstFitWeight_le): at most one item is larger thanC / 2, and on items of size at mostC / 2the bonus is superadditive. Summed over a packingQ, all items weigh at most17 * C * Q.length(IsPacking.sum_map_le_mul_length). - Lower bound. First Fit's bins weigh
10 * Ceach on average, up to8 * Cin total. Every item of a later bin did not fit into an earlier one (pairwise_forall_lt_sum_add_firstFit). So if a binBis at least2/3full and a later binB'has two items, then12 * B.sumplus the bonus ofB'is at least10 * C(Dósa and Sgall, Lemma 1.1). Chaining this over the bins with at least two items, adding the bins holding one item larger thanC / 2, and accounting for at most one bin with two or more items less than2/3full and at most one bin holding a single item of size at mostC / 2, the total weight plus8 * Cis at least10 * C * FF. The exception is a First Fit packing in which all bins but at most one hold a single item larger thanC / 2; thereFF ≤ OPT + 1directly, since no two such items share a bin.
Dósa and Sgall's sketch in their Section 1.2 leaves three bins unaccounted for and concludes
FF ≤ 1.7 * OPT + 3; they remark that examining those bins brings the constant down to 0.6.
The case analysis of the remaining bins here, which gives 0.8, is our own; the constant is not
new, as Xia and Tan's FF ≤ 1.7 * OPT + 0.7, reported in
Dósa and Sgall, Section 1.1, is already stronger. Dósa and Sgall's main result,
the absolute bound FF ≤ ⌊1.7 * OPT⌋ (Dósa and Sgall, Theorem 3.13), is not
formalized here; neither is the matching lower-bound family of their Section 4.
Main definitions #
Cslib.Algorithms.Lean.BinPacking.firstFitBonus: the bonus of an item, scaled by10 * C.Cslib.Algorithms.Lean.BinPacking.firstFitWeight: the weight of an item, scaled by10 * C.
Main results #
Cslib.Algorithms.Lean.BinPacking.sum_map_firstFitWeight_le: a bin weighs at most17 * C.Cslib.Algorithms.Lean.BinPacking.ten_mul_length_firstFit_le:10 * FF ≤ 17 * OPT + 8.Cslib.Algorithms.Lean.BinPacking.length_firstFit_le_ceil:FF ≤ ⌈17/10 * OPT⌉.
References #
- G. Dósa, J. Sgall, First Fit bin packing: A tight analysis
- M. R. Garey, R. L. Graham, D. S. Johnson, A. C.-C. Yao, Resource constrained scheduling as generalized bin packing
- D. S. Johnson, A. Demers, J. D. Ullman, M. R. Garey, R. L. Graham, Worst-case performance bounds for simple one-dimensional packing algorithms
The bonus of an item of size a in bins of capacity C, scaled by 10 * C.
The weight of an item of size a, scaled by 10 * C.
The amortized weight of First Fit bins #
First Fit uses at most 17/10 * OPT + 4/5 bins: against any packing Q of the same
items, 10 * FF ≤ 17 * Q.length + 8. This is the asymptotic 17/10 bound of
Johnson, Demers, Ullman, Garey and Graham with the additive
constant 4/5, by the weighting argument of Dósa and Sgall, Section 1.2. The
constant is not tight: Dósa and Sgall prove FF ≤ ⌊17/10 * OPT⌋.
First Fit uses at most ⌈17/10 * OPT⌉ bins, the bound of
Garey, Graham, Johnson and Yao as reported by
Dósa and Sgall, Section 1.1.