Skip to main content
. 2024 Mar 28;9(4):204. doi: 10.3390/biomimetics9040204
Algorithm 3. RPSO
Input:
N: population size
T: Matrix of population information
Maxfes: Maximum number of iterations
Dim: Dimension of the problem
Lb: Lower bound of the problem
Ub: Upper bound of the problem
f: objective function
Output:
xgbest: Matrix of newly generated stock information
Fmin: optimal solution
1.      The position matrix x is obtained by random initialization based on the set parameters.
2.      Calculate the objective function value based on f to obtain the optimal position xgbest, the optimal solution fmin
3.       Fes = N;
4.       T = 1;
5.       While (t <= T)&&(Fes <= Maxfes)
6.           Calculate the new population position x according to Equations (1) and (7)
7.       Calculate the objective function value according to f to get the current optimal position xl its subscripts q, update the optimal position xgbest, the optimal solution fmin
8.       Fes = Fes + N;
9.           Nk = 0
10.         For i = 1:N
11.       If i ≠ q
12.       The cosine similarity between the individual and xl was calculated to obtain nc according to Equation (2)
13.       End
14.       If nc < 0
15.       Nk = Nk + 1;
16.       end
17.       end
18.         If Nk > N/2
19.       Perform according to Algorithm 2.
20.       Calculate the objective function value based on f to obtain the optimal position xgbest, the optimal solution fmin
21.       Fes = Fes + TS;
22.       else
23.       Perform according to Algorithm 1.
24.       Calculate the objective function value based on f to obtain the optimal position xgbest, the optimal solution fmin
25.       Fes = Fes + N;
26.         End
27.       t = t + 1;
28.       End
Return xgbest, fmin