User:Malin Rau/sandbox

Comparison of heuristics
In his doctoral thesis Johnson compared many of the above-mentioned algorithms and proved the following results

There exist lists $$L$$ with $$\mathrm{OPT}(L)$$ arbitrarily large, such that
 * $$\frac{BF(L)}{FF(L)} = \frac{BF(L)}{NkF(L)} = \frac{BF(L)}{AWF(L)} = \frac{4}{3}$$
 * $$\frac{FF(L)}{BF(L)} = \frac{NkF(L)}{BF(L)} = \frac{AWF(L)}{BF(L)} = \frac{3}{2}$$
 * $$\frac{AWF(L)}{FF(L)} = \frac{5}{4}$$
 * $$\frac{FF(L)}{AWF(L)} \rightarrow \frac{5}{4}$$
 * $$\frac{NkF(L)}{FF(L)} = \frac{NkF(L)}{AWF(L)} \rightarrow \frac{5}{4}$$

First-fit algorithm
This is a straightforward greedy approximation algorithm. The algorithm processes the items in arbitrary order. For each item, it attempts to place the item in the first bin that can accommodate the item. If no bin is found, it opens a new bin and puts the item within the new bin.

This algorithm achieves an approximation factor of 2; the number of bins used by this algorithm is no more than twice the optimal number of bins. In other words, it is impossible for 2 bins to be at most half full because such a possibility implies that at some point, exactly one bin was at most half full and a new one was opened to accommodate an item of size at most $$B/2$$. But since the first one has at least a space of $$B/2$$, the algorithm will not open a new bin for any item whose size is at most $$B/2$$. Only after the bin fills with more than $$B/2$$ or if an item with a size larger than $$B/2$$ arrives, the algorithm may open a new bin.

Thus if we have $$K$$ bins, at least $$K-1$$ bins are more than half full. Therefore, $$\sum_{i \in I} s(i)>\tfrac{K-1}{2}B$$. Because $$\tfrac{\sum_{i \in I} s(i)}{B}$$ is a lower bound of the optimum value $$\mathrm{OPT}$$, we get that $$K-1<2\mathrm{OPT}$$ and therefore $$K \leq 2\mathrm{OPT}$$. See the analysis below for better approximation results.

Modified first fit decreasing (MFFD) improves on FFD for items larger than half a bin by classifying items by size into four size classes large, medium, small, and tiny, corresponding to items with size > 1/2 bin, > 1/3 bin, > 1/6 bin, and smaller items respectively. Then it proceeds through five phases:


 * 1) Allot a bin for each large item, ordered largest to smallest.
 * 2) Proceed forward through the bins. On each: If the smallest remaining medium item does not fit, skip this bin. Otherwise, place the largest remaining medium item that fits.
 * 3) Proceed backward through those bins that do not contain a medium item. On each: If the two smallest remaining small items do not fit, or if there is only one small item remaining, skip this bin. Otherwise, place the smallest remaining small item and the largest remaining small item that fits.
 * 4) Proceed forward through all bins. If the smallest remaining item of any size class does not fit, skip this bin. Otherwise, place the largest item that fits and stay on this bin.
 * 5) Use FFD to pack the remaining items into new bins.

Analysis of approximate algorithms
The best fit decreasing and first fit decreasing strategies are among the simplest heuristic algorithms for solving the bin packing problem. They have been shown to use no more than 11/9 OPT + 1 bins (where OPT is the number of bins given by the optimal solution). The simpler of these, the First Fit Decreasing (FFD) strategy, operates by first sorting the items to be inserted in decreasing order by their sizes, and then inserting each item into the first bin in the list with sufficient remaining space. Sometimes, however, one does not have the option to sort the input, for example, when faced with an online bin packing problem. In 2007, it was proven that the bound 11/9 OPT + 6/9 for FFD is tight. MFFD uses no more than 71/60 OPT + 1 bins (i.e. bounded by about 1.18 OPT, compared to about 1.22 OPT for FFD). In 2013, Dósa and Sgall gave a tight upper bound for the first-fit (FF) strategy, showing that it never needs more than 17/10 OPT bins for any input.

(I)LP formulations and the MIRUP
A possible integer linear programming formulation of the problem is: where $$ y_j = 1$$ if bin $$j$$ is used and $$ x_{ij} = 1$$ if item $$i$$ is put into bin $$j$$.

Gilmore-Gomory LP Relaxation: