# Mobility- and Energy-Aware Cooperative Edge Offloading for Dependent Computation Tasks +
## 5 Solution of Dynamic Computation Offloading Optimization Problem
### Energy-Efficient Task Offloading (EETO) Algorithm  
In this section, we propose a stochastic mapping method to obtain the optimized offloading strategy according to the inter-task dependency and the whole application completion time \(T_{d}^{\text{max}}\). We apply SDR by dropping the last non-convex constraint of rank 1 to obtain an approximate solution \(\tilde{G}\), the last row of which includes \([\alpha,\beta,1,1]\). If \(\text{rank}(\tilde{G})=1\), then we directly extract \(\alpha\) as an offloading decision for all tasks from the last row of \(\tilde{G}\). Otherwise, we employ a probability-based stochastic mapping method to recover the solution. For each task \(k\), we select the largest value of each offloading decision from the elements group with index \(k\) in \(\alpha\) and denote them as \(t_{1}\), \(t_{2}\), \(t_{3}\), and \(t_{4}\). We map \(t_{1}\), \(t_{2}\), \(t_{3}\), and \(t_{4}\) with the probability-based stochastic mapping method:  
\[q_{1}t_{1}+q_{2}t_{2}+q_{3}t_{3}+q_{4}t_{4}=1 \tag{32}\]  
\[Q_{1}=q_{1}t_{1},Q_{2}=q_{2}t_{2},Q_{3}=q_{3}t_{3},Q_{4}=q_{4}t_{4}, \tag{33}\]  
where \(Q_{1}\), \(Q_{2}\), \(Q_{3}\), and \(Q_{4}\) are the probabilities of the corresponding offloading decision being 1. We randomly set \(t_{i}=1\) according to the probabilities \(Q_{i}\), and the other elements in \(\alpha\) are set to 0. For example, when \(I=2,M=2\), and \(K=3\), then the dimension of vector \(\alpha\) would be \((1+I+M+IM)K=27\). For each task, there are \(1+I+M+IM=9\) elements; if the solution were not rank 1, each element could be a value between 0 and 1 and the sum of the nine elements equals 1. Taking out the first nine elements in vector \(\alpha\), for instance, as \([0.25,0.15,0.05,0.05,0.10,0.10,0.05,0.15,0.10]\), we can find that the largest numbers of each offloading decision are 0.25, 0.15, 0.10, and 0.15, i.e., \(t_{1}=0.25\), \(t_{2}=0.15\), \(t_{3}=0.10\), and \(t_{4}=0.15\). According to Equations (32) and (33), we stochastically map the probabilities that the corresponding offloading decision would be selected with \(Q_{1}\), \(Q_{2}\), \(Q_{3}\), and \(Q_{4}\), respectively. Then, we randomly set one of the two numbers to 1, while we set the rest of the nine elements to 0, which means that only one offloading decision would be selected for the currently considered task. For each task, we perform the same stochastic mapping, and after a decision has been made for each task, we obtain the offloading strategy \(\tilde{\alpha}\). Furthermore, we compare \(FT_{K}\) with \(T_{d}^{\text{max}}\), and the strategy could be a final solution only if \(FT_{K}\leq T_{d}^{\text{max}}\). For higher accuracy, we repeat the process \(L\) times to obtain a set of solutions and select the solution that yields the minimum energy cost. The algorithm can be summarized as Algorithm 1. ```
1:\(\alpha\), \(\beta\)
```
Input:\(L\), \(K\), \(\mathcal{I}\), \(\mathcal{M}\), \(T_{d}^{\max}\), \(B\), \(\mathcal{P}(k)\), \(b_{k}\), \(c_{k}\), \(P_{k}^{tr}\), \(P_{k}^{wait}\), \(f_{k}^{UE}\), \(f_{k}^{UH_{i}}\), \(f_{k}^{S_{n}}\), \(\forall k\in\mathcal{K}\), \(\mathbf{X}^{UE}\), \(\mathbf{X}^{UE}\), \(\mathbf{X}^{UH_{i}}\) (see Table 1) Output: Offloading strategy \(\alpha\) Initialize: Predict paths of UE and helpers with PECNet with historical paths \(\mathbf{X}^{UE}\), \(\mathbf{X}^{UH_{i}}\), calculate sojourn times \(T_{s,k}\) with Equation (24). Initialize all matrices in Equation (31). Solve the SDP in Equation (31) without the rank-1 constraint to get the optimal solution \(\hat{G}\). Extract the first \((1+I+M+IM)K\) elements of the last row in \(\tilde{G}\) as \(\alpha^{\prime}\); ifrank(\(\tilde{G}\))==1 then \(\alpha=\alpha^{\prime}\); else for\(l\) = 1:Ldo for\(k\) = 1 : \(K\)do \(s(k)=(1+I+M+IM)\) elements in \(\alpha^{\prime}(l)\) related to task \(k\);  Perform probab. based stoch.