| (1) | function [S] = choreography (, S, En) |
| (2) | Input: //Task workflow |
| (3) | S//Task slice scheme |
| (4) | En//Environmental parameters, including channel bandwidth, server processing capacity, etc |
| (5) | output: Ord(S) |
| (6) | CreTree(, S)//Build the number of task slice levels |
| (7) | Init(En)//Initialize the offload environment |
| (8) | for i = 1:|S| |
| (9) | T(i) = ExeTime(TLi)//Calculate the earliest start time of the task slices |
| (10) | KP = LogicP(S, T)//Find the longest path for the task slices to execute |
| (11) | NKP = DelP(S, KP)//Get the task slices not in the longest path |
| (12) | Cons = priority(S, ExeTime)//Obtain scheme constraint |
| (13) | Sord = rand (Popsize, Cons, S)//Program population size |
| (14) | while (k ≤ maxnum) |
| (15) | for i = 1: Popsize |
| (16) | F(i) = fitness (, Sord)//Set the optimization target of the heuristic algorithm |
| (17) | [globlalMinT, ordi] = min(F) |
| (18) | for i = 1: Popsize |
| (19) | Sord = IteV (Cons, KP, NKP)//Optimize the population of the choreography scheme under the constraints |
| (20) | [BestMinT, bestord] = min (global, ordi) |
| (21) | Ord(S) = BestMinT |