# Computational-Intelligence-Based Spectrum-Sharing Scheme for NOMA-Based Cognitive Radio Networks
## 3 CI-Based Power Allocation Schemes
### PSO-Based Power Allocation Scheme  
PSO is a swarm-intelligence-based tool that operates intelligently by randomly spreading members of the swarm, commonly known as \"particles,\" in the search space of the problem [33]. It offers rapid, effective, and robust treatment of multiconstraint nonlinear optimization problems. PSO employs a velocity-position model in which position defines the search region and velocity defines the mutative direction to reach the global best in the search space. Both velocity \(v\) and position \(u\) are randomly initialized in the intervals \(v_{min}\leq v\leq v_{max}\) and \(u_{min}\leq u\leq u_{max}\), respectively. The information about velocity is then utilized to update the position. This process also involves sharing of individual and mutual experiences among the particles. After initialization, the velocity \(v\) of each particle is updated in every generation using the following expression until the stopping criterion is met [34]:  
\[v_{jk}^{i}=v_{jk}^{i-1}+\alpha_{1}\beta_{1}\Big{(}c_{jk}^{i-1}-u_{jk}^{i-1} \Big{)}+\alpha_{2}\beta_{2}\Big{(}b_{jk}^{i-1}-u_{jk}^{i-1}\Big{)} \tag{12}\]  
The corresponding position \(u\) is updated using:  
\[u_{jk}^{i}=u_{jk}^{i-1}+v_{jk}^{i} \tag{13}\]  
The variables used in the above expressions are defined below. \(\alpha_{1},\alpha_{2}\): Cognitive coefficients for controlling the particle's direction, usually set as \(\alpha_{1}+\alpha_{2}\leq 4\)  
\(\beta_{1},\beta_{2}\): Uniform random variables generated in the interval [0, 1]  
\(j^{*}\): Index of current best particle  
\(b_{jk}\) and \(c_{jk}\) denote the individual and collective experience of the particles respectively. Using (12) and (13), each particle makes an effort to move towards the optimum by updating its position using the step function \(v_{jk}\), which is added to the particle's present position. This step may be positive or negative. The particle tries to achieve this objective using two search memories during each generation. One is the individual best \(b_{jk}\) stored in its own history, and the other is the global best \(c_{jk}\) among all particles so far. However, it is very common that the algorithm falls into a local optimum while operating recursively, which results in reduced search efficiency and failure to achieve the global best [35]. To avoid this problem, several modifications and hybridization procedures to the classic PSO algorithm have been proposed in the literature to develop better control and balance between exploration and exploitation [36]. ```
Inputs:\(h_{0},g_{0},K,\{g_{k}\}_{k=1}^{K},\{h_{k}\}_{k=1}^{K},\sigma^{2},\gamma_{0},\{ \gamma_{k}\}_{k=1}^{K},P_{s},\delta,MGN,limit\)
1. Initialization Phase forj=1:j \(p_{jk}^{0}=p_{lb}+rand(0,1)\times(p_{ub}-p_{lb})\) \(\forall k\) \(\sum_{k=0}^{K}p_{jk}^{0}=P_{s}\) and \(p_{lb}^{0}\geq 0\) // \(p_{ub}\) and \(p_{lb}\) are the upper and lower bounds of the optimization variable respectively compute \(\{R_{jk}^{0}\}_{k=1}^{K}\) endfor Output:\(\max\limits_{j=1,2,\ldots}\sum_{k=1}^{K}R_{jk}^{0}\)
```  
**Algorithm 1**Proposed EABC-based power allocation scheme  
```
Inputs:\(h_{0},g_{0},K,\{g_{k}\}_{k=1}^{K},\{h_{k}\}_{k=1}^{K},\sigma^{2},\gamma_{0},\{ \gamma_{k}\}_{k=1}^{K},P_{s},\delta,MGN,limit\)
1. Initialization Phase forj=1:j \(p_{jk}^{0}=p_{lb}+rand(0,1)\times(p_{ub}-p_{lb})\) \(\forall k\) \(\sum_{k=0}^{K}p_{jk}^{0}=P_{s}\) and \(p_{lb}^{0}\geq 0\) // \(p_{ub}\) and \(p_{lb}\) are the upper and lower bounds of the optimization variable respectively compute \(\{R_{jk}^{0}\}_{k=1}^{K}\) endfor Output:\(\max\limits_{j=1,2,\ldots}\sum_{k=1}^{K}R_{jk}^{0}\)
```  
**Algorithm Phase for**\(i=1:MGN\)  
```
Inputs:\(h_{0},g_{0},K,\{g_{k}\}_{k=1}^{K},\{h_{k}\}_{k=1}^{K},\sigma^{2},\gamma_{0},\{ \gamma_{k}\}_{k=1}^{K},P_{s},\delta,MGN,limit\)
1.