Skip to main content
. 2023 Jul 25;10(8):883. doi: 10.3390/bioengineering10080883
Algorithm 1. The pseudocode of the WOA algorithm.
Input:
G: the maximum iterations
b: a constant for defining the shape of the logarithmic spiral
n: the number of whale populations
Output : Optimal individual Xbest and its fitness value fg
1: Initialize the whale population Xii=1,2,,n
2: Calculate the fitness value of each individual
3: while (t < G)
4: for each individual
5: Update a, A, C, l, P (some constants)
6: if1 (P < 0.5)
7: if2 (|A| < 1)
8: Xi updates its position by encircling prey
9: else if2 (|A| ≥ 1)
10: Xi updates its position by searching for prey
11: end if2
12: else if1 (P ≥ 0.5)
13: Xi updates its position by bubble-net attacking
14: end if1
15: end for
16: Check to see if any individuals are out of range and remove them if they are
17: Calculate the fitness value of each individual
18: Update the current optimal individual Xbest  and its fitness fg
19: end while
20: Return Xbestfg