## 3 Joint Optimal Power Allocation and Relay Selection Scheme  
In this section, we propose a joint optimal power allocation, TS factor and relay selection scheme for wireless-powered TWRN that maximizes the smaller of the bidirectional instantaneous information rate under some constraint conditions. As mentioned in [20], the performance of TWRN is mainly affected by the worse instantaneous information rate between \(S_{1}\to R_{i}\to S_{2}\) and \(S_{2}\to R_{i}\to S_{1}\). Therefore, the proposed scheme first optimizes the transmit power. Then the optimal TS factor can be obtained with the optimal power allocation. At last, we select the optimal relay with the maximum instantaneous information rate in the set. Applying (10) and (11), the instantaneous signal-to-noise-ratio (SNR) at two source nodes \(S_{1}\) and \(S_{2}\) can be described as  
\[\gamma_{S1}=\frac{\beta^{2}P_{S2}|h_{i}|^{2}|g_{i}|^{2}}{\beta^{2}|h_{i}|^{2} \sigma^{2}+\sigma_{1}^{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{12}\]\[\gamma_{S2}=\frac{\beta^{2}P_{S1}|h_{i}|^{2}|g_{i}|^{2}}{\beta^{2}|g_{i}|^{2} \sigma^{2}+\sigma_{2}^{2}}=\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}} \tag{13}\]  
Since the information is only transmitted within \((1-\alpha)T\) time and all nodes operated in a half-duplex mode, the instantaneous information rate from \(S_{1}\) to \(S_{2}\) and the instantaneous information rate from \(S_{2}\) to \(S_{1}\) are given by  
\[R_{S1}=\frac{1-\alpha}{2}\log_{2}(1+\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{14}\]  
\[R_{S2}=\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}^{2}}) \tag{15}\]  
Therefore, the optimization function of the proposed scheme can be expressed as  
\[ \begin{array}{c}\underset{i}{\operatorname{argmax}}\underset{P_{S1},P_{S2} \text{s.t.}}{\operatorname{argmax}}\min(R_{S1},R_{S2})\\ \text{s.t.}\ P_{T}\leq P_{T}^{\text{max}}\\ P_{S1}\geq 0,P_{S2}\geq 0\\ 0\leq\alpha\leq 1\\ i\in(1,\ldots N)\end{array}  \tag{16}\]  
where \(P_{T}^{\text{max}}\) is the total transmit power and \(P_{T}=P_{S1}+P_{S2}\). In order to remove the minimized symbol, the original optimization problem can be converted as  
\[ \begin{array}{c}\underset{i}{\operatorname{argmax}}\underset{P_{S1},P_{S2} \text{s.t.}}{\operatorname{argmax}}t\\ \text{s.t.}\ R_{S1}\geq t\\ R_{S2}\geq t\\ P_{T}\leq P_{T}^{\text{max}}\\ P_{S1}\geq 0,P_{S2}\geq 0\\ 0\leq\alpha\leq 1\\ i\in(1,\ldots N)\end{array}  \tag{17}\]  
To obtain the optimal solution of (17), we divide the optimization problem (17) into three parts. First, we perform an optimal power allocation in the case of the fixed TS factor and the fixed relay node. Second, we perform an optimal TS factor with the optimal power allocation and fixed relay node. Last, we perform an optimal relay selection with the optimal power allocation and the optimal TS factor. For the fixed TS factor and the fixed relay node, the optimization problem can be described as  
\[ \begin{array}{c}\underset{P_{S1},P_{S2},t}{\operatorname{max}}t\\ \text{s.t.}\ R_{S1}\geq t\\ R_{S2}\geq t\\ P_{T}\leq P_{T}^{\text{max}}\\ P_{S1}\geq 0,P_{S2}\geq 0\end{array}  \tag{18}\]  
**Lemma 1**. : _The optimization problem (18) is optimal when \(R_{S1}=R_{S2}\), i.e., \(\gamma_{S1}=\gamma_{S2}\)._  
Proof of Lemma 1.: The total power constraint \(P_{T}=P_{S1}+P_{S2}\) can be rewritten as \(P_{S1}=\lambda P_{T}\) and \(P_{S2}=(1-\lambda)P_{T}\). It is easy to know that \(R_{S1}\) and \(R_{S2}\) are the monotonically increasing function and the monotonic decreasing function with respect of \(\lambda\), respectively. Also, the objection function is to select the smaller instantaneous information rate of two links.