Table 1 Pseudocode for the WOA-GWO hybrid optimization algorithm.
From: (IoT) Network intrusion detection system using optimization algorithms
Step | Description | Remarks |
|---|---|---|
1 | Initialize population X[1…N] by randomly generating N candidate solutions | Each candidate represents a combination of LSTM hyperparameters |
2 | Evaluate the fitness of each candidate \(Fitness(X[i]) = Accuracy_{val}\) | Validation accuracy is used as the fitness metric |
3 | Select the current best solution:\(X_{best} = arg\;max(Fitness)\) | Record the globally optimal hyperparameter set |
4 | While iteration < MaxIter do | Set the maximum number of iterations MaxIter = 50 |
4.1 | For each candidate X[i] do | WOA global exploration phase |
Update position using WOA’s bubble-net mechanism:\(X_{new} = X_{best} - A \cdot D\) | A and D are calculated using WOA equations | |
Compute fitness at new position: Fitness(Xnew) | Retain the better solution | |
4.2 | For each candidate X[i] do | GWO local exploitation phase |
Update position based on GWO hierarchy:\(X_{new} = \frac{{X_{\alpha } + X_{\beta } + X_{\delta } }}{3}\) | α, β, and δ denote the top three individuals | |
Compute fitness at new position: Fitness(Xnew) | Retain the better solution | |
4.3 | If the best fitness improves, update Xbest | Dynamically track the global optimum |
4.4 | If \(\Delta Fitness < 1 \times 10^{ - 5}\) for 10 consecutive generations, break | Early stopping criterion |
4.5 | iteration + = 1 | Increment iteration counter |
5 | Return Xbest | Output the optimal hyperparameter set |