Bin Packing Problem
1 Outline
- Explanation of original bin packing problem
- On-line algorithms for original bin packing problem
- Definition of extensible bin packing problem
- Brief information about some real world applications related to extensible bin packing problem
- A FPTAAS for extensible bin backing problem
2 Original Bin Packing Problem
In original bin packing problem, we are given a list of n items L={a
1,a
2,…,a
n} and infinite number of bins with capacity C.
The size of i-th item ai is s(ai), where 0 < s(ai) ≤ C.
The problem is to pack the items in minimum number of bins under the constraint that the total size of items in each bin cannot exceed the capacity of the bin.
3 On-line Algorithms for Original Bin Packing Problem
On-line bin packing algorithms are the algorithms which packs each item one by one without any knowledge of the next items. Thus, approximation factor of these algorithms are higher than offline algorithms in which size and number of items in the list are known before starting to pack them.
In this section, we give very brief information about some naive online algorithms to warm you up.
3.1 Definitions
The following definitions will be used in this section when we talk about on-line algorithms for original bin packing problem.
- There are two types of nonempty bins. Open bins are available for packing additional items whereas closed bins are unavailable for packing. Closed bins cannot be re-opened.
- Bj denotes the items packed in j-th bin.
- |Bj| denotes the number of items in j-th bin.
- The size of a bin is computed as following: c(Bj) = ∑ai ∈ Bj s(ai)
- p denotes the size of the largest item in the item list.
- Without loss of generality, we give algorithms for scaled version of bin packing problem such that bins have a nominal capacity 1, and size of items are specified as rationals.
3.2 Next-Fit (NF)
- Pack the first item into the first bin
- For each successive item
- If it fits in the bin that contains the last packed item, pack in that bin.
- Otherwise, close this bin and pack the item in an empty bin.
The disadvantage of this algorithm is that it closes a bin that can be used in the future. This algorithm packs a list of items and its reverse in the same number of bins. The asymptotic performance ratio (APR) of NF is as following
|
NF(I) ≤ 2*OPT(I) if 1/2 < p ≤ 1
NF(I) ≤ (1-p)-1*OPT(I) if 0 < p ≤ 1/2
|
3.3 Worst-Fit (WF)
- If there are no open bins in which the current item fits, pack the item into an empty bin.
- Otherwise, pack the item into the bin of smallest content in which the item fits.
Although WF never closes a bin, the APR of this algorithm same as the previous one.
3.4 First-Fit (FF)
- Pack the current item into the lowest indexed nonempty bin in which it fits.
- If there is no bin in which the current item can fit, pack the item in an empty bin.
3.5 Best-Fit (BF)
- If there are some bins in which the current item can fit, pack the item into the bin of largest content in which the item fits.
- Otherwise, pack the the item into an empty bin.
3.6 Conclusion on on-line algorithms
The drawback of these on-line algorithms is their performance when size of items in the list or part of the list are in increasing order. If a list is in increasing order, the performances of the on-line algorithms suffer greatly.
Even "average-case" lists that have portions in increasing order can greatly affect an on-line algorithm's approximation guarantee ratio. For example, when the bin size is 1, then following list of items will be packed into 3 bins according to all four on-line algorithms...
.2, .7, .3, .8
It is easy to see that these items can be packed into two bins.
We touched the approximation guarantee of some algorithms above, but in general the analysis of these algorithms are very complicated and it is out of scope of this tutorial. You can read the papers listed in references for more information.
4 Extensible Bin Packing Problem
Extensible bin packing problem is a variation of original bin packing problem. In this problem, number of bins is given as an input. The capacity of each bin is 1 and bins may be extended to hold more than their capacities. The cost of a bin is 1 if it is not extended, and the total size of items in it if it is extended. The goal of this problem is to pack a set of items of given sizes into the specified number of bins in a way to minimize the total cost. In this tutorial, a fully polynomial time asymptotic approximation scheme (FPTAAS) is introduced for extensible bin packing problem.
Extensible bin packing has a number of important real world applications such as:
- The problem of assigning tasks to workers: There are a set of tasks which must be assigned to a set of identical workers which are available at a fixed cost for a given time and can be acquired for additional time at an additional cost. In this problem, the goal is to minimize the cost.
- Scheduling problem: There are two machines and two types of tasks to be executed at these machines. Suppose that the tasks of first type requires only the first machine, and the tasks of second type requires both machines for some time, and then only the first machine for an additional time. The goal in this problem is the minimization of makespan.
- Storage Allocation problem: In this problem, extra capacity can be obtained from a fixed set of locations with given capacity at a proportional cost. The goal is to minimize the total cost when storing a set of items in those locations.
5 A FPTAAS for Extensible Bin Packing Problem
5.1 Introduction
Input
- xi: size of i-th item. 1 ≤ i ≤ n
- m: number of bins
Notations
- bj: j-th bin 1 ≤ j ≤ m
- l(bj): level of bj (total size of items packed into bj)
- c(bj) = max(1,l(bj)): cost of bj
Goal
- minimize ∑j=1..m c(bj) (Pack all items in bins in a way to minimize the total cost.)
5.2 Algorithm
We present an algorithm A(I,ε), which takes a problem instance and a parameter ε and produces an approximation guaranteeing that
A(I,ε) ≤ (1 + ε)OPT(I) + O(ε-1logε-1)
in time bounded by a polynomial in n and ε
-1
Before showing how this algorithm produces this approximation guarantee, we can make some assumptions
without loss of generality for the sake of simplicity. For each assumption, we prove that this assumption can be made without loss of generality.
5.2.1 First Assumption
There are no
small items. In other words
|
xi > ε/(1+ε) for i=1,2,…,n
|
Proof
Suppose we have an approximation algorithm A
′ which guarantees given approximation guarantee with so small items. We can use this algorithm to pack an arbitrary list of items as following:
- First, use A′ to pack items that are not small
- Pack the small items greedily.
There are two cases when we pack small items
- Packing small items does not increase the cost. Then we clearly satisfy the approximation guarantee.
- Packing small items does increase the cost. For convenience, let ε′ equal to ε/(1+ε) (maximum size of a small item). Then we can say that before packing small items the level of each bin is at least 1 - ε′. Therefore
|
OPT(I) ≥ ∑j=1..m l(bj) > m(1-ε′)
A′(I) ≤ ∑j=1..m max(1,l(bj)) ≤ ∑j=1..m l(bj)+ε′ ≤ mε′ + ∑j=1..m l(bj)
(A′ - OPT(I))/OPT(I) ≤ mε′/m(1-ε′) = ε.
|
5.2.2 Second Assumption
There are no
big items. In other words
Proof
We claim that there is an optimum packing algorithm which packs big items into a bin by itself. Similar to the proof given above, we can construct an 1+ε approximation algorithm from 1+ε which packs without big items. Suppose some optimum packing placed some item x in a bin together with a big item. Then we could move x to another bin that does not contain a big item without increasing the cost.
5.2.3 Third Assumption
Total size of all items cannot exceed 2m
Proof
When there are no big items, greedy method guarantees that as long as any bin is packed to a level of less than 1, no bin will be packed to a level of 2 or more. In other words, when a bin is packed to a level at least 2, then the cost of packing is simply the sum of items, so the packing is optimum. Thus, we can make this assumption without loss of generality.
5.2.4 Fourth Assumption
The level of a bin cannot exceed 3.
Proof
Suppose, there is a bin of level 3 or more. According to the previous assumption, there will be a bin of level less than 2. Thus, we can move an item from bin that has higher level to the other level without increasing the cost. Therefore, without loss of generality, we can assume that the level of any bin is at most 3.
For convenience, we will show that
|
A(I,ε) ≤ (1 + ε)2OPT(I) + O(ε-1log{ε-1})
|
We can obtain original approximation guarantee by a different choice of ε
In high level, this algorithm works as following:
First we group the items in terms of their sizes. (We round the sizes up to specified values) Then we define different ways of packing these items in bins. Then coarsening method (dynamic programming) gives a way of packing all items at minimum cost. (We give an ILP to find the optimum result.)
It is an approximation algorithm because we change the size of the items, and we relax ILP to LP.
We will round the sizes of items up to s1, s2, ..., sN where N is the smallest value for the following inequality
⌊(1+ε)j/ε⌋ε2 ≥ 1
According to the inequality above, N approximately equals to ε-1lnε{-1}
We define the value of s1,s2,…,sN according to the following equation
|
sj = ⌊(1+ε)j/ε⌋ε2 for 1≤ j<N
sj = 1 for j=N
|
Thus,
- s1 < s2 < … < sN
- sN = 1. (Recall that we assume that the maximum size of an item is 1.)
- If sj-1 <xi ≤ sj then round xi to sj.
Increase ratio of items of size less than s1
|
s1/(ε/(1+ε)) ≤ ⌊(1+ε)/ε⌋ε2/(ε/(1+ε)) ≤ (1+ε)2
|
Increase ratio of items of size larger than s1
|
sj+1/sj = ⌊(1+ε)j+1ε-1⌋/⌊(1+ε)jε-1⌋ ≤ (1+ε)j+1ε-1/((1+ε)jε-1-1) = (1+ε)j+1/((1+ε)j - ε) ≤ (1+ε)j+1/ (1+ε)j-1 ≤ (1+ε)2
|
Thus, Rounding increases the cost of the optimum solution by a factor of at most (1+ε)2)
- nj: number of items of size sj after rounding.
- configuration: packing a bin to a level of at most 3 with sizes chosen from sj
- M: number of configurations
- Cij: number of items of size sj in the i-th configuration
- max(1,∑j=1..N Cijsj): cost of packing a bin according to i-th configuration
The figure given above gives an intuitive explanation for the ILP we introduce in next section.
Each row in this table is a configuration. In each configuration we pack a number of items of each size (Cij) such that the level of the bin is at most 3. The number of configurations can be in terms of ε.
We can use a configuration zi times in the solution. Our goal is to pack all items and use all bins. These are the constraints in ILP given below.
5.3 Integer Linear Program
z
i: number of times we use i-th configuration
Objective function:
min ∑i=1..M zi.max(1,∑j=1..N Cijsj)
subject to
|
∑i=1..M ziCij ≥ nj for j=1,2,…,N (We need to pack all items of each size)
∑i=1..M zi ≥ m(We need to use all bins)
zi ∈ {0,1,2,ldots} (We can use a configuration any time we want)
|
When we relax this ILP to LP by allowing zi to be any nonnegative value, number of inequalities in LP will be N+1.
Thus,
- There will be a feasible solution with at most N+1 nonnegative non-integer values.
- Round LP to ILP increases the solution by at most 3(N+1) because each coefficient in the objective function is at most 3. (Recall that l(bj) < 3 for j=1,2,…,m)
Relaxation increases the optimum solution by at most 3(N+1) = O(ε-1logε-1) which is the asymptotic part in the approximation guarantee shown in the beginning.
Thus, this algorithm gives a solution with an approximation guarantee
|
A(I,ε) ≤ (1 + ε)OPT(I) + O(ε-1logε-1)
|
References
- Edward G. Coffman Jr. and George S. Lueker. Approximation Algorithms for Extensible Bin Packing. Symposium on Discrete Algorithms, 586-588 2001
- P. Dell'Olmo, H. Kellerer, M. G. Speranza, and Z. Tuza. A 13/12 approximation algorithm for bin packing with extendable bins. Information Processing Letters, 65:229-233, 1998.
- N. Karmarkar and R. M. Karp. An efficient approximation scheme for the one-dimensional bin-packing problem. In Proceedings of the 23rd Annual Symposium on Foundations of Computer Science, pages 312{320, 1982.
- E. G. Coffman, M. R. Garey, and D. S. Johnson. Approximation algorithms for bin packing: A survey. In D. Hockbaum, editor, Approximation Algorithms for NP-Hard Problems, pages 46--93, Boston, MA, USA, 1996. PWS Publishing