Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 The bin packing problem

2 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 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?

3 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

4 BinPackFirstFit(S, n, bin) 1 initialize all b[j] as 0.0 // space used up in bin j 2 for i←1 to n do 3 for j←1 to n do 4 if b[j]+s[i]≤1.0 then 5 B[i]← j 6 b[j]← b[j]+s[i] 7 break 8 j←1 9 while (b[j]!=0) do 10 j← j+1 11 return

5 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.4 0.3 Note that this is not optimal: the objects would fit into 3 bins.

6 Lemma Let S = (s 1, …, s n ) 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.

7 Proof Let i be the index of the first object placed by FFD in bin OPT(I)+1. S i must be no larger than 1/3.

8 Suppose S i > 1/3. Then S 1, …, S i-1 > 1/3, and are placed in bins B j 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 B k+1, …, B OPT hold two objects each. S i > 1/3 can not fit even by an optimal solution. But an optimal solution must fit object S i in one of the first OPT(I) bins. Therefore, the assumption that S i > 1/3 must be false.

9 Lemma For an input S = (s 1, …, s n ) 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 t 1, …, t OPT(I) in extra bins. Let b i be the used space for each of the first OPT(I) bins. Then

10 However, since all the objects fit in OPT(I) bins, we must have Therefore, the assumption of OPT(I) objects being put into extra bins is not valid.

11 Lemma R(I) ≤ (4/3) + (1/3m) and for infinitely large S, R(I) =3/2. Proof Let S = (s 1, …, s n ) 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

12 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

13 Theorem There exists a polynomial time algorithm FFD such that for all instances S for the bin packing problem, namely

14 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.

15 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.

16 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.

17 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.

18 Homework Experiments: Implement First Fit decreasing, Next Fit decreasing, Best Fit decreasing, Worst Fit decreasing and compare these algorithms for the bin packing problem

19 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 (w i,h i ), 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)

20

21 2. 2D bin packing problem Given a set of rectangular objects (w i,h i ), 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


Download ppt "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."

Similar presentations


Ads by Google