# A Hybrid Routing Protocol Based on Naive Bayes and Improved Particle Swarm Optimization Algorithms
## 3 Network Model and Assumptions
### Cluster Head Selection Based on a Naive Bayes Classifier
\(V_{i}\) = random(\(x\), \(y\)) Set the residual energy of all nodes to \(E_{0}\). 3. Calculate \(re(n)\), \(ds(n)\), \(de(n)\), \(dc(n)\), and \(Lqc(n)\), i.e., the residual energy, distance to the \(BS\), node degree, distance to neighbors, and average link quality. All \(C^{(i)}=[c_{0}]\). 4. For \(i=1\) to \(N\) Calculate \(re(i)\) by using Equations (3) and (4) Calculate \(Lqc(i)\) by using Equations (6) and (7) 5. If \(re(i)>RE_{Threshold}\) // Energy advantage node 6. Add node(\(i\)) to Cluster-head Candidate Node Set 7. Else 8. Add node(\(i\)) to Common Perception Node Set 9. End if 10. End for 11. For all nodes in Cluster-head Candidate Node Set 12. Calculate \(P(C=c_{1}|\mathbf{Y}^{(i)})\) by using Equations (9), (11), and (12) //Probability of becoming CH 13. Training 14. If \(P(C=c_{1}|\mathbf{Y}^{(i)})=\max\left\{P(C=c_{1}|\mathbf{Y}^{(i)})\right\}\) 15. \(C^{(i)}=[c_{1}]\) //set node \(i\) as Cluster head 16. Else 17. \(C^{(i)}=[c_{0}]\) //set node \(i\) as Common Perception Node 18. End if 19. End for
```

**Algorithm 1**Pseudo code for the proposed CH selection method based on a Naive Bayes classifier. ### Multi-Hop Path Optimization between Cluster Heads Using Improved PSO

Multi-hop path selection between cluster heads in a WSN is a typical combinatorial optimization problem [34; 35]. This paper proposes an improved PSO algorithm for multi-hop path selection between cluster heads. By improving the algorithm's fitness function and initialization method, the search iteration efficiency of the PSO algorithm for the routing path can be improved. The key element of multi-hop path selection optimization based on the PSO algorithm is the construction of the fitness function [36]. The main goal is to extend the network's lifetime [37]. During transmission path selection, denote a multi-hop path from the source node to the \(BS\) as \(PT_{i}\), which refers to a particle in the PSO algorithm. \[Fitness\propto\frac{1}{\sum\limits_{PT}\frac{Er_{i}}{Er_{enough}}} \tag{14}\]

where \(Er_{average}\) is the average node residual energy of the network and \(Er_{i}\) is the residual energy of node \(i\). Similarly, it is desirable to select the path with the lowest expected energy consumption \(Ec\)

\[Fitness\propto\frac{1}{Ec} \tag{15}\]

Equations (13) and (14) represent the energy factor in the definition of the fitness function, that is, the optimal path should satisfy the condition that the path energy depletion should be as small as possible and the relative residual energy of nodes on the path should be as high as possible. In addition, the number of hops has a significant impact on the efficiency of the routing algorithm and the network energy consumption performance [38]. Therefore, the number of hops should be as small as possible when solving for the optimal path. In addition, due to the signal fading characteristics under conditions of complex dynamics, we take the link quality as one of the parameters of the fitness function and give priority to the link with the highest quality as the multi-hop path. Then, we can obtain:

\[\mathit{Fitness}\propto\frac{1}{\mathrm{H}\mathit{o}ps} \tag{16}\]

\[\mathbf{Y}^{(i)}=\left\{re^{(i)},ds^{(i)},de^{(i)},dc^{(i)},Lqc^{(i)},Df^{(i)}\right\} \tag{8}\]0

Combining Equations (14)-(17), we can obtain:

\[\mathbf{Y}^{(i)}=\left\{re^{(i)},ds^{(i)},de^{(i)},dc^{(i)},Lqc^{(i)},Df^{(i)}\right\} \tag{8}\]1

It is easy to find from the definition of \(E_{\textit{effi}}\) that the larger the \(E_{\textit{effi}}\) value, the lower the energy utilization rate of network nodes. In contrast, the smaller the \(E_{\textit{effi}}\) value, the higher the energy utilization rate of network nodes. As can be seen from Figure 6, the energy consumption efficiency of the network nodes of the four algorithms maintains a low level before 200 rounds and then gradually increases after 200 rounds. As the number of rounds increases, the energy consumption efficiency curves diverge.