PTAS for Bin

advertisement
PTAS for Bin-Packing
Special Cases of Bin Packing
1. All item sizes smaller than 
Claim 1: FF  OPT (1  2 )  1
Proof: If   12 then
FF  2OPT  1  (1  2 )OPT  1
So assume   12



FF
Therefore: ( FF  1)(1   )  OPT
FF  1  OPT /(1   )
But
1
 1  2
1 
for

1
2
since (1  2 )(1   )  1    2  1   (1  2 )
2
and
1

2
 2  1  0  (1  2 )
Therefore: FF  1  OPT  (1  2 )
FF  OPT  (1  2 )  1
2. Assume that there are only k different sizes
(k fixed).
Claim 2: Optimum number of bins can be
2 k 1
)
found in time: O(n
Proof: For every subset of items compute
the optimal number of bins it can be packed
in.
Total number of subsets is O(n k )
Why?
Sort items by size:
size S1
n1
size S k
size S 2
nk
n2
n
Denote a subset by a k-tuple of the number of
elements of each size in the subset.
 i1 , i2 ,..., ik ;
1 ij  nj,
j  1,..., k
Number of different such tuples:
k
k
j 1
j 1
k
n

n

n
 j 
Compute optimal number of bins for each subset
using dynamic programming.
Find subsets that can be packed in 1 bin
Find subsets that can be packed in 2 bins
…
Find subsets that can be packed in OPT bins
(Note OPT can not exceed n)
Number of values per iteration:
n
Number of iterations:
n
k
IMPLEMENTATION:
1.Sort subsets by sums of sizes. Those with sum
not exceeding 1 are packed in a single bin. Call
them 1-bin subsets.
2.For all pairs of 1-bin subsets, consider their union.
Every union that is not a 1-bin subset is a
2-bin subset.
If entire set is packed – done.
o/w continue to next step.
...
i+1. For all pairs consisting of a 1-bin subset and an
i-bin subset, consider their union.
If it is not an i-bin subset or less , then it is a
(i+1)-bin subset.
If entire set is packed – done.
o/w continue to next step.
...
Time: We consider all pairs at every step, thus
2k
O( n )
time per step.
At most OPT steps. OPT
Conclude:
O( n
2 k 1
)
n
3. Conclude: Given I  S1 ,..., S n  and 

Assume that all items have size 
then
2
FF ( I )  (1   )OPT ( I )  1
(By claim 1).

4. Assume that all items have size 
2
Claim 2: There exists a packing algorithm PA
for which
PA( I )  (1   )OPT ( I )  1
Proof: Consider the following approximation
algorithm.
Fix k (we will later decide the value of k)
1.Sort I in non-decreasing order. Split into
groups of k elements each.
n
 k 
k
k
k
k
k
G1
G2
G3
Gn k 1
Gn k 
2. Pack group G1 in at most k bins.
3. Change all numbers in Gi , 2  i  n k  to largest
number in group. Call new item set I’.
EXAMPLE:
G1
I:
I’:
10 9 8
G2
G3
G4
7 7 6
6 6 5
3 2
7 7 7
6 6 6
3 3
4. Find OPT(I’) (by Claim 2).
Lemma: OPT(I’) ≤ OPT(I)
Proof: Consider I” constructed as:
Discard Gn k 
For G1 ,..., G 1 change every
element in group to smallest.
n
k
EXAMPLE:
G1
G2
G3
G4
3 2
I:
10 9 8
7 7 6
6 6 5
I”:
8 8 8
6 6 6
5 5 5
Clearly OPT(I”) ≤ OPT(I)
(since I” has less elements and they are smaller)
OPT(I’) ≤ OPT(I”)
Why?
1. I’ may have less elements. ( G   G1 ,
and all other sets are equal sized in both)
2. I’ has smaller total sum.
( max Gi 1  min Gi , i  1,..., n k   1 )
n
Conclude:
OPT(I’) ≤ OPT(I“) ≤ OPT(I)
k
Algorithm Running Time: O ( n
2 n k 1
)
Approximation Factor:
PA(I) ≤ OPT(I)+k
 n 
NOW CHOOSE: k    si 
 i 1 
 n 
  si    OPT ( I )  1
 i 1 
Therefore:
Approximation Factor:
(1+ε) OPT(I)+1
What about the time?
n
n

k  n si
i 1

But si 
2
n
n

n
k
 i 1 si
for all i, so:

n
 i 1 2
n

n
2

2

n


2
Thus
Algorithm Running Time:
O(n
2
2 1
2
)  O(n
4 1
2
)
Since ε is fixed, this is a polynomial.
Algorithm for the General Case:
1. Split items into two sets:
small (≤ε/2) and large (>ε/2).
2. Handle large items as in Claim 4.
3. Use FF to pack small items into remaining spaces of large item bins.
When all such space is used, open new bins using FF.
Time: Clearly polynomial.
Approximation Factor:
Case 1: All large item bins are filled, and new ones
opened.
Case 2: Not all large item bins are filled.
Case 1: The situation is:

2

2

2
This is the case of claim 1, so approximation is
(1+ε) OPT(I)+1
Case 2: Let IL be the set of large items. The
number of bins produced by our algorithm is:


OPT(I’)+k ≤ OPT ( I L )    si   OPT ( I )   OPT ( I )  1 
 si I L 
=(1+ε) OPT(I)+1
Download