|
Algorithm 2 Task Offloading Algorithm |
|
Input: Workload matrix representing the resource requirements of tasks over time and Edge server information matrix EdgeServerInfo |
|
Output: Predicted data, Energy consumption matrix, Delay matrix, Cost matrix |
-
1:
Initialize
-
2:
Load a pre-trained model for predicting task resource requirements
-
3:
for each edge server i do
-
4:
Calculate
-
5:
end for
-
6:
for each edge server i do
-
7:
Calculate
-
8:
end for
-
9:
Sort edge servers based on the decision factor:
-
10:
for each service do
-
11:
if then
-
12:
Process the service locally
-
13:
else
-
14:
Migrate the service to the selected edge server
-
15:
end if
-
16:
end for
-
17:
for each edge server i in do
-
18:
if the edge server has enough capacity to host the current service and the service is not already hosted then
-
19:
-
20:
Increment
-
21:
Exit the loop to ensure the service is migrated only once
-
22:
end if
-
23:
end for
-
24:
if then
-
25:
Halt the process
-
26:
end if
|