## 4 Late Acceptance Hill-Climbing Matheuristic Template
### Mathematical Programming-Based Neighborhood  
As discussed in the previous section, LAHCM differentiates from the standard LAHC in the way the candidate solutions are generated. While in the LAHC a neighborhood structure is usually used, in LAHCM generation of the candidate solution is done by means of an exact algorithm. Thus, in order to produce a candidate solution for the GLSP-RP, the method fixandsolve() is proposed. By means of this function, an input solution is used for extracting and fixing decision variables with the aim of generating smaller sub-problems and solving them in an exact way, producing thus a candidate solution. In a similar way as proposed in [6] through the definition of reduced sub-problems from larger and more complex ones, we are able to address them using an exact algorithm in a small and reasonable computational time. This, as discussed in the relevant section, allows improving the quality of the provided solution while reducing the overall solving time. The input of our approach considers different strategies in order to obtain a reduced sub-problem. In the current work, we use the following strategies:  
Strategy 1 (\(\alpha_{1}\)): The \(x_{j,m}\) variables are fixed except for those regarding a product \(j\) selected at random. Strategy 2 (\(\alpha_{2}\)):The \(x_{j,m}\) variables are fixed except for those regarding two products \(j\) and \(j^{\prime}\) selected at random and where \(j\
eq j^{\prime}\). Strategy 3 (\(\alpha_{3}\)):The \(x_{j,m}\) variables are fixed except for those regarding three products \(j\), \(j^{\prime}\), and \(j^{\prime\prime}\) selected at random and where \(j\
eq j^{\prime}\
eq j^{\prime\prime}\).  
Henceforth, the resulting subset of non-fixed variables of \(x_{j,m}\) is denoted as \(x_{j,m}^{f}\). Moreover, the application of these strategies requires previous information about those variables that are to be fixed. That is done by considering previous information from a given solution \(s\).  
The pseudo-code of fixandsolve() is depicted in Algorithm 2. For a given problem instance of the GLSP-RP, the algorithm fixes some of the decisions associated to the variables \(x\) taking into account an input solution \(s\). To determine the subset of variables to be free from \(x\) (i.e., \(x^{\prime}\)), a strategy is selected at random (line 2). Afterward, the optimization model of the GLSP-RP is solved for the ensuing sub-problem obtained from the input instance \(p\) with the decisions concerning \(x\) fixed except for \(x^{f}\) (line 3). Hence, the model to be solved includes the following:  
\[x_{j,m}^{f}\geq 0,\forall j,m. \tag{27}\]  
The solution \(s^{\prime}\) obtained from solving the reduced problem is compared to the input one to check if an improvement has been achieved (line 4). If no improvement is achieved, the input solution \(s\) is returned (line 7).  
```
Data: Problem instance of the GLSP-RP, \(p\) Input: Initial solution \(s\), strategies \(\alpha=\{\alpha_{1},...,\alpha_{3}\}\) Output: Updated solution for the GLSP-RP
1\(\alpha_{selected}\leftarrow\) select a strategy from \(\alpha\) at random
2\(x^{\prime}\leftarrow\) fixvariables\((s,p,\alpha_{selected})\)
3\(s^{\prime}\leftarrow\) SolveFixedGLSP-RP\((x_{f},p)\)
4 if\((f(s^{\prime})<f(s))\)then
5 return\(s^{\prime}\)
6 else
7 return\(s\)
```  
**Algorithm 2**Fix and Solve algorithm for the GLSP-RP