An algorithm for the 2D guillotine cutting stock problem

An algorithm for the 2D guillotine cutting stock problem

400 European Journal of Operational Research 68 (1993)400-412 North-Holland Theory and Methodology An algorithm for the 2D guillotine cutting stock...

1MB Sizes 52 Downloads 250 Views

400

European Journal of Operational Research 68 (1993)400-412 North-Holland

Theory and Methodology

An algorithm for the 2D guillotine cutting stock problem Bruce MacLeod

University of Southern Maine, Portland, ME, USA Robert

Moll and Mahesh

Girkar

University of Massachusetts, Amherst, MA, USA

Nassim Hanifi University of Southern Maine, Portland, ME, USA Received March 1991; revised October 1991 Abstract: The two-dimensional guillotine cutting stock problem seeks to apply a sequence of guillotine (edge to edge) cuts to extract a collection of smaller rectangles from a stock piece. In this paper an O(n 3) approximation algorithm for the two-dimensional guillotine cutting stock problem is presented. The algorithm considers each rectangle, in turn, and attempts to locate a guillotine feasible position on the stock piece. The algorithm has the property that a position will be located for the n-th rectangle if and only if such a feasible placement exists. This paper establishes the efficiency and effectiveness of the new algorithm by presenting computational results.

Keywords: Optimization; Heuristics; Geometric; Computational analysis; Computers

1. Introduction

The two-dimensional guillotine cutting stock problem involves extracting rectangles from a larger stock piece by a sequence of guillotine (edge to edge) cuts. Each rectangle has a value associated with it and the objective is to extract a collection of rectangles with maximum total value. Guillotine cutting has important applications in the glass, paper, and sheet metal industries [7,11].

Correspondenceto" B. Macleod, Universityof Southern Maine, Portland, ME, USA.

In addition this form of rectangle packing has been applied to VLSI placement and routing [13]. This research considers a single fixed size stock piece and a collection of smaller rectangle types with a value associated with each rectangle type. The objective is to extract from the stock piece, via a sequence of orthogonal edge to edge cuts, a collection of rectangles that have maximum total value and which are instances of the rectangle types. We consider problems in which the number of allowable instances of a particular rectangle type is bounded. These assumptions are in keeping with previous work on the subject [2,5,12].

0377-2217/93/$06.00 © 1993 - Elsevier Science Publishers B.V. All rights reserved

B. MacLeod et al. / An algorithm for the 2D guillotine cutting stock problem

a2

b2

b2

bl

bl al

al

(~)

(b)

Figure 1. (a) Not guillotine feasible; (b) guillotine feasible

In Figure 1, two rectangle types are represented (types A and B) and there are two instances of each type in each of the layouts. In Figure la, rectangle instances are placed in such a way that no guillotine cuts can be made on the stock piece without penetrating one of the rectangles. Figure lb illustrates a layout of the same rectangles which is guillotine feasible. We assume that the orientation and dimensions of the stock piece and rectangle types is fixed. Fixed orientation is not a serious restriction, since the alternative orientation can be represented by a new rectangle type. A number of methods for solving the two-dimensional guillotine cutting stock problem have been identified. Gilmore and Gomory [8,9] present a linear programming formulation for multidimensional cutting stock problems. The resulting LP requires the solution of the generalized knapsack problem at every pivot step. In Christofides and Whitlock [5], an exact solution to the problem is presented which is based on a tree-search algorithm. Solutions are given for problems which involve up to 62 rectangles. A more recent approach to this problem, due to Wang [12], generates cutting patterns with minimal waste by successively combining rectangles and collections of rectangles. One algorithm presented in that work reduces the potentially large number of rectangle combinations by excluding rectangle combinations with a waste area which exceeds a specified fraction of the total area. A related algorithm measures the waste area with respect to rectangle conglomerates (formed by successive combinations) and excludes rectangle combinations which exceed a specified fraction of this area. The user is responsible for designating the maximum allowable waste percentage.

401

A related area of research involves the placement of rectangles without the guillotine restriction. Chazelle [4] gives an implementation of bottom-left rectangle packing which requires O(n 2) time and linear space. The bottom-left rectangle placement heuristic considers each rectangle in turn and places rectangles in the bottommost, then leftmost position on the stock piece. Chazelle's algorithm is shown to be optimal among all algorithms which solve the rectangle packing problem with the bottom-left placement of pieces. Baker, Coffman and Rivest [1] establish worst case bounds for the placement of rectangles without guillotine restrictions. They consider the placement of rectangles in a fixed width stock piece of (potentially) infinite height. They prove that ordering rectangles by decreasing width and then placing them in the bottom-leftmost position results in a worst case performance of three times the optimal height. Girkar [10] proves that bottom-left, decreasing-width guillotine packing also results in a worst case performance of three times optimal - a somewhat unexpected result given the additional guillotine constraint. This paper presents a two-dimensional guillotine cutting stock algorithm that seeks approximate solutions rather than exact, optimal solutions. Our empirical results demonstrate that inordinate computing resources are required by exact solution methods for relatively small sized problems. Thus the approximate algorithm presented in this work fills a niche by solving moderate to large sized guillotine cutting stock problems. Moreover our algorithm is fast enough to allow many different feasible solutions to be constructed so that the best one can be chosen. Finally, the algorithm is naturally consistent with interactive testing for guillotine feasibility, and could therefore be integrated into a combined optimization/user-interactive system. Section 2 of this paper gives some background and presents preliminary results. Section 3 starts by developing a procedure to determine whether a given layout is guillotine feasible. This procedure is then incorporated into an algorithm which determines, in O(n 2) time, whether there is a feasible position for a rectangle in a layout. The algorithm is shown to have the property that a position will be located on the stock piece if]" such a feasible position exists. Section 4 provides

402

B. MacLeod et al. / An algorithm for the 2D guillotine cutting stock problem

the results of a computational comparison of the algorithm presented in [12] with our proposed algorithm.

2. Background and preliminary results The guillotine cutting stock problem considered in this paper involves extracting instances of rectangle types, hereafter called rectangle instances or simply rectangles, from a fixed size larger rectangle called a stock piece. We define a layout structure as an arrangement of non-overlapping rectangle instances on the stock piece. A cut c is a horizontal or vertical line segment in a given layout structure which contains the face of at least one rectangle and which does not penetrate any rectangle. In addition c must be proper, i.e. it must not lie along an edge of the stock piece. Note that the use of the term cut refers only to a line segment along the border of a rectangle and does not necessarily imply anything about the final sequence of physical cuts to extract rectangles in the layout. A cut c is a guillotine cut if it extends across an entire stock piece. When a guillotine cut is applied, it divides a stock piece, and therefore its associated layout L, into two separate sublayouts, L 1 and L 2. L~ and L 2 can now be thought of as residing on two separate and independent stock pieces. A layout L is a guillotine layout if there exists a sequence of guillotine cuts c~, c 2 . . . . , cp, which when applied to L (and its successive sublayouts) cut along all rectangle borders which lie inside the original layout structure. We observe that a guillotine cut applied to a guillotine layout results in two sublayouts that are themselves guillotine layouts. In general, unoccupied rectangular pieces of a stock piece are generated when a sequence of cuts is applied to layout L. Given a layout L, we call an unoccupied subrectangle w of the associated Stock piece a waste piece if some sequence of guillotine cuts on L extract w.

Proposition 1. L e t L be a guillotine layout and let R be a new rectangle not included in L. R can be placed in L in a guillotine legal position iff R can be placed entirely inside a waste piece o f L. Proof. If R can be placed entirely inside a waste piece of L, apply the cuts that extract this waste

piece, then extract R from it. Conversely, suppose that R can be added to L at some guillotine feasible position. Apply guillotine cuts which extract R until R resides in a sublayout that contains R only. This sublayout is a waste piece of the original layout. [] Let C be a set of cuts on L. We define a precedence relation on C as follows: Let ci, c i E C be two different cuts. We say that c i is less than c~ (denoted by ci < cj) if one endpoint of c i lies properly on the face of the some rectangle along c i. We call this endpoint of cj a blocking point. We observe that each c ~ C has at most two blocking points. The precedence relation < is antisymmetric, but not reflexive or transitive. A cut c i ~ C is minimal if it has no blocking points. Thus a minimal cut is a guillotine cut. The set of minimal elements of a structure L, plays an important role in our analysis. In Figure lb, cuts along the top of b 1 (c01_top), the left side of b 1 (Cbl.left) , the top of a 1 (Cal_top), and along the right side of b 2 (Cb2_right) are related by precedence: Cb 1-left ( Cal--to p ( Cb2- right ( Cb I - t o p "

Cuts that are not minimal have at least one blocking point. For example, the Cbl_tOp cut is blocked by the right side of b 2, therefore the Cb_to p cut has a (single) left blocking point with (x, y)-coordinates equal to (b2_right(X), bl_to p (y)). The Cbl_~eft cut is minimal while the Cb~_top cut, because of the left blocking point, is not minimal.

3. An O(n 3) algorithm for guillotine rectangle layout 3.1. G S - A n O(n) guillotine slicing procedure

Before describing our main result, an O(n 3) algorithm for guillotine layout, we present an important preliminary algorithm which does the following: Given a guillotine layout L, an unplaced rectangle R, and a possible location in the layout to place R, the algorithm determines in linear time if this is a guillotine feasible location for the placement of R in L. Suppose n rectangles R i , i <~n, have been placed to form a guillotine layout L and suppose

B. MacLeod et al. ,/An algorithm for the 2D guillotine cutting stock problem

to its partner blocking point. The {v/} for this particular example is empty since no vertical cuts are blocked. The list {m i} enumerates the active minimal cuts and in this example it consists of all vertical cuts which are not along the edges of the stock piece. Each entry on the {m i} list identifies the cut and its orientation. Suppose rectangle R is placed without overlap somewhere in a layout. The above data structures can be updated in O(n) time by checking the borders of each rectangle R i, i ~
the layout has been represented as follows: Three lists {hi}, {ui} and {m i} represent, respectively, blocking points of horizontal cuts, blocking points of vertical cuts, and minimal c u t s . {h i} is a doubly linked list ordered by the x-coordinate of the blocking point. {vi} is a doubly-linked list ordered by the y-coordinate of the blocking point. The {h i} and {vi} lists can be accessed from either the front or back of the list. There is an hi-entry for each blocking point of a horizontal cut. The following information is maintained in an hi-entry: • the x- and y-coordinate of the blocking point; • an indicator which tells if the blocking point is a left or right endpoint of the associated cut; • a pointer to the cell representing the blocking point at the other end of the cut. If the other end of the cut is not blocked, this pointer is nil. Similar information is maintained in the vertical blocking point list, {vi}. The list (m i) enumerates the minimal cuts. Each entry on the {m i} list identifies the cut and its orientation. The above data structures are sufficient for the operation of the O(n) guillotine slicing procedure. Figure 2 gives a sample layout and its associated data structure. For example, the cut along Ctop has two blocking points, (1,2) and (3,2), and these two entries point to one another. A left to right listing of points in h i is obtained by traversing the list from top to bottom; similarly a right to left listing is obtained by a bottom to top traversal of the list. Each entry in the hi-list has a pointer

3

2



d

a

1

c

b 1

hi hi h2 ha h4 h5

403

2

3

Blocking Pt. Left/ Partner Blocking Point (x,y) Right (1,1) Left h3 (1,2) Left h4 (2,1) Right hi (3,2) Right h2 (3,3) Right nil Figure 2. Guillotine layout and associated h i list

Cut

btop Ctop btop Ctop atop

404

B. MacLeod et al. / An algorithmfor the 2D guillotine cutting stock problem

{m i} () nil do begin apply the first cut, m, of the minimal cut list {mi} and delete this cut; if m enters the active region of the layout, then consolidate the effect of this cut on R's side of m according to the procedure outlined in the text. end; if Ihi}, {Ui/ are empty, then return 'succeed' else return 'fail'

while

Figure 3. The guillotine slicing procedure

minimal cuts in the active region. It runs in O(n) time and is key to the guillotine placement algorithm to follow. The consolidation phase of the guillotine slicing loop works as follows. Without loss of generality suppose m is a vertical cut and suppose R lies to the left of m. Then, starting at the end of the {h i} list corresponding to positions to the right of m and continuing to the front until an h i is reached with (x-coordinate) < (x-coordinate of m), process each h i on the list according to the following rules: 1. If the blocking point is a left endpoint, do nothing: the entire cut lies in the inactive region. 2. If the blocking point is a right endpoint and has a nil pointer to its cut's paired blocking point, then move this cut to the m-list: the cut is now minimal for the region to the left of m. 3. If the blocking point has a non-nil pointer to the cut's paired blocking point and this points to another blocking point that is also to the right of m, do nothing: the entire cut lies in the inactive region. 4. If the blocking point has a non-nil entry that points to a blocking point to the left of m, set the pairing pointer of that blocking point to nil. This operation reflects the fact that this cut is in the portion of the layout to the left of m (the portion containing R) and the cut identified in this h-entry is now unconstrained on the right. When an hi-entry is reached with (x-coordinate) < (x-coordinate of m), the consolidation is complete. Theorem 2. Given a stock piece S and a guillotine layout L o f rectangles R1, R 2 . . . . . Rn, the GS procedure will determine in O(n) time if a newly placed rectangle R preserves the guillotine legal structure o f L.

Proof. The GS procedure executes only minimal cuts in the active region of a layout. Inactive regions are necessarily guillotine feasible, since they are unaffected by the placement of R. If GS successfully extracts R, then clearly R has been placed in a guillotine feasible location. On the other hand if GS terminates without extracting R, then R's placement is illegal, since all cuts in the active region are blocked. The algorithm runs in O(n) time by the following argument: First, O(n) time is required to check for overlap, and to update the blocking point lists and minimal cut list in order to reflect the placement of R. Because the three lists together contain only O(n) entries and because no cell on any list is serviced more than three times - once to have its pointer set to nil, once to be moved to the minimal cut list, and once to be applied as a minimal cut - the total time required for the guillotine feasibility check is also O(n). [] 3.2. GCS - The guillotine cutting stock algorithm This section presents an O(n 3) approximation algorithm for the guillotine feasible placement of n rectangles on a stock piece. The algorithm exhibits the following weak completeness property: at stage n of the algorithm, the algorithm will successfully place the n-th rectangle if and only if such a placement exists. This is difficult to achieve because despite Proposition 1, which asserts that a rectangle is guillotine placeable in a guillotine layout iff it is completely contained in a waste piece of that structure, there are in general O(n 2) possible distinct waste pieces. The potential for O(n 2) waste pieces can be shown with a simple example. Consider a layout of n squares where half of the squares are positioned along the bottom of the stock piece and the remaining half are positioned along the left wall of the stock piece. There are O(n) horizontal cuts and O(n) vertical cuts. Since there are O(n) possible choices along one axis which can followed by another O(n) choices along the other axis, there are O(n 2) possible waste pieces that could act as 'holders' for an incoming rectangle. The GCS algorithm must systematically examine the waste area of the layout in such a way that O ( n ) time is not expended to examine each of the possible waste pieces.

B. M a c L e o d et al. / A n algorithm for the 2D guillotine cutting stock problem

We begin the development of GCS by observing that every waste piece must completely contain, along one of its four borders, the entire face of some already placed rectangle. Indeed, the final cut applied to a border of a waste piece must sever the waste piece from the entire face of some rectangle, and this cut witnesses for the desired inclusion property. We define an exposed border of layout L to be an edge of a placed rectangle which does not overlap any other rectangle in the layout. There are O(n) such faces, and by the argument above it is sufficient to consider only waste pieces that are adjacent to one of the exposed borders. We now describe the GCS algorithm. Suppose R1, R 2. . . . . R k have already been placed, and we wish to place new rectangle R. Let F be a placed rectangle with an exposed border, and without loss of generality let us assume that its north border is exposed. We first construct and place a rectangle R' on F with height equal to R's height and width equal to the maximal width possible without overlapping any rectangles already placed in L. We call the region covered by R' the critical region. If the width of R' is smaller than the width of R, we move on to the next exposed border; otherwise we update the layout's data structures in O(n) time and apply the GS algorithm on R'. If the GS procedure determines that R' is guillotine legal, we remove R' and left justify R in the critical region. Otherwise we extract from the final state of the above GS procedure application a doubly linked list e l , . . . , e q of all vertical cuts that are blocked by R'. This list is constructed from the {h i} list, which is assumed to be ordered by increasing x-coordinate value. This order is maintained in the list e I. . . . , eq. Now we remove R' and replace all pointers to blocking points on R' with pointers to the blocking points before R' was placed (this information is saved in a location associated with each cell in each hi-entry). We call the resulting layout L' and observe that L' has the property that any minimal cut must enter the critical region. The GCS algorithm proceeds by systemically cutting into the critical region. The cuts into the critical region are made along the e t . . . . . eq-edges in left to right and then right to left order. For each ei-cut, we place the rectangle R alongside the cut and check to see if the el-cut is minimal -

405

Stage i: Step 1. Place R in the critical region left justified against e i. If R does not fit at this position go to Step 6. Step 2. If e i is not a minimal cut, go to stage i + 1. Otherwise apply cut e i. Step 3. Apply the GS procedure. Step 4. If the GS procedure terminates successfully, return success: R legally fits left justified against e i. Step 5. If GS does not terminate successfully and i < q, go to stage i + 1. (Note that the effects of GS during this step are cumulative.) Step 6. Reverse the order of list {ei} so that the right most cut into critical region, eq, is e 1 and reapply Steps 1-5 to L', this time with R right justified against e i Fig. 4. Portion of the GCS algorithm which executes cuts into the critical region

if it is, we apply the minimal cut and consolidate the effect of the minimal cut on other cuts in the layout. The guillotine slicing procedure is then applied to account for the possibility that the application of an e i minimal cut made other cuts in the layout minimal. If R can be extracted by the guillotine slicing procedure, then the layout with R in its present position is feasible. Otherwise, we continue to the next cut into the critical region. Figure 4 outlines the systematic cutting into the critical region. The variable i is used to index into the e I. . . . . eq-edges. It is initialized to the For each exposed border of rectangles R l . . . . . Rk: Step 1. Construct and place a critical region rectangle adjacent to the exposed border. The dimensions of the critical region rectangle are maximal along the exposed border axis and minimally sufficient to hold R along the orthogonal axis. Step 2. If critical region is smaller than the size of R stop consideration of this exposed border. R will not fit along this exposed border - continue to the next exposed border. Step 3. Apply the GS algorithm to the layout which includes R 1.... , R k and the critical region rectangle. If the critical region can be extracted by GS, then R will fit in that area. If the first feasible position is desired, then place R; otherwise note this feasible position and continue to next exposed border. Step 4. If the critical region cannot be extracted, then remove the critical region rectangle and apply the procedure given in Figure 4 to systemically slice up the critical region. If the procedure is successful, R can be placed at some position in the critical region (location is given by the procedure); otherwise R cannot be placed in the waste space adjacent to the exposed border under consideration - continue to the next exposed border. Figure 5. T h e GCS algorithm

406

B. MacLeod et al. / An algorithm for the 2D guillotine cutting stock problem

value of 1 and the steps outlined in Figure 4 are applied. We can now present a complete summary of the GCS algorithm. GCS considers each rectangle, in turn, for placement alongside any one of the exposed borders in a layout. For each exposed border, we construct and check whether a critical region rectangle (which is at least as large as the rectangle to be placed) will 'guillotine fit' alongside the exposed border. If it will fit, then we can place the new rectangle anywhere in the critical region. If it does not fit, then we systematically check for feasible positions in the critical region according to the steps outlined in Figure 4. A description of GCS in algorithmic form is given in Figure 5. The pseudocode applies to the placement of a single rectangle R in a guillotine layout with rectangles R~,..., R~ already placed. Theorem 3. Given a stock piece S and rectangles R a, R 2 . . . . , Rn, the GCS algorithm is weakly complete in the following sense: if R 1. . . . . R k have already been placed, then the algorithm will place R k + 1 i f and only if there exit a guillotine feasible position f o r this rectangle. Moreover, the GCS algorithm will place the rectangles in guillotine style in O(n 3) time. Proof. Suppose that GCS locates a placement for Rk+ ~. This placement is guillotine feasible because R k + ~ does not overlap any of the R~ . . . . . R k rectangles in L, and furthermore, the sequence of minimal cuts identified by the algorithm extracts a waste piece of sufficient height and width to contain R k + 1. Now we prove that the GCS algorithm finds a placement for Rk+t in L if one exists. By Proposition 1, a placement for Rk+ ~ exists if Rk+ 1 fits in one of the waste pieces of L. Furthermore, every waste piece must completely contain, along one of its four borders, the entire face of some already placed rectangle. The exposed border of an already placed rectangle is used as a starting point for the construction of waste pieces that could hold Rk+ I. The critical region identifies a waste area along an exposed border that is sufficiently large so that, if a fit exists in any one of the waste pieces adjacent to that exposed border, a fit will exist in the critical region. Specifically, the critical region is maximal along the exposed border axis and minimally sufficient in the direc-

tion orthogonal to the exposed border. It remains to prove that if there exists a guillotine feasible placement for Rk+ 1 in some critical region, GCS will locate that placement. Suppose R~+ 1 can indeed be legally placed in a critical region. Let it be placed at the left-most legal position, and suppose C = c~ . . . . , c r is any sequence of cuts which apply exclusively to the active region and which extracts Rk+ 1 from L'. Without loss of generality, assume that the first cut in C that enters the critical region is to the left of the position identified for R~+ 1. (If the first cut is to the right of Rk+~'s position, we apply the same analysis based on step 6 of the GCS algorithm). Let d a. . . . , d s be the cuts of C that enter the critical region. By assumption an initial segment of {di}'s must occur to the left of Rk+ 1. In addition, the x-coordinate values of this initial segment must be monotone increasing (never go back to the inactive region) and culminate in the cut that borders Rk+t's left-most position. Indeed if any critical region cut to the right of Rk+ 1 is applied before Rk+l's left border cut is made, then Rk+ 1 is not in its left-most position (application of left and right cuts allow the remaining top and bottom cuts to proceed). Now we argue that the GCS algorithm tracks a significant initial segment of C. First of all, the algorithm applies cut d I of C by the following reasoning. If d~ = e l, then e~ must be a minimal cut for L' and so will be applied. On the other hand if d~ =e~ for some j > 1, then when R~+ 1 is left justified against ei (d~), ej must be minimal because d~ - the first critical cut in C - is minimal and earlier application of steps 2 and 3 in the algorithm do not affect its minimality. Now suppose that for each j < t, dj strictly to the left of Rk+l'S final position and d t to the left of Rk+l's final position, d r has been applied by the algorithm. We need to show that dt is also applied. Reasoning as before, when R~+~ is leftjustified against dr, the d t cut must be minimal because its application depends only on the cuts dj for j < t which have already been applied and on various non-critical cuts, which are applied by the GS procedure. Since the initial segment of the C critical cuts are monotonically increasing, d t can be executed without the application of critical cuts to the right of R~+~'s final position and without the application of critical cuts be-

B. MacLeod et al. / An algorithm for the 2D guillotine cutting stock problem

tween d t and the final left-most position of Rk+ 1" Thus all critical cuts to the left of Rk+~'s final position will be made by GCS. We can therefore conclude that Rk+ 1 will eventually reach its left-most legal position. At this point the initial segment of cuts in the critical region to the left of R have been executed. It remains to show that the remaining cuts to the right and top of R can be executed. Since C defines a feasible sequence of minimal cuts, Theorem 2 allows us to conclude that GS will find some sequence of cuts that will eventually result in the remaining top, right, and bottom cuts of R being applied. The complexity of GCS on one exposed border is O(n). The data structure updates associated with moving rectangle Rk+ 1 in Step 1 can be performed in constant time with the following observations. Two sets of cuts enter into the critical region: those along the axis perpendicular to the exposed border and the e l . . . eq cuts. Cuts along the axis parallel to the exposed border are blocked and Rk+ 1 movements do not cause an immediate change in their status. The other set of cuts - e 1. . . . . % - is sorted so the position of the two Rk+l borders with respect to the

I

q

I

II

oj

e l , . . . , eq-list can be maintained. This allows us to remove e i cuts incrementally from the minimal list as the rectangle Rk+ ~ moves across their path. Similarly, when Rk+ ~ moves out of the path of an e i cut, the previous blocked state of that cut can be reinstalled. Steps 2 - 5 only require linear time because, as we have observed, the effect of the GS algorithm in Step 4 is cumulative, and thus no entry associated with a particular blocking point at the beginning of algorithm application is processed more than three times. There are O(n) exposed borders, so GCS requires at worst O(n 2) time to place a rectangle in a layout. The proof is complete. [] 3.3. A n example o f the G C S algorithm

We illustrate the GCS algorithm with an example. Assume pieces a through p have been placed in a guillotine fashion on the stock rectangle depicted in Figure 6a. We wish to determine if piece q (now floating on top of the stock piece) will fit into the existing layout in such a way that a guillotine layout is generated. We start by determining all the exposed bor-

p k

m n

k

m n ilto,

i

1

critical region

a

blcldle~]glhli (a)

blcldle

[hli

(b)

p

m oll

1

]

n °II q

a

oldie

(c)

407

hli

Figure 6. Example of the GCS algorithm

(d)

408

B. MacLeod et al. / An algorithm for the 2D guillotine cutting stock problem

ders in the layout. In this example the exposed borders are btop, Ctop, drop, etop, ftop, gtop, /top, /left, /top, Obottom, Oright, Otop~ Pright, nbottom, and mbottom. TO determine whether rectangle q will fit into this layout all of the above exposed borders will need to be considered and for each exposed border the steps given in Figure 5 will be applied. To continue the example, consider the placement of q on top of f - the ftop exposed border. A critical region is defined with respect to the exposed border of f and the rectangle q. To avoid cuts into the critical region, a rectangle R' is constructed and temporarily placed in the critical region. From this layout, the GS algorithm is applied. The GS algorithm will apply all minimal cuts in the active region (the portion of the layout that includes the critical region). In this case, the only minimal cut is along Pbottom" The critical region rectangle cannot be extracted so the algorithm proceeds to systemically carve up the critical region in a manner outlined by Figure 4. The layout before the critical region is sliced up is depicted Figure 6b. Since GS was unable to extract the critical region rectangle, all cuts which are blocked by R' are collected into the list denoted by e 1..... eq. In this example, the initial sequence in the e-list includes bleft, bright , Cleft, kright , mleft. The rectangle R' is removed and starting from the left, each e i is checked to determine if it is minimal. In this example, the first ei-cut which is minimal is along the bright-axis. So the rectangle q is placed along the bright-axis and the GS algorithm is applied. The resulting layout is given in Figure 6c. This is not a guillotine feasible location - all rectangles in active region cannot be extracted, so q is moved to a position along the next ei-cut which is minimal - Cright. Moving q and applying the minimal cut Cright also does not allow all rectangles to be extracted from the layout, so q is moved to the next position - dright. When q is placed along the dright-axis, the GS algorithm terminates successfully. So one feasible position for q is along the dright-axis. The results of placing q along dright are given in Figure 6d. 4. Computational results Experimental results are presented in this section. The first collection of experiments involves a

benchmark of GCS on 16 test problems in the OR-Library [3]; the results of which are described in Section 4.1. The second collection of experiments involves the application of Wang's algorithm and GCS on random generated test problems. Section 4.2 describes the method of dataset construction and Section 4.3 summarizes the results from the second collection of experiments. 4.1. Results from the OR-Library datasets

The OR-Library contains a collection of test problems that can be accessed via electronic mail [3]. As of August 1991, thirteen datasets related to the guillotine cutting stock problem were in the library. Ten of the datasets are unconstrained guillotine cutting stock problems. That is, there are no limits on the number of pieces of the same size that can be cut from the stock piece. The remaining three are constrained guillotine cutting stock problems. The datasets were modified for the purposes of this benchmark. The ten unconstrained problems were converted to constrained problems by calculating, for each rectangle type, the total number of replicate pieces that could fit into the stock piece. Rather than an unlimited number of replicate pieces, the unconstrained problems were limited to having the maximum number of replicate pieces that could fit into the stock piece. The remaining six problems are based on the three constrained guillotine cutting stock problems. In addition to the original three datasets, three more datasets were constructed by converting them into unconstrained problems and determining for each rectangle type the maximum number that could fit into the stock piece. In all, sixteen datasets were considered. The results from the GCS approximation algorithm are compared with optimal and provably near-optimal algorithms given in [5,12]. It is possible to get the optimal value in these sixteen datasets because the optimal layouts always involve twelve or fewer pieces. Each rectangle type has a value associated with it. For the first ten problems, the value is equivalent to the area of the rectangle type. In the remaining six problems the rectangle value is not equal or proportional to the area of the rectangle type. While the GCS algorithm can be run on datasets with arbitrary weighting schemes,

409

B. MacLeod et al. / An algorithm for the 2D guillotine cutting stock problem Table 1 Comparison of GCS and Wang's algorithm: results are given in terms of the percent of the stock piece covered Stock piece size

# Rectangle types

# of rectangles

100 GCS runs

500 GCS runs

Wang's

500 500 250 250 1000 1000 500 500 1000 1000

10 20 30 50 10 20 30 50 30 50

51 83 147 248 51 76 123 246 145 212

98.40 94.02 96.18 97.61 97.11 98.20 93.86 97.90 96.01 94.22

98.40 94.43 96.18 97.61 97.11 98.20 96.69 97.90 98.01 97.27

98.40 95.60 96.68 98.72 97.11 98.20 97.03 98.65 98.01 98.00

500 500 250 250 1000 1000 500 500 1000 1000

the near-optimal algorithms given in [12] are based on minimizing waste area. We did not see any easy way to convert the algorithm to operate in a near optimal fashion on datasets with rectangle values which are not proportional to the area of the pieces. Therefore, this section presents a comparison of GCS with Wang's algorithm on the first ten problems (where the rectangle values are equal to the area) and the remaining six datasets are c o m p a r e d with the results given in [5]. Wang's algorithms (Algorithms one and two given in [12]) require the specification of a parameter (/3) which designates the allowable waste percentage. If this p a r a m e t e r is overestimated, then the algorithm may require enormous computational resources. If this p a r a m e t e r is underestimated, then it fails to place many of the rectangles in the stock piece. There is no procedure to determine this p a r a m e t e r in advance so to give Wang's algorithm an opportunity to perform well, we decided to fix/3 at six different values - 0.001, 0.003, 0.005, 0.01, 0.03, and 0.05. The best results from the different /3 are chosen and reported in this section. Since Wang's algorithms are exponential in nature we needed to impose a ceiling

on the CPU and memory use for any one run. For the purposes of this comparison the maxim u m run time was fixed at 2 C P U hours on a DECstation 3100 (approximately 14 MIPS) and maximum m e m o r y usage was set at 8MB. We note that if these bounds were exceeded, then the machine started thrashing and little more useful computation was performed. The GCS algorithm allows rectangles to be processed in any order and the placement of a rectangle can be in any one of the collection of feasible positions identified by the algorithm. The open-ended nature of rectangle ordering and placement allows the GCS algorithm to act as a shell for different ordering and placement schemes. For instance, GCS could be applied to a list of randomly ordered rectangle types and the best solution from a number of these random runs could then be chosen. In the results that follow, we use this capability and present the best solution of 100 and 500 GCS runs. The entries in Table 1 are given in terms of the percentage of the stock piece covered by rectangles. While the total number of rectangle instances is quite high, the maximum number of

Table 2 Comparison of GCS and Christofides and Whitlock algorithm: results are given in terms of total weight of pieces cut from stock piece Stock piece Size

# Rectangle types

# of rectangles

100 GCS runs

500 GCS runs

Christo Fides & Whitlock

15 40 40 15 40 40

7 10 20 7 10 20

16 23 62 148 168 110

243 2678 1860 248 3076 2240

243 2708 1860 248 3076 2240

243 2892 1860 249 3006 2240

10 70 70 10 70 70

410

B. MacLeod et aL / An algorithm for the 2D guillotine cutting stock problem

rectangles in the final layout is always less or equal to twelve. Under these circumstances, Wang's algorithm was able to obtain results that were provably near-optimal. For all of the datasets in this collection, 500 runs of GCS is within 1.2% of Wang's results. With four of the datasets, 500 runs of GCS achieves the same value as Wang's algorithm. The entries in Table 2 provide a comparison between GCS and the algorithm given by Christofides and Whitlock [5]. Each entry is the summation of weights associated with the pieces assigned to the layout. We assume that the value for the fifth dataset given by the optimal algorithm in [5] is an oversight - there is indeed a better layout with total weight equal to 3076. GCS seems to do poorly on dataset two. One explanation is given by examining the structure of the optimal layout: rectangles of the same type are not near to one another in the layout and the current randomized ordering scheme of GCS shuffles only the rectangle types - not the individual rectangle pieces. Therefore, GCS will tend to place pieces of the same type near to one another. The computation time for a single GCS run is, on average, equal to 0.1 CPU seconds on a DECstation 3100. The computation time for Wang's algorithm varies dramatically. For instance, with the high value as previously mentioned, Wang's algorithm was run on six different /3-values an the best result was chosen. The average computation time for these six /3-values varied dramatically. F o r / 3 equal to 0.001 we found an average of 0.5 seconds; for/3 at 0.05, an average of 1845 seconds was observed. In five of the ten datasets, runs at the last two levels (/3 at 0.03 and 0.05) were necessary to get the reported results. That is, the lower levels o f / 3 were unable to generate layouts of the same quality as the higher/3-values. If the user could correctly guess the approximate waste area, then such a range of different/3 values may not be necessary. If we include all /3-runs in the computation time estimates for Wang's, then it takes an average of 2670 CPU seconds for Wang's algorithms to generate a solution to one of the above problems. The next two sections continue our comparison of GCS with Wang's algorithm using random data sets. First we describe our data set generation method; then we report on our results.

4.2. Dataset construction

To elaborate on the comparison between Wang's algorithm and GCS, we consider the behavior of the algorithms on ten different classes of randomly generated guillotine placement problems. The first five problem classes involved the placement of approximately 20, 30, 40, 80, 100 rectangle instances onto a stock piece with an area approximately equal to the total area of the rectangle instances. The datasets for the first five problem classes were constructed in such a way that an optimal solution is known. The remaining five problem classes involved the placement of approximately 20, 30, 40, 80, 100 rectangle instances onto a stock piece with an area equal to approximately 110% of the total area of the stock piece. An optimal solution to the second five classes of problem instances is, in general, unknown. The problem classes considered in this paper set a maximum of five rectangle instances with the same dimensions (maximum of five instances of the same type). In general terms, datasets are constructed by applying a number of randomly placed guillotine cuts to fixed size stock piece of size (420 x 420). More specifically, let N denote the total number of rectangle instances in a class (either 20, 40, 60, 80 or 100) and set M to 2.5 - the mean of the uniform distribution [1 . . . . ,maximum number of rectangle instances of the same type]. The average number of rectangle types, T, is determined by [ N / M J. T - 1 randomly placed guillotine cuts are made on the stock piece and the subsequent subpieces (All random choices required by this dataset construction process are modeled with the uniform distribution). The position of cuts on the stock piece and the subsequent subpieces is determined by randomly choosing a horizontal or vertical cut and a position on the appropriate edge of the piece. After the T - 1 cuts have been applied, a number between one and five (the maximum number of rectangle instances of a particular type) is randomly chosen for each sublayout. This number will determine the number of equal sized rectangles instances to slice out of the sublayout. For each sublayout, we randomly choose a horizontal or vertical orientation for the cuts that extract the rectangle instances from the sublayout.

B. MacLeod et aL ,/An algorithm for the 2D guillotine cutting stock problem

The first five problem classes involve placing rectangle instances generated from the above process onto a stock piece of size (420 x 420). The remaining five classes of datasets are similar to the first five except that they involve placing rectangles instances on a stock piece of size (400 x 400). The algorithms were run on ten problem instances in each class.

4.3. Algorithmic performance of GCS and Wang's algorithm The GCS algorithm allows rectangles to be processed in any order; the placement of a rectangle can be in any one of the collection of feasible positions identified by the algorithm. In Girkar [10], a few of the possible alternatives for ordering rectangles and choosing placement positions are considered. In this section, we report on two forms of GCS: one in which rectangles are ordered by decreasing area and are placed in the bottommost leftmost position (BLDA GCS); and a second in which there are multiple runs of GCS on the same dataset but with different (random) orderings of rectangles. Tables 3 and 4 compare the performance of the GCS algorithm with Wang's algorithm two (the algorithm that gave the best results on this data) presented in [12]. Each entry in the table is an average of the results from ten different problem instances. Wang's algorithm does well when it is applied to problems with a small number of rectangles that allow very tight packings. In Table 3, Wang's algorithm outperforms GCS on layouts with approximately twenty rectangles. On layouts with approximately forty rectangles, Wang's algorithm

Table 3 Comparison of GCS and Wang's algorithm: rectangle area = stock piece area Approximate number of rectangles

BLDA GCS

100 GCS runs

500 GCS runs

Wang's algo. two

20 40 60 80 100

76.86 82.94 89.33 86.91 88.62

95.85 92.38 91.13 90.52 90.45

98.14 94.17 92.03 91.87 91.46

99.81 89.00t a ~b 5

$: Results for six of ten datasets - rest did not complete. b 5: No runs completed.

411

Table 4 Comparison of GCS and Wang's algorithm: rectangle area = 110% of stock piece area Approximate number of rectangles

BLDA GCS

100 GCS runs

500 GCS runs

Wang's algo. two

20 40 60 80 100

83.25 88.92 91.67 93.34 89.96

85.62 88.92 93.17 93.41 91.18

85.62 89.95 93.57 93.50 92.12

84.47 88.835 ~ 5b 5 5

a 5: Results for three of ten datasets - rest did not complete. b 5: No runs completed.

loses it's lead; primarily because the memory and CPU limits restrict the amount of search. The results of size forty rectangles reflect the completion of Wang's algorithm on six of the ten datasets; Wang's algorithm was unable to complete on the remaining four. We found that substantial increases in available memory (64MB) and available CPU time increased the range of Wang's algorithm by approximately ten rectangles. In Table 4, the datasets reflect problems in which there is not necessarily an optimal layout. Under these circumstances, Wang's algorithm does not do as well. For the results in this table, we needed to increase the /3-values to 0.1, 0.15, and 0.2 to get any reasonably results (higher #-values than these did not do any better). With these higher /3-values, Wang's algorithm constructed more layouts that were less densely packed and was able to locate layouts with the coverages mentioned in the table. The two algorithms represent fundamentally different approaches. Wang's algorithm typically packs a smaller collection of rectangles very tightly in an enclosed region, while the GCS algorithm places more rectangles in a somewhat less densely occupied area. Wang's algorithm operates better when there is a solution which involves relatively little waste. When a low waste percentage solution is not necessarily possible, Wang's algorithm incurs substantially more computation time, often constructs inferior solutions, and is not guaranteed to finish. This is because rectangle conglomerates are formed that respect the designated /3 waste percentage parameter, but often collections of rectangles cannot join the conglomerate since their addition would violate the /3-parameter. There is no solution that includes all rectangle

412

B. MacLeod et al. / An algorithm for the 2D guillotine cutting stock problem

instances with the designated fl-value. Increasing the/3-term to allow for more rectangle instances in a layout substantially increases the running time, and often the algorithm was unable to finish within the time allotted.

the layout and it could also support a user interface that would allow for interactive rectangle placement.

References 5. Conclusions The GCS algorithm presented in this paper has been shown to be an effective and efficient means of solving the guillotine cutting stock problem. The GCS algorithm operates by considering each rectangle, in turn, for placement on the stock piece. This work shows that GCS will locate a guillotine feasible position for a rectangle if/ such a position exists on the stock piece. A computational comparison of GCS with Wang's algorithm for guillotine placement demonstrates that there are many guillotine cutting stock problems for which a fast, reasonably effective algorithm such a GCS gives better results than an algorithm which maintains exact bounds on the quality of the guillotine layout. The GCS algorithm does not dictate an order for rectangle placement or positioning in the layout. This flexibility can be exploited in a number of ways. The effectiveness of one technique, that of choosing the best of many random runs, is shown to have results that rival a provable nearoptimal problem solver. Other techniques, primarily those based on local search, will form the basis of future research. The potential for the GCS algorithm lies in not only solving large guillotine cutting stock layouts, but in supporting different approximation approaches to the guillotine cutting stock. The GCS algorithm could operate in an environment in which a portion of the pieces are to be fixed in

[1] Baker B., Co//man, E.G., and Rivest, R., "Orthogonal packings in two dimensions", SIAM Journal on Computing 9/4 (1980) 846-855. [2] Beasley, J., "Bounds for two-dimensional cutting", Operational Research Society 30/1 (1985) 71-74. [3] Beasley, J., "OR-Library: Distributing test problems by electronic mail", Journal of the Operations Research Society 41/11 (1990) 1069-1072. [4] Chazelle, B., " A bottom-left bin-packing heuristic: An efficient implementation", IEEE Transactions on Computers 32/8 (1983) 697-707. [5] Christofides, N., and Whitlock, C., "An algorithm for two-dimensional cutting problems", Operations Research 25/1 (1977) 30-44. [6] Coffman, E.G., Garey, M.R., Johnson, D.S., and Tarjan, R.E., "Performance bounds for level-oriented two-dimensional packing algorithms", SIAM Journal on Computing 9 (1980) 808-826. [7] Dyson, R.G,, and Gregory, A.S., "The cutting stock problem in the flat glass industry", Operational Research Quarterly 25 (1974) 41-53. [8] Gilmore, P.C., and Gomory, R.E., " A linear programming approach to the cutting stock problem", Operations Research 9 (1961) 849-859. [9] Gilmore, P.C., and Gomory, R.E., "Multistage cutting stock problems of two and more dimensions", Operations Research 13 (1965) 94-1120. [10] Girkar, M., "Guillotine placement of rectangles", Master's Thesis, University of Southern Maine, Portland, Me, 1989. [11] Hahn, S., "On the optimal cutting of defective sheets", Operations Research 16 (1968) 1100-1104. [12] Wang, P.Y., "Two algorithms for constrained two-dimensional cutting stock problems", Operations Research 31/3 (1983) 577-586. [13] Wong, D.F., and Lui, C.L., " A new algorithm for floor plan design", in: Proceedings of the 23rd Design Automation Conference, 1986, 101-105.