Documentation

CslibFrontier.Algorithms.Lean.BinPacking.OnlineLowerBound

Yao's 3/2 lower bound for online bin packing #

No deterministic online bin-packing algorithm has asymptotic competitive ratio below 3/2: the abstract of Yao defines r(S) as the maximum ratio S(L) / L* for large L* and states that every on-line algorithm S has r(S) ≥ 3/2. The construction uses the item types 1/7 + ε, 1/3 + ε and 1/2 + ε, as reported in Balogh, Békési, Dósa, Epstein and Levin, Section 1; Yao's full text, and so his theorem number and proof, were not inspected. The input has three phases of 6 * m items each, of sizes just above 1/7, 1/3 and 1/2. Here the capacity is 41 and the sizes are 6, 14 and 21. These give the same 20 feasible bin patterns (counts of the three sizes that fit into one bin) as 1/7 + ε, 1/3 + ε and 1/2 + ε with capacity 1, and 41 is the smallest capacity with this property. The optima after the three phases are m, 3 * m and 6 * m (isPacking_yao₁ and le_length_of_isPacking_yao₁, and so on).

OnlinePacker.yao_lower_bound: for every online packer A and every m, after one of the three phases A uses at least 3/2 times the optimum, exactly, with no additive constant. Since the packer only sees a prefix, it cannot tell at which phase the input stops.

The certificate. Give the items of sizes 6, 14 and 21 the weights 1, 2 and 2 (yaoWeight). For every bin b with b.sum ≤ 41,

weight b ≤ 2 + 2 * [b has a 6] + 2 * [b has a 6 or a 14] (sum_map_yaoWeight_le).

omega checks this from 6 * #6 + 14 * #14 + 21 * #21 ≤ 41, so the certificate is checked against all 20 feasible patterns (#6, #14, #21); the test file also lists the 20 patterns and checks the inequality on each by decide. Equality holds for the patterns (6, 0, 0), (4, 1, 0), (2, 2, 0), (0, 2, 0), (0, 1, 1) and (0, 0, 1). Summed over the final bins, the left side is the total weight 30 * m. Bins holding a 6 already exist after the first phase, and bins holding a 6 or a 14 after the second (OnlinePacker.countP_any_runFrom). So, writing F₁, F₂ and F₃ for the numbers of bins after the three phases, 30 * m ≤ 2 * F₁ + 2 * F₂ + 2 * F₃ (OnlinePacker.sum_map_yaoWeight_le_run). If 2 * F₁ < 3 * m, 2 * F₂ < 9 * m and 2 * F₃ < 18 * m, then 2 * F₁ + 2 * F₂ + 2 * F₃ < 30 * m, a contradiction. In linear-programming terms, the weights are the dual multipliers 3/10, 3/5 and 3/5 of the three item counts and the factor 2 is the multiplier 3/5 of each phase's ratio constraint, scaled by 10/3; an exact rational LP over the 20 patterns gives the optimal ratio 3/2 for this input, so the certificate is optimal, and the test file checks an online packer attaining 3/2 after every phase. The integer instance and the explicit certificate are a presentation chosen here; the bound and the item types are Yao's.

The last two phases alone give 4/3 (OnlinePacker.four_thirds_lower_bound), by the same certificate.

OnlinePacker.exists_ratio_violation_of_lt restates the bound: for a / b < 3/2 and every additive constant c, every online packer violates b * ALG ≤ a * OPT + c on some input.

Main definitions #

Main results #

References #

The weight of an item in Yao's certificate: 1 for size 6, 2 for sizes 14 and 21, and 0 otherwise.

theorem Cslib.Algorithms.Lean.BinPacking.sum_map_yaoWeight_le {b : List ℕ} (hb : b.sum ≤ 41) :
(List.map yaoWeight b).sum ≤ (2 + 2 * if (b.any fun (x : ℕ) => x == 6) = true then 1 else 0) + 2 * if (b.any fun (a : ℕ) => a == 6 || a == 14) = true then 1 else 0

The certificate. A bin of capacity 41 has weight at most 2, plus 2 if it holds a 6, plus 2 if it holds a 6 or a 14.

theorem Cslib.Algorithms.Lean.BinPacking.OnlinePacker.sum_map_yaoWeight_le_run (A : OnlinePacker 41) {l₁ l₂ l₃ : List ℕ} (h₂ : 6 ∉ l₂) (h₃ : 6 ∉ l₃ ∧ 14 ∉ l₃) (hle : ∀ a ∈ l₁ ++ l₂ ++ l₃, a ≤ 41) :
(List.map yaoWeight (l₁ ++ l₂ ++ l₃)).sum ≤ 2 * (A.run l₁).length + 2 * (A.run (l₁ ++ l₂)).length + 2 * (A.run (l₁ ++ l₂ ++ l₃)).length

Yao's counting. If the second phase has no 6 and the third has no 6 or 14, the total weight is at most twice the sum of the numbers of bins after the three phases.

theorem Cslib.Algorithms.Lean.BinPacking.OnlinePacker.yao_lower_bound (A : OnlinePacker 41) (m : ℕ) :
3 * m ≤ 2 * (A.run (List.replicate (6 * m) 6)).length ∨ 3 * (3 * m) ≤ 2 * (A.run (List.replicate (6 * m) 6 ++ List.replicate (6 * m) 14)).length ∨ 3 * (6 * m) ≤ 2 * (A.run (List.replicate (6 * m) 6 ++ List.replicate (6 * m) 14 ++ List.replicate (6 * m) 21)).length

Yao's lower bound. Against 6 * m items of size 6, then 6 * m of size 14, then 6 * m of size 21, in bins of capacity 41, every online packer uses at least 3/2 times the optimum after one of the three phases. The optima are m, 3 * m and 6 * m (le_length_of_isPacking_yao₁ and isPacking_yao₁, and so on).

The two-phase bound 4/3. Against 6 * m items of size 14, then 6 * m of size 21, every online packer uses at least 4/3 times the optimum (3 * m, then 6 * m, by isPacking_twoPhase₁ and le_length_of_isPacking_twoPhase₁, and so on) after one of the two phases.

The first phase fits into m bins.

The first two phases fit into 3 * m bins.

All three phases fit into 6 * m bins.

Every packing of the first phase has at least m bins: a bin holds at most six items of size 6.

Every packing of the first two phases has at least 3 * m bins: a bin holds at most two items of size 14.

Every packing of all three phases has at least 6 * m bins: a bin holds at most one item of size 21.

The 6 * m items of size 14 of the two-phase input fit into 3 * m bins.

Both phases of the two-phase input fit into 6 * m bins.

Every packing of 6 * m items of size 14 has at least 3 * m bins.

Every packing of both phases of the two-phase input has at least 6 * m bins.

Yao's lower bound, packaged. For every m there are items with an optimal packing Q of at least m bins on which the online packer A uses at least 3/2 * Q.length bins.

theorem Cslib.Algorithms.Lean.BinPacking.OnlinePacker.exists_ratio_violation_of_lt (A : OnlinePacker 41) {a b : ℕ} (hab : 2 * a < 3 * b) (c : ℕ) :
∃ (l : List ℕ) (Q : List (List ℕ)), IsPacking 41 l Q ∧ (∀ (Q' : List (List ℕ)), IsPacking 41 l Q' → Q.length ≤ Q'.length) ∧ a * Q.length + c < b * (A.run l).length

No online ratio below 3/2. If a / b < 3/2, then for every additive constant c some input has an optimal packing Q with a * Q.length + c < b * ALG.