Skip to main content
. 2022 Sep 7;22(18):6760. doi: 10.3390/s22186760
Algorithm 3: Preference-Based Bilateral Matching Offloading Algorithm
Input: , C
Output: X
1: Initialize ncandidate, Nmreq, Nmcandidate, Nmno, Nmrec, Nmoff, Nmexe equal to Ø;
2: User side: each user sends an offloading request to its associated BS;
3: MEC side: BSs mutually forward the users offloading requests;
4: Initial task offloading:
5: for m do
6: Nmreq received offloading requests;
7: Nmcandidate, NmnoC0;
8: Initial offloading strategy X0: Nmcandidatexnm,In=1, Nmno according to user preferences, with full acceptance of offloading requests;
9: Initial resource allocation strategy: 0X0, according to Algorithm 2;
10: end for
11: for nN do
12:  Computing Tn Equation (7);
13:  NmexemX;
14: if Tntnmax and ΣnNmexefmnfm(m, nNmexe)
15:   Nmexe=Nmexe;
16:   xnm,In=1;
17: else
18:  Computing γnm(nNmexe);
19:  Sort γnm in descending order, select a task with the smallest value to offload in turn, let Nmexe=Nmexe\{n} and Nmoff=Nmoff{n} until and nNmexefmnfm(nNmexe);
20: end if
21: end for
22: for nNmoff do
23: Computing offloading preference xm,In(k)(kncandidate);
24: Sort xm,In(k) in descending order, select a collaborative BS k with the biggest value to send the offloading request preferentially.
25: if k=0 do
26:  Accept the offloading request of In, let Nmoff\{n}, xn0,In=1;
27: else
28:  if k accepts the offloading request of In, let Nmoff\{n}, xnk,In=1;
29:  else send the offloading request of In to the suboptimal collaborative BS k, until it is accepted, let xnk,In=1;
30:  end if
31: end if
32: end for