Area double cluster head APTEEN routing protocol-based particle swarm optimization for wireless sensor networks

APTEEN is a typical routing protocol for wireless sensor networks, but when clustering, cluster heads are randomly selected, which makes it easy to select nodes with low residual energy as cluster heads, thus forming network holes. At the same time, in multi hop transmission, the cluster head near the sink node is overloaded due to forwarding a large amount of data. Aiming at these problems, this paper introduces PSO algorithm and proposes ADCH-EPE-APTEEN routing protocol. In order to make the particle swarm optimization algorithm more suitable for routing protocol, this paper first proposes DCA-PSO based on particle swarm optimization algorithm. DCA-PSO uses the classification adaptive change inertia weight for different states of particles in the optimization process. At the same time, dynamic learning factor is used to improve the influence of particle experience and other particle experience on convergence speed and to improve the optimization accuracy and speed of the algorithm. Secondly, when APTEEN routing protocol is networked, the cluster head is selected by DCA-PSO, in which the residual energy of nodes, the location of nodes, and the energy distribution around nodes are fully taken into consideration. Thirdly, considering the distance between nodes and the sink node, the residual energy and the energy distribution around nodes, a front area is set up in the cluster located in the upper half and the assistant cluster head is selected in the front area through the DCA-PSO algorithm. The simulation results show that the DCA-PSO algorithm can significantly improve the search speed and precision compared with the PSO algorithm. Compared with APTEEN routing protocol, the ADCH-EPE-APTEEN routing protocol can reduce the network energy consumption rate and extend network lifetime by 173%.

1 Introduction 2 Particle swarm optimization and wireless communication model

Particle swarm optimization
Particle swarm optimization (PSO) [7][8][9] is a population based on intelligent optimization algorithm proposed by Eberhart and Kennedy. The proposed algorithm originates from the observation of birds' foraging behavior. When birds forage in the air, they do not know the specific location of food at first, but birds can always change their flight direction by sharing information among individuals, so they can get closer to the right food location and finally find food. The advantage of the PSO algorithm is that it is simple and easy to implement [10]. At present, it is widely used in various fields such as function optimization.
When using PSO algorithm to optimize the practical problem, the bird is abstracted as a particle, and the solution of the optimization problem corresponds to the location of the particle in the search space [11]. In the algorithm, the particle needs to calculate its own fitness function value according to the fitness function, in order to judge the pros and cons of its current position. The flight speed and position of the particle are represented by vectors, and the particle updates its own motion formula and position by updating the following two extreme values. One is the current individual optimal value gbest, which represents the optimal position found by the particle itself. The other is the collective optimal value pbest, which represents the best location for the entire particle population to find. The update formula for particle position and velocity is shown in Eqs. (1) and (2).
where v ij is the velocity vector of particle i in j-dimensional space, and its value range is [v min , v max ], x ij is the position vector of particle i in j-dimensional space, p ij is the individual optimal value of particle i, and p gi is the collective optimal of all particles. Values r 1 and r 2 are random numbers from [0, 1]. c 1 and c 2 are learning factors. w is inertia weight coefficient. The value of w is related to the influence of the particle's historical value on the current value. When the value of inertia weight coefficient w is large, it can enhance the overall search ability of particles. When the value of inertia coefficient w is small, it can enhance the local search ability of particles [12].

Wireless communication model
The wireless communication model commonly used in wireless sensor networks is shown in Fig. 1 [13]. The energy consumption of the transmitter node is mainly composed of two parts: the transmitting circuit and the power amplifier. The energy required to transmit the k-bit data is: The energy consumption at the receiving end of the sensor node only includes the energy consumed by the receiving circuit.
where E elec is the energy consumed by the sensor node for each 1-bit message received or transmitted, and ɛ fs and ɛ amp are the power amplification factors under different conditions. Assuming that the data propagation model in the cluster is a free space model, the energy consumption of normal nodes in each round is shown in formula (6).
Assuming that the data propagation model sent by the cluster head is a multipath spatial model, the energy consumption of cluster head in each round is shown in formula (7).
where n is the number of cluster heads and E DA is the energy consumed to fuse each bit of data. The energy consumption of each cluster in each round is shown in formula (8).
3 Dynamic Classification Adaptive Particle Swarm Optimization (DCA-PSO) In particle swarm optimization, the inertia weight is fixed, which means that the acceleration coefficients of each particle are the same, so it is impossible to further adjust the running speed of the algorithm and the accuracy of the optimal solution. For particles with higher fitness values, the locality should be emphasized, and the fitness function value should be smaller. For particles with lower fitness values, the global value should be emphasized, and the fitness function value should be larger. Therefore, this paper introduces an adaptive change function based on the original particle swarm optimization algorithm and adjusts the inertia weight value to: where w max denotes the maximum inertia weight, w min denotes the minimum inertia weight, f(i) denotes the current fitness function value of each particle, f min denotes the minimum fitness function value in the population, and f avg denotes the average value of the current fitness function in the whole population. The values of learning factors c 1 and c 2 determine the self and social-cognitive abilities of individual particles in the algorithm. If the c 1 value is too large, it will cause too many particles to stay near the local area; if the c 2 value is too large, it will cause the particles to reach the local optimum value ahead of time and converge to this value. The algorithm should have a larger c 1 value and a smaller c 2 value in the initial stage, so as to enhance the self-recognition ability of the particles, which is conducive to enhancing the global search ability of the algorithm in the initial stage of operation. In the later stage, there should be smaller c 1 and larger c 2 values, so that more particles can learn from the global optimum, which is conducive to strengthening the ability of local fine search in the later stage of the algorithm. Therefore, the values of learning factors A and B are adjusted as shown in formulas (10) and (11): where c 1ini and c 1fin represent the starting and final values of accelerator c 1 . c 2ini and c 2fin represent the starting and final values of accelerator c 2 . k represents the number of current iterations; T max represents the maximum number of iterations.
By substituting formula (9), formula (10), and formula (11) into formula (2), a new speed updating formula can be obtained: The specific steps of DCA-PSO are shown in Fig. 2.

Particle Swarm Optimization Cluster Head Selection Algorithm
It is assumed that N static nodes whose initial energy is E0 are randomly distributed in the M × M region. At the same time, it is assumed that the wireless sensor network built by the group has the following characteristics: (1) All nodes have unique IDs and are randomly distributed in the monitoring area.
(2) Each node can locate its own coordinate position.
(3) All nodes are fixed and energy is limited, base station is fixed, but energy is not limited. (4) All nodes can obtain their own residual energy, and the communication power can be adjusted. The node can adjust the transmission power according to the distance.
The sensor nodes in this paper can be divided into two types: common node and cluster head node. The cluster head node can communicate with a cluster head node that is within its communication range and closer than the base station, but the next hop can only be one of the nodes. The sensor node can also communicate with cluster head nodes in its communication range, and the sensor node can belong to any cluster head node in its communication range. Sensor nodes have a list of cluster head nodes, but each sensor node can only specify one of them. Data acquisition and transmission work adopts recycling mechanism. In each round, all sensor nodes collect local data and send it to the corresponding cluster head node. Once the cluster head node receives the data, it will fuse the data, discard redundant and irrelevant data, and send the fused data directly or through other cluster head nodes to the base station.

Pre-clustered
In a wireless sensor network, the energy consumption of the entire sensor network in each round is shown in Eq. (13).
The total energy consumption in the network is a function related to the number of cluster heads n, and the optimal number of cluster heads can make the network life cycle longer. In the initial stage of the network, the base station collects energy and coordinates information of all nodes and calculates the optimal number of cluster heads in the network k opt according to formula (14).
Then, based on the collected energy information, the base station calculates the average energy remaining E avg in the network according to formula (15), selects k opt node as the preselected cluster head according to formula (16), and divides the clusters by the network.

Optimize cluster head selection
After the pre-clustered phase, the cluster head is adjusted by considering the energy, position, and energy balance of each node. This paper reduces the computational complexity by introducing the DCA-PSO algorithm.
In order to make the DCA-PSO algorithm suitable for optimizing the cluster heads' selection problem, the formula (1) and the formula (12) need to be adjusted. Since the distribution of nodes can be imagined as a plane space, we need to split the velocity and position vectors into components in both the x-axis and the y-axis. Formula (1) and Formula (12) are split into: In order to avoid the particle search range beyond the desired region during the iterative process, this paper adds restrictions on the speed and position of the DCA-PSO algorithm. The specific conditions are as follows: x k iy ¼ where v ixmin , v iymin , v ixmax , and v iymax represent the minimum and maximum velocities of particles on the x-axis and y-axis respectively; x ixmin , x iymin , x ixmax , and x iymax represent the minimum and maximum positions of particles on the x-axis and y-axis respectively.
Since the network nodes are discretely divided in the wireless sensor network, the particle swarm optimization algorithm is designed for continuous problems. The values calculated by the nodes according to formula (17) cannot be mapped to the corresponding network nodes one by one, so need to adjust the position obtained by the algorithm, so that the adjusted x ix ∈{P 1x ,P 2x ,…,P nx },x iy ∈{P 1y ,P 2y ,…,P ny }. P ix is the x-axis component of the i-th node in the cluster, and P iy is the y-axis component of the i-th node in the cluster. Order ΔP jx = |x ix − p jx |,ΔP jy = |x iy − p jy |, ΔP jx represents the absolute value of the difference between x ix and the x component of node j in the cluster, and ΔP jy represents the absolute value of the difference between x iy and the y component of node j in the cluster. Let ΔP k = min{ΔP 1 , ΔP 2 ,…,ΔP n }. It indicates that the position of the k-th node in the network is the closest to the distance of x i , so adjust x ix ≈ P kx , x iy ≈ P k , that is, the point of the search is located at the position of the node k.
The fitness function is an important indicator when the DCA-PSO algorithm selects the optimal value. In order to solve the problem of uneven energy consumption between cluster heads and common nodes in APTEEN protocol, this paper mainly sets up fitness functions in three aspects: (1) residual energy of nodes, (2) average distance within clusters, and (3) the energy distribution around nodes.
In the network, because the cluster head needs to forward the information of each node, it consumes a lot of energy. Therefore, the amount of remaining energy is an important factor in the selection of cluster heads.
The energy consumption of sending messages is proportional to the transmission distance. In order to reduce the energy consumption of the entire network, the position of the cluster head in the cluster should be close to the geometric center of the entire cluster. R(j) is the distance from node j to node i.
The energy distribution around nodes is an important condition for measuring the energy distribution of selected cluster heads and surrounding nodes. The higher the node distribution around nodes of the selected cluster head, the more balanced the energy distribution in the network, and the life cycle of the network can be maximized.
Based on the above three influencing factors, the fitness function modeled in this paper is as follows: where a, b, and c are the weights of the fitness function impact factor, the value range is [0, 1], and a + b + c = 1. By adjusting the weight value, the performance of the algorithm can be emphasized. The smaller a value can make the network more effective to avoid the network void, a smaller b value can make the cluster more compact, and a smaller c can make the network energy distribution more uniform. As long as the value of f(i) is smaller, the overall life of the network will be longer.

Select assistant cluster head
In multi hop transmission, the cluster head near the sink node is overloaded due to forwarding a large amount of data. It is necessary that reducing the energy consumption of the cluster head near the sink node and avoiding the energy waste caused by the nodes near the sink node returning the information to the cluster head is necessary. After the selection of the main cluster head in the cluster is completed, a front area is set in the cluster located in the upper half of the monitoring area, and an assistant cluster head is elected again in the front area.
The front area is shown in Fig. 3. In the figure, the sink node is the base station, node i is the cluster head, and node j is the node farthest from cluster head i within the cluster. Make circle 1 with i as the center, d (i, j) as the radius, and circle 2 with sink as the center and d (i, sink) as the radius. The intersection of circle 1 and circle 2 is called the front area of the cluster. As shown in Fig. 4, according to the distance between the cluster head and the sink node, the data transmission mode of the nodes in the front area can be divided into two situations. If d (i,j) ≤ d (i,sink), the nodes within the front area is transmitted date to the assistant cluster head. If d (i,j) > d (i,sink), then the nodes within the front area directly transmit the date to the sink node to alleviate the energy consumption of the cluster head.
In order to alleviate the energy consumption of cluster heads and reduce the energy waste caused by the nodes near the sink node returning the information to the cluster head. This paper sets the fitness function in three aspects when selecting assistant cluster heads: (1) residual energy of nodes, (2) distance between nodes and sink node, and (3) the energy distribution around nodes.
The front area is close to the sink node, and the assistant cluster heads are mainly used to alleviate the energy consumption of cluster heads and reduce the unnecessary energy waste caused by information return. Therefore, when selecting the assistant cluster head, the distance between the assistant cluster head and the sink node is very important.
Based on the above three influencing factors, the fitness function for selecting the assistant cluster head is as follows: The value range of d, e, f is [0, 1], and d + e + f = 1. As long as the value of f a (i) is smaller, the effect of cluster head is better, the overall life of the network will be longer.
The data transmission diagram of ADCH-EPE-APTEEN is shown in Fig. 5. The specific process of ADCH-EPE-APTEEN algorithm is shown in Fig. 6.

Simulation and analysis
In order to verify the performance of the proposed algorithm, the algorithm is tested and simulated on the Matlab simulation platform. The experimental scenario is that 100 nodes are randomly distributed in the region of 100 m × 100 m, the initial energy of the node is E 0 = 0.1 J, the base station coordinates are at (50,50), and the data fusion degree is 60%. When transmitting and receiving data, only the energy consumption of data transmitted and received is considered, Among them, consumes energy is E elec = 50 nJ/bit. Under the same population size, the randomization process of PSO algorithm and DCA-PSO algorithm to the same objective function is shown in Fig. 7. As can be seen from the figure, the output of PSO algorithm is no longer significantly changed at about 70 rounds, while that of DCA-PSO algorithm tends to be stable at about 30 rounds, and the output of PSO algorithm is obviously inferior to that of DCA-PSO algorithm due to falling into local optimal. This shows that this algorithm can accelerate the convergence speed and enhance the search ability.
In order to highlight the improvement of network in life cycle, in the simulation model, APTEEN protocol is compared with the EDD-APTEEN protocol which is improved cluster heads selection based on energy and location factors, and the ADCH-EPE-APTEEN optimization protocol. As can be seen from Fig. 8, the first dead node appeared in the original APTEEN clustering method in about 100 rounds, and all the nodes died in about 350 rounds. EDD-APTEEN algorithm has the first dead node in 300 rounds and all the dead nodes in 600 rounds. The ADCH-EPE-APTEEN algorithm showed the first dead node in 500 rounds, and all died in about 1000 rounds. This shows that the algorithm can extend the lifetime of the network.
As can be seen from Fig. 9, because the ADCH-EPE-APTEEN algorithm considers the location problem and the energy distribution equilibrium problem when the cluster heads are selected, the transmission energy consumption is significantly reduced. And because algorithm elect the assistant cluster head to ease the cluster head energy consumption, the energy consumption rate is also significantly slowed down. It can be seen that the ADCH-EPE-APTEEN algorithm can reduce the energy consumption in the network.

Conclusions
Aiming at the problem of slow convergence speed and being easy to fall into local optimum of particle swarm optimization, an improved DCA-PSO algorithm is proposed. The algorithm proposes that the inertia weight and acceleration factor be adaptively adjusted at the same time to enhance the global search ability in the initial search stage and the local search ability in the later search stage. The network simulation shows that DCA-PSO algorithm can significantly improve the search speed and accuracy compared with PSO algorithm. Meanwhile, aiming at the problem that APTEEN routing protocol is easy to select low-energy long-distance nodes in cluster head selection, and in multi hop transmission, the cluster head near the sink node is overloaded due to forwarding a large amount of data, a new ADCH-EPE-APTEEN algorithm is proposed in which the optimal number of cluster heads is added at the stage of cluster head selection to control the proportion of selected cluster head nodes and the DCA-PSO algorithm is introduced. Algorithm optimizes cluster head selection through high energy and energy distribution balance between close distance and surrounding nodes. And algorithm also set front area to ease the cluster head energy consumption. Network simulation shows that the algorithm can significantly prolong the survival time of the entire network; at the same time, it can slow down the network energy consumption rate and improve the network energy utilization efficiency.

DCA-PSO
The search accuracy of DCA-PSO is about 30% higher than that of PSO, and the convergence speed is about 50%. It can be seen that the convergence speed and accuracy of DCA-PSO are greatly improved than that of PSO, and the algorithm is more stable and more suitable for cluster head optimization in wireless sensor networks.

ADCH-EPE-APTEEN
ADCH-EPE-APTEEN delays the time of node death, balances energy consumption, and extends network lifetime further operating in the same settings compared with APTEEN. The proposed algorithm has good scalability, and it is suitable for large-scale network. The reason is that ADCH-EPE-APTEEN optimizes the cluster head selection, and alleviates the energy consumption of cluster head near sink by means of double cluster heads.

DCA-PSO
DCA-PSO adopts adaptively changing inertial weight coefficients, continuously changes the inertial weight coefficients for particles at different positions, and adjusts the global and local search capabilities of particles. At the same time, the algorithm adjusts the fixed learning factor to a dynamically changing learning factor. The global search ability of the algorithm is enhanced at the initial stage of operation and the ability of local fine search is enhanced at the later stage.

ADCH-EPE-APTEEN
ADCH-EPE-APTEEN is the optimization of APTEEN. In order to prevent cluster head nodes from dying prematurely and forming network holes, ADCH-EPE-APTEEN introduced the DCA-PSO algorithm to optimize cluster head selection through three conditions: the remaining energy of the node, the position of the node in the cluster, and the energy distribution around the node. At the same time, in order to avoid the excessive energy consumption of nodes close to sink, the algorithm sets a front area in the upper half and selects the assistant cluster head to reduce the pressure of cluster head nodes. Compared with APTEEN, the ADCH-EPE-APTEEN algorithm can significantly prolong the survival time of the entire network; at the same time, it can slow down the network energy consumption rate and improve the network energy utilization efficiency.