## 2 Materials and Methods
### Preliminary Knowledge
#### 2.1.2 Introduction of Model Components
For an uplink task, the user's device collects data and uploads them to the server after local computation and encoding. Then, the server processes the data and sends the corresponding result to the user. In this kind of task, the model assumes that the computation capacity of the MEC server is much larger than that of user devices. The returned result is usually very small in terms of bytes. Therefore, the time required for server computation and the time for result transmission can be removed from the model. This delay can be expressed as:  
\[\mathrm{t_{\varphi=2,m}}\bigg{(}\overrightarrow{\mathrm{u_{m}}},\overrightarrow {\mathrm{v_{m}}}\bigg{)}=\frac{\omega_{\varphi=2,m}\mathrm{B_{m}}}{\mathrm{F_ {m}}}+\frac{\mathrm{cB_{m}}}{\mathrm{U_{m}}\bigg{(}\overrightarrow{\mathrm{u_ {m}}},\overrightarrow{\mathrm{v_{m}}}\bigg{)}}, \tag{6}\]  
In Equation (6), \(\mathrm{F_{m}}\) is the CPU frequency of the user's device; \(\omega_{\varphi=2,m}\) is the number of CPU cycles required by the user's device to compute this kind of task (per bit); \(\mathrm{B_{m}}\) denotes the task bytes for user m; and c is the compression ratio of the data. The two terms on the right-hand side represent the delay resulting from local computation and the delay associated with the uplink transmission of data. The last kind of task is the interactive task. In this kind of task, both uplink and downlink transmission should be considered. The MEC server first obtains real-time data from users via their mobile devices. Then it performs real-time processing and transmits specific data required by users according to the feedback obtained. Obviously, these kinds of MEC tasks require task segmentation, cooperation between the server and user and frequent uplink and downlink data transmission. The delay associated with this kind of task is expressed as follows:  
\[\mathrm{t_{\varphi=3,m}}\bigg{(}\overrightarrow{\mathrm{u_{m}}}, \overrightarrow{\mathrm{v_{m}}},\overrightarrow{\mathrm{d_{m}}}, \overrightarrow{\mathrm{w_{m}}}\bigg{)}=\max(\frac{\mathrm{u_{m}}\omega_{ \varphi=3,m  
\(\omega_{\varphi=3,m}\) and \(\omega_{\varphi=3,s}\) are the number of CPU cycles required by the user's device and the MEC server to process this kind of task (per bit ); B\({}_{m}\) represents the task bytes requested by user m; and c is the compression ratio. In the'max' function, the first term is the delay of local computation. The second term is the sum of three components: i.e., the delay for uploading the edge-computed portion of the task, the delay for server computation and the delay for downlink transmission. For simplicity, the user's local computing and edge computing are parallel; thus, the delay can be expressed as the larger of the two.
* Energy consumption model In order to alleviate the conflict between the battery capacity of mobile devices and application performance, the user's energy consumption should also be considered in the model for optimization. Generally speaking, when communicating, the energy consumption of the system should contain at least three components: namely, the energy consumption for device standby, data transmission and computation. In addition, for different kinds of tasks, the expressions of these three terms are also different.  
For downlink tasks, since the model assumes that the communication facilities are powered by the grid, the energy consumption of the base station and server is not considered. Generally, requests for downlink tasks only contain a small amount of data. Therefore, the energy consumption of such tasks is equal to the standby energy consumption of the mobile device. In multiple equal and small time slots, standby energy is only related to the intrinsic parameters of devices. Thus, this energy consumption can be expressed by P\({}_{s}\), a constant; i.e.,  
\[\mathrm{e}_{\varphi=1,m}=\mathrm{P}_{s}, \tag{8}\]  
For uplink tasks, energy consumption usually includes device standby consumption, local computing consumption and data transmission consumption.