# Application of Machine Learning Methods for Pallet Loading Problem
## 3 Methodology
### Number of the Boxes Loaded onto the Pallet
#### 3.1.1 Phase I: Determining the Box Arrangement on a Horizontal Layer  
In this phase, different heuristics, such as one-block, three-block, five-block, hollow-block, and G5-heuristics, are implemented to arrange the boxes on a horizontal layer with known and fixed dimensions. Any of these five heuristics can yield the maximum number of boxes in the layer. Furthermore, three partition methods, termed _feasible_ partition, _efficient_ partition, and _perfect_ partition, are utilized to fit the boxes completely on the pallet without any overlap or overhang. These methods are explained as follows:  
Figure 1: Flow chart of the proposed approach. Assuming that \((q,n)\) denotes an ordered pair of non-negative integers satisfying the condition \(q*l+n*w\leq S\) for a pallet dimension \(S\) (\(L\) or \(W\)), then the ordered pair \((q,n)\) is known as a _feasible_ partition of \(S\). If \(q\) and \(n\) also satisfy the condition \(0\leq S-q*l-n*w<l\), then \((q,n)\) is called an _efficient_ partition of \(S\). Similarly, if \(q\) and \(n\) satisfy the condition \(q*l+n*w=S\), then \((q,n)\) is called a _perfect_ partition of \(S\). The set of all _feasible_ partitions of the pallet dimension \(S\) is denoted as \(F(S,l,w)\). The set of all _efficient_ partitions of the pallet dimension \(S\) is denoted as \(PE(S,a,b)\), and the set of all _perfect_ partitions of the pallet dimension \(S\) is denoted as \(P(S,l,w)\)[34; 35]. In the one-block heuristic, the boxes are loaded in either H-box or V-box orientation on the basis of the ratio between the dimensions of the pallet and boxes without any overhang. For example, identical boxes with known dimensions are loaded onto the pallet; \(h\) is a dimension perpendicular to the surface of the pallet, as depicted in Figure 2. If \(\left[\frac{L}{T}\right]*\left[\frac{W}{w}\right]>\left[\frac{W}{T}\right]* \left[\frac{L}{w}\right]\), where the length of the boxes is parallel to the length of the pallet, then the horizontal layout pattern for the boxes in this layer is known as the H-box pattern; otherwise, if the length of the box is parallel to the width of the pallet, the box vertical layout pattern is known as the V-box pattern. All boxes in the layer should be loaded into the layer in the uniform orientation, which means that all boxes must have either an H-box or V-box layout. There are also three possibilities to load the boxes in the layer, where either \(l,w\lor h\) is perpendicular to the surface of the pallet. In the three-block and five-block heuristics, the layout of the layer is divided into three and five blocks, respectively (Figure 3). The boxes in each block should be arranged uniformly in either an H-box or V-box orientation [31; 36]. Figure 2: One-block heuristic. (**a**) Arrangement of boxes per horizontal layer using the one-block heuristic. (**b**) Top view for the horizontal layer using the one-block heuristic. The hollow block heuristic can also be utilized to load identical boxes on the horizontal layer. The heuristic divides the layer layout into diagonal and main blocks, as presented in Figure 4. Diagonal blocks (\(DB\)) and main blocks (\(MB\)) are created with boxes loaded in different directions, where these blocks should cover the entire length and width of the pallet [28]. The boxes' orientation in each block is identical. The G5-heuristic is one of the heuristics in the PLP literature frequently used in order to maximize the total number of boxes loaded into a horizontal layer and minimize the waste area. In this heuristic, the layout of the layer is divided into five different blocks (four blocks in the corners and one in the center). The dimensions of the central block decrease if the dimensions of the other four blocks in the corners increase, and vice versa. Each block is loaded independently, and the loading process can be performed by any of the other four heuristics, namely the one-block, three-block, hollow block, and five-block heuristics.