Heuristic Placement Routines for Two-Dimensional Bin Packing Problem

. Problem statement: Cutting and packing (C and P) problems are optimization problems that are concerned in finding a good arrangement of multiple small items into one or more larger objects. Bin packing problem is a type of C AND P problems. Bin packing problem is an important industrial problem where the general objective is to reduce the production costs by maximizing the utilization of the larger objects and minimizing the material used. Approach: In this study, we considered both oriented and non-oriented cases of Two-Dimensional Bin Packing Problem (2DBPP) where a given set of small rectangles (items), was packed without overlaps into a minimum number of identical large rectangles (bins). We proposed heuristic placement routines called the Improved Lowest Gap Fill, LGFi and LGFi OF for solving non-oriented and oriented cases of 2DBPP respectively. Extensive computational experiments using benchmark data sets collected from the literature were conducted to assess the effectiveness of the proposed routines. Results: The computational results were compared with some well known heuristic placement routines. The results showed that the LGFi and LGFi OF are competitive when compared with other heuristic placement routines. Conclusion: Both LGFi and LGFi OF produced better packing quality compared to other heuristic placement routines.


INTRODUCTION
Generally, Cutting and Packing (C and P) Problems can be summarized as follows [10] : "Given two sets of elements, namely, a set of large objects (input, supply) and a set of small items (output, demand) which are defined in one, two, or an even larger number of geometric dimensions. Then some or all the small items will be grouped into one or more subsets and assign each of them into one of the larger objects with the conditions all small items of the subset lie entirely within the large object and the small items are not overlapping" The C and P problems contribute to many areas of application in business and industry such as in metal, wood, glass and textile industries, newspaper paging and cargo loading. The objective of the allocation process is to maximize the utilization of the larger objects or maximizing the number of items to be packed in the larger objects.
In this study, we consider oriented and non-oriented cases of two-dimensional rectangular single bin size bin packing problems which known as 2DRSBSBPP in Wäscher et al. [10] . According to Lodi et al. [8] , the problem can be defined as follows: "Given a set of n rectangular items j∈J = {1, 2,…, n}, each item j is defined by a height h j and a width w j and an unlimited number of rectangular bins, each having a height H and width W. The objective is to allocate without overlaps, all the rectangles into the minimum number of bins" For the oriented case, the rectangles have fixed orientation while the rectangles can be rotated at 90° in non-oriented case of 2DBPP. This problem is classified as a class of NP-hard problem by [6] .
The non-oriented case of 2DBPP can be found in metal industry, where the pieces of the metal as the bins (larger objects) while the different dimension of layouts that needed to be cut out from the pieces of metal are the items. The aim of this problem is to find a good arrangement of the layout which give the highest utilization of the metal. The oriented case of 2DBPP can contributes in newspaper paging process where the pieces of pages in newspaper are the bins and the news or advertisements (with fixed orientation) are the items. The purpose is to arrange the maximum numbers of news into minimum number of pages.
Most of the classical placement routines for 2DBPP work on levels heuristics where the packing is obtained by placing the rectangles in row from left to right which form levels. The first level is at the bottom edge of the bin while the subsequence levels in the bin are the horizontal line denoted by the top edge of the tallest rectangle packed on the level below. Coffman et al. [4] suggested three classical strategies for level packing which are summarized in Table 1 (note j = current rectangle).
The BLF routine places the rectangles by searching through a list of location points in bottom left ordering sequence that indicates potential positions where the rectangle may be placed. Meanwhile, TP will first initialize L bins (where L is the lower bound) before packing the rectangle at the bin and position which give the highest score (percentage of the rectangle perimeter which touches the bin and the others rectangles that have been packed). The FC is a two-phase placement routine. In the first phase, the current rectangle will be packed on a floor, according to Best-Fit strategy or on a ceiling if the rectangle cannot be packed on the floor below. If neither floor nor ceiling at that level can fit the rectangle, a new level is initialized. In the second phase, the levels are packed into finite bins either through the Best-Fit Decreasing (BFD) algorithm or by using an exact algorithm for the one-dimensional bin packing problem. BFD algorithm is referred to the rectangles that are initially sorted in decreasing width, height or area following by the BF routine. For the AD, the routine is started by sorting the items according to non-increasing heights and L (lower bound) bins are initialized by packing on their bottoms a subset of the rectangles, following best-fit decreasing policy. The remaining rectangles are packed into the bands according to the current direction associated with the bin. The LGF routine consists of two stages: Preprocessing and packing stage. In the preprocessing stage, the rectangles are initially arranged following a horizontal orientation and sorted in non-increasing order of their width (breaking ties by non-increasing order of height).
LGFi uses a pointer (x, y) to indicate the position of the lowest available gap in the bin during packing stage. Best-fit strategy is used to examine the rectangles list and dynamically select a best fitting rectangle to place at the lowest available gap in the bin. The objective of this study is to develop an improved version of the Lowest Gap Fill (LGF) routine proposed by Lee [7] for 2DBPP. Then, the developed heuristic routine will be modified to design a new heuristic placement routine for solving the oriented case.

Heuristic placement routine for non-oriented case:
The heuristic placement routine, LGFi is a modified version of LGF. Unlike LGF, LGFi chooses the shortest edge between the remaining gap height and gap width as the current gap. This allows the routine to identity the shortest available gap so that it is easier to examine the rectangles list in term of finding a rectangle with its width or height that can fit the current gap completely. If there is no rectangles can fit the current gap completely, the first rectangle in the list that can fit the gap without overlaps is selected.
The preordering process is an important procedure in giving the advantage in time for searching the best-fit rectangle. The appropriate sorting of the rectangles will allow the rectangle with a larger dimension to be packed first to reduce the wastage in the bin. With this in mind, the LGFi will apply the preordering procedure in the preprocessing stage.
Similar to LGF, LGFi uses the pointer (x, y) to indicate the lowest and leftmost point in the current bin where a rectangle can be packed without overlaps with other rectangles that have been packed in the current bin.
LGFi consists of two stages: preprocessing stage and packing stage.
Packing stage: The smallest dimension of height among the available rectangles in the list, min i = 1,2,…,j {w j ,h j } (where j = number of the remaining rectangles in the rectangles list) is stored. The value of min j {h j } will be updated if the rectangle with the smallest dimension of height is packed.
At first, an empty bin is initialized as the current bin, the current point is at the bottom-left corner (x = 0, y = 0) and the current gap is the shortest edge between the height H and the width W of the bin. The first rectangle in the rectangles list is removed and placed at the bottom left of the current bin. The current point and the current gap are updated as follow. The current point is the lowest and leftmost point in the current bin. The current gap is the shortest edge between the remaining gap height and gap width at the current point. The gap width is the difference between the x-coordinate and the right edge of the bin or the left edge of a tall rectangle while the gap height is the difference between the ycoordinate and the height of the bin. The current gap area which is the area with the dimension of the gap width and gap height at the current point is determined.
If the current gap is less than the current value of min j {h j }, then the relevant space is regarded as the wastage. Then, the pointer is raised to the next lowest and leftmost point where the corresponding current gap is at least as big as the value of min j {h j }. The rectangles list is examined again. The rectangle with its width or height that can fill the gap completely is given the priority to be chosen to be packed at the current point. If there is no any rectangle either its width or height can fill the gap completely, then the first rectangle in the list with its area is less than or equal to the current gap area and can fill the gap without overlapping with other rectangles that have been packed is selected. The selected rectangle is placed at the current point by its shortest edge packed at the current gap. The selected rectangle is removed from the rectangles list and the current point and gap are updated. When the current bin is full or the pointer has been raised to the top of the current bin, the bin is closed. A new empty bin is initialized as the current bin and the process is continues until all the rectangles in the rectangles list are packed. This packing stage required O(n 2 ) time.
The time consuming overlapping test is not needed in LGFi since the selected rectangle will always be packed at the updated current point and current gap. Since the current gap will give us both the dimensions of the available gap, the selected rectangle will not overlap with other rectangles that already packed in the current bin. Hence, this will reduce the processing time. Figure 1 shows the LGFi by packing the set P using two bins.
Heuristic placement routine for oriented case: We propose a new heuristic called, LGFi OF which is a modified version of LGFi to solve the oriented case of 2DBPP. Unlike the non-oriented case, the small rectangles have fixed orientation.
LGFi OF also consists of two stages: preprocessing stage and packing stage.
Packing stage: The smallest dimension among the available rectangles in the list min i = 1,2,…j {w j ,h j } (where j = number of the remaining rectangles in the rectangles list) is stored. The value of min j {w j ,h j } is updated after the corresponding rectangle is packed.
At first, an empty bin is initialized as the current bin, the current point is at the bottom-left corner (x = 0, y = 0) and the current gap is the shortest edge between the height of the bin, H and the width of the bin, W. The first rectangle in the rectangles list is removed and placed at the bottom left of the current bin.
The pointer and the gap are updated as follow. The current point is the lowest and leftmost point of the current bin. The gap width is the difference between the x-coordinate and the right edge of the bin or the left edge of a tall rectangle while the height of gap is the difference between the y-coordinate and the height of the bin. The current gap is the shortest edge between the remaining gap height and gap width. The area of the current gap is also determined. Next, the rectangles list is examined again. If the current gap is less than the current value of min j {w j ,h j }, then the relevant space is regarded as the wastage. The pointer is raised to the next lowest and leftmost point where the corresponding current gap is at least as big as the value of min j {w j ,h j }. If the current gap is the gap width, then the rectangle with its width that can fill the gap completely is given priority to be chosen to be packed at the current point. If the current gap is the gap height, then the rectangle with its height that can fill the current gap completely is given the priority.
If there is no any rectangle that can fill the gap completely, the first rectangle in the list which its area is less than or equal to the area of the current gap and can fill the gap without overlapping with other rectangles that have been packed is selected to be placed at the current point. When the current bin is full or the pointer has been raised to the top of the current bin, the bin is closed. A new empty bin is initialized as the current bin and the process is continues until all the rectangles in the rectangles list are packed. Only one bin is opened at a time. This packing stage required O(n 2 ) time. Figure 2 shows the LGFi OF by packing the set Q using two bins.
Computational experiments: The first set of experiment compares the different preordering sequences of the rectangles in the preprocessing stage of LGFi by using the lower bounds proposed by [2,5] . Then, the LGFi is compared with some well known heuristic placement routines, namely BLF, LGF, FC and TP using the lower bounds proposed by [5] . The LGFi is also compared with BLF and LGF where both routines required O(n 2 ) time using lower bound proposed by Boschetti and Mingozzi [2] . In the oriented case, LGFi OF is compared with AD and FC. All placement routines are coded in ANSI-C using Microsoft Visual C++ version 6.0 as the compiler. In this study we consider ten different classes of problems instances proposed in the literature. The first six classes (I-VI) are proposed by [1] .
In each class all the items are generated in the same interval and are classified as follows: Class I: w j and h j uniformly random in [1,10], W = H = 10 Class II: w j and h j uniformly random in [1,10], W = H = 30 Class III: w j and h j uniformly random in [1,35], W = H = 40 Class IV: w j and h j uniformly random in [1,35], W = H = 100 Class V: w j and h j uniformly random in [1,100], W = H = 100 Class VI: w j and h j uniformly random in [1,100], W = H = 300 The other four classes (VII-X) are introduced by Martello and Vigo [9] where a more realistic situation is considered. The items are classified into four types: The bin size is W = H = 100 for all classes, while the items are as follow: Class VII: Type 1 with probability 70%, Type 2, 3, 4 with probability 10% each. Class VIII: Type 2 with probability 70%, Type 1, 3, 4 with probability 10% each. Class IX: Type 3 with probability 70%, Type 1, 2, 4 with probability 10% each. Class X: Type 4 with probability 70%, Type 1, 2, 3 with probability 10% each.
For each class, we consider five values of n: 20, 40, 60, 80 and 100, where n is the number of rectangles that need to be packed into the bins. For each combination of class and value of n, ten problem instances are generated. To investigate the best sorting procedure that gave LGFi better packing quality, different preordering sequences of the rectangles are tested in the preprocessing stage which is listed in Table 2.
The performance of the different preordering sequences of the rectangles and the various heuristic placement routines are compared on the basis of the average Ratio defined by: where, UB i and LB i represent the heuristic solution and the lower bound of the problem instance i respectively.

Table 3 and 4 show the computational results of
LGFi with different preordering sequences of the rectangles in the preprocessing stage by using the lower bounds proposed by Dell'Amico et al. [5] and Boschetti and Mingozzi [2] respectively. Table 5 gives the comparison of five different heuristic placement routines namely BLF, LGF, FC, TP and LGFi using the lower bound proposed by Dell'Amico et al. [5] while Table 6 shows the comparison of LGFi with other two heuristic placement routines namely BLF and LGF where both routines required O(n 2 ) time by using the lower bound proposed by Boschetti and Mingozzi [2] . Table 7 gives the comparison between the three different heuristic placement routines for oriented case of 2DBPP namely FC, AD and LGFi OF . For each type of sorting in Table 3 and 4 as well as the different placement routines in Table 5-7, the entries report the average ratio, computed over ten problem instances. The final line for each class gives the average overall values over that class. The final line in all tables gives the overall average value over all classes. We do not give the execution time because it is negligible (never exceed 0.1 CPU sec).
From the overall average ratio of all classes in Table 3 and 4, we found that LGFi with DH(DW) preordering sequence gives the best solution quality. Therefore, in the preprocessing stage of LGFi, the rectangles are initially sorted in DH(DW). The computational results in Table 5 indicate that the LGFi produced a slightly better packing quality compared to LGF. However, neither of the placement routines for LGF, LGFi and TP can be classified as the clear winner in this experiment as they produced mixed degrees of success in each class. It is worth mentioning that TP has a time complexity of O(n 3 ), while both LGF and LGFi has a time complexity of only O(n 2 ). This shows that the LGFi is a more competitive heuristic placement routine.
Since the results in Table 5 gives the LGFi a more competitive heuristic, so the purpose of the computational experiment in Table 6 is only to investigate the improvement in term of ratio for the heuristic routines which required the same time complexity. Therefore, the comparisons are only done on BLF, LGF and LGFi. The computational results in Table 6 show that BLF, LGF and LGFi give the improvement in terms of the ratio by using lower bound proposed by Boscetti and Mingozzi [2] . All three heuristic placement routines show a 1.2% of improvement if compared with the ratio using the lower bound proposed by Dell'Amico et al. [5] .    LGFi routines using lower bound proposed by Boschetti and Mingozzi [2] LGFi LGF BLF LGFi LGF   In Table 7, the overall average ratio of all classes indicates that LGFi OF gives better packing quality if compared to AD and FC.
LGFi OF is also better than AD and FC in terms of time complexity where both of AD and FC required O(n 3 ) time while LGFi OF required only O(n 2 ) time.

CONCLUSION
In this study, we developed heuristics placement routines called the Improved Lowest Gap Fill, LGFi and LGFi OF for solving both non-oriented and oriented cases of two-dimensional bin packing problems respectively. Both routines are capable of filling the available gaps in the partial layout by dynamically selecting the best rectangle for placement during packing stage. The routines require only O(n 2 ) time. Computational results shown that our proposed routines are capable of producing high quality solution.