Abstract
A backtracking heuristic algorithm (BHA) was proposed for a two-dimensional rectangular strip packing problem with rotations and without guillotine cutting, which has many applications. An improved fitness strategy was used to select the fittest rectangle to be packed on a strip with a certain height. Next, a backtracking constructive heuristic was repeatedly used at a higher height until all the rectangles were packed. A multi-start improvement procedure then found the best solution by taking a different rectangle as the first rectangle, whereas the sequence of the other rectangles remained unchanged. Finally, in order to further expand the scope of the solution, a simple randomized local search procedure based on random sequences of rectangles with the first rectangle unchanged was applied to search for the optimal solution. BHA has only two parameters; it is simple and effective. Computational results on benchmark problems (zero-waste instances and non-zero-waste instances) with different scales (from 10 to 75,032 rectangles) indicate the following: (1) though it is non-deterministic, the difference between the results after each running is tiny and (2) the proposed algorithm outperforms most of the other algorithms under comparison on the whole, especially for large-scale instances with more than 1000 rectangles, which is further verified by statistical analysis and greatly meaningful in mass industrial production like metal cutting.
Introduction
In numerous industries, two-dimensional rectangular strip packing problems (2DRSPPs) are frequently encountered when cutting materials such as paper, glass, textiles, wood, metal, and other sheet materials. Given a set of
2DRSPP is a typical NP-hard problem, 5 and numerous algorithms have been proposed to solve it.1,6–10 Generally, there are typically three types of algorithms: exact algorithms, heuristic algorithms, and meta-heuristic algorithms. Exact algorithms ensure the solutions generated are optimal. However, with the number of rectangles increasing, the execution time becomes too high to be accepted. Martello et al. 11 and Kenmochi et al. 12 demonstrated that the commonly-used branch and bound algorithm was inefficient in solving benchmark instances with more than 200 rectangles. Therefore, most researchers have devoted their efforts to heuristic algorithms. 13 Oliveira et al. 10 have comprehensively reviewed the heuristics proposed for 2DRSPPs. The famous heuristic algorithms are bottom-left (BL) algorithms and their variants. The heuristic algorithms based on fitness strategies are also commonly used. With the popularization of intelligent algorithms, meta-heuristic algorithms have been presented. Genetic algorithms, simulated annealing algorithms, neural network algorithms, and mixed meta-heuristic algorithms are some of the most common intelligent algorithms. Meta-heuristic algorithms are non-deterministic and often have many parameters to adjust.
With the development of industrial technology, the number of rectangles involved in 2DRSPPs has increased sharply, leading to a demand of more effective algorithms for large-scale instances. Exact algorithms have difficulty to solve large-scale instances, while heuristic and meta-heuristic algorithms have some advantages, which have been proven by some exploratory work. For example, Hopper & Turton
13
had demonstrated that some meta-heuristics could find good solutions for large-scale instances with more than 72 rectangles, but the running times were extremely long due to their higher computational complexity. Leung et al.
14
had demonstrated that the hybrid simulated annealing algorithm (HSA) proposed could obtain high-quality solutions for large-scale instances with
The difficulty in solving larger instances lies in improving algorithm efficiency to make the solving time acceptable. In life, when we pack things, we always try to put them in a small box first. If it can't fit, we will replace it with a bigger box. By drawing inspiration from real-world events, our algorithm first attempts to pack all the rectangles in a strip with an ideal height. If this is not possible, some of the packed rectangles are backtracked, and the packing process is repeated under a higher height until all the rectangles are packed. Moreover, almost all studies on 2DRSPPs show that the sequence of rectangles significantly affects the solution quality. Although each rectangle's position impacts the solution quality, the first rectangle has a greater impact than the others because the rectangles in the other positions are chosen based on the nesting method under the first rectangle. Based on this empirical law, the backtracking heuristic algorithm (BHA) is proposed for 2DRSPPs.
In the BHA, the first fittest rectangle is first searched, and then the most suitable sequence of the other
The remainder of this paper is structured as follows. Section 2 shows the related works. Details of the backtracking constructive algorithm are illustrated in Section 3. The computational results for zero-waste and non-zero-waste instances with varying scales and large-scale instances are presented in Section 4, which also demonstrates the effect of multi-start improvement. Finally, Section 5 summarizes the conclusion.
Related works
So far many excellent algorithms have been developed to solve 2DRSPPs, which can be classified as exact algorithms, heuristic algorithms, and meta-heuristic algorithms. The exact algorithm based on integer programming formulation is one of the early algorithms developed to solve 2DRSPPs. 5 Martello et al. 11 proposed a branch and bound algorithm for solving instances involving up to 200 rectangles. Kenmochi et al. 12 designed a branch and bound algorithm that introduced several branching rules and bounding operations to solve all benchmark instances with up to 29 rectangles for RF and all but one instance with up to 49 rectangles for OF. In general, exact algorithms easily find the optimal solution for small-scale instances but face challenges for large-scale instances.
Heuristic algorithms are becoming increasingly prevalent, because exact algorithms take too long to calculate. 13 Baker et al. 16 proposed a BL algorithm for placing each rectangle as downward and leftward as possible. Based on the BL algorithm, the bottom-left-fill, 17 bidirectional best-fit, 18 and modified bidirectional best-fit 19 algorithms were presented. Burke et al. 20 developed a new best-fit algorithm to determine the fittest rectangle for a partial solution. FH, 15 IA (an efficient intelligent search algorithm), 21 and SRA (a simple randomized algorithm) 22 are heuristics based on fitness strategies. Many excellent algorithms, such as the heuristic recursive algorithm, 23 heuristic rectangle packing (HRP) algorithm, 24 greedy randomized adaptive search procedure, 25 least wasted first heuristic algorithm, 26 and residual-space-maximized packing (RSMP) algorithm 27 were proposed. He et al. proposed a best-fit algorithm (BFA), 28 deterministic heuristic algorithm (DHA), 29 and dynamic reduction algorithm 30 built from the BFA.
In recent years, meta-heuristic algorithms have been another significant research focus. Jakobs 31 and Liu & Teng 32 used a genetic algorithm (GA) to evolve the ordering of all rectangles to be packed based on the BL heuristic. Dowsland et al. 33 enhanced the GA approach by using tree search bounds. Bortfeldt 34 built a GA to search the space of complete packing directly, rather than encoding of orderings as in the cases of Jakobs 31 and Liu & Teng. 32 Burke et al. 35 presented a simulated annealing enhancement of the best-fit heuristic (BSA). Dagli & Poshyanonda 36 used a neural network algorithm, but the running time was too long. Leung et al. 37 proposed a simulated annealing-genetic algorithm that outperformed the pure genetic algorithm. Leung et al. proposed a two-stage intelligent search algorithm (ISA) 38 and HSA 14 by combining different fitness strategies with simulated annealing-genetic algorithms. Hifi et al. 39 presented a parallel beam combining a search beam with strip generation solution procedures.
It is observed that fitness strategies are commonly used not only in heuristics algorithms,15,21–22 but also in meta-heuristic algorithms.14,38 Generally, fitness strategies are used to select the best-fit rectangle for the current partial packing solution to ensure that each step in nesting is the current optimal choice. Based on fitness strategies or other best-fit chosen strategies, finding the optimal solution is equivalent to finding the best sequence of the rectangles. Therefore, many studies sort the rectangles in a specific order. The common sequence used is non-increasing ordering of perimeter,
15
area,23,26,27,29 height,11,13,15,27 or width.
13
Some authors14,15,21,22,38 have even proposed swapping all possible two rectangles in a sequence to obtain the best sequence, which is time-consuming; therefore, the algorithms always have time limits. Additional comparisons of HSA,
14
FH,
15
IA,
21
SRA,
22
and ISA
38
are presented in Table 1. For large-scale instances with
Comparisons of HSA, FH, IA, SRA, and ISA.
To improve solution quality, Alvarez-Valdes et al.
25
backtracked the last
Despite numerous algorithms developed to solve 2DRSPPs, they mainly focused on solving small-scale instances, and solving large-scale instances has become a challenge. Heuristic algorithms are easy to understand and have advantages in searching speed, so they are more easily promoted and applied in engineering practices. On the basis of the aforementioned related work, BHA builds a backtracking constructive heuristic by combining a new fitness strategy and backtracking method that backtracks some packed rectangles and searches for the optimal sequence of all the rectangles in two pieces to improve the search efficiency and solution quality. Correspondingly, the presence of BHA could provide a new method and research reference for solving the RF sub-type of large-scale instances with
Backtracking heuristic algorithm
BHA includes three phases: backtracking constructive heuristic, multi-start improvement, and randomized local search. In this section, some key principles are defined, followed by a detailed description of BHA.
Definitions
Assuming multiple rectangles have been already packed in a strip, horizontal and vertical line segments exist between the packed and unpacked regions. Several horizontal line segments are used to present the partial solution. Before packing, there is only one horizontal line segment—the bottom strip boundary. The packing point is the left endpoint of the lowest horizontal line segment. If several lowest horizontal line segments exist at the same height, the leftmost segment is chosen. The packing point's coordinates are expressed as For a given packing point
The horizontal line segments, packing point, and available space change dynamically during packing. Figure 1(a) shows a partial solution for a strip of width

Available space in a partial solution. (a) Available space in a partial solution and (b) the new available space.
Backtracking constructive heuristic algorithm
Constructive heuristic based on the fitness strategy
Imahori & Yagiura,
40
Burke et al.,
35
Wei et al.,
41
and some authors14,15,21,22,38 have employed fitness strategies to promote good placement quality by placing the fittest rectangle in an available area. Usually,

Fitness value.
Note that
For case (1),
For case (2),
For case (3),
For cases (4.1) and (4.2),
For case (5),
If the widths of all unpacked rectangles meet
Since BHA handles the RF sub-type, each rectangle's initial and 90° rotation poses are considered during packing. The constructive heuristic based on the fitness strategy is as follows: At the beginning of packing, the first rectangle in the given sequence
Backtracking constructive heuristic
At the beginning of packing, we set the height of strip
Multi-start improvement
If the solution
Randomized local search
If the solution obtained by the Multi-start Improvement Algorithm is not the ideal solution
Backtracking Algorithm
Parameter setting
In the BHA, there are two parameters to be set: the number
Nice and Path: This data set generated by Valenzuela & Wang
42
using the techniques described by Wang & Valenzuela
43
comprises 72 instances ranging from 25 to 5000. This float data set has similarly sized rectangles (Nice1–Nice5t) and vastly differently sized rectangles (Path1–Path5t). Nice1t, Nice2t, Nice5t, Path1t, Path2t, and Path5t include 10 instances. Because BHA is a fit for the integer data set. We used BHA for the data set at https://github.com/18439870129/BHA/tree/master with
ZDF: This data set generated by Leung & Zhang 15 comprises 16 instances ranging from 580 to 75,032.
BHA has three stages;
Effect of various
To determine

Computational results of various

Computational results of various
For data sets Nice and Path, we observed that
For the data set ZDF, zdf1–zdf5 omitted in Figure 4 always had the same solutions. It is observed that
Overall, the solution of
Effect of various
Since BHA has some randomness, the test was run 20 times for each condition with

Effect of various
For
Computational results
There are many benchmark instances in the literature. Iori et al. 44 listed the benchmarks (C, N, and ZDF) originally proposed for 2DRSPPs. To evaluate the performance of BHA, we compared it with some other excellent algorithms for the RF sub-type on more instances with wide scales. The benchmark specifications are as follows.
C: This data set generated by Hopper and Turton 13 comprises 21 instances with 16–197 rectangles.
N: This data set generated by Burke et al. 20 comprises 13 instances with 10–3152 rectangles.
CX: This data set generated by Pinto and Oliveira 45 comprises 7 instances with 50–15,000 rectangles.
Nice and Path: as mentioned above.
ZDF: as mentioned above.
There are two categories depending on whether there is unused space in the ideal solution. Zero-waste instances, such as C, N, and CX, are in the first category, and their optimal solutions are known as
BSA, 35 HRP, 24 FH, 15 DHA, 29 and RSMP 27 solve the RF sub-type and have excellent solutions, and we mainly compare our algorithm with them. HRP, FH, DHA, and RSMP are deterministic algorithms that need to be run only once. BSA is a non-deterministic algorithm similar to BHA and is run 10 times to decrease the randomness; therefore, we ran BHA 10 times. BHA was performed using C#. The detailed computational environment is presented in Table 2.
Computational environments.
The computational results for BSA, FH, DHA, and RSMP were obtained from the original atricles.15,27,29,35 The computational results of HRP were taken from Leung & Zhang, 15 which differ from the original results, 24 where HRP was designed to calculate the waste area of each instance and just has original results for data set C.
Computational results on zero-waste instances
Tables 3‒5 present the computational results for C, N, and CX, respectively. We compared BestH of BHA with those of other algorithms.
Computational results on the data set C.
In Table 3, BHA obtained three optimal results, whereas DHA, HRP, FH, BSA, and RSMP obtained 11, 8, 5, 3, and 0 optimal results, respectively. Figure 6 shows that

Comparison on the data set C.
Table 4 shows that BHA finds 2 optimal results in the overall 13 instances, while the numbers of optimal results obtained by BSA, HRP, FH, DHA, and RSMP are 2, 1, 2, 8, and 1, respectively. As shown in Figure 7, DHA (

Comparison on the data set N.
Computational results on the data set N.
In Table 5, BHA obtained optimal results for all instances (500cx, 1000cx, 5000cx, 10000cx, and 15000cx) with no less than 500 rectangles; however, the results for 50cx and 100cx are poor.
Computational results on the data set CX.
For data sets C, N, and CX, Figure 8 shows that BHA always performs better than BSA and outperforms RSMP in most instances. Although DHA performed better than BHA for C and N with mostly small-scale instances, it performed worse for CX. FH is stable in finding good solutions for all data sets. FH is better than BHA not only for

Comparison on the data sets C, N, and CX.
Comparison between BHA and FH for the data sets (C, N, and CX).
The best and mean results of BHA are always the same, as shown in Tables 3 to 5. This phenomenon can occur because they are zero-waste instances and most instances are not large. Despite applying the randomized local search method 1000 times, the solution space remains restricted after the initial rectangle
Computational results on non-zero-waste instances
Table 7 and Figure 9 show that BSA and HRP are unable to develop solutions for large-scale instances within the time limit, and all solutions of BHA, with the exception of Path1, Path2, and Path3, are inferior to those of FH and BHA. Although HRP has good solutions for small-scale instances, it is inferior to FH and BHA for all instances with

Comparison between BHA and FH for the data sets Nice and Path.
Computational results on the data sets Nice and Path.
The comparative results of the various algorithms for ZDF are summarized in Table 8. BHA, FH and HRP obtained 11, 8, and 0 optimal results, respectively. BHA obtained the most optimal results. FH outperformed BHA in only three instances (zdf8–zdf10), whereas BHA outperformed FH in five instances (shown in Figure 10). It is noted that the result of zdf8 computed by BHA is especially poor, which is 63 higher than that of FH. Nonetheless, the

Comparison between BHA and FH for the data set ZDF.
Computational results on the data set ZDF.
Tables 7 and 8 show that BHA has a certain uncertainty for large-scale instances, but the gaps between the best and mean results are smaller, except for zdf8. MeanH of BHA is almost the same as BestH of BHA for Nice and Path. For ZDF, they are different, but even MeanH of BHA is better than
Table 9 analyzes the running times of all algorithms mentioned previously. STD is the standard deviation. Range is from the minimum time to the maximum time. The running time and STD of BHA for each data set are significantly smaller than those of HRP and DHA. Since there is no running time limit for BHA, the computation time and STD of BHA increases with increasing number of rectangles, whereas those of FH change slightly because of its limitation of 60 seconds. Although the computation time of BHA is longer than that of FH mostly, it is acceptable. STD of BHA for each data set signifies that BHA is more stable than HRP and DHA in terms of the running time.
The running time comparison.
Computational results on large-scale instances
To illustrate the advantages of BHA on large-scale instances of various kinds, Table 10 summarizes the results of all instances of
Computational results on instances of
For BSA and HRP, not all instances could be computed within the time limit. DHA and RSMP did not compute instances of Nice, Path, and ZDF. Hence, we just compare the summarized results of BHA with those of FH that performed better for instances with
Figure 11 shows the comparison between BHA and FH, and Figure 11(a) to (d) shows instances with

Comparison between BHA and FH for instances with no less than 500 rectangles.
In order to further test the superiority of BHA in solving instances with
Comparison between BHA and FH for instances with no less than 1000 rectangles.
According to the computational results, DHA is the best algorithm for data sets C and N, RSMP is the best for CX, HRP is the best for Nice1–4, FH is the best for Nice and Path on the whole, and BHA is the best for ZDF. Moreover, BHA performs best for large-scale instances with
Effect of multi-start improvement
The ordering of all rectangles can impact the solution quality, but traversing all possible positions of the rectangles is time-consuming and impractical for large-scale instances. Considering the first rectangle has a greater impact than the others, BHA adopts a multi-start improvement strategy which makes all rectangles take turns as the first rectangle to balance the computation time and solution quality. To test the effect of the multi-start improvement strategy, the computational results of BHA without the multi-start improvement strategy were compared with those of the normal BHA, as listed in Table 12. ΔBestGap is the gap between the two BestHs in a line divided by BestH of BHA without the multi-start improvement phase. The multi-start improvement strategy significantly improves the solutions for all data sets. ZDF and Path have the greatest impact because ZDF has the largest variety of rectangular areas (1–1,081,080) and Path has significantly diverse rectangles.
Comparison between BHA with and without the multi-start improvement strategy.
Nice and Path are similar in that they have the same instances, and their corresponding instances have the same rectangles. The most difference between them is Nice with similarly sized rectangles, but Path with vastly different rectangles. We made a comparison of ΔBestGap between Nice and Path, as shown in Figure 12, to test the effect of the multi-start improvement strategy on the size difference of rectangles. Except for the first instance, every instance in Path was better than the corresponding instances in Nice. The larger the size differences of rectangles in an instance, the more significant the effect of the multi-start improvement. This is because the direction of subsequent layout is largely determined by the first rectangle. A different first rectangle may result in significant variations in the solution if the rectangles’ sizes differ significantly.

Comparison of ΔBestGap between Nice and Path.
Conclusion
The fitness method and the backtracking heuristic are combined in the backtracking constructive heuristic stage. The unique fitness method outperformed the current literature studies (FH, ISA, HSA, IA, and SRA). The backtracking heuristic was used under different heights to pack all the rectangles in a strip with the minimum possible height. For saving running time, BHA backtracked no more than
Footnotes
Abbreviations
Acknowledgments
Availability of data and material
The data presented in this study are available on request from the corresponding author.
Authors’ contribution
Conceptualization: L.L.; methodology: L.L.; formal analysis and investigation: L.L. and Z.W.; resources: Z.W.; writing—original draft preparation: L.L.; writing—review and editing: L.L. and B.L.; supervision: B.L.; funding acquisition: B.L. All authors have read and agreed to this version of the manuscript.
Declaration of conflicting interests
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Ethics approval
The authors certify that this manuscript is original and has not been published and will not be submitted elsewhere for publication while being considered by the journal. The study is not split up into several parts to increase the quantity of submissions and submitted to various journals or to one journal over time. No data have been fabricated or manipulated (including images) to support the conclusions. No data, text, or theories by others are presented as if they were our own.
Funding
The authors disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by the National Natural Science Foundation of China, the Joint Fund of Henan Science and Technology Research and Development Plan, and the Science and Technology Project of Henan Province in China (grant numbers 12072106, 242103810064, 222103810085, 232103810085, and 242102220029).
Informed consent
This article does not contain any studies with human participants.
Research involving human participants and/or animals
This article does not contain any studies with human participants or animals performed by any of the authors.
Appendix: The solutions of BHA on all data sets
A more detailed description of all the data sets is available at https://github.com/18439870129/BHA/tree/master. Tables A1 to A6 give the detailed solutions of BHA on all data sets mentioned. BHA was run 10 times;
