Online bin packing #
An online bin-packing algorithm receives the items one at a time. It puts each item into a bin
that has room for it or opens a new bin, without seeing the items still to come, and it never
moves an item again. This file models deterministic online algorithms with capacity C as
OnlinePacker C. The rule place picks a bin for the next item from the items seen so far and
the current bins. If the chosen bin has no room, or no bin is chosen, the item opens a new last
bin (onlineInsert), so every rule yields a valid packing (OnlinePacker.isPacking_run). Every
deterministic online algorithm is such a rule, since its state after a prefix of the input is a
function of that prefix.
Two facts make lower bounds against all online algorithms possible. The packing of l₁ ++ l₂
continues the packing of l₁ (OnlinePacker.run_append). And items that fail a predicate do
not change the number of bins holding an item that satisfies it (OnlinePacker.countP_any_runFrom):
such bins all exist before the items arrive. First Fit is an online packer
(run_firstFitPacker).
Main definitions #
Cslib.Algorithms.Lean.BinPacking.onlineInsert: put an item into a chosen bin if it fits, and otherwise into a new last bin.Cslib.Algorithms.Lean.BinPacking.OnlinePacker: a deterministic online bin-packing algorithm.Cslib.Algorithms.Lean.BinPacking.OnlinePacker.run: the packing an online packer builds.Cslib.Algorithms.Lean.BinPacking.firstFitPacker: First Fit as an online packer.
Main results #
Cslib.Algorithms.Lean.BinPacking.OnlinePacker.isPacking_run: an online packer packs every list of items that fit into a bin.Cslib.Algorithms.Lean.BinPacking.OnlinePacker.run_append: the packing ofl₁ ++ l₂continues the packing ofl₁.Cslib.Algorithms.Lean.BinPacking.OnlinePacker.countP_any_runFrom: items failingpleave the number of bins with an item satisfyingpunchanged.Cslib.Algorithms.Lean.BinPacking.run_firstFitPacker: the online packerfirstFitPackerisfirstFit.
Inserting an item that fails p does not change the number of bins holding an item that
satisfies p.
A deterministic online bin-packing algorithm with bin capacity C.
The bin chosen for the next item
a, from the items seen so far and the current bins;none, or a bin without room, opens a new bin.
The packing of l that A builds online.
An online packer packs every list of items that fit into a bin.
First Fit as an online packer: the first bin with room.
The online packer firstFitPacker is First Fit.