# Network Lifetime Improvement through Energy-Efficient Hybrid Routing Protocol for IoT Applications
## 4 Proposed Hybrid PSOGA
### PSO Algorithm-Based Routing  
PSO is a stochastic algorithm based on optimizing a candidate solution (or particle) [22; 23; 24; 25; 26]. It is a competent method used in numerous domains, such as architecture, research, education, and so forth. Owing to the proven effectiveness of PSO due to its efficiency, robustness, simplicity, and extreme ease of use, it is suited for various optimization problems. PSO particles travel in swarms inside a search space to find the optimum swarm solution by updating its location and speed, as shown in Figure 1.  
In PSO, the swarm refers to the population, and the particle of the swarm corresponds to the solution. During the flight process, each particle moves in the problem space with a velocity that depends upon its previous position and the best position of the swarm. Now consider \(x_{i}\) and \(v_{i}\) are the position and velocity of the \(i^{\text{th}}\) particle, where the swarm has \(N\) particles. Here, particle \(i\) with a set of solutions is generally represented as \(X_{1}=(X_{i1},\ X_{i2},\ X_{i3}\ldots.X_{iN})\). The position and velocity update of each particle during subsequent iterations is shown by the following equations [25]:  
\[x_{i,m}(t)=x_{i,m}(t-1)+v_{i,m}(t-1) \tag{7}\]  
\[v_{i,m}(t)=w*v_{i,m}^{(t)}(t-1)+c_{1}*rand1()*(pbest_{i,m}-x_{i,m}(t-1))+c_{2}* rand2()*(gbest_{m}-x_{i,m}(t-1)) \tag{8}\]  
Here, \(m\) is the dimension of the solution space. \(rand1\) ( ) and \(rand2\) ( ) are the stochastic variables with uniform distribution and these variables are considered independent functions, that is, \(rand1\) ( ), \(rand2\) ( ) \(\in[0,\ 1]\). \(c_{1}\) and \(c_{2}\) are the positive constants that refer to the cognitive and social constants, respectively. \(pbest_{i,m}\) is the best position that depends on the minimum path buffer, network lifetime, and hop count, with m solutions that are attained using the neighboring particles. Further, \(gbest_{m}\) indicates the global optimal. PSO can also be employed for routing in a WSN by performing the following mathematical operations:  
Particle Representation: A string of cluster heads is used to represent a particle that represents a feasible route in a swarm. Here, the CH makes a significant contribution to initializing the route during the swarm initialization. The BS generates a list \(M_{i}\) with all single-hop cluster heads \(j\) for cluster head \(i\). There must be a communication link from \(i\) to \(j\). Fitness Function: For each particle that represents a route, the fitness function is computed, indicating the maximum lifetime of the WSN. A WSN is alive until the energy of each CH along the route is exhausted. The fitness function \(L\) may be defined as [25] the following:  
\[L=\frac{P\_initial}{P\_max} \tag{9}\]  
Here, \(L\) indicates the network lifetime in terms of the number of rounds. \(P\_initial\) and \(P\_max\) refer to the initial energy and maximum energy, respectively, used during each round of communication. Figure 1: Flowchart of the PSO algorithm. Velocity: Velocity illustrates a binary operation that generates a new position for a cluster head. For instance, a velocity of (1,6) implies that the position of CH 1 will be updated to 6. Position plus Velocity: if \(x\) and \(v\) indicate the position and velocity, respectively, the addition operation may be performed as follows [25]:  
\[x=(2,\,7,\,7,\,4,\,3,\,5,\,8)\]  
\[v=(1,\,6)(5,\,5)\]  
When performing \(x+v\), for (1, 6), the new position of CH 1 will be 6, thus giving the results of (6, 7, 7, 4, 3, 5, 8). Further, after applying a velocity of (5, 5), we get (6, 7, 7, 4, 5, 5, 8). Position minus Position: The minus operation for a position produces a velocity. Suppose route \(r1=\{2,4,5,6,8,8\}\) and \(r2=\{2,6,5,7,8,8\}\). Then, the minus operation indicates the replaced cluster heads and is \(((4,6),(6,7))\). Velocity plus Velocity: The addition of velocity \(v_{1}\) and \(v_{2}\) refers to the list of transpositions of CH in \(v_{1}\), followed by those in \(v_{2}\).