mathematics

Article Optimization Method for Guillotine Packing of Rectangular Items within an Irregular and Defective Slate

Kaizhi Chen 1,2,*, Jiahao Zhuang 1,2, Shangping Zhong 1,2 and Song Zheng 3,4

1 Department of Mathematics and Computer Science, Fuzhou University, Fuzhou 350100, China; [email protected] (J.Z.); [email protected] (S.Z.) 2 Network System Information Security Fujian Provincial University Key Laboratory, Fuzhou University, Fuzhou 350108, China 3 College of Electrical Engineering and Automation Fuzhou University, Fuzhou University, Fuzhou 350108, China; [email protected] 4 Key Laboratory of Industrial Automation Control Technology and Information Processing, Fuzhou University, Fuzhou 350108, China * Correspondence: [email protected]

 Received: 29 September 2020; Accepted: 28 October 2020; Published: 1 November 2020 

Abstract: Research on the rectangle packing problems has mainly focused on rectangular raw material sheets without defects, while natural slate has irregular and defective characteristics, and the existing packing method adopts manual packing, which wastes material and is inefficient. In this work, we propose an effective packing optimization method for nature slate; to the best of our knowledge, this is the first attempt to solve the guillotine packing problem of rectangular items in a single irregular and defective slate. This method is modeled by the permutation model, uses the horizontal level (HL) heuristic proposed in this paper to obtain feasible solutions, and then applies the genetic algorithm to optimize the quality of solutions further. The HL heuristic is constructed on the basis of computational geometry and level packing. This heuristic aims to divide the irregular plate into multiple subplates horizontally, calculates the movable positions of the rectangle in the subplates, determines whether or not the rectangle can be packed in the movable positions through computational geometry, and fills the scraps appropriately. Theoretical analysis confirms that the rectangles obtained through the HL heuristic are inside the plate and do not overlap with the defects. In addition, the packed rectangles do not overlap each other and satisfy the guillotine constraint. Accordingly, the packing problem can be solved. Experiments on irregular slates with defects show that the slate utilization through our method is between 89% and 95%. This result is better than manual packing and can satisfy actual production requirements.

Keywords: defective irregular slate; rectangle packing problems; guillotine cuts; horizontal level packing; computational geometry; genetic algorithm

1. Introduction In various industries, such as stone, glass, paper, and wood, cutting large pieces of raw materials into rectangular items with different quantities and sizes exhibits practical application contexts. In the stone industry, a large stone plate is directly cut from natural rock blocks, typically with irregular contour and black spot cracks, thereby causing difficulties in stone processing. Natural stone currently uses traditional manual packing, which is time-consuming and exhibits a low utilization rate. The data provided by stone enterprises indicate that the slate utilization of manual packing for irregular and defective stone slates is below 85%. In general, numerous defects and edges of a slate indicate low

Mathematics 2020, 8, 1914; doi:10.3390/math8111914 www.mdpi.com/journal/mathematics Mathematics 2020, 8, 1914 2 of 16 efficiency. Therefore, the intelligent packing of irregular and defective slates has become an urgent requirement of the stone industry. The two-dimensional packing problem is also known as the two-dimensional cutting problem in the stone and other industries. Rectangle packing problem [1], a subproblem of the two-dimensional packing problem, refers to the positioning of several axis-aligned rectangles inside a given plane region to satisfy the necessary constraints (such as the guillotine cutting pattern, in which items must be obtained through a sequence of edge-to-edge cuts) while maximizing its utilization. The rectangle packing problem is a classic NP-hard [2] problem, and the optimal solution cannot be obtained in polynomial time at present. A common solution to this type of problem is using an optimization method for determining a favorable or feasible solution in an acceptable time. The irregular shape and surface defects of a slate must be considered in the rectangle packing problem in the stone industry. The rectangle can be rotated by 90◦ (horizontal or vertical), and the cutting pattern is guillotine. At present, the research results on the rectangle packing problem focus on rectangular raw material sheets. Many mathematical models and algorithms have been proposed to solve the rectangle packing problem of rectangular sheets under various constraints. However, to the best of our knowledge, no relevant literature on studying the guillotine packing problem of rectangular items in irregular and defective slates is available. Therefore, our work has practical application significance and provides an effective and feasible solution to the packing problem of irregular slates with defects. The contributions of our work are presented as follows:

We first propose the horizontal level (HL) heuristic based on level packing and computational • geometry for a single irregular and defective plate to obtain feasible packing solutions. The level packing strategy [3] has been proposed to solve the guillotine packing problem of rectangular plates. The core idea is that the rectangles are packed in rows, which form levels within rectangular plates. The HL heuristic applies the level packing strategy to the packing problem of irregular plates with defects, divides irregular plates into multiple subplates with horizontal lines, and separately packs the subplates through computational geometry to obtain a packing solution that satisfies the constraints; Theoretical analysis yields the theorem and confirms that the rectangles obtained through the HL • heuristic are inside the plate and do not overlap with the defects; the packed rectangles do not overlap each other and satisfy the guillotine constraint; We propose a packing algorithm that combines HL heuristic and genetic algorithm [4] based on the • permutation model, and use it as the packing optimization method for natural slate. The packing algorithm optimize the packing solution through continuous iterative search; We use the order data provided by stone enterprises to conduct experiments, and evaluate and • analyze the performance of the packing algorithm, and confirm that the implementation of our Algorithm effectively satisfies the Theorems in this work.

The remainder of this paper is organized as follows: Section2 reviews some related works. Section3 describes the problem and proposes our method. In Section4, we analyze the algorithm of this work and obtain the statement and verify it. Section5 evaluates the algorithm through an experiment. Section6 presents the conclusions drawn from this work.

2. Related Work

2.1. Rectangle Packing Problem The rectangle packing problem is a typical combinatorial optimization problem. The three main algorithms commonly used to solve the rectangle packing problem are exact algorithm, heuristic, and metaheuristic. Mathematics 2020, 8, 1914 3 of 16

2.1.1. Exact Algorithm Usually,the mathematical programming model is established based on practical problems, and then the optimal solution is obtained by solving the model. For common mathematical programming models, such as integer model and mixed integer programming model, the algorithm is generally used to solve it. Sarin et al. [5] proposed a hybrid programming model to solve the problem of packing non-identical rectangles in rectangular regions. Beasley [6] abstracted the rectangle packing problem into a 0–1 integer programming problem and solved it. Martello et al. [7] proposed an enumeration method to search the optimal solution of the Two-Dimensional Strip Packing Problem (2SPP). The branching scheme adopted is an improvement on the branch and bound algorithm proposed by Scheithauer [8] and Martello et al. [9]. The computation time and space required by the exact algorithm will exponentially increase with the size of the packing problem.

2.1.2. Heuristic Algorithm Heuristic is used to seek an intuitive, empirical rule for finding a favorable and feasible solution. The HRBB algorithm proposed by Cui et al. [10] is a heuristic recursive algorithm that combines recursive structure and branch and bound techniques to solve the guillotine packing problem for rectangular strips. Some classic heuristics based on level packing can be used to solve the guillotine packing problem. Examples of such heuristics include the next-fit decreasing height (NFDH) algorithm proposed by Coffman [11]; that is, the item is packed left and justified on the current level (initial bottom) of the rectangular sheet if it fits. Otherwise, a new level is created (as a horizontal line drawn on the top of the tallest item packed on the current level) and then packed. Lodi et al. [12,13] also adopted the level packing strategy and proposed floor–ceiling and knapsack packing algorithms to solve the guillotine packing problem of rectangular boards. Previous studies have shown that the level packing strategy is only used on rectangular plates. Thus, no knowledge of computational geometry is involved. We use the level packing strategy combined with computational geometry to solve the packing problem of irregular and defective plates. Heuristic plays an important role in the actual production packing because it can easily integrate various constraints and specific targets. However, the shortcomings of such heuristics are also evident, and obtaining an excellent packing scheme is typically difficult.

2.1.3. Metaheuristic Algorithm The commonly used metaheuristics for packing problems are genetic algorithm, simulated annealing [14], tabu search [15], etc. Lodi et al. [16] developed an effective tabu search algorithm for rectangle packing and for variants of the problem involving the possibility of rotating the item by 90◦ or the additional constraint. Jakobs [17] used the bottom left heuristic as the decoding process of the genetic algorithm and solved the problem of packing rectangular pieces in a rectangular area with fixed length and width. For an orthogonal packing problem, Soke et al. [18] combined the genetic algorithm and the simulated annealing algorithm to search for the optimal rectangle packing sequence. Bortfeldt [19] proposed the SPGAL algorithm based on genetic algorithm to solve the rectangle packing problem of two-dimensional rectangular strips. A favorable solution by exact algorithms or heuristics for the NP-hard optimization problem is difficult to obtain quickly. By contrast, metaheuristics exhibit favorable performance in this respect.

2.2. Rectangle Packing of Irregular Plates The abovementioned algorithms are all presented for packing on rectangular regions. Few studies and achievements on rectangle packing in irregular or defective regions are available. Research on rectangle packing of irregular plates: Birgin et al. [20] used nonlinear optimization on orthogonal packing of identical rectangles within the arbitrary convex regions. Cassioli et al. [21] proposed a heuristic method based on an iterative local search for the problem of packing the maximum number of identical rectangles within a convex region. An FSS algorithm was proposed by Beasley et al. [22] to Mathematics 2020, 8, 1914 4 of 16 solve the packing problem of rectangle in circular container. Scheithauer et al. [23] solved the problem of guillotine cutting rectangle from rectangular and defective boards with . Jin et al. [24] proposed a heuristic for solving the packing on defective rectangular plates. FSS algorithm was proposed by Beasley et al. Genetic algorithm is a random global search and optimization method and has been effectively applied to solve various combinatorial optimization problems. A population consists of a set of chromosomes. Each chromosome is a possible solution, and the fitness function measures the quality of each possible solution. Genetic algorithm searches new and better solutions to a problem by improving the current population. In the population update process, the genetic algorithm continuously extracts good genes to obtain a better solution.

2.3. Computational Geometry Rectangle packing considered both irregular and defective region always encounters the algorithm of Computational Geometry. The following computational geometry problems are encountered in this work, such as how to determine the rectangle is inside the polygon and the rectangle overlaps the polygon. These problems can be decomposed into the following sub-problems to computer, included whether the point is inside the polygon, whether the line segment is inside the polygon, and whether the two polygons overlap. Two common algorithms, namely, winding number [25] and ray casting, are used to determine whether a point within a polygon is called a point in polygon (PIP) problem in computational geometry. Methods to determine whether two polygons overlap are as follows: (a) Calculate intersection area. (b) Calculate no-fit polygon (NFP) [26]. (c) Use the separating axis theorem (SAT) [27].

3. Formulation and Algorithm

3.1. Problem Description The following notations are the specific symbols used in this work.

Ω: An irregular plate Γ: Set of polygons The polygon of irregular plate boundaries, represented by a set of polygon clockwise vertex B: coordinates Bj: Divide B horizontally into several subplates; Bj is a subplate numbered j D: The set of polygons of irregular plate defects; Dt is the defect numbered t, where 0 t ω ≤ ≤ The polygon of irregular plate defect, represented by a set of polygon counterclockwise Dt: vertex coordinates The set of rectangles. R = {1, ... , N}, where the element in the set is the serial number of the R: rectangle, and the negative number represents the rotation of the rectangle by 90◦ Ri: Ri represents a rectangle numbered |i| Ri(x,y) indicates that the rectangle Ri is in coordinate (x,y), where x and y correspond to the abscissa Ri(x,y): and ordinate of the upper left vertex of the rectangle (horizontal axis rightward, vertical axis downward) hi: The vertical height of Ri wi: The horizontal length of Ri

Given an irregular plate Ω, the boundary polygon is B, and the defect polygon set is D. The set of rectangles is R, and the axis-aligned rectangle Ri can be rotated by 90◦ for packing. The total area of the plate is S , and the total area of the defects is S . The set of the packed rectangle is K, where K R. B D ⊆ The constraints are presented as follows:

(I) The packed rectangles cannot overlap with each other; (II) The packed rectangles must be inside the irregular plate and cannot overlap with the defects; Mathematics 2020, 8, 1914 5 of 16

(III) The packed rectangles must satisfy the guillotine cut constraint.

The rectangle packing problem of the objective function is     X  max h w /(SB SD) , (1)  λ × λ −  λ K  ∈ 3.2. Model Some heuristics construct a feasible pattern for NP-hard packing problems based on a given sequence of the rectangles. Scheithauer [28] mentioned a permutation model that can be used to optimize these problems. In this model, a sequence of rectangles must be determined to ensure that the results obtained using the selected heuristic are optimal. We use this model for optimization. Given an irregular and defective plate Ω, a rectangle set R = {1, ... , N}. The permutation model for our problem is demonstrated as follows: Find a permutation π* of R such that the HL heuristic computes a pattern of maximum plate utilization. HL heuristic is based on the rectangle order to obtain a feasible solution for the packing. Let π be a permutation of rectangle sets and HL heuristic output for plate utilization. The optimization target function of the permutation model can be expressed as follows maxHL(π, B, D), (2)

We use the genetic algorithm to optimize the objective function. GA function is the optimizer. Accordingly, we can obtain the approximate optimal packing solution π*.

3.3. Algorithm

Definition 1. Two polygons W and M are provided. If such polygons intersect, then W M , ∅; if W ∩ is included in M, then W M; if W is separated from M, then W M = ∅; if W and M do not overlap, ⊆ ∩ then W M < Γ. ∩

Definition 2. Given a rectangle Ri and a subplate Bj, the set of movable positions of the rectangle Ri at the subplate Bj is represented as Xi = {xi1, ... , xiu, ... , xiρ}. Xi can be stored in a queue, where the head xi1 is the initial movable position and the rest is the candidate movable position. Due to irregular boundaries and defects, when the position of Ri is not available for packing, Ri can be moved to the next point to pack. Generally, let Rk pack after R . For the movable positions X of R on B , there is x x . i k k j k1 ≥ iρ

In Figure1, the subplate has three shapes, namely, B1, Bj, and BC, and exhibits horizontal edges. Here, we take B1 (the top edge of the polygon is a horizontal line) as an example to calculate the movable positions. The ordinate of the horizontal line of the B1 is y1. We align the top edge of Ri with the horizontal line of B1 and calculate the intersection of B1 and y = y1 + hi as the movable positions (Figure2). Moreover, we must update Xi by removing elements from the queue that is smaller than the current packing point and adding current packing point to Xi as the initial movable position. If defects are present in the subplate, then the rightmost points of these defect polygons are added to Xi as the candidate moveable point, see Figure3. When calculating the first packing rectangle of a subplate, the initial movable position of the rectangle must be adjusted in accordance with the subplate shape. Mathematics 2020, 8, x FOR PEER REVIEW 6 of 17

Mathematics 2020, 8, x FOR PEER REVIEW 6 of 17 Mathematics 2020, 8, 1914 6 of 16 Mathematics 2020, 8, x FOR PEER REVIEW BC 6 of 17

BC Bj BC Bj B1 Bj

B1 Figure 1. HorizontalB1 split plate. Figure 1. Horizontal split plate. y=y Ri Figure 1. HorizontalHorizontal split 1 plate.

Ri y=y1 hi y=y1+hi Ri y=y1

hi y=y1+hi xi1 xi2 xi3 xi4 xi5 xi6 hi y=y1+hi

xi1 x x x Figure 2. Movable positionsi2 ofi3 the rectanglexi4 xini5 the sub-plate.i6 Figure 2. Movablexi1 positionsxi2 xi3 of the rectanglexi4 x ini5 the sub-plate.xi6 Figure 2. Movable positions of the rectangle in the sub-plate. R y=y1 Figurei 2. Movable positions of the rectangle in the sub-plate.

Ri y=y1 hi Ri y=y1 hi x xi1 xi2 xi3 xi4 i5 xi6 xi7 xi8 hi Figure 3. Movable positions of the rectangle in the defective subplate. xi1 xi2 xi3 x xi5 xi6 xi7 xi8 Figure 3. Movable positions of the rectanglei4 in the defective subplate. x x x xi5 xi6 x x Algorithm 1 is the HL heuristic,i1 whichi2 dividesi3 xi4 the irregular platei7 i8 into multiple subplates with horizontalAlgorithm lines 1 and isFigure the packs HL 3. in Movableheuristic, accordance positions which with ofdivides thethe givenrectangle the rectangleirregular in the defective order.plate into subplate. multiple subplates with horizontal lines andFigure packs 3. inMovable accordance positions with of thethe givenrectangle rectangle in the defective order. subplate. Algorithm 1 is the HL heuristic, which divides the irregular plate into multiple subplates with Algorithm 1 HL heuristic horizontalAlgorithmAlgorithm lines 1 HL 1and isheuristic thepacks HL in heuristic, accordance which with divides the given the rectangleirregular plateorder. into multiple subplates with Input: boundary polygon B, defect polygon set D, rectangle sequence π horizontalInput: boundary lines and polygon packs inB, accordancedefect polygon with set the D given, rectangle rectangle sequence order. π Algorithm(1) Swap the 1 height HL heuristic and width of the rectangle if the number is negative. Let R’ be the next rectangle to be (1)packed Swap and theK be height the set and of packed width rectangles. of the rectangle if the number is negative. Let R’ be the next Input: boundary polygon B, defect polygon set D, rectangle sequence π Algorithmrectangle(2) Find the to second1 be HL packed heuristic lowest and vertex K be of the the plateset ofB packed, and subtract rectangles. the height h’ of R’ from the ordinate to obtain a (1) Swap the height and width of the rectangle if the number is negative. Let R’ be the next Input:(2)horizontal Find boundary the line, second thereby polygon lowest dividing B, vertexdefectB into polygonof the the upper plate set subplate BD, ,and rectangleB subtractR and sequence the the lower heightsubplate π h’ ofB R’P; BfromP is the the current rectangle to be packed and K be the set of packed rectangles. (1)ordinatepacking Swap region to the obtain (seeheight Figurea horizontal and4). width line, of the thereby rectangle dividing if the B number into the is upper negative. subplate Let R’ B Rbe and the the next lower (2) Find the second lowest vertex of the plate B, and subtract the height h’ of R’ from the rectanglesubplate(3) Repeat B to (3.1)P; beBP and packedis the (3.2) current untiland BK P packingbefinishes the set itsregion of packing. packed (see Figure rectangles. 4). ordinate to obtain a horizontal line, thereby dividing B into the upper subplate BR and the lower (2)(3)(3.1) CalculateFindRepeat the (3.1) thesecond movableand lowest(3.2) positions until vertex BPX finishes ofof theR’ at plate BitsP. packing. B, and subtract the height h’ of R’ from the subplate(3.2) R’ moves BP; B alongP is the the current horizontal packing line of regionB . If x(seeX ,Figure such that 4).R’ is within B and does not overlap with D, ordinate(3.1) Calculate to obtain the amovable horizontal positions line, thereby XP of R’∃ dividing at∈ BP. B into the upper subplateP BR and the lower (3)then addRepeatR’ to (3.1)K, remove and (3.2)R’ from untilπ, B andP finishes update R’its. Otherwise,packing. B packing is complete. If the height of the next subplate(3.2) R’ moves BP; BP alongis the currentthe horizontal packing line region of B P(see. If ∃ Figurex ∈ X, such4).P that R’ is within BP and does not (3.1)rectangle CalculateRi is greater the movable than h’, then positions search forX ofR tR’whose at BP height. is below h’. Exchange the position of Ri and Rt (3)overlap Repeat with (3.1) D, then and add(3.2) R’ until to K B, Premove finishes R’ its from packing. π, and update R’. Otherwise, BP packing is (3.2)in π, andR’ moves update alongR’ = R tthe. horizontal line of BP. If ∃x ∈ X, such that R’ is within BP and does not (3.1)complete. Calculate If the the height movable of the positions next rectangle X of R’ R ati is B greaterP. than h’, then search for Rt whose height (4) Update B = B . Repeat (2), (3), and (4) for B until B does not constitute a polygon. overlap with DR, then add R’ to K, remove R’R from Rπ, and update R’. Otherwise, BP packing is is below h’. Exchange the position of Ri and RP t in∃ π, ∈and update R’ = Rt. P (3.2)(5) Find R’ themoves maximum along inscribed the horizontal rectangles line for of the B waste. If x space X, aroundsuch that plate R’ boundaries is within B and and defects. does Then, not use complete. If the height of the next rectangle Ri is greater than h’, then search for Rt whose height overlap(4)the NFDHUpdate with algorithm B D =, thenBR. toRepeat add pack R’ the (2), to remaining K(3),, remove and (4) rectangles, R’ for from BR until andπ, and addBR updatedoes the packed not R’ constitute. Otherwise, rectangles a topolygon. BKP. packing is is below h’. Exchange the position of Ri and Rt in π, and update R’ = Rt. complete.(5)(6) CalculateFind theIf platethe maximum height utilization. of inscribed the next rectanglerectangles R fori is thgreatere waste than space h’, thenaround search plate for boundaries Rt whose height and (4) R R R Update BP = B . Repeat (2), (3), andi (4) fort B until B does not constitutet a polygon. isdefects.HL below(π, B, DThen, h’). =Exchange useλ K thehλ theNFDHwλ /position(SB algorithmSD )of R andto pack R in the π, remainingand update rectangles, R’ = R . and add the packed (5) Find the maximum∈ × inscribed− rectangles for the waste space around plate boundaries and (4)rectangles Update to BK =. BR. Repeat (2), (3), and (4) for BR until BR does not constitute a polygon. (5)(6)defects. FindCalculate Then, the maximum useplate the utilization. NFDH inscribed algorithm rectangles to pack for the the remaining waste space rectangles, around plate and addboundaries the packed and rectangles to K. defects.HLBD(,,π Then, )=×− use the hwSSλλ NFDH /( algorithm ) to pack the remaining rectangles, and add the packed λ∈K B D rectangles(6) Calculate to K .plate utilization. HLBD(,,π )=×− hwSSλλ /( ) (6) Calculate plateλ∈K utilization.B D HLBD(,,π )=×− hwSS /( ) λ∈K λλ B D

Mathematics 2020, 8, 1914 7 of 16 Mathematics 2020, 8, x FOR PEER REVIEW 7 of 17

Br R’

Bp

Second lowest vertex Figure 4. Algorithm 1 step (2): split the plate. Figure 4. Algorithm 1 step (2): split the plate. Algorithm 2 is the packing algorithm in this work. Genetic algorithm is utilized as the optimizer,Algorithm and the 2 is rectanglethe packing sequence algorithm is usedin this as work. the geneGenetic coding. algorithm The is HL utilized heuristic as the is optimizer, adopted asand the the decoding rectangle process. sequence is used as the gene coding. The HL heuristic is adopted as the decoding process. Algorithm 2 Genetic algorithm + HL heuristic. Algorithm 2 Genetic algorithm + HL heuristic. Input: boundary polygon B, defect polygon set D, rectangle set R = {1, ... ,N} Input: boundary polygon B, defect polygon set D, rectangle set R = {1,…,N} Initialization: population number M, round iteration number T, crossover probability Pc, mutation Initialization: population number M, round iteration number T, crossover probability Pc, probability Pm (1)mutation Initializing probability population PPm (the set of feasible solutions): randomly generate M integer permutations from 1 to N(1). Each Initializing integer randomly population generates P (the positive set of and feasible negative solutions): signs. (negative randomly signs generate mean the M rectangle integer is rotated 90permutations degrees) from 1 to N. Each integer randomly generates positive and negative signs. (2)(negative For π signsP, perform mean Algorithm the rectangle 1 to calculate is rotated the 90 fitness degrees) of π as f (π) = HL(π,B,D). Let π* be the optimal ∀ ∈ solution(2) For of ∀ populationπ ∈ P, performP. Algorithm 1 to calculate the fitness of π as f(π) = HL(π,B,D). Let π* be (3)the Repeat optimal (3.1) solution and (3.2) of until population the update P. of new population Pe is complete (see Figure5). (3.1) Two individuals are selected from P using the method of Roulette Wheel Selection. A new solution is (3) Repeat (3.1) and (3.2) until the update of new population P is complete (see Figure 5). constructed by a two-point crossover with the cross probability of P . (3.1) Two individuals are selected from P using the method cof Roulette Wheel Selection. A new (3.2) An individual is randomly selected from P, and the two-point mutation is performed with the mutation solution is constructed by a two-point crossover with the cross probability of Pc. probability of Pm. (4)(3.2) For Anπ individualPe, perform is Algorithm randomly 1 to selected calculate from the fitness P, andf ( theπ) of two-pointπ. mutation is performed with ∀ ∈ (5)the If mutation a feasible solution probabilityµ Pe ofwith Pm.f (π*) < f (µ) is obtained, then replace π* = µ. And set P = Pe.  ∈ (6)(4) If theFor population ∀π ∈ P , iterationperform number Algorithm reaches 1 toT, calculate then stop. the The fitness optimal f( packingπ) of π. is π*. Otherwise,   continue(5) If a to feasible (3) solution μ ∈ P with f(π*) < f(μ) is obtained, then replace π* = μ. And set P = P . (6) If the population iteration number reaches T, then stop. The optimal packing is π*. In step 3 of Algorithm 2, individuals must be a permutation with unduplicated numbers from R. Otherwise, continue to (3) Conventional bitwise crossover does not guarantee that permutations are unduplicated. Therefore, we use a scan operator to fill each number in the new sequence after crossover operator. We use an In step 3 of Algorithm 2, individuals must be a permutation with unduplicated numbers from example to describe the specific steps of crossover and mutation operator as Figure5. R. Conventional bitwise crossover does not guarantee that permutations are unduplicated. Therefore, Step 1: Two individuals {5, 1, 3, 4, 7, 6, 2}, {3, 4, 2, 5, 1, 7, 6}, Where N = 7, exchange the we use a scan operator to fill each− number− in th−e new sequence− after− crossover operator. We use an middle 3 number {3, 4, 7} and {2, 5, 1} to each son sequence; example to describe− the specific steps− of crossover and mutation operator as Figure 5. Step 2: Then, scan each parent sequence to put the reminder number into the son sequence. Step 1: Two individuals {5, −1, 3, −4, 7, 6, −2}, {3, 4, 2, −5, 1, −7, 6}, Where N = 7, exchange the As Parent 1, scan the middle number {3, 4, 7} and other reminder number {5, 1, 6, 2} in turn. middle 3 number {3, −4, 7} and {2, −5, 1} to− each son sequence; − − This process must ensure the numbers filled in are not identical to the son middle numbers {2, 5, 1}, Step 2: Then, scan each parent sequence to put the reminder number into the son sequence.− As so the reminder number sequence {3, 4, 7, 6} are filled in Son 1. New individuals are generated; Parent 1, scan the middle number {3,− −4, 7} and other reminder number {5, −1, 6, −2} in turn. This Step 3: Each new individual carries out the mutation operator, as in Figure5b. process must ensure the numbers filled in are not identical to the son middle numbers {2, −5, 1}, so the reminder number sequence {3, −4, 7, 6} are filled in Son 1. New individuals are generated; Step 3: Each new individual carries out the mutation operator, as in Figure 5b.

Mathematics 2020, 8, x FOR PEER REVIEW 8 of 17

Mathematics 2020, 8, 1914 8 of 16 Mathematics 2020, 8, x FOR PEER REVIEW 8 of 17 Parent 1 Parent 2

Parent 1 Parent 2 Son 1 Son 2

(a) Son 1 Son 2

(a)

(b)

Figure 5. Algorithm 2 step (3): (a) tow-point crossover operator. (b) mutation operator. (b) If population P has 200 individuals, it can be divided into 100 groups. Each group with two Figure 5. Algorithm 2 step (3): (a) tow-point crossover operator. (b) mutation operator. individualsFigure can 5.carry Algorithm out one 2 step crossover (3): (a) tow-point operator, crossover and each operator. individual (b) mutation can carry operator. out one mutation operator. Therefore, the total times that the actions (3.1) and (3.2) are performed are 100 and 200, If population P has 200 individuals, it can be divided into 100 groups. Each group with respectively.If population P has 200 individuals, it can be divided into 100 groups. Each group with two two individuals can carry out one crossover operator, and each individual can carry out one individuals can carry out one crossover operator, and each individual can carry out one mutation mutation operator. Therefore, the total times that the actions (3.1) and (3.2) are performed are operator.4. Algorithm Therefore, Analysis the total times that the actions (3.1) and (3.2) are performed are 100 and 200, 100 and 200, respectively. respectively.The genetic algorithm, an optimizer of the permutation model, has favorable global search 4.ability. Algorithm Such an Analysis algorithm maps the rectangle sequence to the encoding of the solution. Thus, the 4. Algorithm Analysis derivativeThe genetic and function algorithm, continuity an optimizer have no of thelimitation. permutation model, has favorable global search ability. SuchTheThe an genetic algorithmHL heuristic algorithm, maps has the antwo rectangle optimizer basic sequenceideas. of theFirst, topermutation thea horizontal encoding model, ofline the musthas solution. favorable be determined, Thus, global the derivative andsearch the ability.andirregular function Such plate an continuity mustalgorithm be divided have maps no theinto limitation. rectangle two parts. sequ Forence the lowerto the part, encoding pack theof theselected solution. rectangle Thus, along the derivativethe horizontalThe HLand heuristic function line. The has continuity rectangle two basic have must ideas. no be First,limitation. moved a horizontal to the next line movable must be determined,position when and encountering the irregular platedefectsThe must orHL irregular be heuristic divided edges. intohas two twoThese parts. basic steps Forideas. are the repeated lowerFirst, part,a forhorizontal pack the remaining the selectedline must parts rectangle be of determined, a plate. along Second, the horizontaland waste the irregularline.is inevitable The plate rectangle after must the mustbe initialdivided be moved pack, into togiven two the parts. nextthe existence movable For the positionlowerof irregular part, when pack boundaries encountering the selected and defects defects.rectangle or We irregular along must use this part of the plate as much as possible. The main method is to obtain the maximum inscribed theedges. horizontal These line. steps The are rectangle repeated formust the be remaining moved to parts the next of a movable plate. Second, position waste when is inevitableencountering after rectangle of the waste material after defect removal and use the NFDH algorithm proposed by defectsthe initial or irregular pack, given edges. the These existence steps of are irregular repeated boundaries for the remaining and defects. parts We of must a plate. use Second, this part waste of the Coffman [11] for a simple fill. isplate inevitable as much after as possible.the initial The pack, main given method the existence is to obtain of theirregular maximum boundaries inscribed and rectangle defects. of We the must waste  usematerial thisLet part afterP of be defectthe the plate population removal as much and after as use possible.the the iterative NFDH Th eT algorithmmain′ round method of proposed genetic is to algorithm. obtain by Co fftheman Let maximum [ π11 be] for a permutation a inscribed simple fill. rectangle of the waste material after defectΩ removal and use the NFDH algorithm proposed by of R andLet Pe πbe ∈ theP . populationFor the irregular after the plate iterative (FigureT0 round 6), ofthe genetic boundary algorithm. polygon Let Bπ andbe athe permutation set of defect of CoffmanRpolygonsand π [11] PeD. forare For arepresented the simple irregular fill. by plate blueΩ (Figureand red,6), respecti the boundaryvely. The polygon boundaryB and polygon the set of is defect divided polygons into C ∈P Dsubplates,areLet represented that be the is, population B by = blue{B1, …, and after B red,j, …, the respectively. B iterativeC}. Let U T =′ round The{U1, boundary…, of U geneticj, …, polygonU algorithm.C}, Uj be is the divided Let set π ofbe into rectanglesa permutationC subplates, to be  Ω ofthatpacked R and is, Bπcorresponding= ∈ {BP1,. ...For, Bthej, ... toirregular ,theBC }.subplate Let plateU = B{Uj, (Figure1and, ... U, Uj =6),j, π... the, where, UboundaryC}, UUj1be = π thepolygon, that set ofis, Brectangles B and1 is thethe setinitial to of be defect packedlayout polygonscorrespondingsubplate. D are represented to the subplate by Bbluej, and andU jred,= π ,respecti where Uvely.1 = πThe, that boundary is, B1 is thepolygon initial is layout divided subplate. into C subplates, that is, B = {B1, …, Bj, …, BC}. Let U = {U1, …, Uj, …, UC}, Uj be the set of rectangles to be packed corresponding to the subplate Bj, and Uj = π, where U1 = π, that is, B1 is the initial layout subplate.

Figure 6. Irregular and defective plate.

Mathematics 2020, 8, 1914 9 of 16

Function F (Ri, Bj, x, y) is used to determine whether Ri is inside Bj at coordinate (x, y). Function Q (Ri, Dt, x, y) is used to determine whether Ri overlaps with defect polygon Dt at coordinate (x, y), where 0 t ω. The specific definition is provided as follows ≤ ≤ ( ) 1, R (x, y) B F(R , B , x, y) = i ⊆ j , (3) i j 0, otherwise ( ) 1, R (x, y) Dt < Γ Q(R , D , x, y) = i ∩ , (4) i t 0, otherwise

Ri moves along the horizontal line yj of Bj. Function G (Ri, Bj, D, Xi) is used to determine whether Ri can be packed in Bj. The first packing area of Bj is denoted as Sj (Uj, Bj, D). Then,

G(Ri, Bj, D, Xi) =  ω   P Q ( ) ( )   1, F Ri, Bj, x, yj Q Ri, Dt, x, yj  (5) x X t=0 ×  ∈ i   0, otherwise  X S (U , B , D) = h w G(R , B , D, X ), (6) j j j i × i × i j i i U ∈ j Let I be the set of rectangles successfully packed for the first time, and π I be the set of remaining − rectangles. Let Z be rectangular wastes without defects, and the NFDH algorithm is used to obtain the packing area of the waste material. We can obtain the total packing area as follows

XC S(π, B, D) = S (U , B , D) + NFDH(π I, Z), (7) j j j − j=1

We pack rectangles π on irregular plates Ω through HL heuristic and obtain the plate utilization as follows S(π, B, D) Rate = HL(π, B, D) = , (8) SB SD − We can derive the following two Theorems through the abovementioned analysis.

Theorem 1. The rectangles obtained through the HL heuristic are inside the plate and do not overlap with the defects. Prove. Let K be the set of rectangles obtained through the HL heuristic. Equation (7) denotes that K is composed of K I and I. K I satisfies Constraint (II) in Section3 because it is obtained through the − − NFDH algorithm. Let λ I. Equations (5) and (6) express that R B , and B B; thus, R B, that is, ∈ λ ⊆ j j ⊆ λ ⊆ R is inside B. Given that Dt D, and R Dt < Γ, R does not overlap with the defects. Then, λ λ ∀ ∈ λ ∩ λ ∀ ∈ I, and (R B) (R Dt < Γ); thus, I satisfies Constraint (II) in Section3. Therefore, rectangles in K λ ⊆ ∧ λ ∩ are inside the plate and do not overlap with the defects. 

Theorem 2. The rectangles obtained through the HL heuristic do not overlap each other and satisfy guillotine constraint. Prove. Let K be the set of rectangles obtained by HL heuristic. K is composed of K I and I. K I − − satisfies Constraints (I) and (III) in Section3 because it is obtained through the NFDH algorithm. The rectangles in I are packed along the horizontal line of subplate; thus, the pack conforms to a guillotine pattern. Accordingly, Constraint (III) in Section3 is satisfied. Let Ri (xi, y) and Rt (xt, y) be two rectangles of the same level in I, and Rt (xt, y) is packed after Ri (xi, y). The movable position indicates that xt x . Therefore, the rectangles in I do not overlap each other. Thus, Constraint (I) ≥ i Mathematics 2020, 8, x FOR PEER REVIEW 10 of 17 two rectangles of the same level in I, and Rt (xt, y) is packed after Ri (xi, y). The movable position Mathematics 2020, 8, 1914 10 of 16 indicates that xt ≥ xi. Therefore, the rectangles in I do not overlap each other. Thus, Constraint (I) in Section III is satisfied. Consequently, the rectangles in K do not overlap each other and satisfy the inguillotine Section 3constraint. is satisfied. □ Consequently, the rectangles in K do not overlap each other and satisfy the guillotine constraint.  In this section, we demonstrate that the HL heuristic can be used to obtain a layout scheme that satisfiesIn this the section,constraints we demonstratethrough theoretical that the analysis HL heuristic. Given can that be the used Algorithm to obtain 2 uses a layout the HL scheme heuristic that satisfiesas the decoding the constraints process, through its packing theoretical result must analysis. satisfy Given Theorems that the 1 Algorithmand 2. Thus, 2 uses the packing the HL heuristic result is asaccurate. the decoding In the next process, section, its packing we will result further must verify satisfy the effectiveness Theorems 1 and of the 2. Thus,Algorithm the packing 2 and evaluate result is accurate.its performance In the nextthrough section, experiments. we will further verify the effectiveness of the Algorithm 2 and evaluate its performance through experiments. 5. Experiments 5. Experiments In this section, we will use the Algorithm 2 to conduct experiments through the actual data In this section, we will use the Algorithm 2 to conduct experiments through the actual data provided by stone enterprises, and analyze the algorithm according to the experimental results. provided by stone enterprises, and analyze the algorithm according to the experimental results. 5.1. Dataset and Experimental Environment 5.1. Dataset and Experimental Environment The experimental data in this work are mainly provided by stone enterprises. They are The experimental data in this work are mainly provided by stone enterprises. They are composed composed of rectangular stone orders and original stone pictures. Rectangular stone orders contain of rectangular stone orders and original stone pictures. Rectangular stone orders contain a total of a total of 272 rectangles in 49 specifications. Table 1 summarizes the partial rectangle information. 272 rectangles in 49 specifications. Table1 summarizes the partial rectangle information. Each rectangle Each rectangle will be renumbered, with numbers ranging from 1 to 272. Another program that we will be renumbered, with numbers ranging from 1 to 272. Another program that we implemented can implemented can obtain the vertex coordinates of the slate through the slate image. Six slates, which obtain the vertex coordinates of the slate through the slate image. Six slates, which are approximately are approximately 3 × 3 m in size, are utilized in this work. Part of the slate image is illustrated in 3 3 m in size, are utilized in this work. Part of the slate image is illustrated in Figure7. The data can Figure× 7. The data can be downloaded from https://github.com/chkz/Plate-data . be downloaded from https://github.com/chkz/Plate-data. The experiments were run on a platform with 3.6 GHz Intel Core i7 processor, 8 GB of RAM, The experiments were run on a platform with 3.6 GHz Intel Core i7 processor, 8 GB of RAM, and Windows operating system. The development language is C++. and Windows operating system. The development language is C++.

Table 1. Partial rectangle information. Table 1. Partial rectangle information. Type Width (mm) Height (mm) Quantity Type Width (mm) Height (mm) Quantity 4 1050 477 4 45 1050950 477 477 4 4 5 950 477 4 66 950 244 244 2 2 77 850 244 244 6 6 88 197 897 897 2 2 99 193 897 897 8 8

Figure 7. Partial slate image. 5.2. Parameters Experiments Analysis 5.2. Parameters Experiments Analysis There are several important parameters in our algorithm: population number M, round iteration There are several important parameters in our algorithm: population number M, round iteration number T, crossover probability Pc, mutation probability Pm. We use experiments to determine the number T, crossover probability Pc, mutation probability Pm. We use experiments to determine the optimal parameters. optimal parameters. To find the optimal values by the traversal method, we set round iteration number T = [10 20 30 To find the optimal values by the traversal method, we set round iteration number T = [10 20 30 40 50 100 150 200 250 300], population number M = [50 100 150 200 250 300], crossover probability 40 50 100 150 200 250 300], population number M = [50 100 150 200 250 300], crossover probability Pc Pc = [0.2 0.4 0.6 0.8], mutation probability Pm = [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08]. = [0.2 0.4 0.6 0.8], mutation probability Pm = [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08].

Mathematics 2020, 8, x FOR PEER REVIEW 11 of 17 Mathematics 2020, 8, 1914 11 of 16 Mathematics 2020, 8, x FOR PEER REVIEW 11 of 17 First, test the relationship between the round iteration number and performance of plate utilizationFirst,First, test rate.test the thePart relationship relationshipof the results between betweenare as the shown round the inroun iteration Figured iteration number8. Generally, number and performance the moreand performance iterative of plate rounds utilization of thereplate rate.utilizationare, the Part better of rate. the the Part results performance of the are results as shownin areall results,as in shown Figure but in8 under .Figure Generally, the 8. Generally,current the moresamples, the iterative more the iterative utilization rounds rounds there rate tendsthere are, theare,to be better the stable better the after performance the almost performance 100 in rounds, all in results, all with results, but only underbut a small under the improvement, currentthe current samples, samples, and theeven utilizationthe some utilization jitters. rate Therefore,rate tends tends to betowe stablebe set stable the after round after almost almost iteration 100 100 rounds, number rounds, with of with our only only algo a smallarithm small improvement,to improvement, 100 in the subsequent and and even even someexperiments. some jitters. jitters.Therefore, Therefore, wewe set set the the round round iteration iteration number number of of our our algorithm algorithm to to 100 100 in in the the subsequent subsequent experiments. experiments.

Figure 8. Relationship between iterations and utilization rate. Figure 8. Relationship between iterations and utilization rate. Figure 8. Relationship between iterations and utilization rate. The relationship between the population number M and performance is as shown in Figure 9. The relationship between the population number M and performance is as shown in Figure9. We setThe the relationship round iteration between number the population to be fixed numberat 100. Among M and theperformance three lines is in as the shown figure, in twoFigure lines 9. We set the round iteration number to be fixed at 100. Among the three lines in the figure, two lines are Weare theset theslates’ round utilization iteration rate number under toth ebe randomly fixed at 100. selected Among fixed the parameters three lines P inc and the Pfigure,m, and twothe otherlines the slates’ utilization rate under the randomly selected fixed parameters Pc and Pm, and the other is the areis the the average slates’ utilizationvalue of the rate slates’ under utilization the randomly rate of selected all Pc and fixed Pm parameters under a different Pc and PMm., Itand can the be other seen average value of the slates’ utilization rate of all Pc and Pm under a different M. It can be seen from the isfrom the theaverage figure value that ofthe the performance slates’ utilization of the populationrate of all P numberc and Pm isunder better a differentwhen it is M 200. It −can250, be hence, seen figure that the performance of the population number is better when it is 200 250, hence, we chose fromwe chose the figureM = 200 that for the our performance algorithm in of the the subsequent population experiments. number is better when− it is 200−250, hence, M = 200 for our algorithm in the subsequent experiments. we chose M = 200 for our algorithm in the subsequent experiments.

Figure 9. Relationship between population number and utilization rate. Figure 9. Relationship between population number and utilization rate. Figure 9. Relationship between population number and utilization rate. For the last two parameters, we traverse Pc and Pm under the condition of T = 100, M = 200. It can For the last two parameters, we traverse Pc and Pm under the condition of T = 100, M = 200. It can be seen from the Figure 10 that when Pc = 0.6, Pm = 0.05, the slates utilization rate is the best. Therefore, be seenFor from the last the twoFigure parameters, 10 that when we traversePc = 0.6, PPmc and= 0.05, Pm the under slates the utilization condition rateof T is = the100, best. M = Therefore,200. It can these optimal parameter value are used in all the subsequent experiments. bethese seen optimal from the parameter Figure 10 value that whenare used Pc = in 0.6, all P them = 0.05,subsequent the slates experiments. utilization rate is the best. Therefore, these optimal parameter value are used in all the subsequent experiments.

MathematicsMathematics 2020 2020, 8, x, FOR8, x FOR PEER PEER REVIEW REVIEW 12 of12 17 of 17

MathematicsMathematics2020 2020, 8, ,8 1914, x FOR PEER REVIEW 1212 of of 16 17

FigureFigure 10. Relationship10. Relationship between between Pc, P Pmc ,and Pm andutilization utilization rate. rate. Figure 10. Relationship between Pc, Pm and utilization rate. Figure 10. Relationship between Pc, Pm and utilization rate. 5.3.5.3. 5.3. Packing Packing Results Results 5.3. PackingIn Figures Results 11–13, the black polygon is the plate, the red polygon is the defect, and the blue fill is InIn FiguresFigures 1111–13,–13, thethe blackblack polygonpolygon isis thethe plate,plate, thethe redred polygonpolygon isis thethe defect,defect, andand thethe blueblue fillfill isis the packed rectangle. The top left corner of the pictures represent the plate utilization, and the axis is thethe packedpackedIn Figures rectangle.rectangle. 11–13, TheThe the toptop black leftleft polygon corner of is thethe picturespictplate,ures th represente red polygon thethe plateplate is the utilization,utilization, defect, and andand the thethe blue axisaxis fill isis is in mm. ininthe mm.mm. packed rectangle. The top left corner of the pictures represent the plate utilization, and the axis is in mm.

(a) (b) (a) (b) FigureFigureFigure 11.11. Packing 11. Packing resultsresults results(a )ofof non-defectivenon-defective of non-defective irregularirregular irregular plates.plates. plates. ((aa)) PlatePlate (a) Plate AA( b result.result.) A result. ((b)) PlatePlate(b) Plate BB result.result. B result. Figure 11. Packing results of non-defective irregular plates. (a) Plate A result. (b) Plate B result.

(a) (b) (a) (b) FigureFigureFigure 12.12. Packing 12. Packing results results(a )ofof irregularirregular of irregular platesplates plates withwith with aa defect.defect. a defect. ((aa)) PlatePlate (a) Plate CC( result.result.b C) result. ((b)) PlatePlate(b) Plate DD result.result. D result. Figure 12. Packing results of irregular plates with a defect. (a) Plate C result. (b) Plate D result.

Mathematics 2020, 8, 1914 13 of 16 Mathematics 2020, 8, x FOR PEER REVIEW 13 of 17

(a) (b)

FigureFigure 13.13. Packing results ofof irregularirregular platesplates withwith twotwo defects.defects. (a)) PlatePlate EE result.result. (b) Plate F result.

From FiguresFigures 1111–13,–13, we can see that the packing results conform to the two two previous previous constraints. constraints. AllAll rectanglesrectangles areare insideinside thethe panel and avoid surface defects, consistent with Theorem 1 in Section 44.. TheThe twotwo adjacentadjacent rectangles do not overlap each other, and all rectangles are packed in levels, consistentconsistent withwith TheoremTheorem 22 inin SectionSection4 4.. InIn summary,summary, thethe experimentalexperimental resultsresults verifyverify thethe eeffectivenessffectiveness ofof thethe algorithmalgorithm andand thethe implementationimplementation isis consistent consistent with with Theorems Theorems 1 and 1 2.and Therefore, 2. Therefore, Algorithm Algorithm 2 can satisfy 2 can the constraintssatisfy the forconstraints different for irregular different plates irregular with defectsplates with and obtaindefects an and eff obtainective layoutan effective scheme. layout scheme.

5.4. Comparative Analysis To ourour bestbest knowledge,knowledge, nono relevantrelevant literatureliterature onon thethe guillotineguillotine packing of rectangles in irregular and defectivedefective platesplates isis availableavailable atat present.present. In this work, we proposepropose thethe packingpacking algorithmalgorithm forfor thethe singlesingle naturenature slate. slate. Therefore, Therefore, we we compare compare Algorithm Algorithm 2 with 2 thewith algorithms the algorithms of other packingof other problems, packing asproblems, well as theas well manual as the packing manual of packing a stone enterprise. of a stone enterprise. We havehave selected selected some some relatively relatively new new packing packing algorithms algorithms that givethat completegive complete experimental experimental results forresults comparison. for comparison. At the At same the time,same thetime, mean the mean waste waste rate and ratemean and mean run timerun time of di offferent different methods methods are calculatedare calculated and usedand used as the as main the performancemain performance indicators. indicators. Table2 Tablegives a2 comparisongives a comparison of the di ffoferent the packingdifferent methods.packing methods. SPGAL [19SPGAL] is based [19] onis based genetic on algorithm; genetic algorithm; HRBB [10 HRBB] algorithm [10] algorithm is a heuristic is a recursiveheuristic recursive algorithm; algorithm; Jin et al. [24Jin] proposedet al. [24] aproposed heuristic a algorithm heuristic toalgorithm solve the to packing solve the problem packing of rectangularproblem of platesrectangular with defects. plates Inwith addition, defects. the In FSS addition, [22] algorithm the FSS and [22] the algorithm method proposed and the by method Birgin etproposed al. [20] areby exactBirgin algorithms. et al. [20] are exact algorithms.

Table 2. Table 2. Comparison of didifferentfferent packingpacking methods.methods. Mean Waste Mean Run ApproachApproach (Author) Plate Typewith with DefectsPack Pack TypeMean Waste Mean Run Plate Type Rate (%) Time (s) (Author) Defects Type Rate (%) Time (s) SPGAL Rectangular strip NO OF 2.41 1.59 Rectangular SPGALHRBB Rectangular stripNO NOOF RG 2.41 1.2 15.68 1.59 Jin et al.strip Rectangular stock YES RG 6.5 6.2 FSSRectangular Circular container NO RF 28.86 43,838 HRBBBirgin et al. Convex regionNO NORG RF 1.2 18.21 15.68 3879 Algorithm 2strip Irregular slate YES RG 7.68 404.25 Manual packingRectangular Irregular slate YES RG >15 Long time Jin et al. YES RG 6.5 6.2 (O: the orientation of the rectanglesstock is fixed, R: the rectangles may be rotated by 90◦, F: no guillotine cutting is required, G: guillotine cuttingCircular is required). FSS NO RF 28.86 43,838 container BirginAs can et be al. seen from Convex the above region table, SPGAL NO and HRBB RF are two algorithms 18.21 for solving the 3879 packing problemAlgorithm of non-defective 2 Irregular rectangular slate plates YES with different RG constraints 7.68 (OF, RG). Both SPGAL 404.25 and HRBBManual have packing a low mean Irregular waste slate rate and mean YES run time, RG so good solutions >15 can be obtained Long time quickly. Among(O: them,the orientation the mean of the waste rectangles rate of is SPGAL fixed, R: is the 2.41%, rectangles and may that be of rotated HRBB by is 1.2%.90°, F: no For guillotine the packing problemcutting of rectangularis required, G: plates guillotine with cutting defects is required). and the packing type is RG, the mean waste rate of the

Mathematics 2020, 8, 1914 14 of 16 method proposed by Jin et al. [24] is 6.5%. The mean waste rate increases slightly compared with HRBB, and the quality of the solution decreases a little. Secondly, for circular containers and convex areas, FSS algorithm and the packing method proposed by Birgin et al. [20] have a higher mean waste rate of more than 18%. Since these two algorithms are exact algorithms, their mean run time is much higher than other algorithms, both above 3000 s. In contrast, the mean waste rate of Algorithm 2 for irregular and defective plates is 7.68%, which is slightly higher than the above-mentioned packing methods for rectangular plates. Besides compared with the packing methods for circular containers and convex regions, the mean run time of Algorithm 2 is greatly reduced. This shows that our method can obtain a relatively good solution in the acceptable time for the packing problem of irregular plates with defects. In addition, the accuracy of manual packing is poor, and the packing efficiency is low. Furthermore, the plate utilization rate is generally below 85%. Our algorithm ensures the effectiveness of packing while significantly improving the plate utilization rate and considerably reducing the time cost of the packing in comparison with manual packing. The plate utilization for general irregular plates can reach more than 90%. By contrast, the plate utilization for irregular and non-defective plates can reach 95%. The packing efficiency of manual packing for plates with numerous irregular boundaries and defects is generally low. The algorithm for these plates can still obtain a good packing scheme in a short time. Therefore, the packing algorithm has a strong practicability.

5.5. Comparison with Jin’s Algorithm The algorithm proposed by Jin et al. [24] is chosen for comparison of performance. The problem it solves has some similarities with our algorithm, such as the same packing type RG, the plates being with defects, and many rectangular specifications in the order. The difference is that both the plate shape and the defect area are rectangular in Jin’s problem. In order to compare comprehensively, we first compare the performance of the two algorithms on the rectangular plates with rectangular defects (Dataset A). Then, we compare the irregular plates with the irregular defects (Dataset B). As shown in Table3, Dataset A contains two plates with no defects, two plates with one defect, and two plates with two defect areas. The polygonal plates still use the above six Plates (Plate A–F) in Figures 11–13. The length and width of the plates are evenly distributed between 2.5 and 3.0 m. The length and width of the rectangular defect areas are evenly distributed between 10 and 80 cm. These size ranges of the plates and defect are commonly encountered in stone enterprises. The rectangles still adopt the order of 272 rectangles in the 49 specifications introduced above. In order to be compatible with Jin’s algorithm in Dataset B, the polygonal plates and the polygonal defect areas must be transformed into rectangles, that is, the largest rectangle is labeled in the polygonal plates by the computational geometry method, and then the smallest rectangle is labeled to cover the polygonal defect areas. According to the results shown in Table3, the Algorithm 2 we proposed is better than Jin’s algorithm by about 1% in utilization rate on the rectangular plates with rectangular defects, but Jin’s algorithm is much faster than our Algorithm 2, as shown in Table2. The reason for this is that Jin’s algorithm is similar to our Algorithm 1, which is a heuristic algorithm. Our Algorithm 2 actually iteratively tried tens of thousands of Algorithm 1 to find the best performance. Therefore, even under the rectangular plates, our Algorithm 2 performs better than Jin’s. In addition, the utilization rate of the polygonal plates has increased by 5–7% in Dataset B. The reason for this is that when Jin’s algorithm is applied, the polygonal plates must first be cut to the largest rectangle. The edge part cut in this process may be utilized in Algorithm 2, so the utilization rate of Algorithm 2 is improved. Mathematics 2020, 8, 1914 15 of 16

Table 3. Comparison of Jin’s Algorithm and our Algorithm 2.

Utilization Rate (%) Plate Defects Jin’s Algorithm 2 Plate 1 0 93.3251 94.4525 Plate 2 0 93.4261 94.6744 Plate 3 1 92.7524 93.2545 Dataset A Plate 4 1 92.6742 93.9825 Plate 5 2 91.8734 92.2525 Plate 6 2 90.8543 91.3456 Plate A 0 88.3251 93.8755 Plate B 0 90.4261 95.3506 Plate C 1 84.6238 93.5568 Dataset B Plate D 1 84.4615 91.8246 Plate E 2 84.2675 92.6362 Plate F 2 81.8765 89.8992

6. Conclusions The stone material increases the complexity of rectangle packing given its physical characteristics. The packing problem in this work is an NP-hard problem and has numerous local extremum points. We propose a packing algorithm that combines HL heuristic and genetic algorithm to solve this problem. The experimental results show that the algorithm is effective and has favorable packing performance. The algorithm can obtain excellent packing results with a relatively short time loss for different irregular slates with defects. Therefore, our approach can reduce the impact of manual factors, such as subjectivity and experience, improve the packing efficiency, and save the use of raw materials, thereby enhancing the economic benefits of the company. In the actual production of stone enterprises, many slates are frequently used given the variety and quantity of rectangles in the order. Therefore, we will consider the simultaneous packing problem of multiple irregular and defective slates in the future work. We will also look for a packing method that is more consistent with actual production requirements.

Author Contributions: Conceptualization, K.C., J.Z., and S.Z. (Shangping Zhong); methodology, K.C, S.Z. (Shangping Zhong); validation, J.Z.; formal analysis, K.C., J.Z.; investigation, K.C., S.Z. (Shangping Zhong), and S.Z. (Song Zheng); data curation, J.Z.; writing—original draft preparation, J.Z.; writing—review and editing, K.C, J.Z, S.Z. (Shangping Zhong) and S.Z. (Song Zheng); visualization, J.Z.; supervision, K.C., S.Z. (Shangping Zhong). All authors have read and agreed to the published version of the manuscript. Funding: This research was funded by the National Natural Science Foundation of China (NSFC), Grant Number 61972187; the Scientific Research Project of Science and Education Park Development Center of Fuzhou University, Jinjiang, Grant Number 2019-JJFDKY-53 and the Tianjin University-Fuzhou University Joint Fund, Grant Number TF2020-6. Acknowledgments: Thanks to the editors and reviewers. Conflicts of Interest: The authors declare no conflict of interest.

References

1. Pietrobuoni, E. Two-Dimensional with Guillotine Restrictions. Ph.D. Dissertation, Alma Mater Studiorum Università di Bologna, Bologna, Italy, 2015. 2. Furini, F.; Malaguti, E.; Thomopulos, D. Modeling two-dimensional guillotine cutting problems via integer programming. INFORMS J. Comput. 2016, 28, 736–751. [CrossRef] 3. Lodi, A.; Martello, S.; Monaci, M. Two-dimensional packing problems: A survey. Eur. J. Oper. Res. 2002, 141, 241–252. [CrossRef] 4. Kramer, O. Genetic Algorithm Essentials; Springer: Cham, Switzerland, 2017; Volume 679. 5. Chen, C.-S.; Sarin, S.; Ram, B. A mixed-integer programming model for a class of assortment problems. Eur. J. Oper. Res. 1993, 65, 362–367. [CrossRef] Mathematics 2020, 8, 1914 16 of 16

6. Beasley, J.E. An Exact Two-Dimensional Non-Guillotine Cutting Tree Search Procedure. Oper. Res. 1985, 33, 49–64. [CrossRef] 7. Martello, S.; Monaci, M.; Vigo, D. An exact approach to the strip-packing problem. INFORMS J. Comput. 2003. [CrossRef] 8. Scheithauer, G. Equivalence and Dominance for Problems of Optimal Packing of Rectangles; Dresden University of Technology: Dresden, Germany, 1997. 9. Martello, S.; Pisinger, D.; Vigo, D. Three-dimensional bin packing problem. Oper. Res. 2000.[CrossRef] 10. Cui, Y.; Yang, Y.; Cheng, X.; Song, P. A recursive branch-and-bound algorithm for the rectangular guillotine strip packing problem. Comput. Oper. Res. 2008, 35, 1281–1291. [CrossRef] 11. Coffman, E.G., Jr.; Garey, M.R.; Johnson, D.S.; Tarjan, R.E. Performance Bounds for Level-Oriented Two-Dimensional Packing Algorithms. SIAM J. Comput. 1980, 9, 808–826. [CrossRef] 12. Lodi, A.; Martello, S.; Vigo, D. Heuristic and Metaheuristic Approaches for a Class of Two-Dimensional Bin Packing Problems. INFORMS J. Comput. 1999, 11, 345–357. [CrossRef] 13. Lodi, A.; Martello, S.; Vigo, D. Neighborhood Search Algorithm for the Guillotine Non-Oriented Two-Dimensional Bin Packing Problem. In Meta-Heuristics: Advances and Trends in Local Search Paradigms for Optimization; Springer: Boston, MA, USA, 1999; pp. 125–139. 14. Kirkpatrick, S. Optimization by simulated annealing: Quantitative studies. J. Stat. Phys. 1984, 34, 975–986. [CrossRef] 15. Glover, F. Future paths for integer programming and links to artificial intelligence. Comput. Oper. Res. 1986, 13, 533–549. [CrossRef] 16. Lodi, A.; Martello, S.; Vigo, D. Approximation algorithms for the oriented two-dimensional bin packing problem. Eur. J. Oper. Res. 1999, 112, 158–166. [CrossRef] 17. Jakobs, S. On genetic algorithms for the packing of polygons. Eur. J. Oper. Res. 1996, 88, 165–181. [CrossRef] 18. Soke, A.; Bingul, Z. Hybrid genetic algorithm and simulated annealing for two-dimensional non-guillotine rectangular packing problems. Eng. Appl. Artif. Intell. 2006, 19, 557–567. [CrossRef] 19. Bortfeldt, A. A genetic algorithm for the two-dimensional strip packing problem with rectangular pieces. Eur. J. Oper. Res. 2006, 172, 814–837. [CrossRef] 20. Birgin, E.G.; Martínez, J.M.; Nishihara, F.H.; Ronconi, D.P. Orthogonal packing of rectangular items within arbitrary convex regions by nonlinear optimization. Comput. Oper. Res. 2006, 33, 3535–3548. [CrossRef] 21. Cassioli, A.; Locatelli, M. A heuristic approach for packing identical rectangles in convex regions. Comput. Oper. Res. 2011, 38, 1342–1350. [CrossRef] 22. López, C.O.; Beasley, J.E. Packing unequal rectangles and squares in a fixed size circular container using formulation space search. Comput. Oper. Res. 2018, 94, 106–117. [CrossRef] 23. Scheithauer, G.; Terno, J. Guillotine cutting of defective boards. Optimization 1988, 19, 111–121. [CrossRef] 24. Jin, M.; Ge, P.; Ren, P. A new heuristic algorithm for two-dimensional defective stock guillotine with multiple stock sizes. Teh. Vjesn. Tech. Gaz. 2015, 22, 1107–1116. [CrossRef] 25. Alexander, J.W. Topological Invariants of Knots and Links. Trans. Am. Math. Soc. 1928, 30, 275. [CrossRef] 26. Adamowicz, M.; Albano, A. Nesting two-dimensional shapes in rectangular modules. Comput. Des. 1976, 8, 27–33. [CrossRef] 27. Scholtes, S. Nondifferentiable and two-level mathematical programming. Eur. J. Oper. Res. 1997, 102, 244–245. [CrossRef] 28. Scheithauer, G. Introduction to Cutting and Packing Optimization; Springer: Cham, Switzerland, 2018; Volume 263.

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

© 2020 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).