## 2 Multilevel Edge Network Task Offloading Model
### Offloading Node Resources
#### 2.2.3 G-MEC Offloading  
The above part of the offloading model uses the UAV as the MEC server to provide the offloading service for the terminal. However, the computational and energy resources of the UAV are limited, and the cost of resources is large. In the face of mega data tasks, the UAV will be unsuitable for task processing. With the UAV as the relay, offloading the computation task to the farther ground edge server (G-MEC) is a satisfactory solution. This model considers the Rayleigh channel and adopts the AF(amplify and forward) relay mode for relay offloading. The offloading utility function also includes the delay and energy parts. The delay in partial utility function is first analyzed.  
The delay function is divided into the calculation (\(T_{gmc-x}\)), the task transmission (\(T_{gmac-c}\)), and the task propagation (\(T_{gmac-b}\)) delays on the G-MEC. The formulas are as follows:  
\[T_{GMEC-X}=\frac{N_{Z}}{R_{GMEC}}, \tag{16}\]  
Figure 3: UAV energy level relationship.  
\[T_{GMEC-C}=\frac{Z}{R_{GMEC-b}}, \tag{17}\]  
\[R_{\text{MEC-}b}=\frac{1}{2}B\log_{2}\!\!\left(\!1+\frac{1}{\frac{\sigma^{2}}{h_ {1}^{2}P_{u}d_{u}^{-q}}+\frac{\sigma^{2}}{h_{1}^{2}P_{u}d_{uu}^{-q}}}\!\right)\!. \tag{18}\]  
\[T_{GMEC-b}=(a_{u}+d_{uw})/v, \tag{19}\]  
where \(R_{GMEC}\) denotes the task running rate on the G-MEC, and \(R_{GMEC-b}\) denotes transmission speed. \(P_{u}\) and \(P_{uw}\) are the transmitting power of the terminal equipment and UAV, respectively. Meanwhile, \(d_{u}\) and \(d_{uw}\) are the distance from the terminal device to the UAV and from the UAV to the G-MEC, respectively. Lastly, \(h_{1}\) is the channel gain. The G-MEC offloading total delay function \(T_{GMEC-Z}\) of the UAV relay is obtained by synthesizing the above delay function.  
\[T_{GMEC-Z}=T_{GMEC-X}+T_{GMEC-C}+T_{GMEC-b}. \tag{20}\]  
The energy utility function considers the energy consumed by the task calculation on the G-MEC (\(E_{GMEC}\)), by the UAV operation (\(E_{uw-w}\)), by the signal transmitted by the terminal (\(E_{GMEC-u}\)), and by the UAV relay signal (\(E_{GMEC-uav}\)). \(E_{GMEC}\), \(E_{uav-w}\), \(E_{GMEC-u}\), and \(E_{GMEC-uav}\) are given as follows:  
\[E_{GMEC}=N_{z}\delta_{GMEC}, \tag{21}\]  
\[E_{GMEC-u}=P_{u}\cdot T_{GMEC-c}, \tag{22}\]  
where \(\delta_{GMEC}\) is the energy consumed by the task of performing a cycle at the G-MEC. The energy consumed by the UAV as a relay is shown as follows:  
\[E_{GMEC-uav}=P_{uav}\cdot T_{GMEC-C}, \tag{23}\]  
\[E_{uw-w}=P_{uav-w}T_{GMEC-c}. \tag{24}\]  
With the UAV as a relay node, its energy level will affect system reliability and persistence. That is, such a UAV will influence the system utility function. Combined with the above energy function, the total energy consumption function of the task offloaded to the G-MEC is as follows.  
\[E_{GMEC-Z}=E_{GMEC}+E_{GMEC-u}+\omega_{2}(E_{GMEC-uav}+E_{uav-w}), \tag{25}\]  
where \(\omega_{2}\) is the initial energy level coefficient of the G-MEC offload. When the operation delay of the task is less than the delayed deadline, the system can obtain the reward value, as follows:  
\[f(a=O_{M})=\begin{cases}R_{oGMEC}&T_{GMEC}<T_{\text{deadline}}\\ 0&\text{otherwise}\end{cases}. \tag{26}\]