## 3 Problem Formulation and the PSO-Based Power Allocation Scheme for SEE Maximization  
The objective is to maximize the SEE, subject to the constraints of a minimum required rate at each secondary user, minimum energy harvested by U3, and maximum available power at the relay and transmitter based on the maximum permissible interference with the primary user. The SEE is defined as the ratio of secrecy sum rate maximization to total power consumption [3; 5; 14]. The optimization problem can be modeled as follows:  
\[\max_{p_{1},p_{2},p_{3},p_{r}} \frac{R_{u_{1}}+R_{u_{2}}}{\frac{1}{2}\left(p_{1}+p_{2}+p_{3}+p_{ cT}\right)+\frac{1}{2}\left(p_{r}+p_{cR}\right)}\] (11a) s.t. \[R_{x_{1},Tu_{1}}\geq\phi_{1}, \tag{11b}\] \[R_{u_{2},\min}\geq\phi_{2},\] (11c) \[p_{1}+p_{2}+p_{3}\leq P_{T}^{\max},\] (11d) \[p_{r}\leq P_{R}^{\max},\] (11e) \[E_{3}^{(1)}\geq\xi, \tag{11f}\]  
where \(p_{cT}\) and \(p_{cR}\) are circuit power consumption, \(\xi\) is the minimum required energy harvested by U3, and \(\phi_{1}\) and \(\phi_{2}\) are the minimum required data rates for U1 and U2, respectively. \(P_{T}^{\max}\) and \(P_{R}^{\max}\) are the maximum power permitted at the transmitter and relay, respectively, to avoid interference with the primary user. To guarantee that the power level from the transmitter and the relay will not interfere with the primary user, the maximum transmission power at the transmitter and at the relay, respectively, are constrained as indicated in (12) and (13):  
\[P_{T}^{\max}=\min\left\{\frac{I^{\max}}{\left|h_{Tp}\right|^{2}},P_{T}\right\}, \tag{12}\]  
where \(I^{\max}\) is the power level of the maximum permissible interference with the primary user, \(P_{T}\) is the maximum available power at the BS, and \(h_{Tp}\) is the channel coefficient from the secondary transmitter to the primary user; and:  
\[P_{R}^{\max}=\min\left\{\frac{I^{\max}}{\left|g_{Rp}\right|^{2}},P_{R}\right\}, \tag{13}\]  
where \(g_{Rp}\) is the channel coefficient from the relay to the primary user, and \(P_{R}\) is the maximum available power at the relay. To solve problem (11), we propose a low-complexity algorithm based on PSO [15]. First, we define the boundaries of the variables \(p_{1}\), \(p_{2}\), \(p_{3}\) and \(p_{r}\) based on the constraints in problem (11). Then, the minimum transmit power for Message 1 is calculated based on (11b) and (11f), the minimum transmit power of Message 2 at the transmitter is calculated based on (11c) and (11f), the minimum transmit power intended for the EH user is calculated based on (11f), and the minimum transmit power of the relay is calculated based on (11c), as follows:  
\[p_{1\min}=\max\left(\left(2^{2\phi_{1}}-1\right)\frac{\sigma_{1}^{2}}{h_{T_{n1 }}^{2}},\alpha\right), \tag{14}\]  
\[p_{2\min}=\max\left(\gamma_{1},\gamma_{2},\alpha\right), \tag{15}\]  
\[R_{x_{1},Tu_{1}}\geq\phi_{1}, \tag{11b}\]0  
\[R_{x_{1},Tu_{1}}\geq\phi_{1}, \tag{11b}\]1  
in which \(\gamma_{1}=\left(2^{2\phi_{2}}-1\right)\frac{p_{1\min}h_{T_{n1}}+\sigma_{2}^{2 }}{h_{T_{n}}}\), \(\delta_{1}=\left(2^{2\phi_{2}}-1\right)\frac{\sigma_{2n}^{2}}{g_{Rn_{2}}^{2}}\), \(\gamma_{2}=\left(2^{2\phi_{2}}-1-\frac{P_{R}^{\max}g_{Rn_{1}}}{\sigma_{n1}^{ 2}}\right)\frac{p_{1\min}h_{T_{n1}}+\sigma_{n1}^{2}}{h_{T_{n1}}}\), \(\delta_{2}=\left(2^{2\phi_{2}}-1-\frac{P_{T}^{\max}h_{T_{n1}}}{p_{1\min}h_{T_{n 1}}+\sigma_{n1}^{2}}\right)\frac{\sigma_{2n}^{2}}{g_{Rn_{1}}}\), and \(\alpha=\frac{2\phi}{h_{T_{n1}}}-2P_{T}^{\max}\). The overall algorithm of the proposed scheme using PSO is described in Algorithm 1. Let \(I_{\max}\), \(S\), \(w\), \(c_{1}\), and \(c_{2}\), respectively, denote the maximum number of iterations, the total number of particles, the inertia weight parameter, and the acceleration coefficients. Each particle's position represents a vector of four elements \(\left(p_{1},p_{2},p_{3},p_{r}\right)\) for which the boundaries are \(\left[p_{1\min},P_{T}^{\max}\right]\), \(\left[p_{2\min},P_{T}^{\max}\right]\), \(\left[p_{3\min},P_{T}^{\max}\right]\) and \(\left[p_{r\min},P_{R}^{\max}\right]\), respectively.