# Automated Generation of Hybrid Metaheuristics Using Learning-to-Rank
## 4 Methodology
### Feature Extraction and Model Training
1: Evaluate fitness \(fitness_{i}=func(X_{i}(0))\) for all search agents;
2: Select the best search agent \(X^{*}\);
3:while\(t<I_{\text{max}}\)do
4:foreach whale \(X_{i}\in P\)do
5: Update \(a,\vec{A},\vec{C},l\), and \(p\);
6:if\(p<0.5\)then
7:if\(|\vec{A}|<1\)then\(\triangleright\) Shrinking Encircling (SE)
8: Compute new position via Equation (2);
9:\(act_{i}=2\); //The numerical coding of update behaviors is shown in Table 2
10:\(LabLab_{i}^{2}=1\);
11:else\(\triangleright\) Random Search (RS)
12: Select random leader \(X_{\text{rand}}\);
13: Compute new position via Equation (6);
14:\(act_{i}=1\);
15:\(Label_{i}^{1}=1\);
16:endif
17:else\(\triangleright\) Spiral Updating (SU)
18: Compute new position via Equation (4);
19:\(act_{i}=3\);
20:\(Label_{i}^{3}=1\);
21:endif
22: Construct feature vector \(F_{\text{selected}}\) according to Equation (19);
23:for candidate action \(act_{k}\in[1,2,3]\)do
24:if\(act_{k}=1\)then\(\triangleright\) select Random Search
25:\(Label_{i}^{2}=0\);
26: Construct feature vector \(F_{\text{unselected}}\) for unselected action (SE) via Equation (19);
27:\(LabLab_{i}^{3}=0\);
28: Construct feature vector \(F_{\text{unselected}}\) for unselected action (SU) via Equation (19);
29:elseif\(act_{k}=2\)then\(\triangleright\) select Shrinking Encircling
30: Similarly, construct the feature vectors for the unselected actions (RS, SU);
31:else\(\triangleright\) select Spiral Updating
32: Similarly, construct the feature vectors for the unselected actions (SE, RS);
33:endif
34:endfor
35:endfor
36: Adjust search agents exceeding search space boundaries via \(rand(lb,ub)\);
37: Recalculate fitness values for all search agents via \(fitness_{i}=func(X_{i}(t+1))\);
38: Update \(X^{*}\) when a better solution is available;
39:\(t=t+1\);
40:endwhile
41:return The best fitness\({}^{*}\) of WOA;
```  
**Algorithm 2** The procedure of feature extraction and construction of WOA  
In Algorithm 1, to ensure fairness in the comparison among the algorithms, a unified initial population is used. Subsequently, the algorithms in the given algorithm set are executed sequentially, and the initial fitness values are calculated (lines 1-4). Within the \(I_{\text{max}}\), the search agents are updated according to the strategies of the metaheuristic algorithms while recording the selected update action \(act_{\text{selected}}\) and constructing the corresponding feature vector \(F_{\text{selected}}\) (lines 6-9). The update behaviors of each metaheuristic algorithm (WOA, HHO, GA) are the original, unmodified versions. The specific procedure for feature extraction and construction is illustrated using the WOA as an example, as shown in Algorithm 2. At the same time, the information of unselected candidate actions is equally crucial for model training. Therefore, feature vectors \(F_{\text{unselected}}\) for these actions are also constructed (lines 11-15). In each iteration, the algorithm checks whether the population exceeds the search space boundaries and performs necessary adjustments, followed by recalculating the fitness values of each solution. Whenever a better agent is available, the best agent \(X^{*}\) is updated (lines 19-21). At the end of the algorithm, the best fitness of each algorithm is recorded (line 24). Finally, the algorithms are ranked according to their best fitness values \(\mathit{fitness}^{*}\), and their corresponding labels are reassigned based on this ranking. The ranking is in descending order of best fitness, with the resulting position used as the new _Label_ (lines 26-27). Thus, among the three algorithms, the one with the smallest best fitness value receives the highest label (i.e., \(\mathit{Label}=3\)). The feature vectors set and its corresponding labels set together form the training dataset. During the training stage of the predictive model \(LTRMHA\), the constructed feature set, along with its corresponding label set, is used as the training set.