## 4 Optimal Resource Allocation
### Optimizing Primal Variables at a Given Dual Point  
After obtaining \(\mathbf{\Gamma}^{*}\), we need to determine the optimal \(\left\{\mathbf{s}^{*},\mathbf{\tau}^{*}\right\}\) in this subsection. Observing (15), we can decompose the dual function as follows  
\[g\left(\mathbf{\alpha},\mathbf{\beta}\right)=g_{0}\left(\mathbf{\alpha}\right)+\sum_{n=1} ^{N}g_{n,1}\left(\mathbf{\alpha},\mathbf{\beta}\right)+\sum_{n=1}^{N}g_{n,2}\left(\bm {\alpha},\mathbf{\beta}\right)+\sum_{k=1}^{K}\beta_{k}\left(\sum_{n=1}^{N}\xi \left(h_{n,k,1}p_{n,k,1}+\sigma^{2}\right)\right) \tag{19}\]  
where  
\[g_{0}\left(\mathbf{\alpha}\right) =\max_{\mathbf{r}\in\mathcal{D}}\ L_{0}\left(\mathbf{r},\mathbf{\alpha} \right)=\max_{\mathbf{r}\in\mathcal{D}}\ \sum_{k=1}^{K}\left(1-\alpha_{k,1}-\alpha_{k,2}\right)\cdot r_{k} \tag{20}\] \[g_{n,1}\left(\mathbf{\alpha},\mathbf{\beta}\right) =\max_{\left\{\mathbf{s},\mathbf{\tau}\right\}\in\mathcal{D}}\ L_{n,1} \left(\mathbf{s},\mathbf{\tau},\mathbf{\alpha},\mathbf{\beta}\right)\] (21) \[=\max_{\left\{\mathbf{s},\mathbf{\tau}\right\}\in\mathcal{D}}\ \sum_{k=1}^{K}\left[\alpha_{k,1}\tau_{n,k,1}\ln\left(1+\frac{h_{n,k,1}s_{n,k,1}}{\sigma^{2}\tau_{n,k,1}}\right)-\beta_{k}\tau_{n,k,1}\xi\left(h_{n,k,1} \frac{s_{n,k,1}}{\tau_{n,k,1}}+\sigma^{2}\right)\right]\,,\forall n\] \[g_{n,2}\left(\mathbf{\alpha},\mathbf{\beta}\right) =\max_{\left\{\mathbf{s},\mathbf{\tau}\right\}\in\mathcal{D}}\ L_{n,2} \left(\mathbf{s},\mathbf{\tau},\mathbf{\alpha},\mathbf{\beta}\right)\] (22) \[=\max_{\left\{\mathbf{s},\mathbf{\tau}\right\}\in\mathcal{D}}\sum_{k=1}^ {K}\left[\alpha_{k,2}\tau_{n,k,2}\ln\left(1+\frac{h_{n,k,2}s_{n,k,2}}{\sigma^ {2}\tau_{n,k,2}}\right)-\beta_{k}s_{n,k,2}\right]\,,\forall n.\]  
It can be observed that \(g_{0}\left(\mathbf{\alpha}\right)\) is linearly correlated with \(r_{k}\). In order to maximize \(L_{0}\left(\mathbf{r},\mathbf{\alpha}\right)\), the optimal \(r_{k}^{*}\) must satisfy  
\[r_{k}^{*}=\left\{ \begin{array}{ll}0,&if\quad\alpha_{k,1}+\alpha_{k,2}>1\\ any,if&\quad\alpha_{k,1}+\alpha_{k,2}=1,\forall k\in\mathcal{K}\\ \infty,&if\quad\alpha_{k,1}+\alpha_{k,2}<1\end{array} \right. \tag{23}\]  
If \(\alpha_{k,1}+\alpha_{k,2}<1\), \(g\left(\mathbf{\alpha},\mathbf{\beta}\right)\) tends to infinity which means it cannot be minimized. Therefore, the optimal dual variables must satisfy the constraint of \(\alpha_{k,1}+\alpha_{k,2}\geq 1\), while \(g_{0}\left(\mathbf{\alpha}\right)\) identically equal to \(0\). Through the following two steps, we can obtain the optimal \(\left\{\mathbf{p},\mathbf{\tau}\right\}\) with the optimal variables \(\mathbf{\Gamma}^{*}\). **(1) Optimal Power Allocation for Given Subcarrier Allocation**: As \(L_{n,2}\left(\mathbf{s},\mathbf{\tau},\mathbf{\alpha},\mathbf{\beta}\right)\) is a concave function of \(s_{n,k,2}\), we can get the optimal power allocation by applying the Karush-Kuhn-Tucker (KKT) condition [36]. More specifically, calculating the derivative of function (22) with respect to \(s_{n,k,2}\) and making it equal to \(0\). The optimal power \(p_{n,k,2}^{*}\) are given by  
\[p_{n,k,2}^{*}=\frac{s_{n,k,2}^{*}}{\tau_{n,k,2}}=\left(\frac{\alpha_{n,2}}{ \beta_{k}}-\frac{\sigma_{n,k,2}^{2}}{h_{n,k,2}}\right)^{+} \tag{24}\]  
where \(\left(x\right)^{+}=\max\left\{0,x\right\}\). The complexity of calculating the \(p_{n,k,2}^{*}\) is \(O(1)\).