First Fit #
First Fit keeps every bin open. It places each item into the first bin with enough room, opening
a new last bin when no bin has room. So every item of a bin did not fit into any earlier bin,
even into that bin's final contents
(Cslib.Algorithms.Lean.BinPacking.pairwise_forall_lt_sum_add_firstFit), and as no bin is empty
(Cslib.Algorithms.Lean.BinPacking.ne_nil_of_mem_firstFit), any two bins it returns are jointly
overfull (Cslib.Algorithms.Lean.BinPacking.pairwise_firstFit). So First Fit uses fewer than
twice as many bins as any packing (Cslib.Algorithms.Lean.BinPacking.length_firstFit_lt), that
is at most 2 * OPT - 1 bins, a slight sharpening of the bound 2 * OPT + 1 of
Williamson and Shmoys, Section 3.3 by the same pairing argument. Johnson's
thesis Johnson analyses Next Fit and First Fit; by the notes to Chapter 3 of
Williamson and Shmoys, their First Fit argument uses the thesis's analysis of Next Fit. The
asymptotic bound 17/10 * OPT + 2 of
Johnson, Demers, Ullman, Garey and Graham, sharpened to
17/10 * OPT + 4/5, is in CslibFrontier.Algorithms.Lean.BinPacking.FirstFitWeight.
Main definitions #
Cslib.Algorithms.Lean.BinPacking.firstFitInsert: insert an item into the first bin with room.Cslib.Algorithms.Lean.BinPacking.firstFit: the First Fit algorithm.
Main results #
Cslib.Algorithms.Lean.BinPacking.isPacking_firstFit: First Fit returns a packing.Cslib.Algorithms.Lean.BinPacking.pairwise_forall_lt_sum_add_firstFit: every item of a later bin of First Fit overflows every earlier bin.Cslib.Algorithms.Lean.BinPacking.ne_nil_of_mem_firstFit: First Fit opens no empty bin.Cslib.Algorithms.Lean.BinPacking.pairwise_firstFit: any two bins of First Fit are jointly overfull.Cslib.Algorithms.Lean.BinPacking.length_firstFit_lt: First Fit uses fewer than twice as many bins as any packing.
References #
The First Fit rule: every item of a bin opened later did not fit into an earlier bin, even into that bin's final contents.