Bin covering problem

From HandWiki
Short description: Operations research problem of packing items into the largest number of bins

In the bin covering problem, items of different sizes must be packed into a finite number of bins or containers, each of which must contain at least a certain given total size, in a way that maximizes the number of bins used.

This problem is a dual of the bin packing problem: in bin covering, the bin sizes are bounded from below and the goal is to maximize their number; in bin packing, the bin sizes are bounded from above and the goal is to minimize their number.[1]

The problem is NP-hard, but there are various efficient approximation algorithms:

  • Algorithms covering at least 1/2, 2/3 or 3/4 of the optimum bin count asymptotically, running in time [math]\displaystyle{ O(n), O(n \log n), O(n {\log}^2 n) }[/math] respectively.[1][2]
  • An asymptotic PTAS, algorithms with bounded worst-case behavior whose expected behavior is asymptotically-optimal for some discrete distributions, and a learning algorithm with asymptotically optimal expected behavior for all discrete distributions.[3]
  • An asymptotic FPTAS.[4]

The bidirectional bin-filling algorithm

Csirik, Frenk, Lebbe and Zhang[2]:16-19 present the following simple algorithm for 2/3 approximation. Suppose the bin size is 1 and there are n items.

  • Order the items from the largest (1) to smallest (n).
  • Fill a bin with the largest items: 1, 2, ..., m, where m is the largest integer for which the sum of items 1, ..., m is less than 1.
  • Add to this bin the smallest items: n, n-1, ..., until its value raises above 1.

For any instance I, denote by [math]\displaystyle{ \mathrm{OPT}(I) }[/math] the number of bins in the optimal solution, and by [math]\displaystyle{ \mathrm{BDF}(I) }[/math] the number of full bins in the bidirectional filling algorithm. Then [math]\displaystyle{ \mathrm{BDF}(I) \geq (2/3) \mathrm{OPT}(I) - (2/3) }[/math], or equivalently, [math]\displaystyle{ \mathrm{OPT}(I) \leq (3/2) \mathrm{BDF}(I)+1 }[/math].

Proof

For the proof, the following terminology is used.

  • [math]\displaystyle{ t := \mathrm{BDF}(I) = }[/math] the number of bins filled by the algorithm.
  • [math]\displaystyle{ B_1,\ldots,B_t := }[/math] the t bins filled by the algorithm.
  • Initial items - the t items that are inserted first into each of the t bins.
  • Final items - the t items that are inserted last into each of the t bins.
  • Middle items - all items that are neither initial nor final.
  • [math]\displaystyle{ w }[/math] := the number of final items that are at most 1/2 (equivalently, [math]\displaystyle{ t-w }[/math] is the number of final items larger than 1/2).

The sum of each bin [math]\displaystyle{ B_1,\ldots,B_t }[/math] is at least 1, but if the final item is removed from it, then the remaining sum is smaller than 1. Each of the first [math]\displaystyle{ w }[/math] bins [math]\displaystyle{ B_1,\ldots,B_w }[/math] contains an initial item, possibly some middle items, and a final item. Each of the last [math]\displaystyle{ t-w }[/math] bins [math]\displaystyle{ B_{w+1},\ldots,B_t }[/math] contains only an initial item and a final item, since both of them are larger than 1/2 and their sum is already larger than 1.

The proof considers two cases.

The easy case is [math]\displaystyle{ w = t }[/math], that is, all final items are smaller than 1/2. Then, the sum of every filled [math]\displaystyle{ B_i }[/math] is at most 3/2, and the sum of remaining items is at most 1, so the sum of all items is at most [math]\displaystyle{ 3t/2+1 }[/math]. On the other hand, in the optimal solution the sum of every bin is at least 1, so the sum of all items is at least [math]\displaystyle{ \mathrm{OPT}(I) }[/math]. Therefore, [math]\displaystyle{ \mathrm{OPT}(I) \leq 3t/2+1 }[/math] as required.

The hard case is [math]\displaystyle{ w \lt t }[/math], that is, some final items are larger than 1/2. We now prove an upper bound on [math]\displaystyle{ \mathrm{OPT}(I) }[/math] by presenting it as a sum [math]\displaystyle{ \mathrm{OPT}(I) = |K_0|+|K_1|+|K_2| }[/math] where:

  • [math]\displaystyle{ K_0 := }[/math] the optimal bins with no initial/final items (only middle items).
  • [math]\displaystyle{ K_1 := }[/math] the optimal bins with exactly one initial/final item (and some middle items).
  • [math]\displaystyle{ K_2 := }[/math] the optimal bins with two or more initial/final items (and some middle items).

We focus first on the optimal bins in [math]\displaystyle{ K_0 }[/math] and [math]\displaystyle{ K_1 }[/math]. We present a bijection between the items in each such bin to some items in [math]\displaystyle{ B_1,\ldots,B_t }[/math] which are at least as valuable.

  • The single initial/final item in the [math]\displaystyle{ K_1 }[/math] bins is mapped to the initial item in [math]\displaystyle{ B_1,\ldots,B_{|K_1|} }[/math]. Note that these are the largest initial items.
  • The middle items in the [math]\displaystyle{ K_0 }[/math] and [math]\displaystyle{ K_1 }[/math] bins are mapped to the middle items in [math]\displaystyle{ B_1,\ldots,B_{w} }[/math]. Note that these bins contain all the middle items.
  • Therefore, all items in [math]\displaystyle{ K_0 }[/math] and [math]\displaystyle{ K_1 }[/math] are mapped to all non-final items in [math]\displaystyle{ B_1,\ldots,B_{|K_1|} }[/math], plus all middle items in [math]\displaystyle{ B_{|K_1|+1},\ldots,B_{w} }[/math].
  • The sum of each bin [math]\displaystyle{ B_1,\ldots,B_{w} }[/math] without its final item is less than 1. Moreover, the initial item is more than 1/2, so the sum of only the middle items is less than 1/2. Therefore, the sum of all non-final items in [math]\displaystyle{ B_1,\ldots,B_{|K_1|} }[/math], plus all middle items in [math]\displaystyle{ B_{|K_1|+1},\ldots,B_{w} }[/math], is at most [math]\displaystyle{ |K_1| + (w-|K_1|)/2 = (|K_1|+w)/2 }[/math].
  • The sum of each optimal bin is at least 1. Hence: [math]\displaystyle{ |K_0| + |K_1| \leq (|K_1|+w)/2 }[/math], which implies [math]\displaystyle{ 2 |K_0| + |K_1| \leq w \leq t }[/math].

We now focus on the optimal bins in [math]\displaystyle{ K_1 }[/math] and [math]\displaystyle{ K_2 }[/math].

  • The total number of initial/final items in the [math]\displaystyle{ K_1 }[/math] and [math]\displaystyle{ K_2 }[/math] bins is at least [math]\displaystyle{ |K_1| + 2|K_2| }[/math], but their total number is also [math]\displaystyle{ 2 t }[/math] since there are exactly two initial/final items in each bin. Therefore, [math]\displaystyle{ |K_1| + 2|K_2|\leq 2 t }[/math].
  • Summing the latter two inequalities implies that [math]\displaystyle{ 2 \mathrm{OPT}(I) \leq 3 t }[/math], which implies [math]\displaystyle{ \mathrm{OPT}(I) \leq 3 t/2 }[/math].

Tightness

The 2/3 factor is tight for BDF. Consider the following instance (where [math]\displaystyle{ \epsilon\gt 0 }[/math] is sufficiently small):[math]\displaystyle{ \begin{align} 1-6 k \epsilon, ~&~ \tfrac{1}{2}-\epsilon, \ldots, \tfrac{1}{2}-\epsilon, ~&~ \epsilon,\ldots,\epsilon \\ ~&~ \{\cdots 6k ~ \text{units} \cdots \} ~&~ \{ \cdots 6k ~ \text{units} \cdots \} \end{align} }[/math]BDF initializes the first bin with the largest item and fills it with the [math]\displaystyle{ 6k }[/math] smallest items. Then, the remaining [math]\displaystyle{ 6k }[/math] items can cover bins only in triplets, so all in all [math]\displaystyle{ 2k+1 }[/math] bins are filled. But in OPT one can fill [math]\displaystyle{ 3k }[/math] bins, each of which contains two of the middle-sized items and two small items.

Three-classes bin-filling algorithm

Csirik, Frenk, Lebbe and Zhang[2]:19-24 present another algorithm that attains a 3/4 approximation. The algorithm orders the items from large to small, and partitions them into three classes:

  • X: The items with size at least 1/2;
  • Y: The items with size less than 1/2 and at least 1/3;
  • Z: The items with size less than 1/3.

The algorithm works in two phases. Phase 1:

  • Initialize a new bin with either the largest item in X, or the two largest items in Y, whichever is larger. Note that in both cases, the initial bin sum is less than 1.
  • Fill the new bin with items from Z in increasing order of value.
  • Repeat until either X U Y or Z are empty.

Phase 2:

  • If X U Y is empty, fill bins with items from Z by the simple next-fit rule.
  • If Z is empty, pack the items remaining in X by pairs, and those remaining in Y by triplets.

In the above example, showing the tightness of BDF, the sets are:[math]\displaystyle{ \begin{align} 1-6 k \epsilon, ~&~ \tfrac{1}{2}-\epsilon, \ldots, \tfrac{1}{2}-\epsilon, ~&~ \epsilon,\ldots,\epsilon \\ \{ |X|=1 \} ~&~ \{ \cdots |Y|=6k \cdots \} ~&~ \{ \cdots |Z|=6k \cdots \} \end{align} }[/math]TCF attains the optimal outcome, since it initializes all [math]\displaystyle{ 3k }[/math] bins with pairs of items from Y, and fills them with pairs of items from Z.

For any instance I, denote by [math]\displaystyle{ \mathrm{OPT}(I) }[/math] the number of bins in the optimal solution, and by [math]\displaystyle{ \mathrm{TCF}(I) }[/math] the number of full bins in the three-classes filling algorithm. Then [math]\displaystyle{ \mathrm{TCF}(I) \geq (3/4) (\mathrm{OPT}(I) - 4) }[/math].

The 3/4 factor is tight for TCF. Consider the following instance (where [math]\displaystyle{ \epsilon\gt 0 }[/math] is sufficiently small):

[math]\displaystyle{ \begin{align} \tfrac{1}{2}-6 k \epsilon, \tfrac{1}{2}-6 k \epsilon, ~&~ \tfrac{1}{3}-\epsilon, \ldots, \tfrac{1}{3}-\epsilon, ~&~ \epsilon,\ldots,\epsilon \\ ~&~ \{\cdots 12k ~ \text{units} \cdots \} ~&~ \{ \cdots 12k ~ \text{units} \cdots \} \end{align} }[/math]

TCF initializes the first bin with the largest two items, and fills it with the [math]\displaystyle{ 12k }[/math] smallest items. Then, the remaining [math]\displaystyle{ 12k }[/math] items can cover bins only in groups of four, so all in all [math]\displaystyle{ 3k+1 }[/math] bins are filled. But in OPT one can fill [math]\displaystyle{ 4k }[/math] bins, each of which contains 3 middle-sized items and 3 small items.

Polynomial-time approximation schemes

Csirik, Johnson and Kenyon[3] present an asymptotic PTAS. It is an algorithm that, for every ε>0, fills at least [math]\displaystyle{ (1 - 5 \varepsilon)\cdot \mathrm{OPT}(I) - 4 }[/math] bins if the sum of all items is more than [math]\displaystyle{ 13 B/\epsilon^3 }[/math], and at least [math]\displaystyle{ (1 - 2 \varepsilon)\cdot \mathrm{OPT}(I) - 1 }[/math] otherwise. It runs in time [math]\displaystyle{ O(n^{1/\varepsilon^2}) }[/math]. The algorithm solves a variant of the configuration linear program, with [math]\displaystyle{ n^{1/\varepsilon^2} }[/math]variables and [math]\displaystyle{ 1 + 1/\varepsilon^2 }[/math] constraints. This algorithm is only theoretically interesting, since in order to get better than 3/4 approximation, we must take [math]\displaystyle{ \varepsilon \lt 1/20 }[/math], and then the number of variables is more than [math]\displaystyle{ n^{400} }[/math].

They also present algorithms for the online version of the problem. In the online setting, it is not possible to get an asymptotic worst-case approximation factor better than 1/2. However, there are algorithms that perform well in the average case.

Jansen and Solis-Oba[4] present an asymptotic FPTAS. It is an algorithm that, for every ε>0, fills at least [math]\displaystyle{ (1 - \varepsilon)\cdot \mathrm{OPT}(I) -1 }[/math] bins if the sum of all items is more than [math]\displaystyle{ 13B/\epsilon^3 }[/math] (if the sum of items is less than that, then the optimum is at most [math]\displaystyle{ 13/\epsilon^3\in O(1/\epsilon^3) }[/math] anyway). It runs in time [math]\displaystyle{ O\left( \frac{1}{\epsilon^5} \cdot \ln{\frac{n}{\varepsilon}} \cdot \max{(n^2,\frac{1}{\varepsilon}\ln\ln\frac{1}{\varepsilon^3})} + \frac{1}{\varepsilon^4}\mathcal{T_M}(\frac{1}{\varepsilon^2}) \right) }[/math], where [math]\displaystyle{ \mathcal{T_M}(n) }[/math] is the runtime complexity of the best available algorithm for matrix inversion (currently, around [math]\displaystyle{ O(n^{2.38}) }[/math]). This algorithm becomes better than the 3/4 approximation already when [math]\displaystyle{ \varepsilon \lt 1/4 }[/math], and in this case the constants are reasonable - about [math]\displaystyle{ 2^{10} n^2 + 2^{18} }[/math].

Related problems

In the fair item allocation problem, there are different people each of whom attributes a different value to each item. The goal is to allocate to each person a "bin" full of items, such that the value of each bin is at least a certain constant, and as many people as possible receive a bin. Many techniques from bin covering are used in this problem too.

Implementations

References

  1. 1.0 1.1 Assmann, S. F; Johnson, D. S; Kleitman, D. J; Leung, J. Y. -T (1984-12-01). "On a dual version of the one-dimensional bin packing problem" (in en). Journal of Algorithms 5 (4): 502–525. doi:10.1016/0196-6774(84)90004-X. ISSN 0196-6774. https://dx.doi.org/10.1016/0196-6774%2884%2990004-X. 
  2. 2.0 2.1 2.2 Csirik, János; J. B. G. Frenk and M. Labbé and S. Zhang (1999-01-01). "Two simple algorithms for bin covering" (in en). Acta Cybernetica 14 (1): 13–25. ISSN 2676-993X. https://cyber.bibl.u-szeged.hu/index.php/actcybern/article/view/3507. 
  3. 3.0 3.1 Csirik, Janos; Johnson, David S.; Kenyon, Claire (2001-01-09). "Better approximation algorithms for bin covering". Proceedings of the Twelfth Annual ACM-SIAM Symposium on Discrete Algorithms. SODA '01 (Washington, D.C., USA: Society for Industrial and Applied Mathematics): 557–566. ISBN 978-0-89871-490-6. https://dl.acm.org/doi/abs/10.5555/365411.365533. 
  4. 4.0 4.1 Jansen, Klaus; Solis-Oba, Roberto (2002-11-21). "An Asymptotic Fully Polynomial Time Approximation Scheme for Bin Covering". Proceedings of the 13th International Symposium on Algorithms and Computation. ISAAC '02 (Berlin, Heidelberg: Springer-Verlag) 2518: 175–186. doi:10.1007/3-540-36136-7_16. ISBN 978-3-540-00142-3. https://dl.acm.org/doi/abs/10.5555/646345.689912.