# Multi-User AF Relay Networks with Power Allocation and Transfer: A Joint Approach
## 3 Proposed Power Allocation and Transfer Algorithm
### Master Problem  
By using subgradient method [26], \(\boldsymbol{\lambda}\), \(\boldsymbol{\mu}\), \(\boldsymbol{\eta}\), \(\boldsymbol{\
u}\), \(\boldsymbol{\vartheta}\), and \(\boldsymbol{\kappa}\) can be obtained in the \((t+1)^{th}\) iteration as  
\[\lambda_{k,m}^{(t+1)} =\left[\lambda_{k,m}^{(t)}+\epsilon_{1}\left(\sum_{i=1}^{m}e^{ \tilde{\mathbf{P}}_{k,i}}-\sum_{i=1}^{m}\left(E_{k,i}-\delta_{k,i}\right) \right)\right]^{+}\,\ \ \forall k,m\ ;\] (30  
With the updated multipliers, we compute \(\tilde{P}_{s,i}^{(t+1)}\), \(\tilde{P}_{r,i}^{(t+1)}\) and \(\delta_{i}^{(t+1)}\). Next, \(\rho_{i}\) and \(\beta_{i}\) using (26) and (27) are recomputed in order to further enhance the lower bound performance in (24). We repeat this procedure until convergence of the algorithm. The proposed algorithm is outlined in Algorithm 1 for the fixed values of \(\mathbf{\Omega}\) and \(\mathbf{\Omega}_{r}\). ```
1: Set \(I_{max}\) as the maximum number of iterations with step sizes \(\epsilon_{1},\epsilon_{2},\cdots,\epsilon_{6}\);
2: Initialize \(t=0\), \(\rho_{j,i}^{(t)}=1\) and \(\beta_{j,i}^{(t)}=0\);
3: Initialize \(\mathbf{P}_{s}^{(t)}\), \(\tilde{\mathbf{W}}_{r}^{(t)}\), \(\boldsymbol{\lambda}^{(t)}\), \(\boldsymbol{\mu}^{(t)}\), \(\boldsymbol{\eta}^{(t)}\), \(\boldsymbol{\upsilon}^{(t)}\), \(\boldsymbol{\phi}^{(t)}\), and \(\boldsymbol{\kappa}^{(t)}\). 4:repeat
5:repeat (Solving (\(\mathbf{P4}\)))
6: Compute \(\mathbf{P}_{s}\) and \(\tilde{\mathbf{W}}_{r}\) and \(\boldsymbol{\delta}\);
7: Compute \(\boldsymbol{\lambda}\), \(\boldsymbol{\mu}\), \(\boldsymbol{\eta}\), \(\boldsymbol{\upsilon}\), \(\boldsymbol{\vartheta}\), and \(\boldsymbol{\kappa}\) using (30)-(35). 8:until convergence;
9: Compute \(\rho_{j,i}^{(t+1)}\) and \(\beta_{j,i}^{(t+1)}\) using (26) and (27) ;
10: Set \(\tilde{\mathbf{P}}_{s}^{(t+1)}\leftarrow\tilde{\mathbf{P}}_{s}^{\star(t)}\), \(\tilde{\mathbf{W}}_{r}^{(t+1)}\leftarrow\tilde{\mathbf{W}}_{r}^{\star(t)}\), and \(\delta^{(t+1)}\leftarrow\delta^{\star(t)}\) and \(t\gets t+1\). 11:until convergence or \(t>I_{max}\). ```  
**Algorithm 1**Proposed algorithm for given values of \(\mathbf{\Omega}_{s}\) and \(\mathbf{\Omega}_{r}\). Theorem 4.1: _The optimal \(\big{(}\tilde{\mathbf{P}}_{s}^{\star},\tilde{\mathbf{W}}_{r}^{\star}, \boldsymbol{\delta}^{\star}\big{)}\) of the problem \((\mathbf{P4})\) must fulfill the following two conditions:_  
\[\text{(T.1)} \sum_{i=1}^{N_{T}}e^{\tilde{\mathbf{W}}_{r}^{\star}}=\sum_{i=1}^ {N_{T}}\left(E_{k,i}-\delta_{k,i}^{\star}\right),\ \forall k\,; \tag{36}\] \[\text{(T.2)} \sum_{i=1}^{N_{T}}e^{\tilde{\mathbf{W}}_{r}^{\star}}=\sum_{i=1}^ {N_{T}}\left[E_{r,i}+\sum_{k=1}^{N}\beta_{k}\tilde{\delta}_{k,i}^{\star} \right],\ \forall k\,. \tag{37}\]  
Proof. : This theorem can be proved by contradiction. Let \(\big{(}\boldsymbol{P}_{s}^{\star},\tilde{\mathbf{W}}_{r}^{\star},\boldsymbol{ \delta}^{\star},\boldsymbol{\Omega}_{s}^{\star},\boldsymbol{\Omega}_{r}^{ \star}\big{)}\) be the optimal solution of \((\mathbf{P4})\). First suppose \(\sum_{i=1}^{N_{T}}e^{\tilde{\mathbf{W}}_{r}^{\star}}<\sum_{i=1}^{N_{T}}\left(E _{k,i}-\delta_{k,i}^{\star}\right)\) is true for \(\big{(}\tilde{\mathbf{P}}_{s}^{\star},\tilde{\mathbf{W}}_{r}^{\star}, \boldsymbol{\delta}^{\star},\boldsymbol{\Omega}_{s}^{\star},\boldsymbol{\Omega }_{r}^{\star}\big{)}\). Then, we can ameliorate \(e^{\tilde{\mathbf{W}}_{r}^{\star}},\forall k\) to achieve an increased sum rate of \(\tilde{f}_{R}(\tilde{\mathbf{P}}_{s}^{\star},\tilde{\mathbf{W}}_{r}^{\star})\), directly implied by utilizing the SINR obtained in (4), without conflicting with any other constraints in \(\mathbf{P4}\). Thus, (T.1) contradicts with the optimality of \(\big{(}\tilde{\mathbf{P}}_{s}^{\star},\tilde{\mathbf{W}}_{r}^{\star}, \boldsymbol{\delta}^{\star},\boldsymbol{\Omega}_{s}^{\star},\boldsymbol{\Omega }_{r}^{\star}\big{)}\).