2017 2nd International Conference on Electrical and Electronics: Techniques and Applications (EETA 2017) ISBN: 978-1-60595-416-5 Solving Rectangle Packing Problem Based on Heuristic Dynamic Decomposition Algorithm Shi WANG1,2,3 1 Department of Computer Engineering, Dongguan Polytechnic, Dongguan, China 2 DG-HUST Manufacturing Engineering Institute, Dongguan, China 3 GuangDong Intelligent Robotics Institute, Dongguan, China Keywords: Heuristic, Dynamic decomposition, Global optimization, Rectangle packing problem. Abstract. This paper proposes a heuristic dynamic decomposition algorithm for solving twodimensional rectangular layout and global optimization problems. First, the container was orthogonally decomposed according to the emission rectangle, and the layout was carried out based on a heuristic placement strategy with a high hit rate, so the large-scale and complex problem can be solved quickly and efficiently. The results of several internationally recognized studies show that this algorithm has a distinct advantage in terms of computing time and calculation accuracy. In addition, the algorithm can be effectively extended to the global layout of multi-vessel and threedimensional layout optimization. Introduction The rectangle packing problem [1] is the optimization problem of the non-overlapping layout of a set of rectangular objects in a limited area, and it has many applications in different fields, such as sheet metal cutting, container freight and VLSI layout. These types of issues directly affect the efficiency of the industry, so the solution to this problem has a great practical value; however, this problem has been proved to be an NP-hard problem. Solving an NP-hard problem accurately is extremely difficult, especially in larger cases. Thus, finding a solution to such problems has attracted many scholars. Literature [3-12] has proposed a variety of algorithms for solving the rectangle packing problem in two-dimensions; some examples include the greedy algorithm, genetic algorithm, particle swarm optimization, heuristic algorithm and hybrid algorithm. Literature [13] has also proposed an anthropomorphic algorithm to solve the rectangle packing problem in three-dimensions. However, the above studies are subject to various conditions, and it is difficult to apply them to other kinds of rectangle packing problems. This paper presents a heuristic dynamic decomposition algorithm for the rectangle packing problem, which is robust and adaptable. In addition, the algorithm can be extended to the algorithm of three-dimensional packing and several rectangle containers packing. The rest of the paper is organized as follows. In section II, we introduce the mathematical description of the rectangle packing problem. Section III details the proposed algorithm and its implementations. The experimental results are provided and discussed in Section IV. Conclusions are summarized in Section V. Mathematical Description The rectangle packing problem is the challenge of maximizing the utility of the container area. In Figure 1, S is a rectangle container of width W and height H. For N rectangular blocks Ri (width wi , height hi ), the aim is to use the method of mutual noninterference and place as much Ri as much into container S. In Figure 1, the bottom-left corner of the rectangle container S is the coordinate origin, while the lower base of the rectangle container is X-axis. The literature [7] gives the mathematical description as follows: 187 1) xr ,i xl ,i wi and yl , i yr , i hi， or xr ,i xl , i hi and yl , i yr , i wi (1) 2) xr , i xl , j and xl , i xr , j , or yr ,i yl , j and yl , i yr , j 3)0 xr ,i , xl , i W and 0 yr , i , yl , i H where ( xr ,i , yr ,i ) are the coordinates of upper-left corner, and corner. ( xl , i , yl , i ) are the coordinates of lower-right R1 Ri R2 Figure 1. Mathematical Descriptor of packing problem. The Proposed Algorithm and Its Implement Dynamic Decomposition The traditional method of decomposition container uses the reverse thinking of cutting to solve the packing problem. According to the method of the literature [14], the container is divided into two parts using a binary tree structure; however, the remaining sub-containers cannot be dynamically fused, which means the row of containers gets smaller and smaller without taking into account the mutual nested layout. Hence, we can combine the reverse thinking of cutting with the mutual nested layout to solve the packing problem. As the nested layouts of Figure1 display, the traditional nesting algorithm sequentially would attempt a horizontal split and a vertical split along R1 and then choose the segmentation layout with the maximum utility. However, it is difficult to place R2 in container S usin horizontally split container S along R1, which is shown in Figure 2(a). Using vertically split container S, R3 cannot be placed in container S, as shown in Figure 2(b). We find that the above split cannot achieve the optimal layout. R3 R2 R1 R1 (a) Horizontally split (b) Vertically split Figure 2. In Figure 2, each step of the decomposition is independent, so the horizontal and vertical split can be simultaneously carried out through parallel computing which is shown in Figure 3. A nested layout is realized by enumerating all possible rectangular containers in a manner similar to the idea of dynamic programming. This parallel decomposition method avoids the combined computation of the remaining area. R1 S1 R3 S2 S3 S4 R4 Figure 3. Container decomposition process. The above method that dynamically generates a virtual container is called dynamic decomposition, a method that places the best rectangle into the best container. According to the 188 position of the newly placed rectangle, the container is broken into two adjacent rectangular subcontainers along the horizontal and vertical directions, and the new orthogonal sub-containers are added into the container collection and a new round of placement is carried out. The above process continues until all rectangles have been placed or the container collection cannot put down any more rectangles. The above dynamic decomposition considers two questions: The new fitness function, which decides the best rectangle for the best container The new method, which updates all container collections after each rectangle is placed The greatest fitness function of the degree of coupling between rectangle and container can be found by scanning all pending rows of rectangles and container collections to solve the first question. For the second question, the new container collection can be obtained after the plane intersection operation is carried out between the newly placed rectangle and all rectangular containers. Placement Guidelines The first step of placements is to create an evaluation index that judges the tightness of the rectangles in the containers. From Figure 4, we find that the tightness can be checked by distance di between the rectangle and every side of the container. Thus, we set di = min(Dh, Dw) and li=max(Dh , Dw). If two placements have the same value, the placement with the smaller value li is chosen. In addition, the rectangle with the high aspect ratio or larger area should be placed first. Dh Ri Dw Figure 4. The distance between rectangle and container. According to the above, we gain the computation expression of placement coupling as follows: li wi hi wi hi 2 di fd 1 (2) where wi and hi are the width and height of the rectangle, respectively. However, S is the virtual container of the container collection, so di of Eq. (2) equals the Euclidean distance between rectangle Ri and the surrounding rectangle in the actual placement calculations. This distance must traverse all placed rectangles and takes di as its minimum. At the same time, the best docked position and the placement direction of the rectangle should be determined after choosing the rectangle and container. From Figure 4, we see that the placement coupling will be larger when the rectangle has more edges with the surrounding rectangle. Thus, the heuristic method is used to find the docked position and direction. In this method, the placement with the maximum edge length is chosen, enumerating the state and rewind of four corners, as shown in Figure 5. If two or more of the same value as the corner edge exist, the rectangle is placed on the left bottom corner. Ri Figure 5. The docking position of rectangle. 189 Update of Container Status When a new rectangle is put into the container, the status of the container that has an overlap region with the added rectangle must be updated. The update method is to check for interference between the new rectangle and the container. If the interference exists, the compromised container would be deleted and new child containers would be created. There are six types of interference cases discussed, which are shown in Figure 6. (a) corner interference (b) rectangle edge interference (c) s-edge interference (d) d-edge interference S R R S (e) rectangle in container (f) container in rectangle Figure 6. Six types of interference cases discussed. R represents a rectangle, and S represents the existing container. For the above cases, the status of container updates is as follows: For a corner interference, the original container is deleted and two new containers are generated; For a rectangle edge interference, the original container is deleted and three new containers are generated; For a single edge interference, the original container is deleted and a new container is generated; For a double edge interference, the original container is deleted and two new containers that have up and down or left and right relations are generated; For a rectangle in a container, the original container is deleted and four new containers are generated; For a container in a rectangle, the original container is deleted. The dashed box in Figure 6 is the newly generated container. In addition, since the rectangle is always placed in the corner, the case of Figure 6 (e) and Figure 6 (f) does not appear, so the algorithm may ignore these two cases. Algorithm and Time Complexity The algorithm is written in object Pascal language, and the pseudo-code process is as follows: Procedure GetMaxCase //Pre-placement process to get optimal placement rectangle and container Begin MValue= -MaxInt; For i:=1 to n do Begin For j:=1 to m do //Traverse the collection container If GetPutValue()>MValue then //Calculate coupling Record the best container and rectangle; End. End. Procedure Main // Main algorithm process 190 Begin Initialize container collection; For i:=1 to n do If GetMaxCase() then Begin SetRect(); //place rectangle ; SetNextContainer(); //update container collection; End; End. For the packing of N rectangle, the analysis of time complexity can be divided into three parts: The number of deleted or generated child containers has a nearly linear relation with the number of rectangles that have been placed; the time complexity of choosing a container is O(N); Choice of container, tentative placement of all subsequent rectangles into the container and calculation of coupling; the time complexity of this process is O(N2); For corner interference, the original container is deleted and two new containers are generated; From the above, the time complexity is O(N4). Improvement of the Algorithm Since the dynamic decomposition algorithm is the heuristic greedy algorithm, a rectangle and its placement in each instance are uniquely determined. This means that the candidate child container rarely places the first few rectangles. The heuristic placement strategy is difficult to accurately direct, and placement has a larger blindness. To overcome the above problems, a backtracking method is added into the original algorithm as follows: First step: sort rectangles by size from large to small and set the pointer to the first rectangle; Second step: select the rectangle indicated by the pointer as the first one put into the container, and place the subsequent rectangle according to the coupling placement strategy; Third step: if the container cannot hold any more rectangles, the total area of the rectangle is recorded and the process is terminated. If all rectangles are put into the container, the current layout is the solution of this problem. Fourth step: the pointer that does not reach the last rectangle will add one to get a new pointer, which points to the next rectangle; then, proceed to the second step. If the pointer has reached the last rectangle, the process will be terminated and will return the record with the maximum area as the solution of the problem. The pseudo-code of the algorithm is as follows: Begin SortByArea(); Result.Area := 0; //Initialize layout rectangle area p := 1 ; While p <= n do Begin SetRect();//put rectangle into the empty container SetNextContainer(); //update container collection PutCount :=1; //the number of rectangle put is 1 For i:=1 to n do If GetMaxCase() then //obtain best container and rectangle Begin SetRect(); // put rectangle into the container SetNextContainer(); // update container collection PutCount := PutCount+1; End Else Begin If PutCount = n then Break; If CurrentPacking .Area > Result.Area then Result := CurrentPacking; End; End End 191 In order to verify the improved algorithm, we used cases 1, 2 and 3 of the literature [10] to compare effectiveness. Experiment results show that the origin algorithm can find the optimal solution for case 1 (n=5) and case 3 (n=7), but the improved algorithm can find the optimal solution for all three cases. Figure 7 is the final layout for case 2 (n=6) using two algorithms. (a) original algorithm, (b) improved algorithm Figure 7. Experimental Results In order to verify the algorithm, several internationally recognized benchmark test data are used to compare the effectiveness of different algorithms. The experiments were run on a PC running Windows XP at 2.4GHz CPU with 2 GB memory. Layout Test of OR-Benchmark A set of data is randomly assigned from OR-Benchmark, and the sheet of these data has width 135 and length no limit (http://www.laria.u-picardie.fr/hifi/OR-Benchmark). The layout result of the proposed algorithm is shown in Figure 8. In the test, the backtracking level is set to 1, and the length of the actual layout is 626. The layout utilization was 98.64% and computing time was 0.5 seconds. Meanwhile, study 5 used an exact algorithm in which the layout utilization of these data was 90.14%. We can see that the layout utilization of the proposed algorithm increased 9.4%. Figure 8. Layout test of OR-Benchmark Compared with CAGA and PH Algorithm The GAGA algorithm explained in study [4] combines a constructive method and a genetic algorithm, so it has high computing efficiency. The PH algorithm of study [7] is based on the experience of human transformation of nature, which has higher computational efficiency. The SCPL1 ~ SCPL9 data of the OR-Benchmark are used to test the above three algorithms, and the calculation results are shown in Table 1. In Table 1, H* is the Optimum height, which can be calculated by the following formula: n H* (w * h ) i 1 i i (3) W 192 Table 1. Comparison results of three algorithms. Inst SCPL1 SCPL2 SCPL3 SCPL4 SCPL5 SCPL6 SCPL7 SCPL8 SCPL9 N 425 127 225 365 165 657 357 475 175 Proposed algorithm H* H() T 110 213 1.913 120 108 0.561 84 158 0.747 102 136 1.265 102 117 0.865 126 72 1.145 198 606 0.892 156 955 0.916 117 185 1.156 GAHA H T 48.08 8.153 150.16 3.225 155.84 6.522 58.263 4.698 128.89 3.193 52.4 12.13 119.93 0 63.419 4.07 89.96 5.602 PH H 183.5 463.5 321 684.5 480 234 0 900 507 T 8.153 1.893 5.239 2.981 2.417 22.811 -14.88 7.223 3.379 H is the real layout height and T is the computing time, which varies according to different test environments. As Table 1 shows, the results of the dynamic decomposition algorithm are significantly better than the previous two algorithms, and some results have reached the limit height. In addition, the number of rectangles in SCPL6 and SCPL7 as described in study [4] does not match the actual download, so the corresponding comparison can be ignored. Test of OR-Library Using the test data of the OR-Library, we compare the proposed algorithm and the EA algorithm, as shown in Table 2. Table 2. Comparison results of or-library. cgcut1 cgcut2 cgcut3 ngcut1 ngcut2 ngcut3 ngcut4 ngcut5 ngcut6 ngcut7 ngcut8 ngcut9 ngcut10 ngcut11 ngcut12 beng01 beng02 beng03 beng04 beng05 beng06 beng07 H* Type n 23 63 636 20 28 28 18 36 29 10 33 49 59 51 77 30 57 84 107 134 36 67 7 10 20 5 7 10 5 7 10 5 7 10 5 7 10 20 40 60 80 100 40 80 16 23 62 10 17 21 7 14 15 8 13 18 13 15 22 20 40 60 80 100 40 80 EA H 23 67 670 23 30 28 20 36 31 20 33 50 80 52 87 30 58 85 108 134 37 67 H 23 63 642 20 28 28 18 36 29 10 33 49 59 51 77 30 57 84 107 134 36 67 Proposed RT/s 0.02 0.22 38.5 0.01 0.01 0.02 0.03 0.02 0.02 0.02 0.02 0.02 0.03 0.13 2.11 0.05 0.16 0.03 0.06 0.05 0.03 0.09 From Table 2, we see that all test data sets achieve optimal height in a very short time except for cgcut3. Test of Random Data Set Currently, there is no detailed data set to test for the layout of large-scale scattered rectangles (http://www.solveworks.com/AutoCUT/Test/AutoCUT-Random.htm). The layout of the proposed algorithm for 1000 random rectangles with a size of 3 ~300 in a 6000*4050 rectangular area is shown in Figure 9. The entire process takes 18 seconds, and the layout utilization rate reaches 99.6%. 193 Figure 9. Layout of 1000 random rectangles. Test of Local Backtracking In order to verify local backtracking, all data sets of Table 1~Table 3 in study [10] are used to compare the GARBL algorithm and the proposed algorithm in which the backtracking level is set to 3. The result is shown in Table 3. Table 3. Comparison results of backtracking. GARBL n 5 6 7 8 9 10 Best error Worst error 0 0 0 0 0.025 0.024 0.022 0.078 0.099 0.086 0.162 0.104 Time of 30 trials 0:03:21 0:06:04 0:08:48 0:13:45 0:18:58 0:25:30 Proposed Algorithm Average run error Time time 0:00:07 0 0:00:01 0:00:12 0 0:00:01 0:00:18 0 0:00:01 0:00:28 0 0:00:01 0:00:38 0 0:00:01 0:00:51 0 0:00:01 From Table 3, we can see that all data sets achieve the optimal solution with just one attempt using the proposed algorithm, while the GARBL solution must compute many times. Global Layout Many engineering problems do not belong to a single rectangle packing problem; for example, space utilization of multiple containers in cargo loading, comprehensive layout of multi-block and oddments. The proposed algorithm can be modified to solve the packing problem of multicontainers. In the pre-treatment, multiple containers are sequentially placed in disjointed order, which is shown in Figure 10. Then, the vertex coordinate information of multiple containers can be added to the container set in the initialization, and other steps are similar. S1 S2 S3 Figure 10. Global packing of multiple containers. Commercial Application The proposed algorithm has been applied to commercial software AutoCUT Expert (http://www.solveworks.com), in which 2D and 3D layout tests are shown, as in Figure 11. 194 (a) 2D layout test (b) 3D layout test Figure 11. (a) 2D layout test, (b) 3D layout test. Conclusion In this paper, we addressed the heuristic dynamic decomposition algorithm, which can be used to solve the rectangle-packing problem. Multiple examples of internationally recognized data tests show that the proposed dynamic decomposition algorithm has obvious advantages compared to existing algorithms, including faster computing speed, higher utilization layout and wider adaptation range. It is especially suitable for solving large-scale non-regular rectangle packing problems. Meanwhile, the proposed algorithm can be used to solve the three-dimensional packing problem and irregular-shaped nesting problem, giving it a wide array of possible applications. Acknowledgment The Chinese Academy of Sciences cooperation projects in Guangdong Province No. 2013B090600131, 2013B010134006, 2016A010106001. Guangdong Provincial Key Laboratory fund 2011A060901026. Wang Shi was born in Hunan, China, in 1977. He received the Bachelor's degree in 2000 and Master's degree in 2009, from Huazhong University of Science & Technology, Wuhan, China. He is currently a associate professor of Department of Computer Engineering, Dongguan Polytechnic. His research interests include intelligence algorithm, project management and software development. References [1] Andrea Lodi, Silvano Martello, and Michele Monaci. “Two-dimensional Packing problems: A survey,”. European Journal of Operational Research, vol. 141, 2002, pp. 241-252. [2] Joseph Y.-T. Leung, Tommy W. Tam, and C.S. Wong, et al. “Packing Squares into Square,”. Journal of Parallel and Distributed Computing, vol. 10, 1990, pp. 271-275. [3] Dequan Liu, Hongfei Teng. “An improved BL-algorithm for genetic algorithm of the orthogonal Packing of rectangles,”. European Journal of Operational Research, vol. 112, 1999, pp. 413-419. [4] M. Hifi and R. M'Hallah. “A hybrid algorithm for the two-dimensional layout problem: The cases of regular and irregular shapes,”. International Transactions in Operational Research, vol. 10, 2003, pp. 195-216. 195 [5] Silvano Martello, Michele Monaci, and Daniele Vigo. “An exact approach to the strip-packing problem,”. Informs Journal on Computing, vol. 15, 2003, pp. 310-319. [6] Chen Duanbing and Huang Wenqi. “Greedy Algorithm for Rectangle-packing problem,”. Computer Engineering, vol. 33, 2007, pp.160-162. [7] Zhang DeFu, Han ShuiHua, and Ye WeiGuo. “A Bricklaying Heuristic Algorithm for the Orthogonal Rectangular Packing Problem,”. Chinese Journal of Computers, vol. 33, 2008, pp. 509515. [8] Liang Jun, Wang Qiang, and Cheng Can, et al. “Optimum packing of rectangles based on discrete particle swarm optimization,”. Computer Engineering and Design, vol. 28, 2007, pp. 53595510. [9] Chang-Chun Lin. “A genetic algorithm for solving the two-dimensional assortment problem,”. Computers & Industrial Engineering, vol. 50, 2006, pp. 175-184. [10] Stephen C.H. Leung, Defu Zhang, and Kwang Mong Sim. “A two-stage intelligent search algorithm for the two-dimensional strip packing problem,”. European Journal of Operational Research, vol. 215, 2011, pp. 57-69. [11] Stephen C.H. Leung, and Defu Zhang. “A fast layer-based heuristic for non-guillotine strip packing,”. Expert System with Application, vol. 38, 2011, pp.13032-13042. [12] Stephen C.H. Leung, Defu Zhang, and Changle Zhou et al. “A hybrid simulated annealing metaheuristic algorithm for the two-dimensional knapsack packing problem,”. Computer & Operations Research, vol. 39, 2012, pp. 64-73. [13] He Kun and Huang Wenqi. “Three dimensional rectangular Packing problem anthropomorphic algorithm,”. science china, vol. 40, 2010, pp. 1586-1595. [14] He K., Ji P.L., Li C.M., Heuristics for solving the 2D rectangle packing area minimization problem basing on a dynamic reduction method. Ruan Jian Xue Bao/Journal of Software, 2013, 24(9): 2078-2088(in Chinese). 196

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement