Algorithm 1 Pseudo-code of the Moth Search Algorithm. |
-
1:
Define the population number of moths , the sub-populations and , the maximum number of generations , and the number of decision variables
-
2:
Define the maximum step size of random path in Lévy distribution = 1.0
-
3:
Set g = 1
-
4:
for (g = 1; ; ) do
-
5:
Initialize the position , the best position and the fitness value of each i-th moth in every j-th decision variable at g-th generation
-
6:
——————————Lévy flight——————————
-
7:
Set = 1 and = 1.5
-
8:
for ( = 1; ; ) do
-
9:
Compute the scale factor using (3)
-
10:
Compute the Lévy distribution parameter value using (2)
-
11:
Compute the position of each moth using (1)
-
12:
end for
-
13:
——————————Straight flight——————————
-
14:
Set = 1
-
15:
for ( = 1; ; ) do
-
16:
Set j = 1
-
17:
for (j = 1; ; ) do
-
18:
if () then
-
19:
Compute the position of each moth using (4a)
-
20:
else
-
21:
Compute the acceleration factor using (5)
-
22:
Compute the position of each moth using (4b)
-
23:
end if
-
24:
end for
-
25:
end for
-
26:
Compute the updated fitness value for each moth
-
27:
Update the moth with the best position based on the fitness value
-
28:
end for
|