## 2 Materials and Methods
### Description of Optimization and Algorithm  
#### 2.2.1 Description of Optimization Problem  
According to the above sections, the objective of this paper is to provide an efficient resource allocation algorithm for MEC networks that supports varied services and communication resources and reduces the delay and energy consumption of users' applications, this achieving the optimization of resource allocation in the MEC network. The optimization problem can be defined as a function related to delay and energy consumption at the same time. Here, we use the following function to minimize delay and energy consumption:  
\[\text{obj\_func}:\min_{U,D,V,W,X}\Biggl{(}\max_{\text{mc}\{1,2,\dots,M\}}[ \gamma_{\text{t}}\tau_{\text{m}}^{\text{op}}(\text{u}_{\text{m}},\text{d}_{ \text{m}},\text{v}_{\text{m}},\text{w}_{\text{m}},\text{x}_{\text{m}})]+\gamma_ {\text{e}}\sum_{\text{m}=1}^{M}\text{e}_{\text{m}}^{\text{op}}(\text{u}_{\text{m} },\text{v}_{\text{m}},\text{x}_{\text{m}})\Biggr{)}, \tag{14}\]  
subject to:  
\[\varphi\in\{1,2,3\}, \tag{15}\]  
\[\text{u}_{\text{m},\text{i}},\text{d}_{\text{m},\text{j}}\epsilon\{0,1\}, \qquad\forall\text{m}\in\{1,2,\dots,M\};\,\text{i},\text{j}\in\{1,2,\dots,N\} \tag{16}\]  
\[\text{x}_{\text{m}}=\text{x}_{\text{k}1}\times\text{x}_{\text{k}2}\,,\qquad \forall\text{m}\in\{1,2,\dots,M\} \tag{17}\]  
\[\text{x}_{\text{k}1}\epsilon\{01,10,11\},\,\text{x}_{\text{k}2}\epsilon\{ \text{indexes of tasks}\}, \tag{18}\]  
\[\sum_{\text{m}=1}^{M}\text{u}_{\text{m},\text{i}}\leq 1,\,\sum_{\text{m}=1}^{M} \text{d}_{\text{m},\text{j}}\leq 1,\qquad\text{i}\,,\,\text{j}\in\{1,2,\dots,N\} \tag{19}\]  
\[\sum_{\text{i}=1}^{N}\text{v}_{\text{m},\text{i}}\leq P_{\text{u}1},\,\sum_{ \text{j}=1}^{N}\text{w}_{\text{m},\text{j}}\leq P_{\text{d}1},\qquad\forall \text{m}\in\{1,2,\dots,M\} \tag{20}\]  
In the objective function (14), \(\gamma_{\text{t}}\) and \(\gamma_{\text{e}}\) are the normalized weight coefficients whose summation is 1, and their values indicate the sensitivity of the MEC network to the optimization of delay and energy consumption; M is the number of users; m is the specific user's index; N is the number of resources; i and j are the indexes of the specific resource; and U, D, V, W and X represent the uplink resource allocation matrix, downlink resource allocation matrix, uplink power allocation matrix and identifier matrix, respectively, where U = [u\({}_{1}\) u\({}_{2}\)\(\dots\) u\({}_{M}\)]T and D, V and W are similar to U. The identifier \(\text{x}_{\text{m}}=\text{x}_{\text{k}1}\times\text{k}_{\text{k}2}\), which is used for user cooperation in the network, corresponds to matrix \(X\) = [x\({}_{1}\) x\({}_{2}\)\(\dots\) x\({}_{M}\)]T. Thus, the optimization problem is finally expressed as a function of minimizing the weighted sum of delay and energy consumption. The independent variables of this function include U, D, V, W and X. The first term is the delay term, which  
Figure 2: Overall model of optimization problem. represents the largest delay in the network, and the second term is energy consumption, which is the total energy consumption of the network. Considering the practical network, the optimization process should be restricted by some conditions. First, (15) is the restriction on the kind of task. The user's request must belong to one of the three kinds mentioned above: namely, downlink task (1), uplink task (2) or interactive task (3). Then, (16) is the restriction on the resource allocation status, where 0 and 1 represent non-allocated and allocated status, respectively. Further, (17) and (18) are the conditions of the identifier. Suppose that the identifier \(x_{m}\) of user \(m\) is composed of \(x_{k1}\) and \(x_{k2}\). \(x_{k1}\) represents the kind of task (2 bits in total) and \(x_{k2}\) indicates the index of the specific task (\(\log_{2}K_{task}\) bits in total), where \(K_{task}\) is the number of different tasks of that kind. The fifth restriction (19) ensures each uplink and downlink resource can only be allocated to one user in the same time slot.