Approximation Algorithms Chapter 9 Bin Packing by hcj

VIEWS: 2 PAGES: 38

• pg 1
```									Approximation Algorithms
Chapter 9: Bin Packing
Overview (1/3)
n   Main issue: Asymptotic approximation
algorithms for NP-hard problems
– [Ideal case]: Given an instance, we can always obtain
its solution with any approximation ratio.
• PTAS (Polynomial Time Approximation Scheme)
– See section 8 of the textbook.
– [Better case]: For almost all instances, we can obtain
its solution with any approximation ratio.
• Bin Packing problem
• Minimum approximation ratio = 3/2 if # bin is 2.
Overview (2/3)
– PTAS
• There is a polynomial-time algorithm that always finds a
solution within a given approximation factor e.
– Asymptotic PTAS
• There is a polynomial-time algorithm for any large-sized
instances that always finds a solution within a given
approximation factor e.

Score of                   PTAS                  PTAS
solution
found        (1+ e)                     PTAS                PTAS
solution                        (1+ e’)
OPT
Overview (3/3)
n   Bin packing problem
– An example
– The First-Fit algorithm.
• Approximation factor is 2.
– No approximation algorithm having a guarantee of
3/2.
• Reduction from the set partition, an NP-complete problem.
– Asymptotic PTAS Ae.
• The minimum size of bins=e, # distinct sizes of bins= K.
• Exact algorithm where e and K are constants.
• Approximation algorithm where e is constant.
Bin packing problem
n   Input:
– n items with sizes a1, …, an (0 < ai ≦ 1).
– Find a packing in unit-sized bins that minimizes the
number of bins used.

Items 0.3     0.2     0.2   0.2   0.2   0.4   0.5

Bins            0.2
0.2
1.0     0.2               0.4
0.3                           0.5
0.2
Bin packing problem
n   Input:
– n items with sizes a1, …, an (0 < ai ≦ 1).
– Find a packing in unit-sized bins that minimizes the
number of bins used.

Items 0.3     0.2         0.2   0.2   0.2   0.4   0.5

Bins                0.5               0.4

1.0                           0.2
0.2
0.2
0.3               0.2
Overview (3/3)
n   Bin packing problem
– An example
– The First-Fit algorithm.
• Approximation factor is 2.
– No approximation algorithm having a guarantee of
3/2.
• Reduction from the set partition, an NP-complete problem.
– Asymptotic PTAS Aε.
• Lower bound of bins: e, # distinct sizes of bins: K.
• Exact algorithm where e and K are constants.
• Approximation algorithm where e is constant.
The First-Fit algorithm (1/4)
n   This algorithm puts each item in one of partially
packed bins.
– If the item does not fit into any of these bins, it opens
a new bin and puts the item into it.
Order

Items 0.5     0.3     0.4     0.8    0.2   0.2   0.2

Bins
0.3
1.0
0.5                 0.4
The First-Fit algorithm (2/4)
n   This algorithm puts each item in one of partially
packed bins.
– If the item does not fit into any of these bins, it opens
a new bin and puts the item into it.
Order

Items 0.5     0.3     0.4     0.8    0.2   0.2   0.2

Bins
0.3
1.0
0.5                 0.4
0.8
The First-Fit algorithm (3/4)
n   This algorithm puts each item in one of partially
packed bins.
– If the item does not fit into any of these bins, it opens
a new bin and puts the item into it.
Order

Items 0.5     0.3     0.4     0.8    0.2   0.2   0.2

Bins            0.2
0.3
1.0
0.5                 0.4
0.8
The First-Fit algorithm (4/4)
n   This algorithm puts each item in one of partially
packed bins.
– If the item does not fit into any of these bins, it opens
a new bin and puts the item into it.
Order

Items 0.5     0.3     0.4     0.8    0.2   0.2   0.2

Bins            0.2
0.2
0.3
1.0                         0.2
0.5                 0.4
0.8
First-Fit finds a 2OPT solution (1/2)
n   OPT: # bins used in the optimal solution.
n   [Proof]
– Suppose that First-Fit uses m bins.
– Then, at least m－1 bins are more than half full.
• We never have two bins less than half full.
– If there are two bins less than half full, items in the second bin can
be substituted into the first bin by First-Fit.

0.2

0.4   0.2               0.4
First-Fit finds a 2OPT solution (2/2)
n   Suppose that First-Fit uses m bins.
n   Then, at least m－1 bins are more than half full.

Sum of sizes
of the items

The size
of
Since m and OPT are integers.
Overview (3/3)
n   Bin packing problem
– An example
– The First-Fit algorithm.
• Approximation factor is 2.
– No approximation algorithm having a guarantee of
3/2.
• Reduction from the set partition, an NP-complete problem.
– Asymptotic PTAS Ae.
• Lower bound of bins: e, # distinct sizes of bins: K.
• Exact algorithm where e and K are constants.
• Approximation algorithm where e is constant.
No factor 3/2 approx. algorithms
n   [Sketch of Proof]
– Suppose that we have a factor 3/2 approximation
algorithm A.
– Then, A can find the optimal solution for the set
partition problem in polynomial time.
• Note that the set partition problem is NP-complete.
– The result from the above assumption contradicts with
P ≠ NP.
Overview of the proof (1/2)
Input x of the set partition S
unsolvable in polynomial time

Polynomial
time
Algorithm B

x is in S.      x is not in S.
Overview of the proof (2/2)
Input x of the set partition
Unsolvable in polynomial time
Transformation from x to
an input of Bin Packing
Polynomial
time
(3/2－e) approx. algorithm        Algorithm B

#bins is 2      #bins > 3

x is in S.      x is not in S.
Set partition problem
n   Input:
– n items with sizes a1, …, an.
n   Question:
– Whether or not the n items can be split into two
subsets with the same size?
The sizes of these items
are normalized by
Items 2.8    2.2     2.2   2.2   2.0   3.6   5.0

2.2
3.6
2.0
5.0           2.2                     The sum of the
2.8           2.2                     sizes will be 2.
n    A factor (3/2－e) approx. algorithm A.
Solution of        Optimal solution       Solution by A App. factor
the set partition    of the bin packing
More than 1
Splittable            2 bins

0.5
10       5     5      1.0     0.5
More than 3/2

Unsplittable   More than 3 bins
…
8        7     5     0.8     0.7     0.5
We can find the exact solution of the set
partition by its corresponding solution by A.
Overview (3/3)
n   Bin packing problem
– An example
– The First-Fit algorithm.
• Approximation factor is 2.
– No approximation algorithm having a guarantee of
3/2.
• Reduction from the set partition, an NP-complete problem.
– Asymptotic PTAS Ae.
• The minimum size of bins: e, # distinct sizes of bins: K.
• Exact algorithm where e and K are constants.
• Approximation algorithm where e is constant.
Theorem 9.3
n   We can find an approx. solution with factor [(1+2 e)
OPT+1]
– where 0 < e <1/2.
• First-Fit is available if e ≧ 1/2.
– The factor [(1+2 e) OPT+1] > (2OPT+1) if e ≧ 1/2.
– 3 bins are required if OPT=2.
• Consistent with the previous inapproximable result.
– 1,001 bins are sufficient for an instance with OPT=1,000.
• by setting e =1/4,000.
– Note: Its computation time is polynomial time but huge.
n   Its proof will be shown later.
Lemma 9.4
n   Consider bin packing with constraints (BP1)
– The minimum size e of items is a constant.
– # distinct sizes of bins, K, is a constant.
n   There exists a polynomial-time algorithm for BP1
that finds the best solution.
– The algorithm searches for the solution exhaustively.
• # combinations of items in a bin denotes R.
• # combinations of n bins such that R distinct bins are
available denotes P.
• P is upper-bounded by a polynomial of n (O(nR)).
Lemma 9.4
n     Bin packing with constraints (BP1)
– The minimum size e of items is a constant.
– # distinct bins, K, is a constant.

There are K distinct items.
At most 1/e
1.0            items are
ε                     a1     a2
in a bin.
a1     a1      …..    ak        …..
If e=0.3,             a1     a1              a1
1/e = 3.33… =3.
How many combinations
M is the max. #
of items are possible in a bin?
of items in a bin.
R, # combinations of items in a bin
n    Pack M items in a bin from (K +1) different items.
– K + 1 = items with K sizes + empty (unselected).
– E.g.) K = 3, M = 3.                   a1 a3 unselected
a1 is selected.
a1                               a3
a1                               a1         3 (=M) partitions are
a1                                             selected from
6 (= K + M) elements.
a1   a2     a3
a3
a2                                                 R=
a1
M and K are constants
→ R is also constant.
P, # combinations of bins
n   # combinations of bins with R different bins
– We can find P in a similar way..
– P can be bounded by a function of n.
– E.g.) R=3, n = 3.
b1 was selected.
b1     b1    b1

b1     b3   No bin
# possible combination
b1      b3                                         is bounded by a
polynomial of n.
We can find the best packing
by exhaustive search in polynomial time.
Examples of nR
n   e: min. size of items, K: # different items.
– e =0.3 (M = 3), K=3.
• R = 6C3=20, computation time O(n20).
– e =0.1 (M = 10), K=3.
• R = 10C3=120, computation time O(n120).
– e =0.05 (M = 20), K=3.
• R = 20C3=1140, computation time O(n1140).
Lemma 9.5
n   Bin packing with (less) constraints (BP2)
– The minimum size e of items is a constant.
n   There exists a factor (1+e) approximation
algorithm for BP2.
– It first modifies the sizes of items into only K different
ones.
– It uses the exhaustive search used in Lemma 9.4.
• K = 1/e2 , Q = ne2 .
– Q: # items with the same size in a group.
How to modify the sizes of items
n   I: the original input, J: its modified one.
n   J consists of Q groups.
n   The size of each item is set to the maximum size
of items in its group.
Let Q=3.
I    0.3  0.2  0.1   0.6      0.7   0.4   0.5
Sort them by size.

0.1    0.2   0.3   0.4   0.5   0.6   0.7
Modify I.
There are at
most K different
J      0.3   0.3   0.3   0.6   0.6   0.6   0.7     item sizes.
How to pack items
n    From Lemma 9.4, the optimal packing for J can
be found in polynomial time.
n    The packing for J is also valid for the original
item sizes.
J     0.3    0.3   0.3     0.6    0.6    0.6   0.7

0.3    0.3       0.3                                 0.3
0.2
0.1
0.6    0.6       0.6     0.7          0.4     0.5    0.6    0.7
factor Z where
The optimal # bins                                              OPT(J) ≦ z OPT(I)?
denotes OPT(J).
For evaluating OPT(I),…
n   We prepare another modified instance J’.
n   J’ consists of Q groups.
n   Each item size is set to the minimum in its group.
Suppose Q=3.
Any item in J’ is the
I    0.3    0.2   0.1     0.6   0.7   0.4   0.5
same as or smaller
Sort them by size.                             than the original
item in I.
0.1   0.2   0.3     0.4   0.5   0.6   0.7
Modify I.                                                OPT(J’) ≦ OPT(I)

J’    0.1   0.1   0.1     0.4   0.4   0.4   0.7
Diff. between OPT(J) and OPT(J’)

J
0.3   0.3   0.3   0.6   0.6      0.6    0.7
: basis of size                                            Q items
for modification
JQ 0.3                     Each of the biggest Q items
Any item in J’Q                        0.3   0.3   0.6  packed into Q bins in J.
is always not
smaller than                                           OPT(J) ≦ OPT(JQ)＋Q
one in JQ.
OPT(JQ) ≦ OPT(J’Q)
0.4                0.4   0.4   0.7
J’Q
J’ contains every
Q items                                              item in J’Q.
J’ 0.1    0.1     0.1     0.4      0.4   0.4   0.7   OPT(J’Q) ≦ OPT(J’)
Diff. between OPT(J) and OPT(J’)

OPT(J)                        0.3   0.3   0.3   0.6   0.6     0.6     0.7
≦ OPT(JQ)+Q                                                 Q items
JQ
≦ OPT(J’Q)+Q
≦ OPT(J’)+Q                   0.3   0.3   0.3   0.6
≦ OPT(I)+Q                                            OPT(J) ≦ OPT(JQ)＋Q

OPT(JQ) ≦ OPT(J’Q)
0.4   0.4   0.4   0.7
J’Q

Q items
J’ 0.1     0.1   0.1     0.4      0.4   0.4   0.7   OPT(J’Q) ≦ OPT(J’)
Relation between Q and OPT(I)
n   Q ≦ ne2 since Q = ne2 .
n   OPT(I) > ne since.
– e ≦any item size,
– ne ≦ the total item size (n: # items),
– The total item size ≦. # bins (that is, OPT(I))
n   Then, Q ≦ ne2 = e (ne) ≦ eOPT(I).
n   OPT(J) ≦ OPT(I)+Q ≦ (1+e) OPT(I).
0.2                  I
0.2
0.2             e   0.2   0.3   0.6   0.2   0.4   0.3   0.6
0.2                                               0.2
0.2                              n                0.2   0.4
ne                  OPT(I)
Theorem 9.3
n   We can find an approx. solution with factor [(1+2
e) OPT+1]
– where 0 < e <1/2.
• First-Fit is available if e ≧ 1/2.
– The factor [(1+2 e) OPT+1] > (2OPT+1) if e ≧ 1/2.
– 3 bins are required if OPT=2.
• Consistent with the previous inapproximable result.
– 1,001 bins are sufficient for an instance with
OPT=1,000.
• by setting e =1/4,000.
Algorithm Ae

Input    More          Procedure in
Items I   than e        Lemma 9.5             (1+ε)OPT(I ’)
I’
L ≦ (1+ ? )OPT(I)+?

Output
Not more                                L bins
than e
I–I’       Pack items in I –
I’ into bins of I’
by First-Fit.

We consider two exclusive case
to find the upper bound of L.
Evaluation of Ae (1/2)
n     Consider two exclusive cases:
1. No extra bin was required for packing items in I – I’.
– L ≦ (1+e )OPT(I ’) ≦ (1+e )OPT(I).
• Since there are more items in I than in I’.
2. Extra bins were required for packing items in I – I’.
– In each of L－1 bins, room is smaller than e .

1- e
Total sum of Item size in
item sizes
L－1
Then, we have
Evaluation of algorithm Ae (2/2)

Then, we have

Therefore,
Conclusion
n   We consider the bin packing problem.
– For almost all instances, we can obtain its solution
with any approximation factor.
– There is an approx. algorithm to find factor 2 solution.
– It is impossible to find a solution with arbitrary
approximation ratio under P is not equal to NP.
– There is an approx. algorithm with arbitrary
approximation ratio for large size instances.

```
To top