case studies: bin packing & the traveling salesman problem
DESCRIPTION
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. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/1.jpg)
© 2010 AT&T Intellectual Property. All rights reserved. AT&T and the AT&T logo are trademarks of AT&T Intellectual Property.
Case Studies: Bin Packing &
The Traveling Salesman Problem
David S. JohnsonAT&T Labs – Research
![Page 2: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/2.jpg)
![Page 3: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/3.jpg)
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
![Page 4: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/4.jpg)
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.
![Page 5: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/5.jpg)
![Page 6: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/6.jpg)
![Page 7: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/7.jpg)
![Page 8: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/8.jpg)
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
![Page 9: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/9.jpg)
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.
![Page 10: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/10.jpg)
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.)
![Page 11: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/11.jpg)
Lower Bounds: FF and BF
OPT: N bins FF, BF: N/2 bins + N bins = 1.5 OPT
![Page 12: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/12.jpg)
Lower Bounds: FF and BF
OPT: N bins FF, BF: N/6 bins + N/2 bins + N bins = 5/3 OPT
![Page 13: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/13.jpg)
Lower Bounds: FF and BF
1/2 +
1/3 +
OPT: N bins
1/7 + 1/1806 + , etc. 1/43 + ,
FF, BF = N(1 + 1/2 + 1/6 + 1/42 + 1/1805 + … )
(1.691..) OPT
![Page 14: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/14.jpg)
Jeff Ullman’s Idea
1/2 +
1/3 +
OPT: N bins
1/6 + FF, BF = N (1 + 1/2 + 1/5) = (17/10) OPT
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.)
![Page 15: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/15.jpg)
Lower Bounds: FFD and BFD
1/4-21/4+ 1/4+
1/4+
1/4+
1/4-2 1/4-2
1/4-2
1/4-2
1/4-2
1/4-2
1/4+2
1/4+2
1/4+2
6n bins 3n bins 6n bins 2n bins 3n bins OPT = 9n FFD, BFD = 11n
![Page 16: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/16.jpg)
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.
![Page 17: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/17.jpg)
Why Asymptotics?
• Partition Problem: Given a set X of numbers xi, can they be partitioned into two subsets with the sums (xXx)/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.
![Page 18: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/18.jpg)
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.
![Page 19: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/19.jpg)
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.
![Page 20: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/20.jpg)
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?
![Page 21: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/21.jpg)
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
)c,d(c)c,d(c π(1)π(N)
1N
1i1)π(iπ(i)
N}{1,2,...,N}{1,2,...,:π
![Page 22: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/22.jpg)
• 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)).
Implementing Best Fit
Bin Index
Gap Size
Bin with smaller gap Bin with larger gap
![Page 23: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/23.jpg)
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.
![Page 24: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/24.jpg)
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.
.11
.41 .56 .37
.82 .99.03 .50 .26 .17 .77 .44
.56 .82 .26 .77.99.41
.56 .99 .77
.99 1.00
1.00
1.00
1.00
●●●
![Page 25: Case Studies: Bin Packing & The Traveling Salesman Problem](https://reader034.vdocuments.us/reader034/viewer/2022051821/56815a8a550346895dc7fe6d/html5/thumbnails/25.jpg)
To Be Continued…
• Next time: Average-Case Behavior
• For now: On to the TSP!