Skip to main content
. 2024 May 18;9(5):302. doi: 10.3390/biomimetics9050302
Algorithm 1: WOA for computational offloading decision-making in a smart grid
Inputs: DAGmodel—energy and computational nodes and links, population size Psize, maximum number of iterations tmax, WOA parameters (a, A, C), tasks—workload to be relocated
Outputs: Xsol—Best offloading decision solution
Begin
1. P=Xi=genInitialPopulation(DAGmodel, tasks)
2. Foreach Xi determine the fitness value FXi
3. Select Xbest=min FXi
4. Set initial values for c, A, D, tmax, t=0
5. whilet<tmax do
6.   Foreach solution Xi(t) in P, do
7.    Encircling phase:
8.      Calculate distance between Xit and Xbestt
9.      Determine position Xi(t+1) using Xit and Xbestt in relations (6) and (7)
10.     Exploitation phase:
11.        Determine position Xi(t+1) using Xit and Xbestt in relations (8) and (9)
12.     Random exploration phase:
13.        Explore new solutions Xi(t+1) using relation (10)
14.     Inertia-based exploration phase:
15.        Explore new solutions Xi(t+1) using inertia weight in relations (12) and (13)
16.   End Foreach
17.   Foreach Xit+1, determine the fitness value FXit+1
18.      Select Xbest= minFXit+1
19.   If Xbest remains unchanged for several iterations do
20.      Update exploitation / exploration parameters
21.   t = t + 1
22. end while
23. Foreach Xi(t+1), apply threshold mapping to convert continuous values to binary.
24. return Xsol=Xbest
End