1 / 25

Case Studies: Bin Packing & The Traveling Salesman Problem

Case Studies: Bin Packing & The Traveling Salesman Problem. David S. Johnson AT&T Labs – Research. Applications. Packing commercials into station breaks Packing files onto floppy disks (CDs, DVDs, etc.) Packing MP3 songs onto CDs Packing IP packets into frames, SONET time slots, etc.

fordon
Download Presentation

Case Studies: Bin Packing & The Traveling Salesman Problem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Case Studies: Bin Packing &The Traveling Salesman Problem David S. Johnson AT&T Labs – Research

  2. Applications • Packing commercials into station breaks • Packing files onto floppy disks (CDs, DVDs, etc.) • Packing MP3 songs onto CDs • Packing IP packets into frames, SONET time slots, etc. • Packing telemetry data into fixed size packets Standard Drawback: Bin Packing is NP-complete

  3. NP-Hardness • Means that optimal packings cannot be constructed in worst-case polynomial time unless P = NP. • In which case, all other NP-hard problems can also be solved in polynomial time: • Satisfiability • Clique • Graph coloring • Etc. • See M.R. Garey & D.S.Johnson, Computers and Intractability: A Guide to the Theory of NP-Completeness, W.H.Freeman, 1979.

  4. Standard Approach to Coping with NP-Hardness: • Approximation Algorithms • Run quickly (polynomial-time for theory, low-order polynomial time for practice) • Obtain solutions that are guaranteed to be close to optimal

  5. First Fit (FF):Put each item in the first bin with enough space Best Fit (BF):Put each item in the bin that will hold it with the least space left over First Fit Decreasing, Best Fit Decreasing (FFD,BFD): Start by reordering the items by non-increasing size.

  6. Worst-Case Bounds • Theorem [Ullman, 1971][Johnson et al.,1974]. For all lists L, BF(L), FF(L) ≤ (17/10)OPT(L) + 3. • Theorem [Johnson, 1973]. For all lists L, BFD(L), FFD(L) ≤ (11/9)OPT(L) + 4. (Note 1: 11/9 = 1.222222…) (Note 2: These bounds are asymptotically tight.)

  7. Lower Bounds: FF and BF ½ -  ½ -  ½ -  ½ +  ½ +  OPT: N bins FF, BF: N/2 bins + N bins = 1.5 OPT

  8. Lower Bounds: FF and BF 1/6 - 2 1/6 - 2 1/6 - 2 1/6 - 2 1/6 - 2 1/6 - 2 1/6 - 2 1/3 + 1/3 + 1/3 + ½ +  1/2 + OPT: N bins FF, BF: N/6 bins + N/2 bins + N bins = 5/3 OPT

  9. Lower Bounds: FF and BF 1/43 + , 1/1806 + , etc. 1/7 +  1/3 + FF, BF = N(1 + 1/2 + 1/6 + 1/42 + 1/1805 + … )  (1.691..) OPT 1/2 + OPT: N bins

  10. Jeff Ullman’s Idea FF, BF = N (1 + 1/2 + 1/5) = (17/10) OPT 1/6 +  Key modification: Replace some 1/3 +’s & 1/6+’s with 1/3-i & 1/6+i, and some with 1/3+i & 1/6-i, with i increasing from bin to bin. (Actually yields FF, BF ≥ (17/10)OPT - 2 See References for details.) 1/3 + 1/2 + OPT: N bins

  11. Lower Bounds: FFD and BFD 1/4-2 1/4-2 1/4-2 1/4-2 1/4-2 1/4-2 1/4-2 1/4+ 1/4+ 1/4+ 1/4+ ½ +  ½ +  1/4+2 1/4+2 1/4+2 6n bins 3n bins 6n bins 2n bins 3n bins OPT = 9n FFD, BFD = 11n

  12. Asymptotic Worst-Case Ratios • RN(A) = max{A(I)/OPT(I): OPT(I) = N} • R(A) = max{RN(A): N > 0} • absolute worst-case ratio • R∞(A) = limsupN∞RN(A) • asymptotic worst-case ratio • Theorem: R∞(FF) = R∞(BF) = 17/10. • Theorem: R∞(FFD) = R∞(BFD) = 11/9.

  13. Why Asymptotics? • Partition Problem: Given a set X of numbers xi, can they be partitioned into two subsets with the sums (xXx)/2? • This problem is NP-hard, and is equivalent to the special case of bin packing in which we ask if OPT = 2. • Hence, assuming P  NP, no polynomial-time bin packing algorithm can have R(A) < 3/2.

  14. Online Algorithms • We have no control over the order in which items arrive. • Each time an item arrives, we must assign it to a bin before knowing anything about what comes later. • Examples: FF and BF • Simplest example: Next Fit (NF) • Start with an empty bin • If the next item to be packed does not fit in the current bin, put it in a new bin, which now becomes the “current” bin. Problem 1: Prove R∞(NF) = 2.

  15. Best Possible Online Algorithms • Theorem [van Vliet, 1996]. For any online bin packing algorithm A, R∞(A) ≥ 1.54. • Theorem [Richey, 1991]. There exist polynomial-time online algorithms A with R∞(A) ≤ 1.59. • Drawback: Improving the worst-case behavior of online algorithms tends to guarantee that their average-case behavior will not be much better. • FF and BF are much better on average than they are in the worst case.

  16. Best Possible Offline Algorithm? • Theorem [Karmarkar & Karp, 1982]. There is a polynomial-time (offline) bin packing algorithm KK that guarantees KK(L) ≤ OPT(L) + log2(OPT(L)) . • Corollary.R∞(KK) = 1. • Drawback: Whereas FFD and BFD can be implemented to run in time O(NlogN), the best bound we have on the running time of KK is O(N8log3N). • Still open: Is there a polynomial-time bin packing algorithm A that guarantees A(L) ≤ OPT(L) + c for any fixed constant c?

  17. The Traveling Salesman Problem Given: Set of cities {c1,c2,…,cN }. For each pair of cities {ci,cj}, a distance d(ci,cj). Find: Permutation that minimizes

  18. Implementing Best Fit • Put the unfilled bins in a binary search tree, ordered by the size of their unused space (choosing a data structure that implements inserts and deletes in time O(logN)). Bin Index Gap Size Bin with smaller gap Bin with larger gap

  19. Implementing Best Fit • When an item x arrives, the initial “current node” is the root of the tree. • While the item x is not yet packed, • If x fits in the current node’s gap • If x fits in the gap of the node’s left child, let that node become the current node. • Otherwise, pack x in the current node’s bin, and reinsert that bin into the tree with its new gap. • Otherwise, • If the current node has a right child, let that become the current node. • Otherwise, pack x in a new bin, and add that to the tree.

  20. Implementing First Fit • New tree data structure: • The bins of the packing are the leaves, in their original order. • Each node contains the maximum gap in bins under it. 1.00 .99 1.00 .56 .99 .77 .41 .56 .82 .99 .26 .77 .11 .41 .56 .37 .82 .03 .50 .99 .26 .17 .77 .44 1.00 1.00 ●●●

  21. To Be Continued… • Next time: Average-Case Behavior • For now: On to the TSP!

More Related