## 3 PSO-Based Resource Allocation
Calculate the objective function value of all particles according to Equation (8) and find the \(\boldsymbol{s}^{\textit{bst}}\) and \(\boldsymbol{s}^{\textit{bst}}\) for this generation. One example of \(\boldsymbol{s}^{\textit{bst}}\) and \(\boldsymbol{s}^{\textit{bst}}\) can be \(\boldsymbol{s}^{\textit{bst}}{}_{1}\) = [1 1 3 4 5 6];\(\mathbf{s}^{\mathit{bbest}_{2}}=[7\ 8\ 9\ 10\ 11\ 12]\); \(\mathbf{s}^{\mathit{bbest}_{3}}=[1\ 3\ 4\ 5\ 7\ 6]\) and \(\mathbf{s}^{\mathit{bbest}}=[3\ 4\ 5\ 6\ 7\ 5\ \mid\ 7\ 8\ 9\ 10\ 11\ 12\ \mid\ 1\ 3\ 4\ 5\ 7\ 6]\), respectively. 3. Let \(g=g+1\). According to step (2), we calculate the speed and position of the next generation (\(g+1\)) particle after one generation calculation. After this, One example of the position can be \(\mathbf{s}^{1}_{1}=[2\ 3\ 1\ 4\ 5\ 6\ \mid\ 9\ 7\ 6\ 11\ 13\ 10\ \mid\ 1\ 6\ 7\ 8\ 4\ 9]\). If the number of generations \(g<G\), return to step (2) to update the individual optimal solution and the population optimal solution. One example can be: no change in the previous \(\mathbf{s}^{\mathit{bbest}_{1}}\) by \(\mathbf{s}^{\mathit{bbest}_{1}}=[1\ 1\ 3\ 4\ 5\ 6]\). However, the other two individual optimal solutions is updated by \(\mathbf{s}^{\mathit{bbest}_{2}}=[9\ 7\ 6\ 11\ 13\ 10]\) and \(\mathbf{s}^{\mathit{bbest}_{3}}=[2\ 7\ 8\ 9\ 3\ 5]\), respectively. Moreover, the new \(\mathbf{s}^{\mathit{bbest}}\) is updated according to the object function by \(\mathbf{s}^{\mathit{bbest}}=[2\ 3\ 1\ 4\ 5\ 6\ \mid\ 9\ 7\ 6\ 11\ 13\ 10\ \mid\ 1\ 6\ 7\ 8\ 4\ 9]\). 4. If the number of generations is \(g=G\), the calculation ends. After this, After \(N(N<G)\) generations, one of the positions \(\mathbf{s}^{1}_{i}\) is selected by \(\mathbf{s}^{1}_{1}=[8\ 4\ 5\ 7\ 3\ 2\ \mid\ 7\ 8\ 9\ 10\ 11\ 12\ \mid\ 1\ 5\ 4\ 9\ 6\ 7]\). The global optimal solution \(\mathbf{s}^{\mathit{bbest}}\) is obtained by \(\mathbf{s}^{\mathit{bbest}}=[2\ 3\ 1\ 4\ 5\ 6\ \mid\ 9\ 7\ 6\ 11\ 13\ 10\ \mid\ 1\ 6\ 7\ 8\ 4\ 9]\). Hence, in this PSO calculation, the solution is \(\mathbf{s}^{\mathit{bbest}}=[2\ 3\ 1\ 4\ 5\ 6\ \mid\ 9\ 7\ 6\ 11\ 13\ 10\ \mid\ 1\ 6\ 7\ 8\ 4\ 9]\). To upgrade the effectiveness of SPSO, according to the system schema of the relay station partition characteristics of SPSO for optimization, the learning factor with weight parameters \(\mathbf{cw}_{1}\) and \(\mathbf{cw}_{2}\) are added to Equation (13) to speed up optimization searching in this present study. This PSO is called Refined PSO (RPSO). After this, its next generation of evolution speed of particle \(\mathbf{s}^{g+1}_{i}\) can be obtained by:  
\[\mathbf{v}^{g+1}_{i}\ =\ c_{1}\cdot\mathbf{cw}_{1}\cdot rand()\times(\mathbf{s}^{ \mathit{bbest}}-\mathbf{s}^{g}_{i})+c_{2}\cdot\mathbf{cw}_{2}\cdot rand() \times(\mathbf{s}^{\mathit{bbest}}-\mathbf{s}^{g}_{i}), \tag{16}\]  
where \(\mathbf{cw}_{1}\) and \(\mathbf{cw}_{2}\) are \(1\times K\) vectors, where \(K\) is the number of UE. Both are weighted for adjusting the searching efficiency of particles. The modifying rule of \(\mathbf{cw}_{1}\) is as follows:  
1. \(\mathbf{cw}_{1}(u_{l})\ =\ 1\) for when the RB of the \(u_{l}\)-th UE in \(\mathbf{s}^{\mathit{bbest}}\) does not conflict with the RBs of other relay stations. 2. \(\mathbf{cw}_{1}(u_{l})\ =\ 0\) for when the RB of the \(u_{l}\)-th UE in \(\mathbf{s}^{\mathit{bbest}}\) conflicts with the RBs of other relay stations once. 3. \(\mathbf{cw}_{1}(u_{l})\ =\ 3\) for when the RB of the \(u_{l}\)-th UE in \(\mathbf{s}^{\mathit{bbest}}\) conflicts with the RBs of other relay stations more than once. The modifying rule of \(\mathbf{cw}_{2}\) is as follows:  
1. \(\mathbf{cw}_{2}(u_{l})\ =\ 1\) for when the RB of the \(u_{l}\)-th UE in \(\mathbf{s}^{\mathit{bbest}}\) does not conflict with the RBs of UEs of other relay stations. \(\mathbf{cw}_{2}(u_{l})\ =\ 1\) for \(g>10\). 2. \(\mathbf{cw}_{2}(u_{l})\ =\ 3\) for when the RB of the \(u_{l}\)-th UE in \(\mathbf{s}^{\mathit{bbest}}\) conflicts with the RBs of other relay stations once or more times in \(g\leq 10\).