## 3 Joint Optimal Power Allocation and Relay Selection Scheme
Thus, the optimal power allocation can be obtained when \(R_{S1}=R_{S2}\)According to **Lemma 1**, we obtain that  
\[\frac{2\eta\alpha P_{S1}|h_{i}|^{2}|g_{i}|^{2}}{2\eta\alpha|g_{i}|^{2}\sigma^{2}+( 1-\alpha)\sigma_{2}^{2}}=\frac{2\eta\alpha P_{S2}|h_{i}|^{2}|g_{i}|^{2}}{2\eta \alpha|h_{i}|^{2}\sigma^{2}+(1-\alpha)\sigma_{1}^{2}} \tag{19}\]  
For simple calculation but without loss of generality, we assume \(\sigma^{2}=\sigma_{1}^{2}=\sigma_{2}^{2}\). The Equation (19) can be rewritten as  
\[P_{S1}\Big{(}2\eta\alpha|h_{i}|^{2}+(1-\alpha)\Big{)}=P_{S2}\Big{(}2\eta\alpha| g_{i}|^{2}+(1-\alpha)\Big{)} \tag{20}\]  
Then, applying (20) into (18), the optimization problem (18) can be written as  
\[ \begin{array}{c}\underset{P_{S1}\to}{\max}\\ \text{s.t.}\ t=\frac{1-\alpha}{2}\log_{2}(1+\frac{2\eta\alpha P_{S1}|h_{i}|^{ 2}|g_{i}|^{2}}{2\eta\alpha|g_{i}|^{2}\sigma^{2}+(1-\alpha)\sigma^{2}})\\ P_{S1}+\frac{P_{S1}\left(2\eta\alpha|h_{i}|^{2}+(1-\alpha)\right)}{2\eta \alpha|g_{i}|^{2}+(1-\alpha)}\leq P_{T}^{\max}\end{array}  \tag{21}\]  
For the objective function (21), \(t\) is a monotonically increasing function with respect to \(P_{S1}\). It is easy to get the optimal power value \(P_{S1}^{*}\) when \(P_{T}=P_{T}^{\max}\). And combined with Equation (20), the optimal transmit power of two sources are given by  
\[P_{S1}^{*}=P_{T}^{\max}\frac{2\eta\alpha|g_{i}|^{2}+(1-\alpha)}{2\eta\alpha|g _{i}|^{2}+2\eta\alpha|h_{i}|^{2}+2(1-\alpha)} \tag{22}\]  
\[P_{S2}^{*}=P_{T}^{\max}\frac{2\eta\alpha|h_{i}|^{2}+(1-\alpha)}{2\eta\alpha|g _{i}|^{2}+2\eta\alpha|h_{i}|^{2}+2(1-\alpha)} \tag{23}\]  
For optimal power allocation and fixed relay node, the optimization problem can be written as  
\[ \begin{array}{c}\underset{0\leq\alpha\leq 1}{\max}R_{T}(\alpha)=\frac{1- \alpha}{2}\log_{2}(1+\frac{2\eta\alpha P_{S1}|h_{i}|^{2}|g_{i}|^{2}}{2\eta \alpha|g_{i}|^{2}\sigma^{2}+(1-\alpha)\sigma^{2}})\\ \text{s.t.}\ P_{S1}=P_{S1}^{*}\\ 0\leq\alpha\leq 1\end{array}  \tag{24}\]  
**Lemma 2**. : \(R_{T}(\alpha)\) _is a concave function about \(\alpha\) with the range of 0 to 1._  
Proof of Lemma 2.: We first solve the first derivative of the function \(R_{T}(\alpha)\) with respect of the TS factor \(\alpha\). \[\frac{dR_{T}(\alpha)}{d\alpha}=-\frac{1}{2}\log\!\left(1+\frac{\alpha X}{Y \alpha+1-\alpha}\right)+\frac{1-\alpha}{2\ln 2}\!\left(\frac{X}{(\alpha X+ \alpha Y+1-\alpha)(Y\alpha+1-\alpha)}\right)\]  
where \(X=\eta P_{T}^{\max}|h_{i}|^{2}|g_{i}|^{2}\) and \(Y=\eta\alpha|g_{i}|^{2}+\eta\alpha|h_{i}|^{2}+(1-\alpha)\). The second order derivative of \(R_{T}(\alpha)\) with respect to \(\alpha\) is given by  
\[ \begin{array}{ccl}\frac{dR_{T}(\alpha)^{2}}{d^{2}\alpha}&=&-\frac{X}{\ln 2} \frac{(1-\alpha)+X(1+\alpha)}{(X\alpha+Y\alpha+1-\alpha)(Y\alpha+1-\alpha)^{2 }}\\ &&-\frac{X}{\ln 2}\frac{(1-\alpha)(X+Y-1)(Y\alpha+1-\alpha)}{((X\alpha+Y \alpha+1-\alpha)(Y\alpha+1-\alpha))^{2}}\end{array} \]  
Since \(X\gg 1\) and TS factor \(\alpha\) exists in \([0,1]\), we can obtain that \(dR_{T}(\alpha)^{2}/d^{2}\alpha<0\). Thus, there is a optimal \(\alpha\) value that maximizes \(R_{T}(\alpha)\). **Lemma 2** is proved. \(\square\)According to **Lemma 2**, the original optimization problem with respect to \(\alpha\) is a strictly concave function. Note that \(dR_{T}(\alpha)/d\alpha>0\) when \(\alpha=0\) and \(dR_{T}(\alpha)/d\alpha<0\) when \(\alpha=1\). Obviously, there exists an optimal TS factor \(\alpha^{*}\) in \([0,1]\). However, it is difficult to obtain the closed-form expression of optimal \(\alpha^{*}\) since the first-order derivative of \(R_{T}(\alpha)\) is so complicated and there exist a large amount of unknown. Therefore, the following time allocation scheme is proposed to get the optimal value of \(\alpha^{*}\) when \(dR_{T}(\alpha)/d\alpha=0\).