# Mobility- and Energy-Aware Cooperative Edge Offloading for Dependent Computation Tasks +
## 4 Dynamic Computation Offloading Problem Formulation  
Considering the offloading decision options defined in Section 3, our joint cost optimization of the computation and communication cooperation in the device-enhanced MEC system for the execution of task \(k\) considering the task's execution deadline can be defined based on the battery energy consumption for the execution of task \(k\):  
\[E^{\text{exe}}_{k}=x_{k}E^{l}_{k}+h^{i}_{k}E^{h_{i}}_{k}+s^{m}_{k}E^{s_{m}}_{k }+s^{i,m}_{k}E^{s_{m}}_{k}, \tag{21}\]  
where \(x_{k},h^{i}_{k},s^{m}_{k},\) and \(s^{i,m}_{k}\) represent the binary variables for the offloading decision according to the strategies introduced in Section 3.4. For the execution of task \(k\), only one of these variables can be 1, and the rest are 0, giving the task execution time  
\[T^{\text{exe}}_{k}=x_{k}T^{l}_{k}+h^{i}_{k}T^{h_{i}}_{k}+s^{m}_{k}T^{s_{m}}_{k }+s^{i,m}_{k}T^{s_{i,m}}_{k}. \tag{22}\]  
Hence, the finish time \(FT_{k}\) of task \(k\) is obtained by inserting \(T^{\text{exe}}_{k}\) from Equation (22) into Equation (1). The optimization problem of minimizing the energy cost considering the service execution deadline, the mobility of the end devices, and the task dependencies can be formulated based on the total energy consumption \(E_{\text{tot}}^{\text{exc}}=\sum_{k\in\mathcal{K}}E_{k}^{\text{exc}}\):  
\[ \begin{split} OP1:&\quad\min_{\alpha,\beta}\quad E_{ \text{tot}}^{\text{exc}}\\ s.t:& C1:x_{k},h_{k}^{i},s_{k}^{m},s_{k}^{i,im}\in\{0,1 \},\;\forall k\in\mathcal{K},\;\forall i\in\mathcal{I},\;\forall m\in\mathcal{ M}\\ & C2:x_{k}+\sum_{i=1}^{I}h_{k}^{i}+\sum_{m=1}^{M}s_{k}^{m}+\sum_{ m=1}^{M}\sum_{i=1}^{I}s_{k}^{i,m}=1,\;\forall k\in\mathcal{K}\\ C3:ST_{k}=\left\{\begin{array}{ll}\max\limits_{j\in\mathcal{P}(k )}FT_{j}&\text{ if }\mathcal{P}(k)\
eq\emptyset,\\ 0&\text{ if }\mathcal{P}(k)=\emptyset,\end{array}\right.\quad\forall k\in \mathcal{K}\\ C4:FT_{K}\leq T_{d}^{\text{max}},\\ C5:FT_{k}\leq T_{s,k},\quad\forall k\in\mathcal{K},\end{split}  \tag{23}\]  
where \(\alpha=[x_{1},h_{1}^{1},\dots,h_{1}^{l},s_{1}^{1},\dots,s_{1}^{M},s_{1}^{1,1}, \dots,s_{1}^{I,M},\dots,x_{K},h_{K}^{1},\dots,h_{K}^{l},s_{K}^{1},\dots,s_{K}^ {M},s_{K}^{1,1},\dots,s_{K}^{I,M}\) are the per-task offloading decision making variables, and \(\beta=[ST_{1},ST_{2},\dots,ST_{K}]\) are the start times. The decision-making variables are present in the constraints C1 and C2. Constraint C3 defines the start time for each task \(k\) based on its predecessor tasks. The execution of tasks without predecessor tasks can start immediately, and the start time of all other tasks equals the maximum finish time of their respective predecessors. Constraint C4 indicates that the finish time of the last task \(K\) should be less than or equal to the total time deadline \(T_{d}^{\text{max}}\) of the application. Constraint C5 represents that an offloading destination may only be chosen if the sojourn time \(T_{s,k}\) of the UE in the range of the computation resource is longer than the time \(FT_{k}\) needed to finish executing task \(k\). Utilizing Equation (20), the sojourn time for the different offloading options can be calculated as  
\[T_{s,k}=\left\{ \begin{array}{ll}T_{s,t}^{h_{i}}&\quad\text{if}\quad h_{k}^{ i}\;=1\\ T_{s,t}^{\text{syn}}&\quad\text{if}\quad s_{k}^{m}\;=1\\ \min\{T_{s,t}^{h_{i}},T_{s,t}^{\text{syn}},T_{s,t}^{\text{syn}}\}&\quad\text{ if}\quad s_{k}^{i,m}=1.\end{array} \right. \tag{24}\]  
In Equation (24), \(T_{s,t}^{h_{i}}\) denotes the UE sojourn time in the range of helper node UH\({}_{i}\), \(T_{s,t}^{\text{syn}}\) is the UE sojourn time in the range of MEC server \(S_{m}\), and \(T_{s,t}^{\text{syn}}\) is the sojourn time of helper UH\({}_{i}\) in the coverage area of MEC server \(S_{m}\).