Wireless Sensor Node Localization Algorithm Based on Particle Swarm Optimization and Quantum Neural Network

— Aiming at the problem of node localization in wireless sensor networks, a location algorithm for optimizing distance vector hopping (DV-hop) by constructing a quantum neural network model based on particle swarm optimization (PSO) is proposed. According to the average distance obtained by the traditional DV-HOP and the distance from the measured nodes, the quantum neural network model is constructed, and the average distance is trained by the particle swarm optimization algorithm which would shorten the training time of the traditional artificial neural network and accelerate the convergence speed. By using the proposed model, the optimal mean value is obtained, and the optimization of the DV-HOP algorithm is realized. The simulation results show that compared with the traditional DV-HOP algorithm, the proposed algorithm can reduce the positioning error by about 20%, and the positioning accuracy is significantly improved.


Introduction
In recent years, the research results of wireless sensor networks (WSNs) have been widely used in environmental detection, target tracking, military and other fields [1]. With the deep integration of WSNs theory research and practical application [2][3][4], the current research on WSNs is mainly in three aspects: the energy consumption, node deployment and node location of network nodes. The research of node location is the premise of sensor networks in many fields [5].
In the positioning process of WSNs, the localization algorithm is divided into rangebased and range-free according to whether the node position needs to be measured [6]. Actually, there are many typical range-free localization algorithms, such as Centroid algorithm, approximate triangle interior point-in-triangulation test algorithm [7], distance vector-hop (DV-HOP) algorithm [8], Amorphous algorithm and so on. Their common advantages are simple implementation, no additional hardware, strong viability of network and low cost. So they are often used in the positioning of WSNs.
What is worth mentioning here is that we mainly focus on range-free localization algorithm, especially DV-HOP. The traditional DV-HOP algorithm mainly relies on the estimation of the average hop distance in the process of WSNs node localization. The misbehavior nodes in the network will result in the unreasonable hops information obtained, so that there is a large error in the average single-hop distance obtained from the hop information. As a result, the accuracy and efficiency of WSNs node localization decrease sharply, which makes the positioning process is fuzzy and uncertain. Therefore, we use particle swarm optimization (PSO) algorithm as the learning mechanism of quantum neural network (QNN) [9], and propose a PSO-QNN localization algorithm for WSNs. By combining the two algorithms, a node localization model with short learning time, fast convergence speed and high precision is constructed, and after training, quantum neural network obtains the best initialization weights and thresholds. As a result, when the model is applied to DV-HOP algorithm, a better average hop distance is obtained, thus improving the positioning accuracy of nodes. Besides, simulation results show that the algorithm has greatly improved the positioning accuracy and efficiency.  In Figure 1, A is the anchor node, and the communication radius is r, the I, II and III regions are the first, second and third hop restricted regions of anchor node A.

DV-HOP Algorithm
Effectively, the DV-HOP algorithm [10] can be divided into three stages: 1) The anchor node broadcasts the location information and hops in the network to the whole WSNs. The initial value of hops is 0, and the minimum hop value of each anchor node is recorded by the location node, and the hop value is increased by 1 and forwarded to the neighbor node. At the moment, all nodes get the minimum hops of their own to the anchor nodes through the distance vector exchange protocol; 2) The actual average distance between each anchor node and the other anchor nodes is calculated by each anchor node's position information and the distance with the other anchor nodes, which are recorded by the stage A. (1) Where (xi, yi)(xj, yj) are the position coordinates of node i and node j respectively. hij is the number of hops between anchor node i and anchor node j. Then, the average hop distance as the correction value is broadcast throughout the whole WSNs. When the first correction value is received, the pending node will save it and then no longer receive other correction values. According to the correction value, convert the minimum hop count between the node and anchor node to the distance of them; 3) When the location node gets three or more than three anchor nodes, the nodes to be located can be obtained by three or multilateral measurements.

Quantum neural network
The back propagation (BP) neural network consists of three layers: input layer, hidden layer and output layer. In BP model, input layer LA, output layer LC and hidden layer LB are composed of m, n and p nodes respectively. Moreover, the nodes of the same layer are not connected, and the adjacent layer nodes are all interconnected.
The output of the hidden layer LB of traditional BP neural network can be expressed as follows: (2) The output of the output layer LC can be expressed as follows: where the corresponding relationship is function (it is also called S growth curve), that is, ( ) = (1 + 01 ); is the input of the neural network, the neuron of the input layer is represented by 4 , in the same way, the hidden layer is 6 , and the output layer is 8 . Besides, 46 is the connection weight between the input layer neuron and the hidden layer neuron; 68 is the connection weight between the hidden layer neuron and the output layer neuron; is the threshold of the hidden layer, and is the threshold of the output layer.
For quantum neural network model [11][12][13][14], the multiple Sigmoid functions are superimposed, and a hidden layer neuron can represent a number of orders of magnitude, thus constructing an incentive function of a sandwich-like structure, it makes the fuzziness of the network increase substantially. Now, the hidden layer output can be expressed as follows: Where D is the number of quantum intervals, which is the same as the number of faults. Meanwhile, F is a steepness factor, 6 is a quantum interval.
The gradient neural network algorithm is still used in the training algorithm of layered excitation function. In the training process, the updated contents include the connection weights between different layers of neurons and the quantum spacing between neurons in the hidden layer.
Here, the updating of connection weights is no different from that of BP neural network. And the quantum interval algorithm for hidden layer neurons is updated.
For the pattern class vector F (m is the number of pattern class, that is, the number of neurons in the input layer), so the output variables of the j neurons in the hidden layer can be expressed as follows: where 8,J is the output of the j neurons in the hidden layer when the input vector is J .
By minimizing the total class variance 8 L , the renewal equation of the hidden layer quantum interval 8 6 can be obtained, and the quantum interval of the j neurons in the hidden layer can be expressed as follows: Where is the learning rate, and F is the steepness factor.

Particle swarm optimization algorithm
For particle swarm optimization algorithm, suppose that there is a n dimension target search space composed of m particles, then the position of the p particle in d dimension space is (8) Flight speed can be expressed as follows: The fitness value is expressed as follows: The algorithm has two extremes: the best solution found by each particle itself; the best location found by the whole particle swarm. The position and velocity of particle p in the d dimensional space are updated according to the following iterative equation: where RS J represents the flight speed of the first iteration of the particle in the d dimension space; then RS J is the position of the particle in the d dimensional space for the iteration; () is a random number between [0, 1]; W and L are both learning factors. The particle search will stop at the best location or the maximum number of iterations. The PSO algorithm flow is shown in Figure 2.

Algorithm implementation steps
Assuming that the number of anchor nodes is P, and the number of nodes to be positioned is M. Then the whole WSNs node localization steps are as follows: . PSO algorithm has a very strong searching ability, which can obtain the global optimal solution for each particle. 3. After establishing the model, the anchor nodes and the nodes to be located are distributed in WSNs. Each anchor node regularly broadcasts its own related parameters in the WSNs, including the node coordinates and the parameters of the quantum neural network. All nodes get the minimum hop count to the anchor node through the distance vector exchange protocol. 4. According to the location information and hop count of each anchor node recorded to other anchor nodes, the average distance per hop is calculated by Eq. (1). 5. The average hop distance ^_0`ab ccccccccccc obtained in step (4) is used as the input of the PSO-QNN model, then the optimized distance value bda0eff cccccccccccc , i = 1,2,3, … can be obtained at the output of the model. is the number of selected anchor nodes. 6. According to the average hop distance bda0eff , it will be broadcast as a correction value in the whole WSNs. 7. When the first correction value is received and saved by the location node, it is forwarded to the adjacent node, and the location node calculates the hop distance to each anchor node according to the corrected value and the recorded hops information. 8. When the location node gets three or more than three anchor nodes, the nodes to be located can be obtained by three or multilateral measurements.

Algorithm specific description
The initialization of PSO algorithm is the process of finding the optimal solution through a continuous population iteration of a group of randomly distributed particles. By comparing the optimal solution of the new generation with the previous generation, the optimal value is updated, such as Eq. (11) and Eq. (12). Matlab is used to build the simulation environment of the logarithmic -constant distribution model. According to the measured node distance { 48 , i ≠ j} and the average distance * { 48 * , i ≠ j}, the quantum neural network model is constructed based on the traditional DV-HOP algorithm. In this way, the average distance * is trained by the PSO algorithm, thus the better average value is obtained.
First of all, we should select corresponding data to learn and train QNN, so as to form a practical model applied to WSNs positioning. We trained the parameters of QNN through PSO. The parameters for QNN to be trained are the × parameter and the parameter contained in hidden layer nodes, then the × parameter and the parameter of the output node nodes, where , and are the number of nodes in input layer, hidden layer and output layer, respectively. Besides, is the weight between the neurons, and the threshold is . The connection weights between neurons are mapped to the positions of the particles in the PSO algorithm, then the dimension of the particle swarm is × + × + + . After initializing the particle swarm, the iterative process is carried out according to the algorithm steps, until the position of the particle with the minimum mean square error (MSE) is produced. At this time, the dimension values of the particle position are the optimal initial weights and thresholds.
Assuming that the number of training samples is N, and the MSE of the network is expressed as follows: (13) Where the tij in the formula is the expected output value of sample i on the j output terminal.
The coordinates of the nodes to be positioned in the three side or the multilateral measurement method are (x, y) . The coordinates of the anchor nodes are (x W , y W ), (x L , y L ), (x o , y o ), … , (x p , y p ), in this way, the distance from the location node to the anchor node can be expressed as d W , d L , d o , … , d p , respectively.
Especially, let Here, , according to Eq. (14), it satisfies the relationship = . By simplification, the following relationship can be obtained (15) Accordingly, the position coordinates of the nodes to be located can be obtained by the Eq. (15).

Simulation Results
The experiment is carried out in Matlab7.0 simulation environment, which is specifically configured as Intel (R) Core (TM) i3-2370M CPU, 2.40GHz, and 4GB memory platform. In the simulation experiment, a node location detection area of 100 × 100 is constructed. More specifically, the communication radius of the node r is set to 25m, which contains 150 sensor nodes and is deployed randomly. In the PSO algorithm, the number of initialization of the particle swarm m is set to 40, the maximum iteration number Q is set to100, W and L are the learning factor, their value both are 1.8. Additionally, the anchor node and the location node are distributed as Figure 3.

The number of anchor nodes' influence on positioning error
The nodes are located according to the implementation steps of the proposed algorithm, and then the average positioning error is obtained based on the simulation results [15][16]. The average location error is defined as (16) From Figure 4, we can see that in the same environment, the location error of the algorithm is much lower than that of the traditional DV-HOP algorithm. Additionally, the weighted centroid algorithm is selected as the contrast algorithm. It can be seen that the average positioning error of the three algorithms decreases with the increase of anchor nodes. As a consequence, the average location error of the proposed algorithm is about 26%, in comparison, the weighted centroid algorithm is about 38% and the traditional DV-HOP algorithm is about 48%. Thus this algorithm reduces the average positioning error by about 20% compared with the traditional DV-HOP algorithm.
Due to the large error in the process of hopping to distance, the algorithm requires the nodes to be positioned should have a high density in the implementation process. The simulation results are shown in Figure 5, with the increase of the density of the nodes to be located, the duration of the 3 algorithms is reduced. Accordingly, the time required in this algorithm is reduced by about 100ms compared with the traditional DV-HOP algorithm. Information can be transmitted directly between nodes by using DV-HOP algorithm. Actually, connectivity mainly reflects the relationship between the number of anchor nodes and the radius of communication. In view of that, the experiment compares the positioning error by analyzing the change of connectivity. From Figure 6, we can see that with the increase of connectivity, the average positioning error of the three algorithms is decreasing in general. Therefore, under the same connectivity, the positioning error of the proposed algorithm is the smallest.

Conclusions
In view of the problem that DV-HOP algorithm is easily affected by the external environment factors during the location of WSNs nodes, PSO-QNN algorithm is proposed. Compared with the traditional BP neural network [17], QNN accelerates the convergence speed of the algorithm, and more importantly, it reduces its fuzziness. Furthermore, by using the PSO algorithm as the learning algorithm of QNN, we constructed the PSO-QNN network model, and the DV-HOP algorithm is further improved. The data obtained are analyzed through simulation experiments from three aspects, and the results show that the positioning accuracy of this algorithm has been greatly improved, up to about 20%, which proves the effectiveness of the algorithm in the node location.