A GENETIC ALGORITHM FOR TWO DIMENSIONAL STRIP PACKING PROBLEMS

Cutting and packing problems are combinatorial optimisation problems. In most manufacturing situations a raw material, usually in some standard size, has to be divided or cut into smaller items to complete the production of some product. It is therefore desirable that this raw material be used efficiently. A novel placement heuristic, hybridised with a genetic algorithm, is presented in this paper. A general solution encoding scheme, which is used to encode two dimensional strip packing problems, is also introduced in this study.


INTRODUCTION
Cutting and packing (C&P) problems are combinatorial optimisation problems of practical significance.In most manufacturing situations it is required that the raw material be cut into smaller pieces.This process usually results in waste.It is therefore desirable to reduce the waste that results as much as possible, and hence maximise material utilisation.Examples of this can be seen in the glass, paper, steel, semiconductor, textile, and many other industries.The two-dimensional (2D) packing problems can be classified as bin packing problems and strip packing problems (SPPs).The bin packing problem is concerned with minimising the number of bins into which small items need to be packed.Strip packing involves packing rectangular or irregular items on to a strip of constant width and unlimited height, and the objective is to minimise strip height without overlapping the items.
Solution approaches to SPP can be divided into two categories: exact methods, and heuristics.SPP is a non-deterministic polynomial complete (NP-complete) problem [1].The objective function of an NP-complete problem is often multi-modal, non-smooth, or even discontinuous, and thus causes exact gradient-based optimisation algorithms to fail [2].Few exact methods for the 2D-SPP have been used so far, with applicability limited to piece sets within 200 pieces.Martello et al. proposed a branch-and-bound algorithm for the 2D-SPP [3], while Fekete and Schepers developed a general framework for exact approaches to moredimensional packing problems [4], and Hifi presented an improvement of Viswanathan and Bagchi's exact algorithm based upon branch-and-bound procedures for strip cutting/packing problems [5].
In recent decades, heuristics have received considerable attention, and have been deemed most suitable for solving the 2D-SPP.Stochastic search techniques, such as genetic algorithm (GA), simulated annealing (SA), tabu search (TS), naïve evolution (NE), population heuristic (PH), and other meta-heuristics, have been combined with a placement algorithm (decoding algorithm) for solving 2D-SPPs [2].Hopper and Turton provided an extensive up-to-date overview of the meta-heuristics that have been developed for the different variants of the 2D-SPPs.They hybridised two different placement algorithms (BL, BLF) with three meta-heuristic algorithms (GA, SA, and NE) and local search heuristic (hillclimbing) for the two-dimensional rectangular packing problem [1; 6].Leung et al. applied a pure GA and a mixed SA-GA, which used SA to decide which two parents and children should be selected after crossover and mutation, for 2D orthogonal packing problems.The mixed heuristic SA-GA was found to produce better results in a test of 19 cutting problems [7].
Genetic algorithms utilise search and optimisation procedures that operate in a similar way to the evolutionary processes observed in nature.The GA search is guided, using the 'survival of the fittest' principle, by extracting the most desirable features from a generation of solutions, and combining them to form the next generation.The quality of each solution is evaluated, and the 'fitter' individuals are selected for the reproduction process.Continuation of this process through a number of generations will result in optimal or near-optimal solutions [8].
As a relatively new technique for the packing industry, GAs have already been used successfully in a variety of industrial applications.Jakobs developed an order-based GA with a bottom left (BL) algorithm to place rectangles and polygons on to a rectangular main object.The GA in the study was combined with embedding a shrinking algorithm in place of polygons [9].Liu and Teng improved Jakobs' work by developing a more effective version of the BL algorithm for the orthogonal packing of rectangular pieces [10].Hopper and Turton described two GAs hybridised with two heuristic placement algorithms -the bottom left (BL) algorithm and the bottom left fill (BLF) algorithm -for rectangular packing problems [11].Yeung and Tang proposed a GA combined with a novel heuristic allocation method to transform the 2D-SPP into a simple permutation problem that could be effectively solved by a GA and a greatly reduced searching domain [12].Bortfeldt suggested a GA working without any encoding of solutions by using specific genetic operators to manipulate the fully defined layouts.The GA showed good performance on a comprehensive test using benchmark instances with up to 5,000 pieces [13].
Despite decades of academic research into regular packing problems, the work on twodimensional irregular problems is recent.A major reason for this is the extra dimension of complexity generated by the geometry.However, irregular problems occur within several important industries; examples include die-cutting in the engineering sector, parts nesting for shipbuilding, and marker layout in the garment industry.Gomes and Oliveira presented a hybrid algorithm that uses simulated annealing (SA) to guide the search over the solution space, and linear programming models to generate neighbourhoods during the search process, to solve irregular strip packing problems [14].
In this study, a novel placement heuristic hybridised with GA, and a general solution encoding scheme used to encode two dimensional strip packing problems, were introduced.In the remainder of this paper, Section 2 provides a description of the proposed GA used for the 2D-SPP; Section 3 subjects the GA for 2D-SPP to benchmark tests; and Section 4 gives the study's conclusions.

THE GENETIC ALGORITHMS FOR STRIP PACKING PROBLEMS
The two strip packing problems addressed in this paper are described below:


Given n items of small rectangles each having width i w and height i h , and one large rectangular strip with constant width W and infinite height, the objective is to minimise the packing height H of the strip such that all items can be packed into the strip without overlap.The small rectangular items can be rotated by  90 .This problem is known as the two dimensional strip packing problem (2D-SPP). Given n items of arbitrary shapes and one strip with constant width W and infinite height, the objective is to minimise the packing height H of the strip such that all items are contained in the strip without overlap.The irregular items can be rotated at fixed  90 increments.This problem is known as the two dimensional irregular strip packing problem (2DISP).
GA is the mathematical procedure based on analogies to the natural evolutionary process.It is different from random algorithms, and combines elements of directed and stochastic search.Figure 1   The GA maintains a population of individuals ( ) P t that are created and selected in an iterative process.Each individual consists of a genome, fitness, and possibly some auxiliary variables such as age and sex.The genome consists of a number of genes that altogether encode a solution to some optimisation problem.The encoding is the internal representation of the problem that is the data structure holding the genes.Every member of the population is evaluated to measure their fitness.A new population at iteration 1 t  is formed by selecting those individuals who have more fitness.Some members of the population undergo transformations ('alter' step in the pseudo code).This is achieved by means of some variation operators such as crossover operator and mutation operator.The algorithm executes until some predefined halting condition -for example, the solution quality, number of generations, or simply running out of time -is reached [15].
The following subsections provide a detailed implementation of the proposed GA for 2D rectangular and irregular strip packing problems.

Solution representation
A representation (or encoding) for a problem is needed before the GA can be run.In this study, a potential solution to the 2D-SPP is represented as a set of 3-tuples . These 3-tuples (known as genes) are joined together to form a string of values, referred to as an individual.Each 3-tuple depicts the position and orientation state from which the corresponding item starts being placed.Figure 2 illustrates each element in the 3-tuple of an example solution string for the packing of three items.


The first element in the 3-tuple is the x-coordinate value k x , the distance from the reference vertex of the k th item to the origin of the strip in x direction.The range of , where W and w k is the width of the strip and the kth item, respectively.The value x k determines the starting location of the k th item when placed.The reference vertex of an item is its bottom→left most point -for example, the bottom left corner for a rectangle item.Figure 1 illustrates the xcoordinate values for the three items.


The identification of the k th item in a solution is given by its item index k i .The item indices are randomly generated in the initial population, and will stay unchanged during packing.The appearance sequence of the item indices in the solution represents the placing order of the items.
In the example solution 1, the three items with an index of '1', '2', and '3' are to be placed in the order '3'→'1'→'2' -that is, item 3 is to be placed first, and item 2 last.


The orientation angle k  of the k th item reflects the angle that the item rotated from its initial orientation.In this study, the orientation angle is defined as for an irregular item.Figure 1 shows the orientation angles for the three items:

 
for item 2 and item 3.

Initial population generation
To generate the initial population, it is ensured that every individual belonging to the initial population of solutions is feasible.Every item is represented by a 3-tuple ) , , ( generate initial population, and the following procedure is followed:


Randomly order items. Randomly choose a feasible x -coordinate of the reference vertex for each item from the set of feasible x -coordinates.


Randomly choose an orientation from the set of feasible orientation constraints for each item.

Crossover operator
Crossover operator is simply a matter of replacing some genes in one parent by the corresponding genes of the other.The crossover operation can involve more than two parents.In this study, the crossover operator is randomly chosen from two crossover variants: cross-var1 and cross-var2.A variable {0,1}  CrossVar is randomly generated to decide which of these two variants will be operational.If

 CrossVar
, cross-var1 will be operational, otherwise cross-var2 will be used.A partially mapped crossover (PMX) of Michalewicz and Fogel [16] is slightly modified and applied for that purpose.

Cross−var1
Of the three components in a solution, the cross−var1 allows the orientation angle and the x-coordinate value of the reference vertex to be directly inherited from one parent solution; while the ordering of the items is achieved through breeding between both parent solutions.For example, let 1 p X and 2 p X be the two-parent solution representing a layout of 6 items: O be the offspring that results from the breeding of the two parent solutions.The cross−var1 works as follows: (1) Copy the x -co-ordinate of the reference vertex and orientation angle of every item from solution 2 p X to the offspring 1 O .In this example, at this stage, the offspring becomes: p is generated to be 1, and 2 p to be 3. ( Create a one-to-one mapping between item indices in positions decided by 1 p and 2 p from both parents.For this example, the mapping is created between the item indices of 2 p X and 1 p X from the 1st (p1=1) to the 3rd (p2=3) item index.The series of mappings for this example is: Copy every item index between positions Item indices in the positions excluding 2 1 p p  are copied from corresponding positions from X p1 .To avoid the conflict that might occur when the item index copied from X p1 already exists in O 1 in 2 1 p p  positions, the mapping created in stage b is used to generate a new item index, replacing the conflicting item index, until no conflict occurs.For this example, the 4 th item index '5' and the 5 th item index '4' of X p1 are not in conflict with the ones of O 1 in 2 1 p p  positions; thus they are copied as the 4 th and 5 th item index for O 1 .The 6 th item index in X p1 is '1' and it conflicts with the 2 nd item index of O 1 ; thus the mapping 1↔3 is used to generate new item index '3'.However, the generated item index '3' conflicts with the 1 st item index of O 1 ; thus the mapping 3↔6 is used to generate new item index '6', and '6' is not in conflict with the item indices of O 1 in 2 1 p p  positions.Therefore '6' is used as the 6 th item index for O 1 , as illustrated in Figure 3.

Figure 3: The process of generating item indices for offspring from both parents
The final solution of O 1 becomes: There is a possibility that infeasible solutions might be introduced into the population with this variant of crossover.To counteract this possibility, a penalty function is used to degrade the quality of infeasible solutions, as can be seen in section 3.5.

Cross−var2
The major difference between cross−var1 and cross−var2 is that cross−var1 allows a situation where breeding involves both item characteristics in the solution representation and the ordering of the items for the packing.The cross−var2, on the other hand, is mainly concerned with the ordering of the items without separating the item characteristics and the ordering -that is, when items change positions in the ordering, the item moves with the characteristics that define it.In other words the whole 3-tuple   , , k k k x i  moves.The parents used to demonstrate cross−var1 will again be used to demonstrate cross−var2.
The cross−var2 breeds offspring as follows: ( Generate two random positions 1 p and 2 p , such that n p p    2 1 1 : For example, say the random process results in Create a one-to-one mapping of item indices from both solutions in positions 2 1 p p  .For this example the mapping between the item indices of X p1 and X p2 is: Copy from parent X p1 items in position 2 1 p p  with their related characteristics.This results in a partial offspring solution, which is: (The symbol 'U' can be interpreted as 'at present unknown'). (4) The solution is completed by copying items from parent X p2 , starting from left to right, excluding those items in 2 1 p p  positions.To avoid the conflict between the item indices copied from X p2 and those that already exist in O 2 at 2 1 p p  positions, the mapping list generated in stage ( 2) is used to obtain new 3-tuples to replace the conflicting ones.For this example, the 1 st , 5 th , and 6 th 3-tuples are copied from X p2 to O 2 at corresponding positions.The item index 4 in the 5 th

Mutation operator
Mutation is a one-parent variation operator.The mutation operator is an over-simplified analogue from natural evolution.It usually consists of making small random perturbations to one or a few genes.One of the major reasons for the mutation operator in GAs is the introduction of population diversity during the genetic search.Originally, with binary encoding, a zero would be changed into a one and vice versa.With alphabets of higher cardinality, there are more optional changes that can be made at random or following a set of rules.
The 2-swap mutation operator that is usually used in sequencing problems has been adapted and modified as the mutation operator for 2D problems.The operator works as follows: (1) Randomly choose two items, item1 and item2; (2) Randomly generate a number } 1 , 0 {  num to decide if the orientation of the chosen items will be randomly perturbated; (3) If 1  num changes the orientation of both items randomly (this applies if more than one orientation is allowed); (4) Exchange the position of item1 with that of item2.

Evaluation function
The evaluation function is the mechanism used to judge the quality of the evolved solutions.For the evaluation of the 2D SPP, a placement heuristic is used that considers one item at a time.Items are placed on the strip in the order in which their item indices appear in the solution string.For each item k , the placement heuristic carries out the following steps in turn: ( Item k with index k i is placed at the topmost position at horizontal position k x , with the orientation of item k being that reflected by the orientation angle k  ; (2) Item k is then slid as far down as possible, until it collides with either the bottom edge of the strip or another item; (3) Thereafter item k is slid as far left as possible until it collides with another item or the left edge of the strip.This becomes the final position of item k .In this study, because of the arbitrariness of the geometry of the pieces, the shift left stage is not part of the placement heuristic for irregular items -that is, the placement of irregular items is only carried out in step (1) and step (2).
Figure 4 illustrates the placement-heuristic procedure for the packing of three items, using the example from Figure 2 with the solution .

Figure 4: Placement-heuristic example for strip packing problem
The search space S consists of two subsets: the feasible part S F  and the infeasible part S U  .In the discussion on cross-over operator in sub-subsection 2.3 above, it is mentioned that cross_var1 might introduce infeasible solutions into the population.There are two possible violations of constraints that can occur in 2D SPP, namely overlap constraint and the containment constraint.Cross_var1 is guilty of violating the latter constraint -that is, placement of items outside the borders of the strip.
In this study, the evaluation function for the 2D rectangle strip packing problem is given by: The penalty function 1 ( ) P X is used as a constraint handling mechanism.Any solution in violation of the above-mentioned constraint is 'killed' -that is, the solution is made undesirable.The function measures the efficiency of the packing.The total area of items to be packed is given by: where w k and h k are the width and height of the kth item respectively.Ideally the total area of the strip occupied by the items is supposed to be A, but in most instances this is not the case, and A is a continuous lower bound for every instance of this problem.Let p A be the area that results after all items have been placed on the strip.p A is given by: Where p h is the packing height and W the width of the strip, as illustrated in Figure 5, with the packing result from Figure 4.

Figure 5: Example of packing height
The efficiency function The function

) ( 1 X Eff
reflects the efficient use of the strip -that is, those individuals in the population who use the strip efficiently are rewarded the most.The lowest packing height possible is given by: It is desirable that an individual packing height be as close as possible to this height.To make infeasible solutions undesirable, they are moved as far as possible from this bound by a factor K, such that a penalty packing height The evaluation function for the 2D irregular strip packing problem is given: A be the area of the kth irregular piece; the total area A of the pieces is then . Let p h be the packing height; the packing area p A is given by (4).Function ) ( 2 X Eff is given by: The penalty function ) ( 2 X P for an irregular packing problem is computed similarly to that for a rectangular packing problem as:

NUMERICAL TESTS
In order to evaluate the performance of the GA presented in this work, problematic instances have been collected from the literature.All experiments were conducted using a 3.4 GHz Pentium 4 processor.The algorithm was coded in Matlab and run using Matlab's Genetic Algorithm and Direct Search Toolbox [17].For every problem the population size was set at 100 individuals, although this tended to slow down the speed of the algorithm.After repeated runs for most problems, it was decided that the crossover fraction should be kept at 0.3 for all problems.Two individual spots in the population were reserved for elite children -that is, the two best individuals in every generation.A tournament of size 2 was used as a selection criterion.The GA was run for 2,000 generations for every problem; however, if the best fitness did not improve after 1,000 generations or 2,000 seconds, the algorithm stopped.

Results for the 2D rectangular strip packing problems
The strip packing problems for rectangles that cannot be rotated were first tested with the GA developed in this study.The test problems used in this work were considered in Martello et al. [3].Altogether, 38 test problems were collected from various sources.The number of items to be packed ranged from 10 to 200.(These test problems can also be downloaded from the ESICUP (Euro special interest group on cutting and packing) website home page [18].)Using the GA proposed in this paper, the test results for these 38 problems are shown in Table 1.For each problem Table 1  , where W is the width of the strip.
Table 1 shows that generally the packing efficiency of the GA solution decreases with the number of packed items.The GA, hybridised with the novel placement heuristic, shows good performance for solving the 2D rectangular strip packing problems where items cannot be rotated.Some of the problems are solved with a high packing efficiency of 100%.Figure 6 shows an example layout, in which the gray areas are waste, generated by this hybrid algorithm for problem 21.The item number and packing efficiency of this problem are 14 and 98% respectively.Table 2 shows the width and height of each item shown in Figure 6.The strip packing problems for rectangles that can be rotated by 90 ° were also tested using the hybrid GA developed in this study.The test data, which consists of 21 problems presented in seven different-sized categories, are taken from Hopper and Turton [6].These test problems are very difficult to solve as they are 'perfect packings' obtained by cutting a given rectangle of fixed dimensions into smaller rectangular items.The test results show that the hybrid GA is also suitable for solving 2D rectangular strip packing problems where items can be rotated by 90 °.The packing efficiency of the GA solution generally decreases with the number of packed items.Figure 7 shows an example layout, in which the gray areas are waste, generated by this hybrid algorithm for problem P1 of category C1.The item number and packing efficiency of this problem are 16 and 91% respectively.Table 4 gives the width, height, and rotation angle of each item shown in Figure 7.

Results for 2D irregular strip packing problem
To test the hybrid GA on 2D irregular strip packing, problems of this type (also featured on the ESICUP website) were used [18].The four test problems, all derived from the textile industry, have been brought to the attention of the academic community.These problem details, including the literature source, the problem name, the number of shapes to be packed, the sheet width, and the orientation constraints, are listed in Table 5.The test results on this type of problem are listed in Table 6.For the test problems on which this algorithm was used, the packing efficiencies have been above 60%.For optimum results an interesting study would be to compare current problems with the best results available to date.8 shows an example layout in which the white areas are waste, generated by this hybrid algorithm for the Albano problem.The item number and packing efficiency of this problem are 24 and 74% respectively.Table 7 gives the rotation angle, with the best solution for each irregular item shown in Figure 8.

CONCLUSION
A genetic algorithm was developed in this study to solve two-dimensional cutting and packing problems.A novel general solution coding, which makes use of a set of 3-tuples to represent the position, identification, and orientation of the items to be placed, and a novel heuristic placement procedure have been introduced in the design of this genetic algorithm.An initial population was generated such that every individual solution belonging to the initial population of solutions was ensured feasibility.A partially mapped crossover, using two crossover variants, was slightly modified and applied in the crossover operator.The mutation operator and the evaluation function were used to introduce population diversity during the genetic search and to judge the quality of the evolved solutions.
Computational tests were carried out using the genetic algorithm developed in MATLAB language for a variety of strip packing problems, including rectangles packing and irregular items packing.The test results have shown that the algorithm returned quality solutions for most of the problems.Further study on an alternative implementation of this algorithm by speeding up the computing time, continued testing of the algorithm on problems from both the literature and the real world, and a comparative study between layouts generated by a human expert and those by the general genetic algorithm are needed to improve the genetic algorithm.

Figure 1 :
Figure 1: Pseudo code of a simple GA

Figure 6 :Table 2 :
Figure 6: Layout example of rectangular items that cannot be rotated

Figure 7 :
Figure 7: Layout example of rectangular items that can be rotated by 90 °

Figure 8 :Table 7 :
Figure 8: A textile marker layout generated by the GA for the Albano problem illustrates the pseudo code of a simple GA.

Table 1 : Strip packing problem results where items cannot be rotated
(14)s: LB the lower bound -that is, the ideal lowest packing height h L as defined in(14);  z the best solution found by the GA -that is, the lowest real packing height;  Time the total search time in seconds taken by the GA to find the best solution;  PR the performance ratio -that is, the ratio of z/LB. Eff the packing efficiency of the best solution given by

Table 3 : Strip packing problem results where items can be rotated by 90 °
Table 3 gives the test results obtained by the GA developed in this study.