The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
Bin Packing ● What are the shapes and sizes of objects? - The character of the problem depends greatly on the shapes of the objects to be packed. Packing pieces of a standard jigsaw puzzle is a different problem than packing squares into a rectangular box. In one-dimensional bin packing, each object's size is given simply as an integer, making it a version of the knapsack problem of Section . This is equivalent to packing boxes of equal width into a chimney of that width. If all the boxes are of identical size and shape, the optimal packing is simply a cubic lattice, oriented appropriately with the walls of the bin. It is a waste to use the methods described in this section on such simple problems. ● Are there constraints on the orientation and placement of objects? - In loading a truck, many of the boxes will say ``this side up.'' Respecting this constraint restricts our flexibility in packing and will likely lead to an increase in the number of trucks needed to send out the shipment. Similarly, boxes with fragile objects may be labeled ``do not stack'' and thus are constrained to sit on top of a pile of boxes. Most shippers seem to ignore these constraints. Indeed, your task will be simpler if you don't have to worry about the consequences of them. ● Is the problem on-line or off-line? - Do we know the complete set of objects that we will be packing at the beginning of the job (an off-line problem)? Or will we get them one at a time and have to deal with them as they arrive (an on-line problem)? The difference is important, because we can do a better job packing when we can take a global view and plan ahead. For example, we can arrange the objects in an order that will facilitate efficient packing, perhaps by sorting them from biggest to smallest. The standard heuristics for bin packing order the objects by size or shape (or in an on-line problem, simply the order they arrive in) and then insert them into bins. Typical insertion rules include (1) select the first or leftmost bin the object fits in, (2) select the bin with the most room, (3) select the bin that provides the tightest fit, or (4) select a random bin. Analytical and empirical results suggest that the best heuristic is first-fit, decreasing. Sort the objects in decreasing order of size, so that the biggest object is first and the smallest last. Insert each object one by one into the first bin that has room for it. If no bin has room for it, we must start another bin. In the case of one-dimensional bin packing, this can never require more than 22% more bins than necessary and usually does much better. First-fit decreasing has an intuitive appeal to it; we pack the bulky objects first and hope that the little objects can be used to fill up the cracks. First-fit decreasing is easily implemented in time, where is the number of bins actually used, by doing a linear sweep through the bins on each insertion. A faster implementation is possible by using binary tree to keep track of the space remaining in each bin. We can fiddle with the insertion order in such a scheme to deal with problem-specific constraints. For example, it is reasonable to take ``do not stack'' boxes last (perhaps after artificially lowering the height of the bins to give some room up top to work with) and to place fixed-orientation boxes at the beginning (so we can use the extra flexibility later to stick boxes into cracks). Packing boxes is much easier than packing arbitrary geometric shapes, enough so that a reasonable file:///E|/BOOK/BOOK5/NODE192.HTM (2 of 4) [19/1/2003 1:31:50]
Bin Packing approach for general shapes is to pack each part into its own box and then pack the boxes. Finding an enclosing rectangle for a polygonal part is easy; just find the upper, lower, left, and right tangents in a given orientation. A minimum-area enclosing rectangle can be found by determining the orientation that leads to the smallest box. In the case of nonconvex parts, considerable useful space can be wasted in the holes created by placing the part in a box. One solution is to find the maximum empty rectangle within each boxed part and use this to contain other parts if it is sufficiently large. More advanced solutions are discussed in the references. Implementations: Codes for the one-dimensional version of bin packing, the so-called knapsack problem, are presented in Section . XTango (see Section ) includes an animation of the first-fit bin packing heuristic. Test data for bin packing is available from http://mscmga.ms.ic.ac.uk/info.html. Notes: See [CGJ96] for a survey of the extensive literature on approximation algorithms for bin packing. Expositions on heuristics for bin packing include [Baa88]. Experimental results on bin-packing heuristics include [BJLM83]. Sphere packing is an important and well-studied special case of bin packing, with applications to errorcorrecting codes. Particularly notorious is the ``Kepler conjecture,'' the apparently still-open problem of establishing the densest packing of unit spheres in three dimensions. Conway and Sloane [CS93] is the best reference on sphere packing and related problems. Sloane provides an extensive set of tables of the best known packings, available from ftp://netlib.bell-labs.com. Victor Milenkovic and his students have worked extensively on two-dimensional bin-packing problems for the apparel industry, minimizing the amount of material needed to manufacture pants and other clothing. Recent reports of this work include [DM97, Mil97]. Related Problems: Knapsack problem (see page ), set packing (see page ). Next: Medial-Axis Transformation Up: Computational Geometry Previous: Intersection Detection Algorithms file:///E|/BOOK/BOOK5/NODE192.HTM (3 of 4) [19/1/2003 1:31:50]
- Page 539 and 540: Edge Coloring The minimum number of
- Page 541 and 542: Graph Isomorphism Next: Steiner Tre
- Page 543 and 544: Graph Isomorphism vertices into equ
- Page 545 and 546: Steiner Tree Next: Feedback Edge/Ve
- Page 547 and 548: Steiner Tree The worst case for a m
- Page 549 and 550: Feedback Edge/Vertex Set Next: Comp
- Page 551 and 552: Feedback Edge/Vertex Set An interes
- Page 553 and 554: Computational Geometry complete bib
- Page 555 and 556: Robust Geometric Primitives Next: C
- Page 557 and 558: Robust Geometric Primitives ● Are
- Page 559 and 560: Robust Geometric Primitives Related
- Page 561 and 562: Convex Hull ● How many dimensions
- Page 563 and 564: Convex Hull http://www.cs.att.com/n
- Page 565 and 566: Triangulation Next: Voronoi Diagram
- Page 567 and 568: Triangulation GEOMPACK is a suite o
- Page 569 and 570: Voronoi Diagrams Next: Nearest Neig
- Page 571 and 572: Voronoi Diagrams McDonald's, the ti
- Page 573 and 574: Nearest Neighbor Search Next: Range
- Page 575 and 576: Nearest Neighbor Search Implementat
- Page 577 and 578: Range Search Next: Point Location U
- Page 579 and 580: Range Search subdivisions in C++. I
- Page 581 and 582: Point Location the n edges for inte
- Page 583 and 584: Point Location More recently, there
- Page 585 and 586: Intersection Detection ● Do you w
- Page 587 and 588: Intersection Detection Implementati
- Page 589: Bin Packing Next: Medial-Axis Trans
- Page 593 and 594: Medial-Axis Transformation Next: Po
- Page 595 and 596: Medial-Axis Transformation Implemen
- Page 597 and 598: Polygon Partitioning number of piec
- Page 599 and 600: Simplifying Polygons Next: Shape Si
- Page 601 and 602: Simplifying Polygons vertices and o
- Page 603 and 604: Shape Similarity Next: Motion Plann
- Page 605 and 606: Shape Similarity or how close it is
- Page 607 and 608: Motion Planning There is a wide ran
- Page 609 and 610: Motion Planning often arise in the
- Page 611 and 612: Maintaining Line Arrangements Think
- Page 613 and 614: Maintaining Line Arrangements Next:
- Page 615 and 616: Minkowski Sum where x+y is the vect
- Page 617 and 618: Set and String Problems Next: Set C
- Page 619 and 620: Set Cover Next: Set Packing Up: Set
- Page 621 and 622: Set Cover Figure: Hitting set is du
- Page 623 and 624: Set Packing Next: String Matching U
- Page 625 and 626: Set Packing Notes: An excellent exp
- Page 627 and 628: String Matching shouldn't try. Furt
- Page 629 and 630: String Matching and texts, I recomm
- Page 631 and 632: Approximate String Matching This sa
- Page 633 and 634: Approximate String Matching http://
- Page 635 and 636: Text Compression Next: Cryptography
- Page 637 and 638: Text Compression code string. ASCII
- Page 639 and 640: Cryptography Next: Finite State Mac
Bin Packing<br />
● What are the shapes and sizes of objects? - <strong>The</strong> character of the problem depends greatly on the<br />
shapes of the objects to be packed. Packing pieces of a standard jigsaw puzzle is a different<br />
problem than packing squares into a rectangular box. In one-dimensional bin packing, each<br />
object's size is given simply as an integer, making it a version of the knapsack problem of Section<br />
. This is equivalent to packing boxes of equal width into a chimney of that width. If all the<br />
boxes are of identical size and shape, the optimal packing is simply a cubic lattice, oriented<br />
appropriately with the walls of the bin. It is a waste to use the methods described in this section on<br />
such simple problems.<br />
● Are there constraints on the orientation and placement of objects? - In loading a truck, many of<br />
the boxes will say ``this side up.'' Respecting this constraint restricts our flexibility in packing and<br />
will likely lead to an increase in the number of trucks needed to send out the shipment. Similarly,<br />
boxes with fragile objects may be labeled ``do not stack'' and thus are constrained to sit on top of<br />
a pile of boxes. Most shippers seem to ignore these constraints. Indeed, your task will be simpler<br />
if you don't have to worry about the consequences of them.<br />
● Is the problem on-line or off-line? - Do we know the complete set of objects that we will be<br />
packing at the beginning of the job (an off-line problem)? Or will we get them one at a time and<br />
have to deal with them as they arrive (an on-line problem)? <strong>The</strong> difference is important,<br />
because we can do a better job packing when we can take a global view and plan ahead. For<br />
example, we can arrange the objects in an order that will facilitate efficient packing, perhaps by<br />
sorting them from biggest to smallest.<br />
<strong>The</strong> standard heuristics for bin packing order the objects by size or shape (or in an on-line problem,<br />
simply the order they arrive in) and then insert them into bins. Typical insertion rules include (1) select<br />
the first or leftmost bin the object fits in, (2) select the bin with the most room, (3) select the bin that<br />
provides the tightest fit, or (4) select a random bin.<br />
Analytical and empirical results suggest that the best heuristic is first-fit, decreasing. Sort the objects in<br />
decreasing order of size, so that the biggest object is first and the smallest last. Insert each object one by<br />
one into the first bin that has room for it. If no bin has room for it, we must start another bin. In the case<br />
of one-dimensional bin packing, this can never require more than 22% more bins than necessary and<br />
usually does much better. First-fit decreasing has an intuitive appeal to it; we pack the bulky objects first<br />
and hope that the little objects can be used to fill up the cracks. First-fit decreasing is easily implemented<br />
in time, where is the number of bins actually used, by doing a linear sweep<br />
through the bins on each insertion. A faster implementation is possible by using binary tree to<br />
keep track of the space remaining in each bin.<br />
We can fiddle with the insertion order in such a scheme to deal with problem-specific constraints. For<br />
example, it is reasonable to take ``do not stack'' boxes last (perhaps after artificially lowering the height<br />
of the bins to give some room up top to work with) and to place fixed-orientation boxes at the beginning<br />
(so we can use the extra flexibility later to stick boxes into cracks).<br />
Packing boxes is much easier than packing arbitrary geometric shapes, enough so that a reasonable<br />
file:///E|/BOOK/BOOK5/NODE192.HTM (2 of 4) [19/1/2003 1:31:50]