# Joint Uplink and Downlink Resource Allocation for D2D Communications System
## 3 Resource Allocation Algorithm
### Power Allocation  
When \(k\)th D2D reuses only the uplink channel of \(m\)th CU, the power allocation problem can be simplified as  
\[\max_{P_{kk},P_{k}^{d}}\left\{\log_{2}\left(1+\frac{P_{m}^{c}g_{mB}}{ \sigma^{2}+P_{k}^{d}h_{kB}}\right)+\log_{2}\left(1+\frac{P_{k}^{d}g_{kk}}{ \sigma^{2}+P_{m}^{c}h_{mk}}\right)\right\}\] (18) s.t. \[\gamma_{m,up}^{c}\geq\gamma_{\min}^{c},\gamma_{k,up}^{d}\geq\gamma_{\min}^{d} \tag{19}\] \[0\leq P_{m}^{c}\leq P_{\max}^{c},0\leq P_{k}^{d}\leq P_{\max}^{d} \tag{20}\]  
In order to satisfy the minimum QoS requirement, the SINR of both CUs and D2D pairs should be larger than the threshold, and the transmission power of CUs and D2D pairs cannot exceed its maximum value. According to constraints (19) and (20), we get the range of \(P_{k}^{d}\)  
\[P_{L}^{u}<P_{k}^{d}<P_{H}^{u} \tag{21}\]  
where the parameters \(P_{L}^{u}\) and \(P_{H}^{u}\) are written, respectively. \[P_{L}^{u}=\max\left\{0,\frac{\gamma_{\min}^{d}\left(P_{m}^{c}l_{mk}+\sigma^{2} \right)}{g_{kk}}\right\} \tag{22}\]  
\[P_{H}^{u}=\min\left\{P_{\max}^{d},\frac{P_{m}^{c}g_{mB}-\gamma_{\min}^{c}\sigma ^{2}}{\gamma_{\min}^{c}h_{kB}}\right\} \tag{23}\]  
According to the operational properties of the logarithm function, \(\max\limits_{*}[\log_{2}(1+f(*))+\log_{2}(1+g(*))]\) is equivalent to \(\max\limits_{*}[(1+f(*))\left(1+\ g(*)\right)]\), the optimization problem (18) can be rewritten as  
\[f\left(P_{m}^{c},P_{k}^{d}\right)=\max\limits_{P_{m}^{c},P_{k}^{d}}\left\{ \left(1+\frac{P_{m}^{c}g_{mB}}{\sigma^{2}+P_{k}^{d}h_{kB}}\right)\left(1+ \frac{P_{k}^{d}g_{kk}}{\sigma^{2}+P_{m}^{c}h_{mk}}\right)\right\} \tag{24}\]  
In order to find the optimal values \(\left(P_{m}^{c*},P_{k}^{d*}\right)\), we first prove the following Lemma 1. **Lemma 1**. : _The optimization problem (24) is a convex function with respect to \(P_{k}^{d}\) when another variable \(P_{m}^{c}\) is fixed at its maximal power._  
**Proof of Lemma 1. ** The first-order partial derivative of \(f\left(P_{m}^{c},P_{k}^{d}\right)\) is written as  
\[\frac{\partial f\left(P_{\max}^{c},P_{k}^{d}\right)}{\partial P_{k}^{d}}=\frac {AP_{k}^{d2}+2 BP_{k}^{d}+C}{D}|P_{m}^{c}=P_{\max}^{c} \tag{25}\]  
where the four parameters are  
\[A=g_{kk}h_{kB}^{2} \tag{26}\]  
\[B=g_{kk}h_{kB}\sigma^{2} \tag{27}\]  
\[\gamma_{m,up}^{c}\geq\gamma_{\min}^{c},\gamma_{k,up}^{d}\geq\gamma_{\min}^{d} \tag{19}\]0  
\[\gamma_{m,up}^{c}\geq\gamma_{\min}^{c},\gamma_{k,up}^{d}\geq\gamma_{\min}^{d} \tag{19}\]1From the above Equation (29), it is known that \(D\) is always positive. The Equation (25) is equal to zero and we can get  
\[\gamma_{m,up}^{c}\geq\gamma_{\min}^{c},\gamma_{k,up}^{d}\geq\gamma_{\min}^{d} \tag{19}\]2  
From Equation (30), we are only interested in real-valued \(P_{k}^{d}\in\left[0,P_{\max}^{d}\right]\). According to Equation (30), it is known that a real and non-negative \(P_{k}^{d}\) can only occur for \(C\leq 0\), since \(A,B>0\). Next, the second-order derivative of \(f\left(P_{\max}^{c},P_{k}^{d}\right)\) is obtained as  
\[\gamma_{m,up}^{c}\geq\gamma_{\min}^{c},\gamma_{k,up}^{d}\geq\gamma_{\min}^{d} \tag{19}\]3  
where \(\frac{\partial f^{2}\left(P_{\max}^{c},P_{k}^{d}\right)}{\partial P_{k}^{d2}}\) is seen to be non-negative if the following inequality is satisfied  
\[\gamma_{m,up}^{c}\geq\gamma_{\min}^{c},\gamma_{k,up}^{d}\geq\gamma_{\min}^{d} \tag{19}\]4  
By checking Equation (28), we see \(C\leq 0\) that implies that  
\[\gamma_{m,up}^{c}\geq\gamma_{\min}^{c},\gamma_{k,up}^{d}\geq\gamma_{\min}^{d} \tag{19}\]5  
Divided by \(P_{\max}^{c}g_{mB}\) on both sides of Equation (33), we can get  
\[\gamma_{m,up}^{c}\geq\gamma_{\min}^{c},\gamma_{k,up}^{d}\geq\gamma_{\min}^{d} \tag{19}\]6  
Thus, we can obtain \(\frac{\partial f^{2}\left(P_{\max}^{c},P_{k}^{d}\right)}{\partial P_{k}^{d2}}\geq 0\). Lemma 1 is proved. \(\square\)  
According to the property of the convex function, we note that the maximum of a convex function is obtained at the boundary points.