## 3 GPU Parallelization of Metaphorless Optimization Algorithms
### GPU-Based Acceleration of the Enhanced Jaya Algorithm
Their fundamental algorithmic phases bear a resemblance to those in Java. Notably, the main distinction arises in Rao-2 and Rao-3, where these algorithms necessitate selecting a random candidate solution from the population to compute the newly generated candidate solutions. Given the current parallelization strategy, this random candidate solution must be established in advance for all population candidates in each iteration before conducting the population update. This procedure is outlined in Algorithm 21. ```
1:functionSelect_random_solutions_kernel()
2:/*Device code*/
3:Determine\(index\) using \(x\) dimension of \(blockDim\), \(blockIdx\), and \(threadIdx\);
4:if\(index\leq popSize\)then
5:\(t[index]\gets rand(1,popSize)\)
6:while\(t[index]\
eq index\)do
7:\(t[index]\gets rand(1,popSize)\). 8:endwhile
9:endif
10:endfunction
```
**Algorithm 21** Kernel for selecting random solutions from the population

The kernel is organized to operate using a one-dimensional grid, as its purpose is to generate a 1D array with a length equal to \(popSize\) containing the indices of the random candidate solutions. Algorithm 22 provides a consolidated method that generates updated candidate solutions for all the Rao algorithms in a unified manner. ```
1:functionRao-driven_population_update_kernel(\(X\))
2:/*Device code */
3: Determine row using \(x\) dimension of \(blockDim\), \(blockIdx\), and threadIdx;
4: Determine col using \(y\) dimension of \(blockDim\), \(blockIdx\), and threadIdx;
5:ifrow\(\leq\) popSize and col \(\leq\) numVar then
6:ifalgorithm = 'Rao-1'then\(\triangleright\) Equation (10)
7:\(X^{new}[row,col]\gets X[row,col]+rand()\times(X_{best}[col]-X_{worst}[col])\);
8:elseifalgorithm = 'Rao-2'then\(\triangleright\) Equation (11)
9:if\(f(X)[row]\) is better than \(f(X)[t[row]]\)then
10:\(X^{new}[row,col]\gets X[row,col]+rand()\times(X_{best}[col]-X_{worst}[col])+rand() \times(abs(X[row,col])-abs(X[t[row],col]))\);
11:else
12:\(X^{new}[row,col]\gets X[row,col]+rand()\times(X_{best}[col]-X_{worst}[col])+rand() \times(abs(X[t[row],col])-abs(X[row,col]))\);
13:endif
14:elseifalgorithm = 'Rao-3'then\(\triangleright\) Equation (12)
15:if\(f(X)[row]\) is better than \(f(X)[t[row]]\)then
16:\(X^{new}[row,col]\gets X[row,col]+rand()\times(X_{best}[col]-abs(X_{worst}[col]))+rand() \times(abs(X[row,col])-X[t[row],col])\);
17:else
18:\(X^{new}[row,col]\gets X[row,col]+rand()\times(X_{best}[col]-abs(X_{worst}[col]))+rand() \times(abs(X[t[row],col])-X[row,col])\);
19:endif
20:endif
21:Check_boundary_integrity_function(\(X^{new}\)). 22:endif
23:endfunction
```
**Algorithm 22** Kernel for population update (Rao algorithms)

### GPU-Based Acceleration of the BWP Algorithm

The main skeleton of the GPU-based parallel BWP algorithm presented by the authors in [38] is shown in Algorithm 23. ```
1:/*Initialization */
2:Initialize\(numVar\), popSize and \(maxIter\);\(\triangleright\)Host
3:\(X\leftarrow\textsc{Generate\_initial\_pop\_kernel}()\);
4:Evaluate_fitness_kernel(\(X\));
5:\(i\gets 1\);
6:/*Main loop */
7:while\(i\leq maxIter\)do\(\triangleright\)Host
8:/*Leverage the Java heuristic */
9:Determine \(X_{best,i}\) and \(X_{worst,i}\);
10:\(X^{new}_{i}\leftarrow\textsc{Jaya-driven\_population\_update\_kernel}(X_{i})\);
11:Evaluate_fitness_kernel(\(X^{new}_{i}\));
12:Greedy_selection_kernel(\(X_{i}\), \(X^{new}_{i}\));
13:/*Leverage the Rao-1 based heuristic */
14:Determine \(X_{best,i}\) and \(X_{worst,i}\);
15:\(X^{new}_{i}\leftarrow\textsc{BWP-Rao1-based\_population\_update\_kernel}(X_{i})\);
16:Evaluate_fitness_kernel(\(X^{new}_{i}\));
17:Greedy_selection_kernel(\(X_{i}\), \(X^{new}_{i}\));
18:\(i\gets i+1\);
19:endwhile
20:Output the best solution found and terminate.\(\triangleright\)Host and device Although the BWP optimization strategy involves the consecutive use of two distinct algorithms (namely Jaya and a Rao-1-based heuristic), it is not possible to reduce the number of steps in the main loop. This limitation stems from the absence of overlapping methods, as each algorithmic phase is inherently sequential in nature.