Optimal rectangle packing

The rectangle packing problem considered here consists of finding an enclosing rectangle of smallest area that can contain a given set of rectangles without overlap. Although we focus here on optimal solutions, we also provide an anytime algorithm that immediately returns a solution, and continues to improve on that solution as long as it continues to run, until an optimal solution is found and verified. Our algorithm picks the x-coordinates of all the rectangles before picking any of the y-coordinates. For the x-coordinates, we present a dynamic variable ordering heuristic and an adaptation of a pruning algorithm used in previous solvers. We then transform the rectangle packing problem into a perfect packing problem that has no empty space, and present inference rules to reduce the instance size. For the y-coordinates we search a space that models empty positions as variables and rectangles as values. Our solver is over 19 times faster than the previous state-of-the-art on the largest problem previously solved, allowing us to extend the known solutions for a consecutive-square packing benchmark from N=27 to N=32. We propose two new benchmarks, one where the orientation of the rectangles is fixed and one where it is free, that include rectangles of various aspect ratios. The new benchmarks avoid certain properties of easy instances, which we identify as instances where rectangles have dimensions in common or where a few rectangles occupy most of the area. Our benchmarks are much more difficult for solvers developed only on the consecutive-square packing benchmark, requiring orders of magnitude more time, when comparing similar-sized instances. On the new benchmarks, we improve upon the previous strategy used to handle dominance conditions, we define a variable order over non-square rectangles that generalizes previous strategies, and we present a way to adjust the sizes of intervals of values for each rectangle's x-coordinates. Using these techniques together, we can solve the new oriented benchmark about 500 times faster, and the new unoriented benchmark about 40 times faster than a solver without these techniques. Next, to test the limits of our rectangle packing techniques, we introduce another new benchmark where the precision of the dimensions of the rectangles increases with successively larger instance sizes. We present various adaptations of our low-precision techniques to this new high-precision domain, as well as several new ones, which include limiting the x- and y-coordinate values to the subset sums of the widths and heights of rectangles, and a method to learn from the search effort spent on infeasible subtrees. The data reveals that we are able to pack up to 15 rectangles in our high-precision benchmark, already far exceeding the representational ability of a 32-bit integer. Furthermore, we compare our techniques against a solver using an alternative search space not susceptible to problems of high-precision, and demonstrate that our solver remains competitive. We then turn our attention to the old and interesting question of packing an infinite series of rectangles into the unit square. We describe the techniques we use to provide computational results supporting the conjecture that the problem is feasible, and illustrate a packing solution for the first 50,000 such rectangles. Finally, in our appendix, our contributions also include providing all of the optimal solutions to the various benchmarks that we have used.