## 4 Late Acceptance Hill-Climbing Matheuristic Template
### Initial Solution  
In order to generate an initial solution for the LAHCM algorithm, the procedure createinitialsol() (see Algorithm 1) is proposed. Its functioning consists of relaxing the problem by not considering the constraints concerning the rework and lifetime for defective items, that is to say, we solve the GLSP (see Section 2.1). Once that problem is solved, the solution is appropriately entered by means of fixing the sequence variables \(x_{j,m}\) of the GLSP-RP. That is done by extending its corresponding model (Section 3) with the following constraints:  
\[x_{j,m}\geq x(GLSP)_{j,m}\quad\forall j,m \tag{26}\]  
where \(x(GLSP)_{j,m}\) denote the variable values taken in the GLSP solution. ```
Data: Problem instance of the GLSP-RP, \(p\) Input: number of solutions to store \(l\) Output: Optimized solution for the GLSP-RP
1\(s\leftarrow\)createinitialsol(\(p\))
2\(s_{best}\gets s\)
3 iter\(\leftarrow\) 0 solution[1..l] be the array storing solutions
4 for(\(i=1\) to \(l\))do
5\(solution[i]\gets f(s_{best})\)
6 while(stopping_criteria not met)do
7\(v\leftarrow\) iter mod\(l\)
8\(s^{\prime}\leftarrow\)fixandsolve(\(s\))
9 if\((f(s^{\prime})<f(solution[v])||f(s^{\prime})<f(s))\)then
10\(s\gets s^{\prime}\)
11 if\((f(s^{\prime})<f(s_{best}))\)then
12\(s_{best}\gets s^{\prime}\)
13\(solution[v]\gets s\)
14\(iter\leftarrow\) iter++
15 return\(s_{best}\)
```  
**Algorithm 1**Matheuristic Late Acceptance Hill-Climbing algorithm (LAHCM)  
By means of this procedure, an initial solution is obtained in a reasonable computational time. It is worth pointing out that the solution entered to the GLSP-RP optimization model (Section 3) has the binary setup variables fixed. Since the initial solution comes from the GLSP, the selection of the variables is performed without losing the sense of feasibility. With the goal of facilitating the understanding of the initial solution generation process, an illustrative example considering three products (\(j=1,\ldots,3\)), three macro-periods (\(t=1,\ldots,3\)), and a fixed number of five micro-periods (\(M_{t}=5\)) per macro-period is presented. The available capacity for all macro-periods is constant with \(b_{t}=400\). For all products, the processing times per product are \(tp_{j}=1\), the holding costs are \(h_{j}=5\), and the minimum lot size amount is \(\kappa_{j}=10\). The other parameters of this example are set as follows:  
\[f_{i,j}= \begin{bmatrix}0&0.25&10\\ 0.25&0&5\\ 10&5&0\end{bmatrix} \,st_{i,j}= \begin{bmatrix}0&0.5&5\\ 0.5&0&2\\ 5&2&0\end{bmatrix} \,d_{j,t}= \begin{bmatrix}95&91&108\\ 0&238&58\\ 107&150&93\end{bmatrix} \]  
The first step for generating an initial solution is to solve the corresponding GLSP. This way, for the above-mentioned example the optimal solution is reported in Table 3. It should be noted that since the values of variables \(s_{j,t}\) correspond to macro-periods, to avoid repetition only one number is reported for each row/block. In the solution, we observe six setup changes with a total of 15.75 in setup changing costs. As the available capacity in \(t=2\) with \(b_{t}=400\) is not sufficient to produce the total demand for all three products in \(t=2\), proportions of the demand of products \(j=1\) and \(j=2\) are produced and stored in \(t=1\) leading to storage costs, of 410. Therefore, the overall cost for the GLSP solution is 425.75. As previously described, additional parameters are needed for the GLSP-RP. Consequently, the lifetime of defective items while stored in the rework inventory is set to three micro-periods for all products \((\Omega_{j,m}=3)\) and the disposal cost is \(\lambda_{j}=1000\) per item. Regarding rework, we include rework holding costs of \(h_{j}^{R}=1\), rework processing costs of \(tp_{j}^{R}=1\) for all \(j\). The fraction of defectives per product and macro-period is given as follows:  
\[\Theta_{j,t}= \begin{bmatrix}0&0.005&0.01\\ 0.005&0.01&0.02\\ 0&0&0.005\end{bmatrix}