## 4 Joint Task Offloading, Resource Allocation, and Security Assurance Algorithm
### MEC Server Selection  
Given \(\mathbf{f}\) and \(\lambda\), the MEC server selection problem can be expressed as  
\[\begin{split}\text{P3}:\min\limits_{\mathbf{x}}T(\mathbf{x})& =\min\limits_{i}\sum\limits_{i=1}^{N}\sum\limits_{j=1}^{M}x_{ij}t \Xi_{i}\\ s.t.&\text{C3.1}:\sum\limits_{j=1}^{M}x_{ij}t\Xi_{i} \leq T^{th},\ \forall i\in\mathbf{N}\\ &\text{C3.2}:T_{i,j}^{loc}\leq t\Xi_{i},\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}\\ &\text{C3.3}:T_{i,j}^{LMV}\leq t\Xi_{i},\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}\\ &\text{C3.4}:\sum\limits_{j=1}^{M}x_{ij}=1,\ \forall i\in\mathbf{N}\\ &\text{C3.5}:x_{ij}\in\{0,1\},\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}\\ &\text{C3.6}:0\leq\sum\limits_{i=1}^{N}x_{ij}f_{ij}\leq F_{j}, \ \forall j\in\mathbf{M}\\ &\text{C3.7}:R_{e}\leq R_{th},\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}.\end{split} \tag{17}\]  
In (17), as the constraint C3.5 is \(x_{ij}\in\{0,1\}\), the optimization problem P3 is a zero-one integer programming problem. In addition, the objective function \(T(\mathbf{x})=\sum\limits_{i=1}^{N}\sum\limits_{j=1}^{M}x_{ij}t\Xi_{i}\) is nonlinear with respect to \(x_{ij}\). Accordingly, the optimization problem P3 is a mixed integer nonlinear programming problem, which is also a NP-hard problem [60].  
To solve the above optimization problem P3, we relax the constraint C3.5, i.e., \(0\leq x_{ij}\leq 1\). We can get the following relaxed nonlinear programming problem.  
\[\begin{split}\text{P4}:\min\limits_{\mathbf{x}}T(\mathbf{x})& =\min\limits_{\mathbf{x}}\sum\limits_{i=1}^{N}\sum\limits_{j=1}^{M}x_{ ij}t\Xi_{i}\\ s.t.&\text{C4.1}:\sum\limits_{j=1}^{M}x_{ij}t\Xi_{i} \leq T^{th},\ \forall i\in\mathbf{N}\\ &\text{C4.2}:T_{i,j}^{loc}\leq t\Xi_{i},\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}\\ &\text{C4.3}:T_{i,j}^{LMV}\leq t\Xi_{i},\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}\\ &\text{C4.4}:\sum\limits_{j=1}^{M}x_{ij}=1,\ \forall i\in\mathbf{N}\\ &\text{C4.5}:0\leq x_{ij}\leq 1,\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}\\ &\text{C4.6}:0\leq\sum\limits_{i=1}^{N}x_{ij}f_{ij}\leq F_{j},\ \forall j\in \mathbf{M}\\ &\text{C4.7}:R_{e}\leq R_{th},\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}.\end{split} \tag{18}\]  
**Lemma 2**.: _The optimization problem P4 is a convex optimization problem._  
Proof of Lemma 2.: See the Appendix B.  
By the corollary to Lemma 2, we can solve the optimization problem P4 by general convex optimization algorithms and we can obtain an optimal fractional solution, which can be expressed as \(\mathbf{x}^{*}=[x_{1},x_{2},...,x_{n}]^{T}\), where \(n\) represents the number of solutions and \(\mathbf{x}^{*}\in[0,1]\). However, because of the relaxation of the constraint, the space of the solution is larger. Thus, this solution \(\mathbf{x}^{*}\) is an upper bound of the primal optimization problem P3. In addition, \(\mathbf{x}^{*}\) is continuous and cannot satisfy the integer constraint of problem P3, i.e., \(x_{ij}\in\{0,1\}\). In the light of the analyses above, we adopt the relax-and-rounding method from in [61] to obtain the feasible solution \(x_{ij}^{*}\), where \(x_{ij}^{*}=\{\mathbf{x}^{*}|\mathbf{x}^{*}\in[0,1]\}\).