Bin Packing Algorithms.
1. A classical problem, with long and interesting history.
One of the early problems shown to be intractable. Lends to simple
algorithms that require clever analysis.
2. You are given N items, of sizes s1, s2, .
.., sN. All sizes are such
that 0 < si <= 1. You have an infinite supply of unit size bins.
Goal is to pack the items in as few bins as possible.
EXAMPLE: 0.2, 0.5, 0.4, 0.7, 0.1, 0.3, 0.8
3. Many many applications:
placing data on multiple disks; job scheduling;
packing advertisements in fixed length radio/TV station breaks;
or storing a large collection of music onto tapes/CD's, etc.
4. Two versions.
Online---items arrive one at a time (in unknown order), each must
be put in a bin, before considering the next item.
Offline--all items given upfront.
The online problem would seem more difficult. In fact, it's easy to
convince ourselves that a ONLINE algorithm cannot always get the
optimal solution. Consider the following input:
M "small" items of size 1/2 - e, followed by M "large" items of
size 1/2 + e, for any 0 < e < 0.001.
The optimal solution is to pack them in pairs (one small, one large);
this requires M bins.
Now, the ONLINE algorithm doesn't know what's coming down the pipe,
or even how long the pipe is. So, for instance, what should it do
with the first M small items. If it packs 2 of them in each bin,
then it will be stuck when the second half arrives, with M large
On the other hand, if it puts one small items in each bin
in the first half, then we can just stop the input right there, in
which case the algorithm would have used twice as many bins as needed.
This ad hoc argument is not a proof. But we can turn this into a
formal proof, and show the following LOWER BOUND.
There exist inputs that can force ANY online bin-packing algorithm
to use at least 4/3 times the optimal number of bins.
An important observation is that because we (the adversary) can
truncate the input whenever we like, the algorithm must maintain
its guaranteed ratio AT ALL points during its course.