Jump to content

Rectangle packing

From Wikipedia, the free encyclopedia

Rectangle packing is a packing problem where the objective is to determine whether a given set of small rectangles can be placed inside a given large polygon, such that no two small rectangles overlap. Several variants of this problem have been studied.

Packing identical rectangles in a rectangle

[edit]

In this variant, there are multiple instances of a single rectangle of size (l,w), and a bigger rectangle of size (L,W). The goal is to pack as many small rectangles as possible into the big rectangle without overlap between any rectangles (small or large). Common constraints of the problem include limiting small rectangle rotation to 90° multiples and requiring that each small rectangle is orthogonal to the large rectangle.

This problem has some applications such as loading of boxes on pallets and, specifically, woodpulp stowage. As an example result: it is possible to pack 147 small rectangles of size (137,95) in a big rectangle of size (1600,1230).[1]

Packing identical squares in a rectilinear polygon

[edit]

Given a rectilinear polygon (whose sides meet at right angles) R in the plane, a set S of points in R, and a set of identical squares, the goal is to find the largest number of non-overlapping squares that can be packed in points of S.

Suppose that, for each point p in S, we put a square centered at p. Let GS be the intersection graph of these squares. A square-packing is equivalent to an independent set in GS. Finding a largest square-packing is NP-hard; one may prove this by reducing from 3SAT.[2]

Packing different rectangles in a given rectangle

[edit]

In this variant, the small rectangles can have varying lengths and widths, and they should be packed in a given large rectangle. The decision problem of whether such a packing exists is NP-hard. This can be proved by a reduction from 3-partition. Given an instance of 3-partition with 3m positive integers: a1, ..., a3m, with a total sum of m T, we construct 3m small rectangles, all with a width of 1, such that the length of rectangle i is ai + m. The big rectangle has width m and length T + 3m. Every solution to the 3-partition instance induces a packing of the rectangles into m subsets such that the total length in each subset is exactly T, so they exactly fit into the big rectangle. Conversely, in any packing of the big rectangle, there must be no "holes", so the rectangles must not be rotated. Therefore, the packing must involve exactly m rows where each row contains rectangles with a total length of exactly T. This corresponds to a solution of the 3-partition instance.[3][4]

When there is an additional restriction that the packing must be exact (with no wasted space), the small rectangles may be rotated only by multiples of 90°. In this case, the problem is in NP. Without this requirement, the small rectangles may be rotated in arbitrary angles. In this more general case, it is not clear if the problem is in NP, since it is much harder to verify a solution.[4]

Packing different rectangles in a minimum-area rectangle

[edit]

In this variant, the small rectangles can have varying lengths and widths, and their orientation is fixed (they cannot be rotated). The goal is to pack them in an enclosing rectangle of minimum area, with no boundaries on the enclosing rectangle's width or height. This problem has an important application in combining images into a single larger image. A web page that loads a single larger image often renders faster in the browser than the same page loading multiple small images, due to the overhead involved in requesting each image from the web server. The problem is NP-complete in general, but there are fast algorithms for solving small instances.[5][6]

Integer programming formulation

[edit]

One can model rectangle packing problem for fixed sizes and orientations as an integer linear program. Further, constraints and variables can be added to minimize the bounding-box-netlength. Given small rectangles with widths , heights and nets as well as a larger rectangle with width and height , the integer program looks as follows:

  • Objective minimizing bounding-box-netlength
  • Non-overlap constraints
  • Relative placement disjunction
  • Net bounding box coverage constraints
  • Binary variables
  • Rectangle position variables
  • Net bounding box variables

For fixed relations the above integer program is the dual of a maximum flow problem and therefore solvable in polynomial time.[7]

Not all choices for these spatial relation variables correspond to a feasible placement. A set of relations that contains all feasible placements is called complete. The best known upper bound on the size of a complete set of relations was proved by Silvanus and Vygen, who showed that with spatial relations suffice. They also gave a lower bound of with [8]

Heuristics
Using different representations such as O-trees,[9] B*-trees[10] or sequence pairs[11] for the spatial relations between rectangles, various heuristic algorithms have been proposed to solve floorplanning instances in practice. Some of them restrict the solution space by only considering sliceable floorplans.


[edit]
  • Guillotine cutting is a variant of rectangle packing, with the additional constraint that the rectangles in the packing should be separable using only guillotine cuts.
  • Maximum disjoint set (or Maximum independent set) is a problem in which both the sizes and the locations of the input rectangles are fixed, and the goal is to select a largest sum of non-overlapping rectangles. In contrast, in rectangle packing (as in real-life packing problems) the sizes of the rectangles are given, but their locations are flexible. Some papers use the term "packing" even when the locations are fixed.[12]

References

[edit]
  1. ^ Birgin, E G; Lobato, R D; Morabito, R (2010). "An effective recursive partitioning approach for the packing of identical rectangles in a rectangle". Journal of the Operational Research Society. 61 (2): 306–320. doi:10.1057/jors.2008.141. S2CID 12718141.
  2. ^ Fowler, Robert J.; Paterson, Michael S.; Tanimoto, Steven L. (1981-06-13). "Optimal packing and covering in the plane are NP-complete". Information Processing Letters. 12 (3): 133–137. doi:10.1016/0020-0190(81)90111-3. ISSN 0020-0190.
  3. ^ Demaine, Erik D.; Demaine, Martin L. (2007-06-01). "Jigsaw Puzzles, Edge Matching, and Polyomino Packing: Connections and Complexity". Graphs and Combinatorics. 23 (1): 195–208. doi:10.1007/s00373-007-0713-4. ISSN 1435-5914. S2CID 17190810.
  4. ^ a b Demaine, Erik (2015). "MIT OpenCourseWare – Hardness made Easy 2 – 3-Partition I". Youtube.
  5. ^ Huang, E.; Korf, R. E. (2013-01-23). "Optimal Rectangle Packing: An Absolute Placement Approach". Journal of Artificial Intelligence Research. 46: 47–87. arXiv:1402.0557. doi:10.1613/jair.3735. ISSN 1076-9757.
  6. ^ "Fast Optimizing Rectangle Packing Algorithm for Building CSS Sprites". www.codeproject.com. 14 June 2011. Retrieved 2020-09-09.
  7. ^ Funke, Julia; Hougardy, Stefan; Schneider, Jan (2016). "An exact algorithm for wirelength optimal placements in VLSI design". Integration: The VLSI Journal. 52: 355–366. doi:10.1016/j.vlsi.2015.07.001. Retrieved 2025-06-12.
  8. ^ Silvanus, Jannik; Vygen, Jens (2017). "Few Sequence Pairs Suffice: Representing All Rectangle Placements". SIAM Journal on Discrete Mathematics. 34: 2017–2032. doi:10.1137/16M1095880 (inactive 1 July 2025).{{cite journal}}: CS1 maint: DOI inactive as of July 2025 (link)
  9. ^ Tang, M.; Sebastian, A. (2005). "A Genetic Algorithm for VLSI Floorplanning Using O-Tree Representation". Applications of Evolutionary Computing. Lecture Notes in Computer Science. Vol. 3449. Springer Berlin Heidelberg. pp. 215–224. doi:10.1007/978-3-540-32003-6_22.
  10. ^ Fernando, J.; Katkoori, S. (2008). "An Elitist Non-dominated Sorting Based Genetic Algorithm for Simultaneous Area and Wirelength Minimization in VLSI Floorplanning". Proceedings of the 21st International Conference on VLSI Design. IEEE. pp. 337–342. doi:10.1109/VLSI.2008.56.
  11. ^ Lin, P.-H.; Chang, Y.-W.; Lin, S.-C. (2009). "Analog Placement Based on Symmetry-Island Formulation". IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems. 28 (6). IEEE: 791–804. doi:10.1109/TCAD.2009.2015708 (inactive 1 July 2025).{{cite journal}}: CS1 maint: DOI inactive as of July 2025 (link)
  12. ^ Chan, T. M. (2003). "Polynomial-time approximation schemes for packing and piercing fat objects". Journal of Algorithms. 46 (2): 178–189. CiteSeerX 10.1.1.21.5344. doi:10.1016/s0196-6774(02)00294-8.