## 5 Simulation Results
The values of the minimum rates at the secondary users are \(\phi_{1}=\phi_{2}=1(\text{bit/s/Hz})\), the minimum energy harvested by the EH user is \(\xi=-18\) dBm, and the transmit power at both the transmitter and the relay is \(P_{T}=P_{R}=30\) dBm. In addition, Table 2 shows the comparison of a different number of particles when the number of iterations was selected to satisfy a tolerance of \(10^{-4}\) in the relative change of the SEE. The absolute error is evaluated by taking into account the SEE obtained by exhaustive search. We can observe that the absolute error is very small for all the cases with a small value in the computational time. The case with \(S=10\) archives the lowest computational time, however, the small number of particles in PSO can lead to a local optimal solution, which should be avoided. Therefore, in the paper, we had selected \(S=20\) particles to be used in the rest of the simulations. Figure 2: The relative change of the SEE versus the number of iterations in PSO. Figure 3 shows the convergence behavior of the proposed algorithm given in Algorithm 1 for an average of several channel realizations. The value of the minimum rates at the secondary users are \(\phi_{1}=\phi_{2}=0.5,1,1.5\) (bits/s/Hz), the minimum energy harvested by the EH user is \(\xi=-18\) dBm and the maximum available transmission power at the transmitter and the relay is \(P_{T}=P_{R}=30\) dBm. We can see that the SEE is enhanced as the iteration index is increased, and its convergence reaches a stable value from iteration index 50. However, from Table 2, we observe that we need at least 90 iterations to achieve a tolerance of \(10^{-4}\). Then, we consider \(1I_{\max}=70\) for further simulations, which is a trade-off between accuracy and computational time. We also observed that the SEE increases when decreasing the minimum data rate requirement of the secondary users. The reason for this is that the transmitter and the relay should deliver low transmission power to satisfy the low required rate of the secondary users. Consequently, the eavesdropper hardly trap the messages transmitted from the transmitter and the relay. Note that if a lower computational time is needed, we can reduce the number of particles and iterations with a consequent reduction in the accuracy of the solution. For instance, at 40 iterations, the tolerance value is around 0.03 with an absolute error of around 0.0008 in the case of \(S=20\) and \(\phi_{1}=\phi_{2}=1\)(bits/s/Hz). In this paper, we analyze the computational cost based on the number of equations that the PSO-based algorithm needs to compute in each iteration, where a detailed study of the operations involved in each equation is omitted since it includes simple operations that just uses real values and do not have matrix operations. In addition, it is assumed that the secondary transmitter has high computational capabilities. \begin{table}
\begin{tabular}{l c c c c c} \hline \hline
**Number of Particles** & **30** & **25** & **20** & **15** & **10** \\ \hline
**N. of iterations** & 80 & 85 & 90 & 90 & 100 \\
**Absolute error** & \(6.25\times 10^{-6}\) & \(1.39\times 10^{-5}\) & \(3.13\times 10^{-5}\) & 0.000353 & 0.001005 \\
**Time (ms)** & 22.54316 & 20.96096 & 18.91602 & 13.08286 & 9.843146 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Effects of the number of particles in PSO. Figure 3: The convergence behavior of the proposed PSO-based algorithm with different minimum rates at the secondary users. The computational cost for a complete iteration of the proposed PSO-based algorithm depends on the evaluation of the objective function and constraints in the problem (11), and the computations needed to update the velocity and position of the particles. First, from the problem (11), the algorithm needs to evaluate the expressions of the rates and the energy harvested for the current particle position, which requires the evaluation of 10 equations involving just real numbers.