the bin packing problem. for n objects with sizes s 1, …, s n where 0 < s i ≤1, find the...

21
The bin packing problem

Upload: miles-shaw

Post on 17-Jan-2018

224 views

Category:

Documents


0 download

DESCRIPTION

The First Fit Strategy Place the next object in the list S into the first bin which has not been completely filled into which it will fit. When bins are filled completely they are closed and if an object will not fit into any currently open bin, a new bin is opened. The First Fit Decreasing Strategy First sort the objects in decreasing order of sizes and then run the FF algorithm

TRANSCRIPT

Page 1: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

The bin packing problem

Page 2: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

The bin packing problem

For n objects with sizes s1, …, sn where 0 < si≤1,

find the smallest number of bins with capacity one, such that n objects can be packed into bins.

or find a minimum set partition such that the sum of objects in every set is less than 1.

Can we partition n objects into two sets such the sum of objects in one set is equal to that of objects in another set?

Page 3: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

The First Fit Strategy Place the next object in the list S into the

first bin which has not been completely filled into which it will fit. When bins are filled completely they are closed and if an object will not fit into any currently open bin, a new bin is opened.

The First Fit Decreasing Strategy First sort the objects in decreasing order of

sizes and then run the FF algorithm

Page 4: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

BinPackFirstFit(S, n, bin)1 initialize all b[j] as 0.0 // space used up in bin j2 for i←1 to n do3 for j←1 to n do4 if b[j]+s[i]≤1.0 then5 B[i]← j 6 b[j]← b[j]+s[i]7 break8 j←19 while (b[j]!=0) do10 j← j+111 return

Page 5: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

For example, given objects 0.4, 0.2, 0.4, 0.8, 0.2, 0.2, 0.5, 0.3.

FFD sorts them in decreasing order 0.8, 0.5, 0.4, 0.4, 0.3, 0.2,0.2, 0.2 and then allocates to the first bin that fits

0.8

0.2

0.5 0.4

0.2

0.2

0.40.3

Note that this is not optimal: the objects would fit into 3 bins.

Page 6: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

Lemma Let S = (s1, …, sn) be an input I, in non-increasing order, for the bin packing problem and let OPT(I) be the optimal number of bins for S. All of the objects placed by FFD in extra bins (i.e., bins with index larger than OPT(I)) have size at most

1/3.

Page 7: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

Proof Let i be the index of the first object placed

by FFD in bin OPT(I)+1. Si must be no larger than 1/3.

Page 8: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

Suppose Si > 1/3. Then S1 ,…, Si-1 > 1/3, and are placed in bins Bj for 1≤j≤OPT(I), at most two objects each bin. For some k ≥ 0,the first k bins hold one object each, and bins Bk+1, …, BOPT hold two objects each. Si > 1/3 can not fit even by an optimal solution. But an optimal solution must fit object Si in one of the first OPT(I) bins. Therefore, the assumption that Si > 1/3 must be false.

Page 9: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

Lemma For an input S = (s1, …, sn ) the number of objects placed by FFD in extra bins is at most OPT(I) - 1.

Proof Assume FFD puts OPT(I) objects with sizes t1, …, tOPT(I) in extra bins. Let bi be the used space for each of the first OPT(I) bins. Then

)(OPT)()(OPT

1

)(OPT

1

)(OPT

11

Itbtbs i

I

ii

I

ii

I

ii

n

jj

Page 10: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

However, since all the objects fit in OPT(I) bins, we must have

)(OPT1

Isn

jj

Therefore, the assumption of OPT(I) objects being put into extra bins is not valid.

Page 11: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

Lemma R(I)≤(4/3) + (1/3m) and for infinitely large S, R(I) =3/2.

Proof Let S = (s1, …, sn ) be an input I with OPT(I) =m.

FFD puts at most m-1 objects, each of size at most 1/3, in extra bins, so FFD uses at most m + (m-1)/3 bins. Thus

mmmIR )3/)1(()(

)).3/(1(3/4)3()1(1 mmm

Page 12: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

Therefore, the worst-case ratio R(I) ≤ 4/3 + (1/3m). Regardless the size of S, the

largest R(I) is achieved when m = 2. Therefore,

R(I) ≤ 4/3 + (1/6) = 3/2. namely R(I) =3/2

Page 13: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

Theorem There exists a polynomial time algorithm FFD such that

for all instances S for the bin packing problem, namely

4)(OPT9

11)( IIA

.911

R

Page 14: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

The Next Fit Strategy open a bin and place the objects into it

in the order they appear in the list S. If an object on the list will not fit into the open bin, we close this bin permanently and open a new one and continue packing the remaining objects in the list.

Page 15: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

The Best Fit Strategy One again keeps bins open even when

the next object in the list will not fit in previously opened bins, in the hope that a later smaller object will fit. The criterion for placement is that we put the next object into the currently open bin (e.g. not yet full) which leaves the least room left over.

Page 16: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

The Worst Fit Strategy One places the item into that currently open bin into

which it will fit with the most room left over. The Random Fit Strategy Random Fit is a simple randomized variant of First Fit.

With Random Fit, each time an item is to be placed in a bin the bins are indexed in an order determined by a permutation chosen independently and uniformly at random. Each item is sequentially placed into the lowest indexed bin into which it will t, or into an empty bin if no such bin is available.

Page 17: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

These strategies are greedy algorithms: they make choices based on the short term, not the long term.

Intuitively, you might think the best-fit strategy is better, but in reality they all work about the same.

It has been proven that an FFD solution is at worst 22% of the optimum solution. In practice, FFD solutions are usually much closer to optimal than this.

So, just with a simple rule-of-thumb, we can approximate the optimum solution.

Page 18: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

Homework

Experiments: Implement First Fit decreasing, Next

Fit decreasing, Best Fit decreasing, Worst Fit decreasing and compare these algorithms for the bin packing problem

Page 19: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

Problem 1. Strip packing problem In wood or glass industries, rectangular components

have to be cut from large sheets of material. Given a set of rectangular objects (wi,hi), 0≤i≤n and a large rectangular sheet with width W and unlimited height,the objective is to minimize the height (H) of sheet. For example, given 5 rectangular objects, how to cut them from large rectangular sheet such that H is minimum (see Fig. 1) and every packing rectangles have a fix direction. Please give an approximation algorithm or Tabu search to solve it. (Scores 10)

Page 20: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects
Page 21: The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects

2. 2D bin packing problem Given a set of rectangular objects (wi,hi), 0≤i≤n and

finite rectangular bins with width W and height H,the objective of 2D bin packing problem is to minimize the number of the used bins such that all rectangles can be packed into the used bins and every rectangles have a fixed packing direction. Design an approximation algorithm or meta-heuristic algorithm for it(Scores 10)

21