## 5 Two-Stage Iterative Algorithm Design
### Stage 2: Optimizing Communication Resource Allocation  
According to the task offloading decisions \(\boldsymbol{\eta}\) provided in the first stage, the CRA subproblem can be formulated as  
\[\mathcal{P}3:\min_{\beta}\sum_{n\in\mathcal{N}}\sum_{n\in\mathcal{ U}_{n}}t_{un}\] s.t. C2-C4.  
**Theorem 1**: _The CRA subproblem is a convex problem._  
**Proof of Theorem 1.** To prove that the CRA subproblem is convex, we first describe the first derivative of the objective function with respect to \(\beta_{un}\) as follows:  
\[\frac{\partial t_{un}(\beta)}{\partial\beta_{un}}=\frac{-(1-O_{un})d_{un} \lambda_{un}(\beta_{un})^{-2}}{B_{n}\text{log}_{2}(1+\frac{p_{un}h_{un}}{ \sigma^{2}})} \tag{13}\]  
Then, the second derivative can be expressed as follows:  
\[\frac{\partial^{2}t_{un}(\beta)}{\partial(\beta_{un})^{2}}=\frac{2(1-O_{un})d _{un}\lambda_{un}(\beta_{un})^{-3}}{B_{n}\text{log}_{2}(1+\frac{p_{un}h_{un}}{ \sigma^{2}})} \tag{14}\]  
From (14), it follows that the second derivative is \(\frac{\partial^{2}t_{un}(\beta)}{\partial(\beta_{un})^{2}}>0\), proving that the objective function in the CRA subproblem is convex. Additionally, constraints C3 and C4 are linear and convex, respectively. Therefore, the CRA subproblem is convex.  
To simplify the solution of the CRA subproblem, we define \(x_{un}\) as  
\[x_{un}=\frac{\lambda_{un}(1-O_{un})d_{un}}{B_{n}\text{log}_{2}(1+\frac{p_{un}h _{un}}{\sigma^{2}})}. \tag{15}\]  
Since the CRA subproblem is a convex problem, we solve it using the Lagrange multiplier method to obtain the optimal closed-form solution. Specifically, we introduce non-negative Lagrange multipliers \(\psi_{n}\) and \(\delta_{un}\) for constraints C3 and C4. Then, the objective function is integrated with constraints C3 and C4 to form the Lagrangian function. The Lagrangian function is expressed as  
\[\begin{split}\mathcal{L}(\beta,\zeta,\psi)&=\sum_{n\in \mathcal{N}}\sum_{u\in\mathcal{U}_{n}}\frac{x_{un}}{\beta_{un}}+\sum_{n\in \mathcal{N}}\psi_{n}\Bigg{(}\sum_{u\in\mathcal{U}_{n}}\beta_{un}-1\Bigg{)}\\ &\quad+\sum_{n\in\mathcal{N}}\sum_{u\in\mathcal{U}_{n}}\xi_{un} \Big{(}t_{un}-\lambda_{un}t_{un}^{tol}\Big{)}.\end{split} \tag{16}\]  
Then, the Karush-Kuhn-Tucker (KKT) conditions can be written as  
\[\frac{\partial\mathcal{L}(\beta,\xi,\psi)}{\partial\beta_{un}}=-\frac{x_{un}}{ \beta_{un}^{2}}+\psi_{n}-\xi_{un}\frac{x_{un}}{\beta_{un}^{2}}=0, \tag{17}\]  
\[\psi_{n}\Bigg{(}\sum_{u\in\mathcal{U}_{n}}\beta_{un}-1\Bigg{)}=0,\ \psi_{n}\geq 0, \tag{18}\]  
\[\xi_{un}(t_{un}-\lambda_{un}t_{un}^{tol})=0,\ \xi_{un}\geq 0. \tag{19}\]  
By solving Equation (17), we get  
\[\beta_{un}=\bigg{(}\frac{x_{un}(1+\xi_{un})}{\psi_{n}}\bigg{)}^{\frac{1}{2}}. \tag{20}\]  
Therefore, we have \(\psi_{n}>0\). According to (18), we obtain  
\[\sum_{u\in\mathcal{U}_{n}}\beta_{un}=1. \tag{21}\]  
Then, the optimal solutions corresponding to different values \(\xi_{un}\) are summarized as follows.  
When \(\xi_{un}=0\), (20) can be rewritten as  
\[\beta_{un}=\bigg{(}\frac{x_{un}}{\psi_{n}}\bigg{)}^{\frac{1}{2}}. \tag{22}\]  
Substituting (22) into (21), we have  
\[\psi_{n}=\Bigg{(}\sum_{u\in\mathcal{U}_{n}}(x_{un})^{\frac{1}{2}}\Bigg{)}^{2}. \tag{23}\]  
Based on (21)-(23), we can obtain the optimal solution for the bandwidth allocation ratio as  
\[\beta_{un}=\frac{(x_{un})^{\frac{1}{2}}}{\sum\limits_{u\in\mathcal{U}_{n}}(x_ {un})^{\frac{1}{2}}}. \tag{24}\]  
When \(\xi_{un}>0\), according to (19), we have \(t_{un}-\lambda_{un}t_{un}^{tol}=0\). Therefore, the optimal bandwidth allocation ratio can be expressed as  
\[\beta_{un}=\Bigg{\{}\frac{x_{un}}{\lambda_{un}t_{un}^{tol}-t_{un}^{t,cum}}, \quad\text{if }\eta_{un}=n, \tag{25}\]