Figures
Abstract
The rectangular packing problem has been extensively studied over the years due to its wide application in industry. However, most of the research efforts are devoted to positioning techniques of the rectangles for various problem variants, the efficient implementation of the packing procedure is relatively less studied. In this paper, we propose an efficient constructive algorithm for the rectangular packing problem with rotations. We design a preprocess procedure with four data structures to store the information used for item selection. The gaps on the skyline are categorized into three types according to their associated edges for the placement procedure, during which the item is searched and packed in a descending order of the fitness value. The entire constructive phase takes a time complexity of O(nlogn). For the packing improvement phase, we optimize the packing through random perturbation on the sequence and orientation of the item. Three classes of stochastic problems are generated ranging from small-scale to extra-large-scale, the recorded running time confirms the efficiency of the proposed algorithm. We also test the proposed algorithm on the benchmark problem C21, N13, NT, Babu and CX, the computational results show that it delivers a good performance.
Citation: Zhao X, Rao Y, Qi P, Lyu Q, Yang P, Yu S (2023) An efficient constructive heuristic for the rectangular packing problem with rotations. PLoS ONE 18(12): e0295206. https://doi.org/10.1371/journal.pone.0295206
Editor: Lalit Chandra Saikia, National Institute of Technology Silchar, India, INDIA
Received: August 26, 2023; Accepted: November 16, 2023; Published: December 28, 2023
Copyright: © 2023 Zhao et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Data Availability: All relevant data are within the paper.
Funding: This work was supported by the National Natural Science Foundation of China (Grant No. 51975231). The funder participated in the editing of the manuscript.
Competing interests: The authors have declared that no competing interests exist.
1. Introduction
Given a group of large objects with regular shape and homogeneous material, designing an assortment of the small items accommodated by the large objects to minimize the waste is the classic cutting and packing problem [1]. Additional constraints in industrial applications may add properties to the cutting and packing problem, which defines a wide range of problem variants. For example, the small items can be rectangles, circles, polygons or even contour shapes with curved edges, and the large objects may have concave areas or defective parts that cannot be used for placement [2].
Usually, the computational time allowed for any specific problem depends on the material utilization and the task urgency, thus, most of the solutions attempt to make a trade-off between solution quality and the time consumption [3]. From a mathematical point of view, cutting and packing are closely related as they indicate the same computing process, they also share the same target that the predefined objective should be achieved with the fewest possible resources or the limited resources should be used to generate the best possible results [4].
The rectangular packing problem is categorized as a sub-type of the cutting and packing problem, where the items are rectangles and should be placed exactly into the container without overlap [5]. There are two most documented variants of the rectangular packing problem, the multiple bin packing problem and the strip packing problem. The former arranges a group of identical-sized or variable-sized bins and the items are supposed to fill the bins as much as possible [6–8], the later defines a container holding an open dimension which needs to be minimized through elaborate placement of all the given items [9–11].
Since real application may focus on more complicated scenarios in the field of production planning, scheduling, routing and loading, multi-objective optimization in combination with packing has attracted an increasing amount of attention as well. Wu studied a variant in which the ratio of the two dimensions of the rectangular layout should be kept within given range and predefined central rectangle should be placed near the center of the layout [12]. Fernández analyzed the approach to extend memetic algorithms to solve a the two-dimensional bin packing problem with requirements on loading balance [13]. Queiroz dealt with the two dimensional strip packing problem where the gravity center of the item must lie in a safety region and the given maximum tolerable weight which the item could bear must be satisfied [14]. Gajda studied a container loading problem handling a group of constraints simultaneously, including loading priorities, load bearing and balancing, unloading order, weight limits, cargo stability and positioning constraints [15].
A few exact methods have been proposed to solve the rectangular packing problem in recent years, the algorithms are mainly based on integer programming [16, 17] and dynamic programming [18]. While the exact methods are often used to solve problems of small-scale, most of the literature adopts the heuristic approaches. Burke [3] proposed a best fit (BF) strategy, the algorithm examines the lowest available space and always places the rectangle which matches the space. BF is reported to have made significant progress in terms of packing quality as well as computational efficiency, it is further studied over the years in the placement techniques [19, 20] or the improvement methods [21, 22].
Another recent attempt to solve the packing problem is to automate the design of heuristics, since the problem specific methods may have insufficient generality for other problems within a domain [23]. López-Camacho et al. developed a selection hyper-heuristic approach which constructs the solution incrementally, and each step contains a forward check to ensure the solution quality. Their model automatically selects the best heuristic for a given instance and the results are comparable to single heuristic [24].
As BF executes with the dynamic selection of the item during each placement, trivial implementation naturally takes a time complexity of O(n2). Although many heuristics with the BF architecture have been adopted to solve the packing problems, there are considerably few studies researching the efficient implementation of the packing procedure. The first research considering the efficient implementation of the BF heuristic is reported by Imahori & Yagiura, they stored the skyline with a heap and a doubly linked list, then, they used the balanced binary search tree to search for the fittest rectangle [25]. Wei et al. proposed a scoring rule based BF heuristic for the fixed orientation variant of the strip packing problem, where the scoring rule evaluates the matching edges between the item and the skyline, and they used a segment tree to search for the item in particular placement [26].
Inspired by Wei’s study [26], this paper presents an efficient constructive heuristic for the rectangular strip packing problem, in which the rectangles are allowed with the rotation of 90°. The constructive phase of the packing is initialized with a preprocess in which four data structures are designed to store the necessary information required by item selection. Then, the placement of item is implemented piece by piece, and the four data structures are updated continuously with the item selection. An optimization algorithm with random perturbation is provided for the packing improvement. The main contributions of this paper are: (i) an efficient implementation method of the rectangular constructive phase; (ii) an optimization algorithm to improve the packing quality; (iii) comparison between the efficient implementation and the original implementation on a group of packing problems from small-scale to extra-large-scale; and (iv) performance evaluation on a set of benchmark problems, which demonstrates that the proposed method provides satisfactory packing results.
The rest of the paper is organized as follows. In section 2, we provide the preliminaries of the study, including the best fit heuristic architecture and the segment tree used for item searching. In section 3, we propose the efficient rectangular packing heuristic for the constructive phase and design an optimization algorithm for the improvement phase. We present the computational experiments in section 4 and summarize the conclusions in section 5.
2. Rectangular selection strategy
The problem solved in this paper is defined in the same way as [27], i.e., a container with a fixed width denoted by W and an open dimension is provided to accommodate the rectangles. Let the number of the rectangles to be packed be n, we denote the length of each rectangle by li, width by wi, i∈[1, n]. The packing length is denoted by L’. The rectangles are allowed of the rotation of 90°.
We follow the architecture of the BF heuristic [3] and use the fitness evaluation rule [26] for the item selection. We always choose the bottom left skyline as the placement position. Then, the associated gap on the boundary [27] determines the shape of the next item to be placed. The fitness evaluation rule is used to select the most suitable rectangle. The fitness value is computed as the number of identical dimensions between the item and the gap, if there is an edge of the item which aligns with that of the gap, the fitness value is increased by 1. Then, the fitness value of the placement could 3, 2, 1 or 0.
If there is a tie, the earliest item in the sequence which has not been placed will be chosen. Then, under specific settings, the item selection is transferred to the range minimum query problem, where the item holding the minimal index is supposed to be picked out. The Segment tree [28, 29] is used to solve the range minimum query problem. Suppose the given range contains n’ elements. The segment tree is constructed through the decomposition of the large range into small units. Then, the node is iteratively assigned with the minimum value of the split range, from the leaf to the parent. The construction of the segment tree takes a time complexity of O(n’logn’), and both the query of a particular range and the update of single element take O(logn’).
3. Efficient rectangular packing heuristic
In this section, we present the efficient heuristic for the rectangular strip packing problem. We propose the efficient implementation of the constructive phase in section 3.1 and design a optimization algorithm for the improvement phase in section 3.2.
3.1. Packing constructive algorithm
The constructive phase is composed of the preprocess procedure and the placement procedure. The preprocess procedure defines the necessary data structures used throughout the packing, and the placement procedure implements the placement of the n items piece by piece.
We denote the top edge of the bottom left gap by et, the side edge which represents the width of the gap by ew, and the bottom edge by eb. as shown in Fig 1, the gap is marked with highlight. In this section, the fitness value of the placement is defined as the number of alignments between the item and the three edges of the gap.
3.1.1 Preprocess.
We design four data structures to search for the particular items, which are denoted by D1, D2, D3 and D4, respectively. We list the type of basic data structure contained in D1–D4 and the target placement of each data structure in Table 1.
In the data structure D1, we use a hash table and a group of lists to store the items. The key represents the size of each type of rectangle, it is recorded by (li, wi), i.e., a tuple of the length and width of the rectangle, and the value is represented by a list to store the given sized item. D1 is built by traversing the items. When a new size type of the item is met, a new key will be added to the hash table, and a list is initialized with the item specified as the first element. If an item with the size already stored in the hash table, the relevant list will be found through the key, then, the item will be appended to the list.
An example is provided for the construction of the four data structures. Suppose there are nine items to be packed, we denote them by r1–r9 and their sizes are (2, 3), (4, 5), (3, 2), (6, 8), (4, 5), (6, 10), (6, 3), (6, 5) and (6, 7). The first item with size (2, 3) will add a key of (2, 3) to D1, and it becomes the first element in the relevant list, then, D1 = {key: (2, 3), value: [r1]}. The second item will update D1 in the same way, so will the third item and the fourth item. After the update by the fourth item, D1 = {key: (2, 3), value: [r1]; key: (4, 5), value: [r2]; key: (3, 2), value: [r3]; key: (6, 8), value: [r4]}. When it comes to the fifth item, there already exists the key (4, 5), so no key will be added to D1, and the fifth item will be appended to the list with key (4, 5), then, D1 = {key: (2, 3), value: [r1]; key: (4, 5), value: [r2, r5]; key: (3, 2), value: [r3]; key: (6, 8), value: [r4]}. When the traversal of the nine items is over, D1 = {key: (2, 3), value: [r1]; key: (4, 5), value: [r2, r5]; key: (3, 2), value: [r3]; key: (6, 8), value: [r4]; key: (6, 10), value: [r6]; key: (6, 3), value: [r7]; key: (6, 5), value: [r8]; key: (6, 7), value: [r9]}.
In the data structure D2, another hash table is used to store the items. Unlike D1, the key represents the type of the single dimension of the rectangle, which is recorded with either li or wi, and the value is represented by a list to store the item holding the given dimension. We continue with the example of the nine items presented above. The first item has the dimension of 2 and 3, then, a key of 2 and another key of 3 will be added to D2, and the first item becomes the first element both in the relevant list of key 2 and the relevant list of key 3, i.e., D2 = {key: 2, value: [r1]; key: 3, value: [r1]}. The rest of the seven items will update D2 in the same way. When the traversal of the nine items is over, D2 = {key: 2, value: [r1, r3]; key: 3, value: [r1, r3, r7]; key: 4, value: [r2, r5]; key: 5, value: [r2, r5, r8]; key: 6, value: [r4, r6, r7, r8, r9]; key: 8, value: [r4]; key: 10, value: [r6]; key: 7, value: [r9]}.
The data structure D3 is generated from D2. We make a copy of D2, then, we sort the items in the list of each key by the other dimension of the item in the descending order. Then, a segment tree is built according to the sorted sequence. The hash table, sorted sequence and the segment tree comprise D3. The node of the segment tree represents the item with the minimum index in the given range. For example, the list of key 6 has five items namely r4, r6, r7, r8 and r9, and the other dimensions of them are 8, 10, 3, 5, 7, respectively. Then, the list would be [r6, r4, r9, r8, r7] after sorting. The segment tree is built as shown in Fig 2.
For the data structure D4, we sort the items by the minimal size of their two dimensions in the descending order. Another segment tree is built based on the sorted sequence, with the node still representing the item with the minimum index in the given range. For example, the minimal sizes of the nine items r1–r9 are 2, 4, 2, 6, 4, 6, 3, 5, 6, respectively, then, the list after sorting would be [r4, r6, r9, r8, r2, r5, r7, r1, r3]. The segment tree is built in the same way as that in D3, with the associated range containing all the 9 items.
We sort the items with merge sort in D3 and D4, during which we record the position of each item in the sorted sequence.
Since the skyline is continually updated with each placement, if a skyline does not have enough space for further placement, the skyline will be removed and merged into the neighbor skylines. The space for further placement is judged by the size of the skyline and the minimum dimension of the rest items. Hence, we have to continually track the smallest sized item in order to check if it has been placed or not. We denote the minimum dimension of the rest items by lwmin. We use another hash table denoted by Hlwmin to store all the items, and we make a copy of the sorted sequence in D4. Then, we design a pointer denoted by Plwmin to locate the last item in the sequence, and lwmin is initialized with the minor value of the two dimensions of the item pointed by Plwmin.
As presented in Table 1, among the four data structures D1–D4, D1 is used to search for the full matching placement, i.e., the item which could produce a fitness value of 3 or 2. If none of the remained items satisfy the placement with the fitness value of 3 or 2, D2 and D3 will be used to search for the item which has one dimension alignment with the gap. If none the remained items could not create the placement with non-zero fitness value, D4 will be used to search for the item which could be accommodated by the gap. The details of the item selection will be described in section 3.2.
The data structure D1 is built with the traversal of the items, both the addition of new key and the search for the existing key take the constant time, so does the element addition in the relevant list. Then, the construction of D1 takes O(n). The construction of D2 is similar to D1 and has the time complexity O(n). The merge sort takes O(nlogn), and the construction of the segment tree takes O(nlogn), then, the constructions of D3 and D4 take O(nlogn). Hence, the time complexity of the preprocess is O(nlogn).
3.1.2. Efficient implementation of rectangular constructive algorithm.
According to the position of the gap, we divide the placements of the rectangles into three types, as illustrated in Fig 3.
(a) Type 1: et = eb. (b) Type 2: et ≠ eb. (c) Type 3: et = eb = ∞.
In the first type, the gap is positioned inside the container, and its top edge and bottom edge have the same size, i.e., et = eb. The placement could have a maximum fitness value of 3 if the item has the full matching with the gap, as shown in Fig 3(A). Otherwise, the fitness value would be 1 if the item only aligns with one edge of the gap. If the item has a completely different shape compared with the gap that none of its edges could align with the gap, then, the fitness value is 0.
In the second type, the gap is also positioned inside the container, with its top edge and bottom edge shaped with different size, i.e., et ≠ eb. The maximum fitness value of the placement is 2 if the item could align with ew and et or ew and eb. as shown in Fig 3(B). The fitness value of 1 and 0 is produced by the placement similar to the first case.
The third type is relatively special which represents the case that none of the items have been packed, or the case that the packed items exactly share the same boundary. In this type, the skyline fills the fixed dimension of the container, and both et and eb could extend without limitation. The fitness value could be 1 only if one dimension of the item is equal to the width of the container.
Note that the case in which the gap is positioned on the top of the container (as shown in Fig 4(A)) or the case in which the gap is positioned on the bottom of container (as shown in Fig 4(B)) could be categorized into the first type.
(a) Gap at the top, et = ∞. (b) Gap at the bottom, eb = ∞.
Whether an item could be placed at the gap is decided by the width of the gap. If one of the item dimensions is smaller than ew, then, the item could be placed at the gap, either with a rotation of 0° or 90°.
We initialize the packing length L’ with 0. As there might be more than one item that could produce the placement with non-zero fitness value, we use three lists to store the item in the placement with the fitness value of 3, 2, 1, and they are denoted by Lf = 3, Lf = 2, Lf = 1, respectively. The efficient constructive algorithm is presented in algorithm.
Each placement starts from the gap shaped by the bottom left skyline (line 3, 4), and the placements under the gap type 1 (line 5–15), the gap type 2 (line 16–26) and the gap type 3 (line 27–33) are addressed individually.
If the gap belongs to the type 1, the item with fitness value 3 will be searched first. The item should be shaped with both the dimension of eb and ew. We search for the key of (eb, ew) in D1, if the key exists, enter the relevant list of item, and we select the first item without mark (i.e., it has not been packed) and store the item in Lf = 3. We also search for the key of (ew, eb) in D1, which represents the placement of the item with size (ew, eb) under a rotation of 90°, and we store the item in Lf = 3 (line 7). If Lf = 3 ≠ Ø, we choose the item with the minor index in Lf = 3 as the one to be packed (line 9). Otherwise, there does not exist the placement of fitness value 3, we continue with the search for the placement of fitness value 1.
Algorithm 1. Packing constructive algorithm
1. Initialize L’ and the skyline
2. for i = 1 to n do:
3. Choose the bottom left skyline
4. Compute et, ew, eb of the gap
5. if the gap belongs to type 1:
6. Reset the list Lf = 3, Lf = 1
7. Search for item with fitness value 3 and store the result in Lf = 3
8. if Lf = 3 ≠ Ø:
9. choose the item with minor index in Lf = 3.
10. else:
11. Search for item with fitness value 1 and store the result in Lf = 1
12. if Lf = 1 ≠ Ø:
13. choose the item with minor index in Lf = 1.
14. else:
15. Search for item with fitness value 0 and choose the item
16. if the gap belongs to type 2:
17. Reset the list Lf = 2, Lf = 1
18. Search for item with fitness value 2 and store the result in Lf = 2
19. if Lf = 2 ≠ Ø:
20. choose the item with minor index in Lf = 2.
21. else:
22. Search for item with fitness value 1 and store the result in Lf = 1
23. if Lf = 1 ≠ Ø:
24. choose the item with minor index in Lf = 1.
25. else:
26. Search for item with fitness value 0 and choose the item
27. if the gap belongs to type 3:
28. Reset the list Lf = 1
29. Search for item with fitness value 1 and store the result in Lf = 1
30. if Lf = 1 ≠ Ø:
31. choose the item with minor index in Lf = 1.
32. else:
33. Search for item with fitness value 0 and choose the item
34. Update data structure D1–D4
35. Compute the packing length L’
36. Relocate the pointer Plwmin and reset the minimum dimension lwmin
37. Update the skyline
38. return L’
For the placement of fitness value 1, we search for the key ew in D2 and store the item in Lf = 1, which represents the alignment between ew of the gap and the item. We also search for the key eb in D3, which represents the alignment between eb of the gap and the item. In the relevant list of key eb, the item has to satisfy an additional requirement that the dimension other than eb should be smaller than ew. We use the binary search to find the position of the first item which has the dimension smaller than ew, we denote the position by pD3, then, the items in the range from pD3 to the end of the list could meet the dimension requirement. The segment tree in D3 (presented in section 3.1.1) is used to find the item with the minimum index in the given range, and the item will also be stored in Lf = 1 (line 11). To continue with the example presented in section 3.1.1, we suppose that eb = 6 and ew = 9. Then, the search for the key eb in D3 results in the list [r6, r4, r9, r8, r7], and the additional requirement on the other dimension limits the available item within the range [r4, r9, r8, r7]. In this case, the item r4 is selected since it has the minimum index, and it is stored in Lf = 1. If Lf = 1 ≠ Ø, we choose the item with the minor index in Lf = 1 as the one to be packed (line 13). Otherwise, there does not exist the placement of fitness value 1, we search for the placement of fitness value 0 (i.e., the item with the minimal index which could be placed at the gap).
For the placement of fitness value 0, we use the binary search to find the position of the first item which has the dimension smaller than ew in the list of D4, we denote the position by pD4, then, the items in the range from pD4 to the end of the list could be placed at the gap. The segment tree in D4 is used to find the item with the minimal index in the given range (line 15).
If the gap belongs to the type 2 or the type 3, the operation is similar to that of type 1, with priority given to the placement of the larger fitness value.
After the item selection, the placement orientation of the item is determined by the match between its dimension and the shape of the gap. Besides, each placement of the chosen item will update the four data structures.
For the update of D1, group the length li and the width wi of the selected item as the key (li, wi) and search the key in D1, then the relevant list could be returned. As each item is appended to the end of the list in the preprocess, the items are naturally sorted in an increasing order of the index. We use binary search to search for the index of the item and we get the position, then, we mark this position as the item has been placed.
The update of D2 is similar to D1, we use both the length li and the width wi of the selected item as the key and get the relevant list individually. Then, we use the binary search to find the item and mark the item as used.
For the update of D3, as the hash table in D3 has the same key as that in D2, we already get the position of the chosen item in the relevant list in D2, and we have recorded the position of each element of the list in the sorted sequence (mentioned in section 3.1.1), then, the position of the chosen item in the relevant list in D3 could be computed. The leaf node will be tracked recursively along the direction from the root to the associated child, and its value is replaced with n+1, then, the item will not be selected in later steps in the range query on the tree. For example, when the item r4 is selected, it can be computed that r4 lies in the second position of the relevant list, with which the leaf node in the segment tree is tracked and found, as shown in Fig 5(A). Then, all the nodes along the track are updated, the minimal value of each node and its sibling node will replace that of the parent node, as shown in Fig 5(B).
(a) Leaf node track. (b) Node value update.
The update of D4 is similar to D3, we replace the associated node in the segment tree with value of n+1.
We also update the minimum dimension of the rest items. Each selected item will be removed from the hash table Hlwmin. Then, if the item being located by the pointer Plwmin is still in Hlwmin, it means the item with the minimum dimension has not been placed, thus, the minimum size lwmin will remain unchanged. If the item being located by Plwmin is not in Hlwmin, Plwmin will move towards the beginning of the sequence one by one, until it reaches the item that is still in Hlwmin. Then, lwmin will be replaced by the minimum dimension of the pointed item.
The placement procedure is composed of three major steps, namely the selection of the fittest item, the update of the data structures, and the update of the minimum size lwmin of the item. The search through hash table takes constant time, while the query on the segment tree takes O(logn), then, the selection of the fittest item takes O(logn). The update of the four data structures also takes O(logn) due to the update of the node in the segment tree. Thus, these two steps in the traversal take O(nlogn). For the update of lwmin, as the pointer Plwmin purely moves towards the beginning of the sorted sequence throughout the packing of the n items, it takes O(n). Hence, the placement procedure takes O(nlogn), and the time complexity of the entire constructive phase is O(nlogn).
The procedure of the constructive phase is illustrated in Fig 6, the preprocess procedure (presented in section 3.1.1) and the placement procedure (presented in this section) are marked separately. The four data structures D1–D4 and the pointer Plwmin are initialized in the preprocess procedure. Then, each placement starts from the bottom left skyline and the type of the gap is decided. The item is selected according to the fitness value from largest to smallest, and D1–D4 as well as Plwmin are updated.
3.2. Packing optimization algorithm
We design the optimization algorithm for the improvement phase. Since the rectangles are allowed with the rotation of 90°, the solution is composed of the sequence and the orientation of the n items. We adopt the idea proposed by Wei et al. [26] and adapt it to the optimization on both the sequence and the orientation.
We denote the sequence and orientation of the n items by S and O respectively. The sequence, orientation and the packing length of the best solution are denoted by Sopt, Oopt and L’opt respectively.
A group of solutions is used to explore the neighborhood of the optimal solution. We denote the number of the solutions by Ng, the sequence of the i-th solution by Si and the orientation the i-th solution by Oi, i∈[1, Ng]. The packing optimization algorithm is presented in algorithm 2.
Algorithm 2. Packing optimization algorithm
1. Read the size data of the item
2. for i = 1 to Ngroup do:
3. Initialize Si and Oi
4. Compute the packing length L’i (with algorithm 1)
5. Select Si, Oi and L’i of the best solution as Sopt, Oopt and L’opt
6. for iter = 1 to t do:
7. for i = 1 to Ngroup do:
8. Regenerate Si and Oi through Sopt and Oopt
9. Compute the packing length L’i (with algorithm 1)
10. Update Sopt, Oopt and L’opt
11. return L’opt
Algorithm 1 is invoked to pack the items under the given sequence and the given orientation, with the packing length L’ of the i-th solution returned (line 4, 9). The group of solutions are initialized in line 2–4, the sequence Si is initialized in the descending order of the perimeter of the item, and the orientation Oi is initialized with random rotation of 0° or 90° (line 3). Then, the solution with the minimal packing length is selected as the optimal solution (line 5).
The group of solutions is updated continually in the iterations (line 6–10). Each solution is updated through an operator of random swap implemented on the optimal sequence Sopt or an operator of random orientation change on the optimal orientation Oopt (line 8). The optimal solution will be replaced with new solution which produces the smaller packing length (line 10).
4. Experiments and discussion
In this section, we generate a group of stochastic problems to testify the running time of the proposed algorithm. Then, we test the proposed algorithm on a set of benchmark problems. The algorithm is coded in python and tested under the computational environment of 2.3GHz CPU and 16 GB RAM without multithreading.
We design the stochastic problems in which the number of item is set with 10t, where t∈[1,6], representing the packing problems from small-scale to extra-large-scale. We denote these six stochastic problems by P1–P6, respectively. Three classes of value ranges are set on the item dimension, namely [10, 100], [10, 500] and [10, 1000], and we denote them by class1, class2 and class3 respectively. Both the dimensions of each item are randomly selected integers within the given range.
We list the time consumption of both the original implementation (time complexity O(n2)) and the proposed efficient implementation (time complexity O(nlogn)) of constructive phase in Table 2. For the original implementation, "-" means that the running time exceeds 10 minutes and it cannot be recorded.
The time consumption for the efficient implementation is presented in Fig 7. The x-axis values denote the scale of the problem, and the y-axis values denote the running time (s),
The results from Table 2 and Fig 7 show that the proposed rectangular constructive algorithm is executed considerably fast. The efficient implementation takes almost the same amount of time compared with the original implementation on small-scale problems (n ≤ 102), while it presents clear advantages over the original implementation on the problems with n ≥ 104. The implementation of packing 104 items would only takes about 1s, even for the extra-large-scale problem, the running time could be reduced to nearly 100s, which cannot be completed by the original implementation. We note that the ordinary behavior of the efficient implementation compared with the original implementation on small-scale problems could be explained by the preprocess procedure, since a certain amount of computational effort is allocated to the initialization of the designed data structures.
To test the performance concerning the packing qualities, we evaluate the proposed algorithm on the benchmark problem C21 [30], N13 [3], NT [31], Babu [32] and CX [33], same as the research in [34] has presented. For simplicity, we name the efficient constructive heuristic proposed in this paper (along with the packing optimization algorithm) as EH. The running time od EH is limited within 60s, and the optimization algorithm will be stopped when the packing length reaches LB. EH is run 10 times on each of these problems and the best result is recorded. The results are presented in Tables 3–6. The lower bound (optimal packing length) is denoted by LB, and the gap represents the result of 100 * (L’—LB) / LB.
Some excellent algorithms are listed here for comparison, they include FH (Leung et al., 2011, [35]), BBF (Aşık et al., 2009, [20]), BBFM (Özcan et al., 2013, [36]), IDBS (Wei et al., 2011, [19]), BFHA (Chen et al., 2019, [34]). To the best of our knowledge, IDBS performs rather effectively and it holds by far the best record on the rectangular strip packing problem with rotations. The optimal results (equal to LB) found by the above algorithms are presented in bold.
The computational results testify that EH behaves effectively on the benchmark problems, especially EH could find the optimal solutions on all the problems of N13 within 60s. On C21, EH appears slightly inferior to BFHA, but EH still provides 19 optimal results out of the 21 problems, while BFHA takes a large amount of computational effort on a few particular problems.
The problem NT has been relatively difficult to solve in the literature through heuristic approaches. IDBS shows rather excellent performance that it provides the minimum gap from the optimum, while EH behaves worse than IDBS and better than BFHA. We notice that EH could not provide a good result on the first problem of CX, this may be caused by the extreme shape of the rectangle and the placement strategy used in EH, i.e., the bottom left placement in this problem might generate some extreme gap, leading to the earlier placement of the extreme rectangle which would be later placed in the other position with a specific orientation. Then, vacant regions could be produced without filling, the layout would not be ideally compact.
Future research could examine the efficient implementation of more sophisticated placement strategy and evaluation rule for the item selection. Since the fitness evaluation adopted in this paper only presents the alignments between the edges, it could possibly be strengthened through an extended assessment on the discrepancy between the dimensions of the edges in the non-alignments.
5. Conclusions
We propose an efficient heuristic for the rectangular packing problem with rotations. The packing is comprised of the constructive phase and the improvement phase. We categorize the gaps on the skyline into three types according to their associated edges. Four data structures are designed to store the information used for item selection and a pointer is built to locate the minimum dimension item for the update of skyline. Through the designed data structures, the entire time complexity of the constructive phase is O(nlogn). An optimization algorithm is presented for the improvement phase, where the packing is optimized through random swap on the sequence or the random change on the orientation of the item. We design three classes of stochastic problems with the number of items ranging from 101 to 106, the running time indicates the efficiency of the proposed algorithm. The proposed algorithm is also tested on the benchmark problem C21, N13, NT, Babu and CX, the results show that it provides satisfactory packing qualities.
References
- 1. Wäscher G, Haußner H, Schumann H. An improved typology of cutting and packing problems. European journal of operational research. 2007;183(3):1109–30.
- 2. Alvarez-Valdes R, Martinez A, Tamarit J. A branch & bound algorithm for cutting and packing irregularly shaped pieces. International Journal of Production Economics. 2013;145(2):463–77.
- 3. Burke EK, Kendall G, Whitwell G. A new placement heuristic for the orthogonal stock-cutting problem. Operations Research. 2004;52(4):655–71.
- 4. Martinovic J, Scheithauer G, de Carvalho JV. A comparative study of the arcflow model and the one-cut model for one-dimensional cutting stock problems. European Journal of Operational Research. 2018;266(2):458–71.
- 5. Silva E, Oliveira JF, Wäscher G. 2DCPackGen: A problem generator for two-dimensional rectangular cutting and packing problems. European Journal of Operational Research. 2014;237(3):846–56.
- 6. Wei L, Lim A. A bidirectional building approach for the 2D constrained guillotine knapsack packing problem. European Journal of Operational Research. 2015;242(1):63–71.
- 7. Cui Y, Cui Y-P, Yang L. Heuristic for the two-dimensional arbitrary stock-size cutting stock problem. Computers & Industrial Engineering. 2014;78:195–204.
- 8. Wang Y, Chen L. Two-dimensional residual-space-maximized packing. Expert Systems with Applications. 2015;42(7):3297–305.
- 9. Burke EK, Hyde MR, Kendall G. A squeaky wheel optimisation methodology for two-dimensional strip packing. Computers & Operations Research. 2011;38(7):1035–44.
- 10. Wei L, Tian T, Zhu W, Lim A. A block-based layer building approach for the 2D guillotine strip packing problem. European Journal of Operational Research. 2014;239(1):58–69.
- 11. Alvarez-Valdés R, Parreño F, Tamarit JM. Reactive GRASP for the strip-packing problem. Computers & Operations Research. 2008;35(4):1065–83.
- 12. Wu L, Zhang L, Xiao W-S, Liu Q, Mu C, Yang Y. A novel heuristic algorithm for two-dimensional rectangle packing area minimization problem with central rectangle. Computers & Industrial Engineering. 2016;102:208–18.
- 13. Fernández A, Gil C, Baños R, Montoya MG. A parallel multi-objective algorithm for two-dimensional bin packing with rotations and load balancing. Expert Systems with Applications. 2013;40(13):5169–80.
- 14. de Queiroz TA, Miyazawa FK. Two-dimensional strip packing problem with load balancing, load bearing and multi-drop constraints. International Journal of Production Economics. 2013;145(2):511–30.
- 15. Gajda M, Trivella A, Mansini R, Pisinger D. An optimization approach for a complex real-life container loading problem. Omega. 2022;107:102559.
- 16. Kenmochi M, Imamichi T, Nonobe K, Yagiura M, Nagamochi H. Exact algorithms for the two-dimensional strip packing problem with and without rotations. European Journal of Operational Research. 2009;198(1):73–83.
- 17. Velasco AS, Uchoa E. Improved state space relaxation for constrained two-dimensional guillotine cutting problems. European Journal of Operational Research. 2019;272(1):106–20.
- 18. Russo M, Sforza A, Sterle C. An improvement of the knapsack function based algorithm of Gilmore and Gomory for the unconstrained two-dimensional guillotine cutting problem. International Journal of Production Economics. 2013;145(2):451–62.
- 19. Wei L, Oon W-C, Zhu W, Lim A. A skyline heuristic for the 2D rectangular packing and strip packing problems. European Journal of Operational Research. 2011;215(2):337–46.
- 20. Aşık ÖB, Özcan E. Bidirectional best-fit heuristic for orthogonal rectangular strip packing. Annals of Operations Research. 2009;172:405–27.
- 21. Burke EK, Kendall G, Whitwell G. A simulated annealing enhancement of the best-fit heuristic for the orthogonal stock-cutting problem. INFORMS Journal on Computing. 2009;21(3):505–16.
- 22. Leung SC, Zhang D, Sim KM. A two-stage intelligent search algorithm for the two-dimensional strip packing problem. European Journal of Operational Research. 2011;215(1):57–69.
- 23. Burke EK, Gendreau M, Hyde M, Kendall G, Ochoa G, Özcan E, et al. Hyper-heuristics: A survey of the state of the art. Journal of the Operational Research Society. 2013;64:1695–724.
- 24. López-Camacho E, Terashima-Marin H, Ross P, Ochoa G. A unified hyper-heuristic framework for solving bin packing problems. Expert Systems with Applications. 2014;41(15):6876–89.
- 25. Imahori S, Yagiura M. The best-fit heuristic for the rectangular strip packing problem: An efficient implementation and the worst-case approximation ratio. Computers & Operations Research. 2010;37(2):325–33.
- 26. Wei L, Hu Q, Leung SC, Zhang N. An improved skyline based heuristic for the 2D strip packing problem and its efficient implementation. Computers & Operations Research. 2017;80:113–27.
- 27. Zhao X, Rao Y, Meng R, Fang J. A Q-learning-based algorithm for the 2D-rectangular packing problem. Soft Computing. 2023:1–14.
- 28. Preparata FP, Shamos MI. Computational geometry: an introduction: Springer Science & Business Media; 2012.
- 29. De Berg M. Computational geometry: algorithms and applications: Springer Science & Business Media; 2000.
- 30. Hopper E, Turton BC. An empirical investigation of meta-heuristic and heuristic algorithms for a 2D packing problem. European Journal of Operational Research. 2001;128(1):34–57.
- 31. Hopper E. Two-dimensional packing utilising evolutionary algorithms and other meta-heuristic methods: University of Wales. Cardiff; 2000.
- 32. Babu AR, Babu NR. Effective nesting of rectangular parts in multiple rectangular sheets using genetic and heuristic algorithms. International Journal of Production Research. 1999;37(7):1625–43.
- 33. Pinto E, Oliveira JF, editors. Algorithm based on graphs for the non-guillotinable two-dimensional packing problem. Second ESICUP Meeting, Southampton; 2005.
- 34. Chen M, Wu C, Tang X, Peng X, Zeng Z, Liu S. An efficient deterministic heuristic algorithm for the rectangular packing problem. Computers & Industrial Engineering. 2019;137:106097.
- 35. Leung SC, Zhang D. A fast layer-based heuristic for non-guillotine strip packing. Expert Systems with Applications. 2011;38(10):13032–42.
- 36. Özcan E, Kai Z, Drake JH. Bidirectional best-fit heuristic considering compound placement for two dimensional orthogonal rectangular strip packing. Expert Systems with Applications. 2013;40(10):4035–43.