## 3 Two-Stage Adaptive Relay Selection and Power Allocation Strategy
Based on Equation (5), the achievable rates of \(x_{1}\) and \(x_{2}\) at U\({}_{2}\) can be expressed as  
\[R_{R_{n}U_{2}}^{x_{1},10}=\frac{1}{2}log_{2}\Bigg{(}1+\frac{\beta_{n1}^{10} \rho_{R}\big{|}h_{R_{n}U_{2}}\big{|}^{2}}{\beta_{n2}^{10}\rho_{R}\big{|}h_{R_{ n}U_{2}}\big{|}^{2}+1}\Bigg{)}\text{ and }R_{R_{n}U_{2}}^{x_{2},10}=\frac{1}{2}log_{2}\Big{(}1+\beta_{n2}^{10}\rho_{R} \big{|}h_{R_{n}U_{2}}\big{|}^{2}\Big{)} \tag{12}\]  
Since U\({}_{1}\) has successfully decoded \(x_{2}\) in the first time slot, it can remove \(x_{2}\) from the superimposed signal received in the second time slot. Thus, U\({}_{1}\) can decode \(x_{1}\) without interference from \(x_{2}\). Therefore, based on Equation (6), the achievable rate of \(x_{1}\) at U\({}_{1}\) is given by  
\[R_{R_{n}U_{1}}^{x_{1},10}=\frac{1}{2}log_{2}\Bigg{(}1+\frac{\beta_{n1}^{10} \rho_{R}\big{|}h_{R_{n}U_{1}}\big{|}^{2}}{\rho_{T}\big{|}h_{T_{1}U_{1}}\big{|}^ {2}+1}\Bigg{)} \tag{13}\]  
The prerequisite for U\({}_{2}\) to decode \(x_{2}\) is that \(x_{1}\) is successfully decoded and canceled, i.e., U\({}_{2}\) must satisfy the condition of \(R_{R_{n}U_{2}}^{x_{1},10}\geq R_{1}\). In addition, in order to ensure the QoS of U\({}_{1}\), the signal \(x_{1}\) at U\({}_{1}\) should satisfy the decoding requirements of \(R_{R_{n}U_{2}}^{x_{1},10}\geq R_{1}\). Therefore, in this case, the criterion for determining the optimal relay \(R_{n^{*}}\) is given by  
\[n^{*}=\underset{n\in S_{2}}{argmax}\Big{\{}R_{R_{n}U_{2}}^{x_{2},10}\Big{\}} \text{ subject to }R_{R_{n}U_{1}}^{x_{1},10}\geq R_{1}\text{ and }R_{R_{n}U_{2}}^{x_{1},10}\geq R_{1} \tag{14}\]From Equations (12)-(14), the optimal power allocation coefficient can be obtained by  
\[\beta_{n2}^{10}=min\left\{\frac{\left[\rho_{R}\big{|}h_{R_{n}U_{2}}\big{|}^{2}- \gamma_{1}\right]^{+}}{\rho_{R}\big{|}h_{R_{n}U_{2}}\big{|}^{2}(1+\gamma_{1})}, \frac{\left[\rho_{R}\big{|}h_{R_{n}U_{1}}\big{|}^{2}-\gamma_{1}\left(\rho_{T} \big{|}h_{TU_{1}}\big{|}^{2}+1\right)\right]^{+}}{\rho_{R}\big{|}h_{R_{n}U_{1}} \big{|}^{2}}\right\}, \tag{15}\]  
where \(\gamma_{1}=2^{2R_{1}}-1\), \(\gamma_{2}=2^{2R_{2}}-1\), and \([x]^{+}=max\{0,x\}\). Case 3: U\({}_{1}\) fails to decode \(x_{2}\) but successfully detects \(x_{1}\) (\(\Theta\) = '01')  
In this case, U\({}_{1}\) fails to decode \(x_{2}\) but successfully detects \(x_{1}\) in the first time slot. Thus, if U\({}_{1}\) obtains \(x_{2}\) in the next slot, it can successfully extract \(x_{1}\) from the superimposed signal obtained in the first slot. The optimal relay is selected from \(S_{1}\). Suppose that \(R_{n}\), \(n\in S_{1}\) is selected, the power allocation coefficient is set as \(\beta_{n2}^{01}=1\). This means that \(R_{n}\) will send \(x_{R_{n}}^{01}=x_{2}\) with full power to serve U\({}_{1}\) and U\({}_{2}\). Based on Equations (5) and (6), the achievable rate of \(x_{2}\) at U\({}_{2}\) and U\({}_{1}\) can be given as  
\[R_{R_{n}U_{2}}^{x_{2},01}=\frac{1}{2}log_{2}\Big{(}1+\rho_{R}\big{|}h_{R_{n}U_ {2}}\big{|}^{2}\Big{)}\text{ and }R_{R_{n}U_{1}}^{x_{2},01}=\frac{1}{2}log_{2}\Bigg{(}1+\frac{\rho_{R} \big{|}h_{R_{n}U_{1}}\big{|}^{2}}{\rho_{T}\big{|}h_{TU_{1}}\big{|}^{2}+1}\Bigg{)} \tag{16}\]  
Then, the criterion for determining the optimal relay \(R_{n^{*}}\) is given by  
\[n^{*}=argmax_{n\in S_{1}}\Big{\{}R_{R_{n}U_{2}}^{x_{2},01}\Big{\}}\text{ subject to }R_{R_{n}U_{1}}^{x_{2},01}\geq R_{2} \tag{17}\]  
Case 4: U\({}_{1}\) fails to decode \(x_{2}\) and \(x_{1}\) (\(\Theta\) = '00')  
In this case, both U\({}_{1}\) and U\({}_{2}\) need the assistance from relays in the second slot. The optimal relay is selected from \(S_{2}\). Assuming that \(R_{n}\), \(n\in S_{2}\) is selected, it will generate a new superimposed signal \(x_{R_{n}}^{00}=\sqrt{\beta_{n1}^{00}}x_{1}+\sqrt{\beta_{n2}^{00}}x_{2}\) based on SC to serve U\({}_{1}\) and U\({}_{2}\). U\({}_{1}\) is also considered as the weak user in this case. Based on SIC, \(x_{1}\) is decoded firstly after U\({}_{1}\) and U\({}_{2}\) receive the superimposed signal.