# Bin packing problem

Short description: Mathematical and computational problem

The bin packing problem is an optimization problem, in which items of different sizes must be packed into a finite number of bins or containers, each of a fixed given capacity, in a way that minimizes the number of bins used. The problem has many applications, such as filling up containers, loading trucks with weight capacity constraints, creating file backups in media and technology mapping in FPGA semiconductor chip design.

Computationally, the problem is NP-hard, and the corresponding decision problem - deciding if items can fit into a specified number of bins - is NP-complete. Despite its worst-case hardness, optimal solutions to very large instances of the problem can be produced with sophisticated algorithms. In addition, many approximation algorithms exist. For example, the first fit algorithm provides a fast but often non-optimal solution, involving placing each item into the first bin in which it will fit. It requires Θ(n log n) time, where n is the number of items to be packed. The algorithm can be made much more effective by first sorting the list of items into decreasing order (sometimes known as the first-fit decreasing algorithm), although this still does not guarantee an optimal solution, and for longer lists may increase the running time of the algorithm. It is known, however, that there always exists at least one ordering of items that allows first-fit to produce an optimal solution.

There are many variations of this problem, such as 2D packing, linear packing, packing by weight, packing by cost, and so on. The bin packing problem can also be seen as a special case of the cutting stock problem. When the number of bins is restricted to 1 and each item is characterised by both a volume and a value, the problem of maximizing the value of items that can fit in the bin is known as the knapsack problem.

A variant of bin packing that occurs in practice is when items can share space when packed into a bin. Specifically, a set of items could occupy less space when packed together than the sum of their individual sizes. This variant is known as VM packing since when virtual machines (VMs) are packed in a server, their total memory requirement could decrease due to pages shared by the VMs that need only be stored once. If items can share space in arbitrary ways, the bin packing problem is hard to even approximate. However, if the space sharing fits into a hierarchy, as is the case with memory sharing in virtual machines, the bin packing problem can be efficiently approximated.

Another variant of bin packing of interest in practice is the so-called online bin packing. Here the items of different volume are supposed to arrive sequentially, and the decision maker has to decide whether to select and pack the currently observed item, or else to let it pass. Each decision is without recall. In contrast, offline bin packing allows rearranging the items in the hope of achieving a better packing once additional items arrive. This of course requires additional storage for holding the items to be rearranged.

## Formal statement

In Computers and Intractability:226 Garey and Johnson list the bin packing problem under the reference [SR1]. They define its decision variant as follows.

Instance: Finite set $\displaystyle{ I }$ of items, a size $\displaystyle{ s(i) \in \mathbb{Z}^+ }$ for each $\displaystyle{ i \in I }$, a positive integer bin capacity $\displaystyle{ B }$, and a positive integer $\displaystyle{ K }$.

Question: Is there a partition of $\displaystyle{ I }$ into disjoint sets $\displaystyle{ I_1,\dots, I_K }$ such that the sum of the sizes of the items in each $\displaystyle{ I_j }$ is $\displaystyle{ B }$ or less?

Note that in the literature often an equivalent notation is used, where $\displaystyle{ B = 1 }$ and $\displaystyle{ s(i) \in \mathbb{Q} \cap (0,1] }$ for each $\displaystyle{ i \in I }$. Furthermore, research is mostly interested in the optimization variant, which asks for the smallest possible value of $\displaystyle{ K }$. A solution is optimal if it has minimal $\displaystyle{ K }$. The $\displaystyle{ K }$-value for an optimal solution for a set of items $\displaystyle{ I }$ is denoted by $\displaystyle{ \mathrm{OPT}(I) }$ or just $\displaystyle{ \mathrm{OPT} }$ if the set of items is clear from the context.

A possible integer linear programming formulation of the problem is:

 minimize $\displaystyle{ K = \sum_{j=1}^n y_j }$ subject to $\displaystyle{ K \geq 1, }$ $\displaystyle{ \sum_{i \in I}^n s(i) x_{ij} \leq B y_j, }$ $\displaystyle{ \forall j \in \{1,\ldots,n\} }$ $\displaystyle{ \sum_{j=1}^n x_{ij} = 1, }$ $\displaystyle{ \forall i \in I }$ $\displaystyle{ y_j \in \{0,1\}, }$ $\displaystyle{ \forall j \in \{1,\ldots,n\} }$ $\displaystyle{ x_{ij} \in \{0,1\}, }$ $\displaystyle{ \forall i \in I \, \forall j \in \{1,\ldots,n\} }$

where $\displaystyle{ y_j = 1 }$ if bin $\displaystyle{ j }$ is used and $\displaystyle{ x_{ij} = 1 }$ if item $\displaystyle{ i }$ is put into bin $\displaystyle{ j }$.

## Hardness of bin packing

The bin packing problem is strongly NP-complete. This can be proven by reducing the strongly NP-complete 3-partition problem to bin packing.

Furthermore, there can be no approximation algorithm with absolute approximation ratio smaller than $\displaystyle{ 3/2 }$ unless $\displaystyle{ P = NP }$. This can be proven by a reduction from the partition problem: given an instance of Partition where the sum of all input numbers is 2 T, construct an instance of bin-packing in which the bin size is T. If there exists an equal partition of the inputs, then the optimal packing needs 2 bins; therefore, every algorithm with approximation ratio smaller than 3/2 must return less than 3 bins, which must be 2 bins. In contrast, if there is no equal partition of the inputs, then the optimal packing needs at least 3 bins.

On the other hand, bin packing is solvable in pseudo-polynomial time for any fixed number of bins $\displaystyle{ K }$, and solvable in polynomial time for any fixed bin capacity $\displaystyle{ B }$.

## Approximation algorithms for bin packing

To measure the performance of an approximation algorithm there are two approximation ratios considered in the literature. For a given list of items $\displaystyle{ L }$ the number $\displaystyle{ A(L) }$ denotes the number of bins used when algorithm $\displaystyle{ A }$ is applied to list $\displaystyle{ L }$, while $\displaystyle{ \mathrm{OPT}(L) }$ denotes the optimum number for this list. The absolute worst-case performance ratio $\displaystyle{ R_A }$ for an algorithm $\displaystyle{ A }$ is defined as

$\displaystyle{ R_A \equiv \inf\{r \geq 1 : A(L)/\mathrm{OPT}(L) \leq r \text{ for all lists } L\}. }$

On the other hand, the asymptotic worst-case ratio $\displaystyle{ R_A^{\infty} }$ is defined as

$\displaystyle{ R_A^\infty \equiv \inf\{ r \geq 1: \exists N \gt 0, A(L)/\mathrm{OPT}(L) \leq r \text{ for all lists } L \text{ with } \mathrm{OPT}(L) \geq N\}. }$

Equivalently, $\displaystyle{ R_A^{\infty} }$ is the smallest number such that, for some constant K, for all lists L:

$\displaystyle{ A(L) \leq R^{\infty}_A \cdot OPT(L) + K }$.

Additionally, one can restrict the lists to those for which all items have a size of at most $\displaystyle{ \alpha }$. For such lists, the bounded size performance ratios are denoted as $\displaystyle{ R_A(\text{size}\leq \alpha) }$ and $\displaystyle{ R_A^\infty(\text{size}\leq \alpha) }$.

Approximation algorithms for bin packing can be classified into two categories:

1. Online heuristics, that consider the items in a given order and place them one by one inside the bins. These heuristics are also applicable to the online version of this problem.
2. Offline heuristics, that modify the given list of items e.g. by sorting the items by size. These algorithms are no longer applicable to the online variant of this problem. However, they have an improved approximation guarantee while maintaining the advantage of their small time-complexity. A sub-category of offline heuristics is asymptotic approximation schemes. These algorithms have an approximation guarantee of the form $\displaystyle{ (1+\varepsilon)\mathrm{OPT}(L) + C }$ for some constant that may depend on $\displaystyle{ 1/\varepsilon }$. For an arbitrarily large $\displaystyle{ \mathrm{OPT}(L) }$ these algorithms get arbitrarily close to $\displaystyle{ \mathrm{OPT}(L) }$. However, this comes at the cost of a (drastically) increased time complexity compared to the heuristical approaches.

## Online heuristics

In the online version of the bin packing problem, the items arrive one after another and the (irreversible) decision where to place an item has to be made before knowing the next item or even if there will be another one. A diverse set of offline and online heuristics for bin-packing have been studied by David S. Johnson on his Ph.D. thesis.

### Single-class algorithms

There are many simple algorithms that use the following general scheme:

• For each item in the input list:
1. If the item fits into one of the currently open bins, then put it in one of these bins;
2. Otherwise, open a new bin and put the new item in it.

The algorithms differ in the criterion by which they choose the open bin for the new item in step 1 (see the linked pages for more information):

• Next Fit (NF) always keeps a single open bin. When the new item does not fit into it, it closes the current bin and opens a new bin. Its advantage is that it is a bounded-space algorithm, since it only needs to keep a single open bin in memory. Its disadvantage is that its asymptotic approximation ratio is 2. In particular, $\displaystyle{ NF(L) \leq 2 \cdot \mathrm{OPT}(L) -1 }$, and for each $\displaystyle{ N \in \mathbb{N} }$ there exists a list $\displaystyle{ L }$ such that $\displaystyle{ \mathrm{OPT}(L) = N }$ and $\displaystyle{ NF(L) = 2 \cdot \mathrm{OPT}(L) -2 }$. Its asymptotic approximation ratio can be somewhat improved based on the item sizes: $\displaystyle{ R_{NF}^\infty(\text{size}\leq\alpha) \leq 2 }$ for all $\displaystyle{ \alpha \geq 1/2 }$ and $\displaystyle{ R_{NF}^\infty(\text{size}\leq\alpha) \leq 1/(1-\alpha) }$ for all $\displaystyle{ \alpha \leq 1/2 }$. For each algorithm $\displaystyle{ A }$ that is an AnyFit-algorithm it holds that $\displaystyle{ R_{A}^{\infty}(\text{size}\leq\alpha)\leq R_{NF}^{\infty}(\text{size}\leq\alpha) }$.
• Next-k-Fit (NkF) is a variant of Next-Fit, but instead of keeping only one bin open, the algorithm keeps the last $\displaystyle{ k }$ bins open and chooses the first bin in which the item fits. Therefore, it is called a k-bounded space algorithm. For $\displaystyle{ k\geq 2 }$ the NkF delivers results that are improved compared to the results of NF, however, increasing $\displaystyle{ k }$ to constant values larger than $\displaystyle{ 2 }$ improves the algorithm no further in its worst-case behavior. If algorithm $\displaystyle{ A }$ is an AlmostAnyFit-algorithm and $\displaystyle{ m = \lfloor 1/\alpha\rfloor \geq 2 }$ then $\displaystyle{ R_{A}^{\infty}(\text{size}\leq\alpha)\leq R_{N2F}^{\infty}(\text{size}\leq\alpha) = 1+1/m }$.
• First-Fit (FF) keeps all bins open, in the order in which they were opened. It attempts to place each new item into the first bin in which it fits. Its approximation ratio is $\displaystyle{ FF(L) \leq \lfloor 1.7\mathrm{OPT}\rfloor }$, and there is a family of input lists $\displaystyle{ L }$ for which $\displaystyle{ FF(L) }$ matches this bound.
• Best-Fit (BF), too, keeps all bins open, but attempts to place each new item into the bin with the maximum load in which it fits. Its approximation ratio is identical to that of FF, that is: $\displaystyle{ BF(L) \leq \lfloor 1.7\mathrm{OPT}\rfloor }$, and there is a family of input lists $\displaystyle{ L }$ for which $\displaystyle{ BF(L) }$ matches this bound.
• Worst-Fit (WF) attempts to place each new item into the bin with the minimum load. It can behave as badly as Next-Fit, and will do so on the worst-case list for that $\displaystyle{ NF(L) = 2 \cdot \mathrm{OPT}(L) -2 }$. Furthermore, it holds that $\displaystyle{ R_{WF}^{\infty}(\text{size}\leq \alpha) = R_{NF}^{\infty}(\text{size}\leq \alpha) }$. Since WF is an AnyFit-algorithm, there exists an AnyFit-algorithm such that $\displaystyle{ R_{AF}^{\infty}(\alpha) = R_{NF}^{\infty}(\alpha) }$.
• Almost Worst-Fit (AWF) attempts to place each new item inside the second most empty open bin (or emptiest bin if there are two such bins). If it does not fit, it tries the most empty one. It has an asymptotic worst-case ratio of $\displaystyle{ 17/10 }$.

In order to generalize these results, Johnson introduced two classes of online heuristics called any-fit algorithm and almost-any-fit algorithm::470

• In an AnyFit (AF) algorithm, if the current nonempty bins are B1,...,Bj, then the current item will not be packed into Bj+1 unless it does not fit in any of B1,...,Bj. The FF, WF, BF and AWF algorithms satisfy this condition. Johnson proved that, for any AnyFit algorithm A and any $\displaystyle{ \alpha }$:

$\displaystyle{ R_{FF}^{\infty}(\alpha) \leq R_{A}^{\infty}(\alpha) \leq R_{WF}^{\infty}(\alpha) }$.

• In an AlmostAnyFit (AAF) algorithm, if the current nonempty bins are B1,...,Bj, and of these bins, Bk is the unique bin with the smallest load, then the current item will not be packed into Bk, unless it does not fit into any of the bins to its left. The FF, BF and AWF algorithms satisfy this condition, but WF does not. Johnson proved that, for any AAF algorithm A and any $\displaystyle{ \alpha }$:

$\displaystyle{ R_{A}^{\infty}(\alpha) = R_{FF}^{\infty}(\alpha) }$ In particular: $\displaystyle{ R_{A}^{\infty} = 1.7 }$.

### Refined algorithms

Better approximation ratios are possible with heuristics that are not AnyFit. These heuristics usually keep several classes of open bins, devoted to items of different size-ranges (see the linked pages for more information):

• Refined-first-fit bin packing (RFF) partitions the item sizes into four ranges: $\displaystyle{ (1/2,1] }$, $\displaystyle{ (2/5,1/2] }$, $\displaystyle{ (1/3,2/5] }$, and $\displaystyle{ (0,1/3] }$. Similarly, the bins are categorized into four classes. The next item $\displaystyle{ i \in L }$ is first assigned to its corresponding class. Inside that class, it is assigned to a bin using first-fit. Note that this algorithm is not an Any-Fit algorithm since it may open a new bin despite the fact that the current item fits inside an open bin. This algorithm was first presented by Andrew Chi-Chih Yao, who proved that it has an approximation guarantee of $\displaystyle{ RFF(L) \leq (5/3) \cdot \mathrm{OPT}(L) +5 }$ and presented a family of lists $\displaystyle{ L_k }$ with $\displaystyle{ RFF(L_k) = (5/3)\mathrm{OPT}(L_k) +1/3 }$ for $\displaystyle{ \mathrm{OPT}(L) = 6k+1 }$.
• Harmonic-k partitions the interval of sizes $\displaystyle{ (0,1] }$ based on a Harmonic progression into $\displaystyle{ k-1 }$ pieces $\displaystyle{ I_j := (1/(j+1),1/j] }$ for $\displaystyle{ 1\leq j \lt k }$ and $\displaystyle{ I_k := (0,1/k] }$ such that $\displaystyle{ \bigcup_{j=1}^k I_j = (0,1] }$. This algorithm was first described by Lee and Lee. It has a time complexity of $\displaystyle{ \mathcal{O}(|L|\log(|L|)) }$ and at each step, there are at most $\displaystyle{ k }$ open bins that can be potentially used to place items, i.e., it is a $\displaystyle{ k }$-bounded space algorithm. For $\displaystyle{ k \rightarrow \infty }$, its approximation ratio satisfies $\displaystyle{ R_{Hk}^{\infty} \approx 1.6910 }$, and it is asymptotically tight.
• Refined-harmonic combines ideas from Harmonic-k with ideas from Refined-First-Fit. It places the items larger than $\displaystyle{ 1/3 }$ similar as in Refined-First-Fit, while the smaller items are placed using Harmonic-k. The intuition for this strategy is to reduce the huge waste for bins containing pieces that are just larger than $\displaystyle{ 1/2 }$. This algorithm was first described by Lee and Lee. They proved that for $\displaystyle{ k = 20 }$ it holds that $\displaystyle{ R^\infty_{RH} \leq 373/228 }$.

### General lower bounds for online algorithms

Yao proved 1980 that there can be no online algorithm with asymptotic competitive ratio smaller than $\displaystyle{ 3/2 }$. Brown and Liang improved this bound to $\displaystyle{ 1.53635 }$. Afterward, this bound was improved to $\displaystyle{ 1.54014 }$ by Vliet. In 2012, this lower bound was again improved by Békési and Galambos to $\displaystyle{ 248/161 \approx 1.54037 }$.

### Comparison table

Algorithm Approximation guarantee Worst case list $\displaystyle{ L }$ Time-complexity
Next-fit (NF) $\displaystyle{ NF(L) \leq 2 \cdot \mathrm{OPT}(L) -1 }$ $\displaystyle{ NF(L) = 2 \cdot \mathrm{OPT}(L) -2 }$ $\displaystyle{ \mathcal{O}(|L|) }$
First-fit (FF) $\displaystyle{ FF(L) \leq \lfloor 1.7\mathrm{OPT}(L)\rfloor }$ $\displaystyle{ FF(L) = \lfloor 1.7\mathrm{OPT}(L)\rfloor }$ $\displaystyle{ \mathcal{O}(|L|\log(|L|)) }$
Best-fit (BF) $\displaystyle{ BF(L) \leq \lfloor 1.7\mathrm{OPT}(L) \rfloor }$ $\displaystyle{ BF(L) =\lfloor 1.7\mathrm{OPT}(L) \rfloor }$ $\displaystyle{ \mathcal{O}(|L|\log(|L|)) }$
Worst-Fit (WF) $\displaystyle{ WF(L) \leq 2 \cdot \mathrm{OPT}(L) -1 }$ $\displaystyle{ WF(L) = 2 \cdot \mathrm{OPT}(L) -2 }$ $\displaystyle{ \mathcal{O}(|L|\log(|L|)) }$
Almost-Worst-Fit (AWF) $\displaystyle{ R^{\infty}_{AWF} \leq 17/10 }$ $\displaystyle{ R^{\infty}_{AWF} = 17/10 }$ $\displaystyle{ \mathcal{O}(|L|\log(|L|)) }$
Refined-First-Fit (RFF) $\displaystyle{ RFF(L) \leq (5/3) \cdot \mathrm{OPT}(L) +5 }$ $\displaystyle{ RFF(L)=(5/3)\mathrm{OPT}(L) +1/3 }$ (for $\displaystyle{ \mathrm{OPT}(L) = 6k+1 }$) $\displaystyle{ \mathcal{O}(|L|\log(|L|)) }$
Harmonic-k (Hk) $\displaystyle{ R_{Hk}^{\infty} \leq 1.69103 }$ for $\displaystyle{ k \rightarrow \infty }$ $\displaystyle{ R_{Hk}^{\infty} \geq 1.69103 }$ $\displaystyle{ \mathcal{O}(|L|\log(|L|) }$
Refined Harmonic (RH) $\displaystyle{ R_{RH}^{\infty} \leq 373/228 \approx 1.63597 }$ $\displaystyle{ \mathcal{O}(|L|) }$
Modified Harmonic (MH) $\displaystyle{ R_{MH}^{\infty} \leq 538/33 \approx 1.61562 }$
Modified Harmonic 2 (MH2) $\displaystyle{ R_{MH2}^{\infty} \leq 239091/148304 \approx 1.61217 }$
Harmonic + 1 (H+1) $\displaystyle{ R_{H+1}^\infty \geq 1.59217 }$
Harmonic ++ (H++) $\displaystyle{ R_{H++}^\infty \leq 1.58889 }$ $\displaystyle{ R_{H++}^{\infty} \geq 1.58333 }$

## Offline algorithms

In the offline version of bin packing, the algorithm can see all the items before starting to place them into bins. This allows to attain improved approximation ratios.

### Multiplicative approximation

The simplest technique used by offline algorithms is:

• Ordering the input list by descending size;
• Run an online algorithm on the ordered list.

Johnson proved that any AnyFit algorithm A that runs on a list ordered by descending size has an asymptotic approximation ratio of

$\displaystyle{ 1.22 \approx \frac{11}{9} \leq R^{\infty}_A \leq \frac{5}{4} = 1.25 }$.

• First-fit-decreasing (FFD) - orders the items by descending size, then calls First-Fit. Its approximation ratio is $\displaystyle{ FFD(I) = 11/9 \mathrm{OPT}(I) +6/9 }$, and this is tight.
• Next-fit-decreasing (NFD) - orders the items by descending size, then calls Next-Fit. Its approximate ratio is slightly less than 1.7 in the worst case. It has also been analyzed probabilistically. Next-Fit packs a list and its inverse into the same number of bins. Therefore, Next-Fit-Increasing has the same performance as Next-Fit-Decreasing.
• 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. Its approximation guarantee is $\displaystyle{ MFFD(I) \leq (71/60)\mathrm{OPT}(I) + 1 }$.

Fernandez de la Vega and Lueker presented a PTAS for bin packing. For every $\displaystyle{ \varepsilon\gt 0 }$, their algorithm finds a solution with size at most $\displaystyle{ (1+\varepsilon)\mathrm{OPT} + 1 }$ and runs in time $\displaystyle{ \mathcal{O}(n\log(1/\varepsilon)) + \mathcal{O}_{\varepsilon}(1) }$, where $\displaystyle{ \mathcal{O}_{\varepsilon}(1) }$ denotes a function only dependent on $\displaystyle{ 1/\varepsilon }$. For this algorithm, they invented the method of adaptive input rounding: the input numbers are grouped and rounded up to the value of the maximum in each group. This yields an instance with a small number of different sizes, which can be solved exactly using the configuration linear program.

The Karmarkar-Karp bin packing algorithm finds a solution with size at most $\displaystyle{ \mathrm{OPT} + \mathcal{O}(\log^2(OPT)) }$, and runs in time polynomial in $\displaystyle{ n }$ (the polynomial has a high degree - at least 8).

Rothvoss presented an algorithm that generates a solution with at most $\displaystyle{ \mathrm{OPT} + O(\log(\mathrm{OPT})\cdot \log\log(\mathrm{OPT})) }$ bins.

Hoberg and Rothvoss improved this algorithm to generate a solution with at most $\displaystyle{ \mathrm{OPT} + O(\log(\mathrm{OPT})) }$ bins. The algorithm is randomized, and its running-time is polynomial in $\displaystyle{ n }$.

### Comparison table

Algorithm Approximation guarantee Worst case instance
First-fit-decreasing (FFD) $\displaystyle{ FFD(I) \leq 11/9 \mathrm{OPT}(I) +6/9 }$ $\displaystyle{ FFD(I) = 11/9 \mathrm{OPT}(I) +6/9 }$
Modified-first-fit-decreasing (MFFD) $\displaystyle{ MFFD(I) \leq (71/60)\mathrm{OPT}(I) + 1 }$ $\displaystyle{ R_{MFFD}^\infty \geq 71/60 }$
Karmarkar and Karp $\displaystyle{ KK(I) \leq OPT(I) + O(\log^2{OPT(I)}) }$
Rothvoss $\displaystyle{ HB(I) \leq OPT(I) + O(\log{OPT(I)}\log\log{OPT(I)}) }$
Hoberg and Rothvoss $\displaystyle{ HB(I) \leq OPT(I) + O(\log{OPT(I)}) }$

### Exact algorithms

Martello and Toth developed an exact algorithm for the 1-dimensional bin-packing problem, called MTP. A faster alternative is the Bin Completion algorithm proposed by Korf in 2002 and later improved.

A further improvement was presented by Schreiber and Korf in 2013. The new Improved Bin Completion algorithm is shown to be up to five orders of magnitude faster than Bin Completion on non-trivial problems with 100 items, and outperforms the BCP (branch-and-cut-and-price) algorithm by Belov and Scheithauer on problems that have fewer than 20 bins as the optimal solution. Which algorithm performs best depends on problem properties like number of items, optimal number of bins, unused space in the optimal solution and value precision.

### Small number of different sizes

A special case of bin packing is when there is a small number d of different item sizes. There can be many different items of each size. This case is also called high-multiplicity bin packing, and It admits more efficient algorithms than the general problem.

## Cardinality constraints on the bins

There is a variant of bin packing in which there are cardinality constraints on the bins: each bin can contain at most k items, for some fixed integer k.

• Krause, Shen and Schwetman introduce this problem as a variant of optimal job scheduling: a computer has some k processors. There are some n jobs that take unit time (1), but have different memory requirements. Each time-unit is considered a single bin. The goal is to use as few bins (=time units) as possible, while ensuring that in each bin, at most k jobs run. They present several heuristic algorithms that find a solution with at most $\displaystyle{ 2 OPT }$ bins.
• Kellerer and Pferschy present an algorithm with run-time $\displaystyle{ O(n^2 \log{n}) }$, that finds a solution with at most $\displaystyle{ \lceil\frac{3}{2}\mathrm{OPT}\rceil }$ bins. Their algorithm performs a binary search for OPT. For every searched value m, it tries to pack the items into 3m/2 bins.

There are various ways to extend the bin-packing model to more general cost and load functions:

• Anily, Bramel and Simchi-Levi study a setting where the cost of a bin is a concave function of the number of items in the bin. The objective is to minimize the total cost rather than the number of bins. They show that next-fit-increasing bin packing attains an absolute worst-case approximation ratio of at most 7/4, and an asymptotic worst-case ratio 1.691 for any concave and monotone cost function.
• Cohen, Keller, Mirrokni and Zadimoghaddam study a setting where the size of the items is not known in advance, but it is a random variable. This is particularly common in cloud computing environments. While there is an upper bound on the amount of resources a certain user needs, most users use much less than the capacity. Therefore, the cloud manager may gain a lot by slight overcommitment. This induces a variant of bin packing with chance constraints: the probability that the sum of sizes in each bin is at most B should be at least p, where p is a fixed constant (standard bin packing corresponds to p=1). They show that, under mild assumptions, this problem is equivalent to a submodular bin packing problem, in which the "load" in each bin is not equal to the sum of items, but to a certain submodular function of it.

## Related problems

In the bin packing problem, the size of the bins is fixed and their number can be enlarged (but should be as small as possible).

In contrast, in the multiway number partitioning problem, the number of bins is fixed and their size can be enlarged. The objective is to find a partition in which the bin sizes are as nearly equal is possible (in the variant called multiprocessor scheduling problem or minimum makespan problem, the goal is specifically to minimize the size of the largest bin).

In the inverse bin packing problem, both the number of bins and their sizes are fixed, but the item sizes can be changed. The objective is to achieve the minimum perturbation to the item size vector so that all the items can be packed into the prescribed number of bins.

In the maximum resource bin packing problem, the goal is to maximize the number of bins used, such that, for some ordering of the bins, no item in a later bin fits in an earlier bin. In a dual problem, the number of bins is fixed, and the goal is to minimize the total number or the total size of items placed into the bins, such that no remaining item fits into an unfilled bin.

In the bin covering problem, the bin size is bounded from below: the goal is to maximize the number of bins used such that the total size in each bin is at least a given threshold.

In the fair indivisible chore allocation problem (a variant of fair item allocation), the items represents chores, and there are different people each of whom attributes a different difficulty-value to each chore. The goal is to allocate to each person a set of chores with an upper bound on its total difficulty-value (thus, each person corresponds to a bin). Many techniques from bin packing are used in this problem too.

In the guillotine cutting problem, both the items and the "bins" are two-dimensional rectangles rather than one-dimensional numbers, and the items have to be cut from the bin using end-to-end cuts.

In the selfish bin packing problem, each item is a player who wants to minimize its cost.

There is also a variant of bin packing in which the cost that should be minimized is not the number of bins, but rather a certain concave function of the number of items in each bin.

Other variants are two-dimensional bin packing, three-dimensional bin packing, bin packing with delivery,

## Resources

• BPPLIB - a library of surveys, codes, benchmarks, generators, solvers, and bibliography.