## 3 GRASP Algorithm for SPP
### GRASP Construction  
One of the main contributions of this paper is the use of flags, and at the beginning of the algorithm, we set a single flag at the lowest left corner of the strip to mark the first place for setting an object. Algorithm 2 describes the initial construction that consists of three parts. The first is to select an available flag index with the \(FindFlagIndex\) function (see line 4), which iterates a list of available flags and selects the index of the flag that has the lowest height, and if there were several flags with the same height, it chooses the one furthest to the left. The second part consist of the use of waste functions (see Equations (5)-(7)) to analyze the objects' waste. Finally, the last part is constructing the candidate list (\(CL\)) and the restricted candidate list (\(RCL\)). ```
1:\(k\)
2:\(miss=|O|\)
3:while\(miss>0\)do
4:\(CL=\varnothing\)
5:\(j=FindFlagIndex(Flags)\)
6:for\(i=0\rightarrow|O|\)do
7:if\(s_{i}=0\)&& \(ow_{i}\leq fw_{j}\)then
8:\(CL=CL\cup\{o_{i}\}\)
9:\(wk_{ij}=CalculateWaste(k)\)
10:\(W=W\cup\{w_{ij}\}\)
11:endif
12:endif
13:if\(CL\
eq\emptyset\)then
14:\(kElements=max(|CL|\times 0.10,5)\)
15:\(RCL=\varnothing\)
16:\(RW=\varnothing\)
17:for\(i=1\to kELem\)do
18:\(imin=\arg\min_{i}wk_{ij}\forall wk_{ij}\in W\)
19:\(RCL=RCL\cup\{o_{imin}\}\)
20:\(RW=RW\cup\{wk_{imin}\}\)
21:endfor
22:\(Limit=max(W)+(\beta\times(max(W)-min(W)))\)
23:for\(i=1\rightarrow|RCL|\)do
24:if\(wk_{ij}\in RW>Limit\)then
25:\(RW=RW\setminus\{wk_{ij}\}\)
26:\(RCL=RCL\setminus\{o_{i}\}\)
27:endif
28:endfor
29:\(O_{r}=Roulette(RCL,RW)\)
```  
**Algorithm 2** GRASP Construction Part 1  
The algorithm checks that the set value \(s_{i}\) is equal to zero, where \(S=\{s_{1},s_{2},\ldots,s_{n}\}\) is a set that represents the availability of the objects (see Equation (4)). \[s_{i} = \left\{ \begin{array}{ll}1&\qquad\text{The object is set in the strip}\\ 0&\qquad\text{Otherwise}\end{array} \right. \tag{4}\]  
The \(CalculateWaste(k)\) function calculates the waste area of an object \(wk_{ij}\) (see line 8). We use three waste functions (see Equations (5)-(7)) to analyze the objects' waste. Each function validates different components among the rectangular objects and a specific flag. \[w_{ij}^{1}=min\big{\langle}\big{|}dfw_{j}-ow_{i}\big{|}\,\big{|} tfw_{j}-ow_{i}\big{|}\big{\rangle}+min\big{\langle}\big{|}fth_{j}-oh_{i}\big{|}\, \big{|}rfh_{j}-oh_{i}\big{|}\big{\rangle} \tag{5}\]  
\[w_{ij}^{2}=min\big{\langle}\big{|}fth_{j}-oh_{i}\big{|}\,\big{|}rfh_{j}-oh_{i} \big{|}\big{\rangle} \tag{6}\]  
\[w_{ij}^{3}=(min\big{\langle}\big{|}dfw_{j}-ow_{i}\big{|}\, \big{|}\big{|}ftw_{j}-ow_{i}\big{|}\big{\rangle}\times max(oh,min(lfh_{j},rfh_ {j}))+\\ (min\big{\langle}\big{|}fth_{j}-oh_{i}\big{|}\,\big{|}rfh_{j}-oh_{i} \big{|}\big{\rangle}\times ow_{i}) \tag{7}\]where \(O=\{o_{1},o_{2},\ldots,o_{n}\}\) is the set of objects and \(wk_{ij}\) is the waste of the object \(i\) on the flag \(j\). Hence, in the algorithm, we calculate the waste for all the available objects \(o_{i}\) for the selected flag \(f_{j}\). Figure 1 shows the characteristics of the flags and the objects, i.e., \(dfw_{j}\) and \(tfw_{j}\) are the flag's desirable and total width, respectively; \(lfh_{j}\) and \(rfh_{j}\) are the height to the left and to the right of the flag. Finally, \(SP\) is the starting point and \(ow_{i}\) and \(oh_{i}\) are the current object width and height, respectively. The selection of the first object is the one with the largest area. We select the rest of the elements according to the waste area function which is similar in some sense to the feature selection used in [28]; the \(WA\) value stores all waste area values for each object for a specific flag. Additionally, we validate that \(CL\
eq\mathcal{O}\) in line 12. Therefore, if no object fits in the space of the flag, then we try to raise the flag (see line 35 of Algorithm 3).