150 likes | 596 Views
Bin Packing. The Problem The Algorithms. The Bin Packing Problem. Pack wts w 1 , w 2 , …, w n into bins. Each bin has fixed capacity. Use as few bins as possible. A scheduling problem in disguise! unlimited # of procs each with fixed capacity (Goal: minimize # procs ). Scheduling
E N D
Bin Packing The Problem The Algorithms Mathematics in Management Science
The Bin Packing Problem Pack wtsw1, w2, …,wninto bins. Each bin has fixed capacity. Use as few bins as possible. A scheduling problem in disguise! unlimited # of procs each with fixed capacity (Goal: minimize # procs)
Scheduling task task time processor completion time completing a task # of processors Bin Packing item to pack weight of item bin bin size packing an item # of bins Dictionary
Heuristic Algorithms NF – Next Fit FF – First Fit WF – Worst Fit In last 3, bins stay open until they are completely full. Decreasing Versions NFD – Next Fit D FFD – First Fit D WFD – Worst Fit D With these first sort wts into decreasing order, then pack. The Algorithms
Next Fit Packing Algortihm Pack item in current bin. If item will not fit in current bin: close this bin & open a new bin. Continue until all items packed.
Example using Next Fit Packing Wts6, 6, 5, 5, 5, 4, 4, 4, 4, 2, 2, 2, 2, 3, 3, 7, 7, 5, 5, 8, 8, 4, 4, 5
Next Fit Packing Algortihm Advantages – Do not need to know all the weights in advance; only need to know the remaining space in the bin. Disadvantages – The bin packed early on may have had room for small items that come later in the list. Best method for assembly-line packing.
First Fit & Worst Fit Packing Keep all bins open until full. Then close. To pack an item, look at open bins. FFPlace item in first bin in which it fits. WFPlace item in bin with the most space (and into which item fits) . Only open new bin if item will not fit in any of the already open bins.
Bin Packing Methods Next Fit & First Fit & Worst Fit NFA new bin is opened if the weight to be packed next will not fit in the bin that is currently being filled; the current bin is then closed. FF The next weight to be packed is placed in the lowest-numbered bin already opened into which it will fit. If it does not fit in any open bins, a new bin is opened. WF The next weight to be packed is placed into the open bin with the largest amount of room remaining. If it does not fit in any bins, open a new bin. 9
Bin Packing Methods Next Fit Decreasing (NFD) First Fit Decreasing(FFD) Worse Fit Decreasing(WFD) Decreasing-Time Heuristics NFD, FFD, WFD – Create the priority list by listing the weightsin order of decreasing size before applying selected bin-packing method. 10