Cluster Routing Algorithm for Ring Based Wireless Sensor Network Using Particle Swarm and Lion Swarm Optimization

In order to solve the problem of hot spot caused by uneven energy consumption of nodes and reduce the network energy consumption, a novel Cluster Routing algorithm for ring based wireless sensor networks using Particle Swarm Optimization (PSO) and Lion Swarm Optimization (LSO) is proposed in this paper, which is called CRPL. In CRPL, the optimal cluster heads (CHs) of each ring are determined by using LSO whose fitness function considers not only energy, number of neighbor nodes, number of cluster heads but also distance. Moreover, PSO with a multi-objective fitness function considering distance, energy and cluster size is used to find the next hop relay node in the process of data transmission for each CH, so the optimal routing paths are obtained, which can alleviate the hot spot problem as well as decrease the energy consumption in the routing process. The simulation results show that, compared with the existing correlative cluster routing algorithms, CRPL has better effects in balancing the energy consumption and prolonging the lifespan of the network.


Introduction
In recent years, with the advent of the era of artificial intelligence, WSN has played an important role in environmental observation, military affairs, building monitoring, medical care, home furnishing, etc [1][2][3]. However, the development of WSNs is still constrained 1 3 by many factors. For example, the sensor nodes in a WSN are usually randomly deployed in areas that are difficult or impossible for humans to enter [4], and their energy is usually limited and cannot be supplemented in time [5]. Many nodes far away from the Base Station (BS) consume a lot of energy when sending information, which will cause them die prematurely and make the information received by the BS incomplete [6,7].
In order to solve the above problems to a certain extent, a clustering routing algorithm based on PSO and LSO called CRPL is proposed to balance the network energy consumption and prolong the network lifespan in this paper. CRPL uses LSO algorithm to select the best CHs of each ring based on the objective function considering four factors: energy of the sensor node, distance between the node and the BS, the number of the node's neighbors, and the proportion of CHs in the ring. In addition, PSO algorithm is used to determine the optimal routing path for each CH by establishing a fitness function based on distance between the CH and BS, the number of its cluster members (CMs), the residual energy of its next-hop CHs, and the distance between CH and the vertical section of the current CH and BS in the next hop.
The rest of this paper is organized as follows: The related works are discussed in Sect. 2, and the system model is described in Sect. 3. In Sect. 4, the proposed CRPL is introduced in detail. In Sect. 5, simulations are performed and results are analyzed in sequence. Finally, the summary of the paper is provided in Sect. 6.

Related Works
At present, the clustering routing algorithm has been considered to be one of the most effective methods to improve the lifespan of WSN [8]. LEACH was the first clustering routing algorithm [9], whose main idea was to let nodes act as CHs in turn. LEACH can avoid the situation where some nodes consume too much energy because they are selected as CHs with equal probability. However, energy was not taken into account during the process of CH selection, which would lead to the unbalanced load of each cluster in the network. The LEACH-C algorithm proposed in [10] took the nodes whose residual energy was greater than the average energy as candidate CHs, then the CHs with the smaller objective function values were selected from the candidate CHs by using simulated annealing algorithm, but the location of CHs was not considered in LEACH-C. In the distributed energy-efficient clustering (DEEC) algorithm proposed in [11], the threshold setting method for selecting CHs was the same as that of LEACH. Different from LEACH, the residual energy of nodes and average energy of the network are introduced into the probability equation in this algorithm. However, in the DEEC algorithm, the CHs far away from the BS would consume too much energy. In [12], cluster-Head restricted energy efficient protocol (CREEP) was proposed, which was an improved protocol based on DEEC. First, the influence of residual energy of nodes was considered when setting the threshold. Secondly, the distance factor was introduced into the probability equation so as to reduce the probability that the node far away from the BS became the CH, but the cluster size is not considered, which will lead to excessive load and premature death of the CH.
CH selection in WSNs was affected by many parameters, and fuzzy control was widely used in the multi-parameter control model [13]. LEACH-FL proposed in [14] input the remaining energy of nodes, the density of nodes, and the distance of the BS from nodes into the designed fuzzy logic system (FLS) for logical inference, and obtained a fuzzification function for the possibility of CH selection. Then, the fuzzification function was solved by the moment center algorithm to get specific values as the basis for CH selection. In [15], a clustering routing protocol that combines Fuzzy C Mean (FCM) with FLS was presented. The FCM algorithm computed the Euclidean distance between nodes to cluster one by one to get the optimal clustering result and the cluster center. After clustering, FLS was executed on each cluster to select the CH. The fuzzy logic system was set up with three factors as the fuzzy input variables: the relative residual energy of nodes, the distance from the cluster center, and the distance from the BS. Although fuzzy control can implement multi-parameter control variables, its excessive dependence on experience lacked a corresponding theoretical basis.
With the development of biomimetic swarm intelligence optimization algorithms, such as Lion Swarm Optimization (LSO), Particle Swarm Optimization (PSO), Genetic Algorithms (GA), Artificial Bee Swarm (ABC), Ant Colony Optimization (ACO), Dragonfly (DA), Elephant Swarm Optimization (EHO), Cuckoo Search (CS) were widely used in clustering routing of WSNs [16][17][18][19]. The main idea of LSO was to obtain the optimal value of the objective function through repeated searches. In [20], the lion cluster routing protocol (MOFPL) was proposed, which uses multi-objective fitness functions based on energy, delay, traffic rate, distance, and cluster density to select the best CHs. A hybrid optimization algorithm combining the lion swarm algorithm and fractional calculus was presented in [21]. The selection of optimal CHs in this algorithm mainly refers to several influencing factors, such as intra-cluster distance, inter-cluster distance, residual node energy, and delay. In [22], a multi-objective fractional artificial bee colony hybrid optimization algorithm was proposed, which selects the best CHs by considering the multiobjective function based on energy consumption, driving distance, and delay. In [23], the authors proposed the optimized clustering based on genetic algorithm (GAOC), in which the fitness function of CH election based on residual energy, the BS distance, and node density was established. In addition, an elitism algorithm was introduced to optimize the genetic algorithm, but too many elites would cause local convergence of the algorithm. Although the above-mentioned algorithms have some effects in alleviating the energy "hot spot" problem and prolonging the lifespan of the network, a large amount of energy consumption was ignored in the routing process, which would cause the effects not obvious. Accordingly, there were many optimization algorithms for the routing process. In the routing process, CHs can cooperate with each other to forward their data to the BS through multi-hop mode [24]. A GA-based clustering and routing algorithm (GACR) proposed in [25] applied a genetic algorithm to routing, and established a routing fitness function based on total transmission distance and cluster head hops. This algorithm can save the energy consumed in the routing process, but it was very likely to choose the CHs with less energy as the relay nodes. In [26], the authors proposed the routing protocol based on particle swarm optimization (PSO), which considered not only the number of relay nodes and the distance between CH and BS but also the relay load. However, when a relay node was overloaded, CH may choose a longer alternative path. Thus the energy consumption of CH is increased. In the ant colony optimization algorithm proposed in [27], not only the best routing direction from the CH node to BS is considered, but also the distance band, search angle, and distance factors are comprehensively considered when looking for the next hop CHs, and the incentive strategy is introduced to balance the "hot" nodes with a heavy load to optimize the routing path. However, there may be several similar routing paths from CHs to the BS in the network, which leads to the problems of fast energy consumption of some nodes or low activity of some nodes.
In [28], the authors adopted a ring wireless sensor network model, which implements multi-hop communication between CHs by means of ring splitting. Except for the first ring, CHs located each ring sequentially search for their relay nodes in the next ring. Then the best routing path of each CH can be found through the ring structure. In [29], the authors presented an annulus-based energy balanced data collection (AEBDC) method which transmits data with the help of candidate CHs to reduce the load of CHs. However, during the process of data transmission, more candidate cluster heads need to forward data in the ring network, which increases the energy consumed. The CAMP routing proposed in [30] divides the CMs in the ring area into two types. The two different types of CMs forward their data to the next-hop nodes according to different working constraints. This algorithm achieves the balance of node energy consumption but dividing the CMs into two categories increases the complexity of the network. In order to solve the problems in the above algorithm to a certain extent, this paper proposes a cluster routing algorithm for ring WSNs based on particle swarm and lion swarm to balance network energy consumption and prolong the lifespan of the network. In this paper, a clustering routing algorithm based on particle swarm optimization and lion swarm is proposed to balance the network energy consumption and prolong the network lifespan.

Network Model
The wireless sensor network model proposed in this paper is shown in Fig. 1. The network model is a ring area with a radius of R, in which N sensor nodes are randomly distributed throughout the ring area;The annular region is divided into n concentric rings with the same width, BS is located at the center of the ring. The regional environment of the entire ring network is assumed as follows: • After the sensor node is deployed, the position of the node in the network will no longer change, and the BS will broadcast its position information to each sensor node in the network; • BS will broadcast its position information to each sensor node in the network; • The whole network is isomorphic, and each sensor node has a unique ID; • Each sensor node has the same initial energy and the same communication radius;

Energy Model
The energy consumption in WSN mainly includes the energy consumed by the CM node sending data message information to CH in cluster, the energy consumed by CH receiving CM node sending data information, the energy consumed by CH node fusing the message sent by CM node and forwarding it to BS through multi-hop mode, and the energy consumed by CH forwarding the data information of previous hop CH. The above energy consumption is mainly manifested in the receiving and sending process of sensor nodes. From the energy model in [10,21,26], it can be seen that when the distance between the sending node and the receiving node is longer, more energy will be consumed in the process of data transmission. Assuming that the energy consumed by the i-th CM node in a ring in the network area to transmit data to the j-th CH node in the corresponding ring is E c S i a , the expression is shown in formula (1): where E e is the energy consumption of electronic circuit in WSN, which can be expressed by formula (2). m is the size of the packet sent or received by the sensor node, ε fs is the amplification parameter when the free space model is used, and ε mp is the amplification parameter when the multi-channel attenuation model is used. The distance threshold d 0 from CM node to ch node is shown in formula (3). E tx represents the energy required for the sensor node to transmit data, E da represents the energy required for the sensor node to fuse data. E c (CH j a ) represents the energy consumed by the j-th ch node in ring a to receive m bit data, and its expression is shown in formula (4).
After the CM node and CH node in the network send or receive data, they update the energy according to formula (5) and formula (6).
Among them, E t+1 S i a represents the update energy of the i-th CM node in the a ring, E t S i a represents the energy of the i-th CM node in the a ring at time t, E c S i a is the energy consumed by the i-th CM node in ring a before time t, E t+1 CH j a is the update energy of the j-th CH in ring a, E t CH j a is the energy of the j-th CH in a ring at time t, and E c CH j a is the energy consumed by the j-th CH in a ring before time t. Figure 2 shows the specific scheme of the fitness function built in the CRPL algorithm proposed in this paper. The CRPL algorithm uses the LSO algorithm to select the optimal CH of each ring in the network during the setup phase and uses the improved PSO algorithm to find the best routing path for network data transmission in the steady-state phase. The following are the advantages of the CRPL algorithm proposed in this paper.

The proposed CRPL algorithm
• Using LSO and PSO algorithms to optimize the selection of CH nodes and routing paths, not only speeds up the convergence speed, but also reduces energy consumption, and is more targeted; • A fitness objective function based on multiple factors is used to optimize CH and routing paths so that the selection of CH and the determination of the best path are more global; • This paper uses the LSO algorithm to find the optimal CH in the network, which provides convenience for finding the optimal path and speeds up the path search speed.

Brief Introduction of LSO
This paper is mainly based on the territorial defense and territorial takeover of the lion group in [31] to find the CH of each ring in the network. In the LSO algorithm, lions are divided into two categories: territorial lions T and nomadic lions Y m , of which territorial lions are further divided into male territories and female territories. It is the main task of the male territory lions to prevent the nomadic lions from invading the lions and to mate with the female territory lions to give birth to the next generation of cubs. Nomadic lions become new territory lions after they expel or kill territory lions and cubs. This behavior of nomadic lions increases the global optimization of LSO. This article assumes that the sensor node in the wireless sensor network is the lion in the lion group, and three nodes are randomly selected from the network to represent the male lion T m , the female land lion T f and the nomadic lion Y m in the lion group. The fitness functions are V m , V f and V Y , and the fitness function of the common territories lion is used as the reference value of the fitness value. At the same time, the fertility of female territory lions was evaluated according to formula (7).
where T f q and T f j represent the i-th and j-th female territory lion respectively, formula (8) is the boundary condition, and ∇ j represents the update function of female territory lion.
where r 1 and r 2 are random numbers between 0 and 1. The female territory lion completes the update according to formula (9). Due to the problems of crossover, mutation, and gender differences in cubs due to mating between female and male land lions, it is necessary to kill the weak and more sexual cubs in order to maintain the balance of the lion group and realize the regeneration of the whole lion group. At the same time, when defending the territory between the nomadic lion and the territory lion, the lion with the highest fitness value is selected as the new territory lion to realize the regeneration of the lion group. When the cubs mature, the mature male cubs take over the territory and become a new territory lion. These updating behaviors of the lion group until the maximum iteration period required by the lion group is reached.

CH Election Fitness Function
The choice of CH directly affects the energy balance of the network, and also determines the efficiency of data transmission in the network. This paper adopts the four factors proposed in formula (10) based on the remaining energy of the node, the distance from the node to the BS, the proportion of the CH node in the ring, and the number of neighbor nodes covered by the node's communication range to select the CH in the network. The CH selected in the network should meet the maximum value provided by the fitness function, and the fitness function is expressed as follows.
where E i ae is the ratio of the residual energy E i ac and the initial energy E i o of the i-th node in ring a of the network, d i ab is the ratio of the distance d i ib from the inner ring boundary to BS and the distance d i ab from the node to BS,C a is the ratio of the optimal number of CH nodes n c a in a ring to the number of nodes n a in the corresponding ring, ( 1 ≤ i ≤ c max a ,1 ≤ a ≤ n , where c max a is the maximum number of nodes per ring). The values of , β , γ and μ are constants between 0 and 1, and α + β + γ + μ = 1 . The expressions ofE i ae ,d i ab , C a and n i n are formula (11)(12)(13)(14).

Brief Introduction of PSO
The PSO algorithm [32,33], is derived from the study of bird foraging behavior. It is a global search algorithm, which formulates optimization rules for each particle. Suppose that in a D-dimensional solution space, there are N particles, each particle has the same size, and the D-dimensional vector expression of the i-th particle S i is formula (15).
Each particle has an initial position and initial velocity, and the velocity V i,k (t) and position X i,k (t) of particle S i are updated according to formulas (16) and (17).At the same time, the fitness value F f it (S i ) of the updated particle is calculated.
where c 1 and c 2 are acceleration constants and r 1 and r 2 are random numbers between [0,1].V i,k (t + 1) is the update speed of particle S i , X i,k (t + 1) is the updated position of particle S i {i = 1, 2, … , N,k = 1, 2, … , D} . w is the inertia weight of the particle. When w ∈ (0.8 ∼ 1.2) , the particle swarm algorithm has a faster convergence speed. In this paper, the expression is shown in (18): pbest i is the best position searched by a particle S i so far, that is, the individual extreme value, and Gbest k is the best position searched by particle swarm so far, that is, the global extreme value. After obtaining the new update position and speed, in order to find the optimal solution particle and the global optimal solution particle in the particle iteration process, the fitness value F f it (S i ) of particle S i is compared with the individual extreme value pbest i and the global extreme value Gbest k until the appropriate or Gbest k reaches the maximum number of iterations T max . The update formulas for pbest i and Gbest k are as follows.

Route Selection Fitness Function
The core idea of routing optimization is to find the best relay node in the data transmission stage. This paper proposes a fitness function based on four factors: the distance between CH and BS, the number of cluster member nodes, the residual energy of nexthop CH and the distance between next-hop CH and the vertical segment of the current CH connecting with BS. The optimal routing path satisfies the minimum value provided by the fitness function, and the fitness function is expressed as a formula (21).
Assuming that the current CH is located in a ring in the network, and the communication between all nodes is within the communication radius r c of the node,d c−nc denotes the ratio of the distance d a c−c from the k-th CH CH a k in a ring to the k-th CH CH a−1 p in (a-1) ring to the distance d a c−B from the k-th CH CH a k in a ring to BS. It is expressed as formula (22).
When the cluster where a CH is located is smaller, the number of CM nodes is smaller, and the data transmission delay of this cluster is smaller. C cm−ccm is the ratio of the number of CM nodes C a−cm k in the cluster where the CH CH a k is located to the number of all CM nodes C a−cm all in ring a. It is expressed as a formula (23).
d c−cB is the ratio of the distance d c−c between the p-th CH CH a−1 p in ring ( a − 1 ) and the vertical segment of the connection line between the k-th CH CH a k and BS in ring a to the distance d a c−B between the k-th CH CH a k and BS. As shown in Fig. 3, when d c−c is smaller, the routing path of CH a k nodes forwarding data to BS through relay node is closer tod a c−B . According to the shortest straight line between the two points, it can be seen that the less energy is consumed for data transmission at this time, which balances the energy consumption of the network. Where BS coordinate is ( x 0 , y 0 ), CH a−1 p coordinate is x a−1 p , y a−1 p , CH a k coordinate is | ,d c−cB expression such as formula (24). E next−c can be expressed as the ratio of the current residual energy E a−1 c of the c-th CH in ( a − 1 ) ring to its initial energy E o ,The expression is formula (25).
In the data transmission process, the CH in the first ring communicates directly with the BS, while the CH in other rings needs to be forwarded by the CH (namely relay node) in the next ring to communicate with the BS. The best routing path depends on the selection of relay nodes. When selecting relay nodes, the improved PSO algorithm fitness function is used to find the best path. The CH with a short distance to BS, fewer cluster members, and more residual energy is selected as the relay node. At the same time, the relay node should be close to the connection between the current CH and BS as far as possible to reduce the energy consumption caused by the long transmission distance in the process of data transmission. In addition, the flow chart of CRPL algorithm is shown in the Fig. 4. Fig. 3 The best route selection road map

Performance Evaluation
The CRPL algorithm proposed is a simulation experiment in MATLAB 2019a, which is mainly carried out in the ring network area with the sensing area of 400 * 400 m and 600 * 600 m. Through a large number of experiments and analyses, the simulation results of four performance indicators of the CRPL algorithm are obtained: network survival node, network energy consumption, network throughput, and network residual energy. The simulation results are compared with the classic clustering algorithm LEACH proposed in [26], the FCM-FSL algorithm proposed in [10], and the PSO routing algorithm proposed in [21]. The setting of simulation experiment environment parameters is shown in Table 1.

Analysis of Network Surviving Nodes
The lifespan of a network is related to the number of surviving nodes in the current network round. Corresponding to the number of surviving nodes in the network is the number of deaths of network nodes. Therefore, the number of death rounds of the first node in the network and the number of death rounds of half of the nodes are the best measure of the lifespan of the network. The simulation results are shown in Table 2. The change in the number of surviving nodes is shown in Fig. 5. As can be seen from Fig. 5, at the beginning of the network operation, the number of surviving nodes in the network remains unchanged. However, due to the different working principles of the CRPL algorithm, LEACH algorithm, FCM-FSL algorithm, and PSO routing algorithm, the workload of the nodes in the network is different, which causes the nodes to begin to die in different rounds of CH. According to the data in Table 1, it can be seen that the first node death in the LEACH algorithm network in Scenario # 1 and Scenario # 2 occurred in 267, 298, 68, and 60 rounds, respectively. When FCM-FSL runs 545, 692, 76, and 96 rounds respectively, the first node dies. PSO routing algorithm and CRPL algorithm adopt multi-hop communication algorithm. In the simulation results, the first node death rounds of the PSO algorithm appear in 880, 432, 102, and 83 rounds respectively.The CRPL algorithm's first node death rounds appeared in 1085, 1669, 168, and 209 rounds,the simulation results of CRPL are 75.30%, 82.14%, 59.52% and 71.29% higher than leach, 49.77%, 58.54%, 54.76% and 54.07% higher than FCM-FSL, and 18.89%, 74.12%, 39.29% and 60.29% higher than PSO. At the same time, it can be seen from Fig. 5 that the curve of the number of surviving nodes in CRPL network is always above the curve of LEACH

Analysis of Network Energy Consumption
The lifespan of a network is also inversely proportional to the total energy consumption of the network. The change of the total energy consumption of the network is shown in Fig. 6. It can be seen from Fig. 6 that with the increase in the number of CH rotations in the network, the network energy consumption continues to increase. The total network energy consumption curve of LEACH, FCM-FSL, and PSO algorithms is always above the total energy consumption curve of the CRPL algorithm network. In Scenario # 1 and Scenario # 2, the network energy consumption of the LEACH algorithm reaches 50% at 615, 645, 199, and 164 rounds respectively, FCM-FSL algorithm network energy consumption reaches 50% in 763, 996, 212, and 166 rounds respectively, PSO algorithm reaches 50% when the number of CH rotation rounds reaches 1028, 1052, 270, and 264 rounds respectively, while that of CRPL algorithm reaches 50% when the number of CH rounds reaches 1509, 1649, 514 and 737 respectively. It can be seen that compared with LEACH algorithm, FCM-FSL algorithm, and PSO algorithm, the CRPL algorithm has more obvious advantages in saving network energy consumption.

Analysis of Network Throughput
The total network throughput represents the total amount of data transmitted from the network to the BS. Figure 7 shows the change of network throughput in the simulation of Scenario # 1 and Scenario # 2. It can be seen from Fig. 7 that for all algorithms, their network throughput increases with the number of rounds of the simulation run. In addition, in the network throughput simulation results of Scenario # 1 and Scenario # 2, compared with LEACH, FCM-FSL, and PSO, CRPL has the highest network throughput. CRPL is 23.94%, 24.67%, 8.3% and 15.87% higher than Leach, 23.18%, 20.54%, 12.0% and 11.87% higher than FCM-FSL, 12.03%, 16.31%, 6.56% and 9.43% higher than PSO. This simulation result shows that the CRPL algorithm not only effectively saves energy consumption, but also ensures the amount of data transmitted over the network.

Analysis of Residual Energy
The remaining energy of the network is a key indicator to measure the network lifespan and network energy consumption, and the balance of network energy consumption can be further measured by its mean and standard deviation. Figure 8a and b are graphs of changes in the average residual energy of network nodes, and Fig. 8c and d are graphs of standard deviation changes of network residual energy. Firstly,It can be seen from Fig. 8a and b that with the increase in the number of CH rotations, the average remaining energy of the nodes in the network in the CRPL algorithm, LEACH algorithm, FCM-FSL algorithm, and PSO algorithm continues to decrease. When the nodes in the network begin to die, the decline of the residual energy curve of the network slows down. It can also be clearly seen from Fig. 7 that the average remaining energy curve of the network nodes in the CRPL algorithm is always above the remaining energy curve of the LEACH algorithm, FCM-FSL algorithm, and PSO algorithm. Secondly, it can be seen from Fig. 8c and d that the standard deviation of residual energy of each round of nodes in network operation is less than that of LEACH algorithm, FCM-FSL algorithm, and PSO algorithm, which can further show that CRPL algorithm has certain advantages in balancing network energy consumption.

Conclusion
The development of swarm intelligence optimization algorithms has brought inspiration for solving some complex distributed problems. At the same time, it is inspired to solve the problems of fast energy consumption and short network lifespan in WSN. The main purpose of this paper is to balance network energy consumption, improve network energy efficiency and prolong the network lifespan. For the above purpose, this paper proposes a cluster routing algorithm for ring wireless sensor networks based on PSO and LSO to balance network energy consumption and extend the lifespan of the network. This algorithm mainly elects CH based on LSO algorithm and uses an improved PSO algorithm to select the best routing path in the process of data transmission. Through the analysis of the simulation experiment results, in terms of network lifespan performance, the CRPL algorithm proposed in this paper increases by 72.22%, 54.28%, and 48.15% respectively compared with LEACH algorithm, FCM-FSL algorithm, and PSO algorithm. In terms of saving network energy consumption, CRPL compared with LEACH algorithm, FCM-FSL algorithm, and PSO algorithm, the algorithm has increased by 60.45%, 51.01%, and 37.69% respectively. In terms of network data throughput, the CRPL algorithm has increased by 26.46%, 30.04%, and 27.34% compared with LEACH algorithm, FCM-FSL algorithm, and PSO algorithm. The simulation experiment analysis shows that the CRPL algorithm has obvious advantages in balancing network energy consumption and extending network the lifespan, and has better scalability in networks of different scales.