# A Two-Stage Wireless Sensor Grey Wolf Optimization Node Location Algorithm Based on K-Value Collinearity

Authors: Yinghui Meng; Qianying Zhi; Qiuwen Zhang; Erlin Lin
Journal: Mathematical Problems in Engineering
 (2020)

---

## Abstract

In the practical application of WSN (wireless sensor network), location information of the sensor nodes has become one of the essential information pieces in the whole network. At present, some localization algorithms use intelligent optimization algorithm to optimize the node group directly. Although the overall localization error is reduced, the location deviation of individual unknown nodes will be larger, and the large number of iterations will cause a large energy consumption of nodes. Aiming at the above problems, this paper comes up with a two-stage WSN localization algorithm based on the degree of K-value collinearity (DC-K) and improved grey wolf optimization. The first stage is aiming at the defects of the existing collinearity algorithm, putting forward the concept of DC-K, according to the K-value to carry out the initial location in the first stage. The second stage is using the improved grey wolf optimization algorithm to optimize the location results which were obtained in the first stage, so as to get more accurate location results. The experimental results display that this localization algorithm with a better localization accuracy has high robustness and has fewer iterations in the optimization process, which greatly reduces the energy consumption of nodes.


---

## Body

## 1. Introduction

Localization is to identify the coordinates of something in a geographical environment. The significance of node localization technology in WSN is to deduce the coordinates about the unknown nodes which are located in the network. Due to the continuous development and progress of sensing technology, the use of the WSN (wireless sensor network) is more and more powerful. At present, the application of WSN in transportation, medical and electrical appliance, and other areas of life is wide. WSN deploys a large number of stationary or mobile sensor nodes in the area to be monitored, making these sensor nodes form a network system through radio communication. The purpose is to collaboratively perceive multidimensional information within the monitoring area (such as humidity, temperature, noise, geological characteristics, and life characteristics) and then process and transmit the collected data. When the sensor node is working, firstly, the node sends it, collecting the physical, chemical, biological, and other information to the terminal computer, and then feeds back the information to the user. Finally, the user makes corresponding operations according to the information. In most applications, the information sent back by the node must be combined with the coordinate of the node to make sense. Sometimes, it is even necessary for the node to simply send the location information. In conclusion, sensor node location is the critical technology in sensor networks.At present, according to whether it is necessary to acquire the angle information or distance information between nodes through physical measurement, sensor node location technology could be divided into two parts that are range-free algorithm and range-based algorithm [1]. Due to the use of measuring equipment, the location accuracy of range-based is higher, such as RSSI (received signal strength indication). However, the cost of adding additional distance measurement equipment to the node is very high; the lifetime of the sensor node is also greatly shortened by frequent receiving of ranging information. In addition, this method fails in extremely complex geographical environments. The range-free technique is using the localization algorithm to estimate the Euclidean distance from the unknown sensor nodes to the beacon sensor nodes or estimating the possible area containing the unknown node according to some nodes with known coordinates (beacon nodes) and then inferring the coordinates of the unknown nodes [1]. This type of technology does not require hardware ranging modules. The classical range-free node localization methods are such as DV-hop (distance vector-hop algorithm), centroid algorithm, and APIT algorithm (approximate point-in-triangulation test). Range-free technology does not require additional hardware support; its advantages are easy implementation, having low cost, low energy consumption, and high computational efficiency, compared to the range-based algorithm which can be more suitable for the actual application of the sensor network.For increasing the location accuracy of range-free location technology, many experts and scholars have studied and improved the DV-hop, which can be divided into two steps. So, the first stage is to estimate the Euclidean distance of beacon nodes to unknown nodes. And the second stage is to infer the coordinates of the unknown nodes from the distance. For raising the accuracy of distance estimation from unknown nodes to beacon nodes, in [2], a search algorithm for similar paths is proposed to find a path between beacon node pairs with the highest similarity according to the Ochiai coefficient and calculate the single hop correction value according to the hop’s number and the Euclidean distance of the pair of beacon sensor nodes, thus raising the accuracy of Euclidean distance estimation; in [3], it is assumed that the communication radius of the sensor node is R, and the one-hop’s distance within the whole wireless sensor network is modified to R/2, which reduces the error within the one-hop range; in [1], the authors put forward the concept of intersection ratio; first, they calculated the area of intersection between the unknown node and the neighboring beacon node communication circle, then they calculated the ratio of this area to the entire communication range, and finally they estimated the distance between the unknown node and the beacon node according to the ratio. In the second stage, more and more scholars apply the intelligent optimization method to location estimation of wireless sensor node; in [4], PSO (particle swarm optimization algorithm) is introduced, through hundreds of iterations of the particle swarm optimization model; the coordinates of the unknown nodes that are consistent with the fitness function are finally obtained; implementing localization algorithm [5] improved the particle swarm optimization localization method and came up with the concept of quantum particle swarm, choosing the wave function to describe the state of the particle and increasing the location accuracy, but the computational cost is higher. At present, there are few improved two-stage localization algorithms for both distance estimation and coordinate calculation. In summary, the existing researches still have large errors in the distance estimation stage; in the second stage, particle swarm optimization, simulated annealing optimization, and other intelligent optimization algorithms are used directly, which can easily fall into local optimization and cause huge energy consumption due to too many iterations. However, the existing two-stage positioning algorithm directly refers to DV-hop and intelligent optimization algorithm which cannot solve the defects of intelligent optimization algorithm that consumes too much energy and easily falls into local optimization. In this paper, aiming at the shortcomings of the above studies, we came up with a two-stage wireless sensor grey wolf optimization node localization algorithm based on K-value collinearity. In the first stage, according to the defects of collinearity [6–8], in this paper, we propose the new collinearity based on K-value and then infer to the initial location of the node from the collinearity of K-value; in the second stage, the improved localization algorithm of GWO is used to optimize the node location. Experiments show that two-stage DC-K localization method could raise the location accuracy effectively. In the optimization stage, only 30 iterations are needed to obtain a better location result, which greatly reduces the energy consumption of nodes.


## 2. Selection of Location Unit Based on Collinearity

### 2.1. Error Analysis

After obtaining the Euclidean distance which is from beacon nodes to unknown node, localization algorithms perform the trilateral measurement or maximum likelihood method to infer the coordinate of unknown sensor nodes. In the process of location estimation, the location topology between beacon sensor nodes and topology shape from beacon nodes to unknown nodes will greatly affect the localization accuracy [9]. Generally, the more uniform the distribution of beacon nodes is, the more accurate the localization will be. In the following, we take three beacon nodes as an example to discuss the influence of location topology between nodes on localization accuracy.Figure 1
Two beacon nodes in the localization unit are close to each other.Figure 2
Beacon nodes in localization units are collinear or approximately collinear.Figure 3
Three beacon nodes in the localization unit are close to each other.Case 1.
When any two of the three beacon nodes of the localization unit are too close to each other, meanwhile, the unknown sensor node is very far from the two beacon sensor nodes and there will be a large localization error. As is displayed in Figure1, A, B, and C are beacon sensor nodes and D is unknown sensor node in the localization unit, compared with the distance from node D to the localization unit; the distance between B and C is easy to be ignored; therefore, the localization result of the unknown node D may appear at the location of D′, which causes a large localization error.Case 2.
When the beacon nodes in the localization unit are collinear or close to collinear, the localization matrix is irreversible, resulting in a large localization error and even leading to the localization failure. From Figure2 we could get that when the beacon nodes A, B, and C are close to collinear, then the unknown node D is located that will lead to the localization result which may be at the location of D′.Case 3.
When the three beacon nodes in the localization unit are very close to each other and the unknown node is very far away from the localization unit, it will cause a large localization error. As shown in Figure3, A, B, and C are beacon nodes, D is unknown sensor node, and D′ is localization result that may occur.


### 2.2. Degree of Collinearity Based on Minimum Height (DC-H) and Minimum Cosine of Interior Angle (DC-A)

In [8], the authors came up with the concept of collinearity. According to the collinearity estimate for whether the topological shape between beacon nodes is suitable for localization, this came up with the concept of DC-H. As shown in Figure 4, ΔABC is a triangle formed by beacon nodes A, B, and C. The minimum height is the minimum value of three heights in ΔABC (the height on the longest side). Therefore, the value of minimum height is the collinearity of the three beacon nodes:(1)DC−H=minhi,i=1,2,3.Figure 4
Diagram of DC-H.Under this definition, the value range of collinearity is0,3/2R; the communication radius of the nodes is R, which is in the network. When the degree of collinearity is equal to 0, it indicates that the nodes A, B, and C are collinear and the localization accuracy is the worst; when the degree of collinearity is equal to 3/2R, beacon sensor nodes A, B, and C constitute an equilateral triangle, which is most suitable for locating unknown node. In summary, when the minimum height is closer to 3/2R, the localization accuracy is higher.According to [7], the interior angle size of a triangle can better reflect the shape of a triangle; therefore, the degree of collinearity is defined by the cosine of the minimum interior angle, as shown in Figure 5. ΔABC is a triangle formed by beacon nodes A, B, and C:(2)DC−A=maxcosA,cosB,cosC.Figure 5
Diagram of DC-A.InΔABC, the cosine of the three interior angles is(3)cosA=b2+c2−a22×b×c,(4)cosB=a2+c2−b22×a×c,(5)cosC=a2+b2−c22×a×b.In a triangle, the value range of the minimum interior angle is0,π/3; therefore, the value range of the cosine of the minimum internal angle is 0.5,1, which is inversely proportional to the angle. When the degree of collinearity is equal to 0.5, it means that the topology formed by the localization unit is an equilateral triangle; when the degree of collinearity is equal to 1, it means that the beacon nodes in the localization unit are collinear. In summary, the closer the DC-A is to 0.5, the higher the localization accuracy is and vice versa.In [6], the authors considered the minimum height and the minimum angle at the same time and came up with the concept of Degree of Aggregation-Collinearity (DAC). However, in the first stage, it still uses the RSSI algorithm and needs to add peripheral devices to the nodes; it belongs to the category of the range-based algorithm, so it will not be described in this paper.


### 2.3. Defects of DC-H and DC-A

#### 2.3.1. Defects of DC-H

Through the above research, it is not difficult to find that the collinearity localization algorithm based on the minimum height cannot accurately reflect the topological shape of the triangle. When the area of a triangle is also larger, the minimum height of the triangle is larger, but the topological shape may not be closer to an equilateral triangle. As shown in Figure6, the minimum height of ΔABC is obviously larger than the minimum height of ΔA1B1C1; however, ΔA1B1C1 is an equilateral triangle with better localization effect, which is contrary to the statement in [8].Figure 6
Schematic diagram of the minimum height contrast of a triangle.


#### 2.3.2. Defects of DC-A

If the topological shape of the three beacon nodes of a localization unit is an equilateral triangle, so, the DC-A is equal to 0.5; according to [7], the localization effect is the best. However, if the three beacon sensor nodes are close to each other, the unknown sensor nodes are far away from the beacon sensor nodes; as described in Case 3 of the above error analysis, the localization accuracy is very low.At the same time, whether it is DC-H or DC-A, the DAC localization algorithm will have the following disadvantages: once a group of optimal localization units is found, the unknown nodes of the whole network will use it for location estimated. It can not only effectively make full use of other beacon sensor nodes’ coordinate conditions which are in the WSN, but also cause large localization error.


### 2.4. K-Value Collinearity (DC-K) Based on APIT Algorithm

The theory of APIT (approximate point-in-triangulation test) is triangular coverage approximation [10], as shown in Figure 7. The unknown node randomly selects three beacon nodes from the whole sensor network and then determines whether it is located in the triangular topology formed by the three beacon nodes, repeating the process until enumerating all the beacon nodes units; finally, the center of mass of all the overlapped triangles that can make the unknown node inside is taken as its estimated location [11]. How to control the unknown sensor node is located inside the triangle which consists of the beacon sensor nodes, being key of APIT algorithm. APIT algorithm adopts PIT test method; the principle of PIT is as follows: Figure 8 shows that A, B, and C are beacon nodes and D is unknown node; if there is a direction that enables the unknown node D to move in this direction, approaching or being away from the beacon sensor nodes A, B, and C at the same time, it indicates that D is located outside of the triangle; if it does not exist, this indicates that the unknown sensor node D is located inside of the triangle. In practice, it is impossible to test all directions [12]; so, T. HE came up with the APIT algorithm based on PIT; the principle of APIT is as follows: if there is a neighbor node away from or close to the beacon nodes at the same time relatively to D, it indicates that the unknown node is outside of the triangle; or, else, D is in the triangle [13].Figure 7
Schematic diagram of APIT algorithm.Figure 8
Example of APIT algorithm.In the above error analysis, it is pointed out that although the topological shape of beacon nodes in the localization unit is equilateral triangle or close to equilateral triangle, the Euclidean distance of the three beacon nodes is very close to the unknown sensor node which is very far away from the beacon nodes; it will cause a large localization error. This is a problem that has not been solved in previous research of DC algorithm. In this paper, aiming at the shortcomings and limitations of the existing DC algorithm, we came up with the K-value collinearity based on APIT algorithm; its basic principle is as follows: by executing APIT algorithm, we found the localization unit which could locate the unknown node inside the triangle and meet the K-value condition; then, these beacon nodes are used to locate the unknown node’s coordinate in the localization unit. In this way, the unknown node could be controlled inside the triangle and consists of the three beacon nodes in the localization unit, which not only make full use of the location information of beacon nodes in the WSN, but also avoid the situation described in the error analysis above and make up for the common defects of other DC algorithms.The calculation method of K-value is as follows:(6)K=2h3l−1,h is the minimum height (the height corresponding to the longest side or the largest interior Angle) and l is the value of the longest side in the triangle. When K is equal to the minimum value of 0, (7)2h3l−1=0,(8)2h3l=1,(9)hl=32.So, whenK=0, the topological shape of beacon nodes is an equilateral triangle. In summary, when K-value is smaller, the distribution of beacon nodes A, B, and C is closer to equilateral triangle and the localization accuracy is higher. Using 2h/3l, the influence of the maximum angle and the minimum height on the shape of the triangle is considered as shown in Figure 9.Figure 9
Diagram of DC-A.Each time the algorithm is executed, an unknown node is located, so the maximum number of the iteration is set as(10)Tmax=UNAmountthe count of unknown nodes.The steps of wireless sensor node location algorithm based on K-value collinearity are as follows:(1)
Execute the APIT algorithm, enumerate all locating units, and record the localization units inM set which can make the unknown sensor node u located inside topological triangle. If the set is empty, execute step (6) directly; otherwise, execute the next step:(11)M=…ΔAiBiCi….(2)
For the unknown nodeu, enumerate all the localization unit combinations which are in M set: ΔA1B1C1…ΔAiBiCi…ΔAnBnCn. According to (6), respectively, calculate the K-value of this localization unit; if the K-value meets (12), then record the localization units in N set. If N is empty, then execute step (6) directly. Otherwise, execute the next step:(12)0≤K≤0.3,(13)N=…ΔAiBiCi….(3)
At this moment, the unknown nodeu is inside the ΔAiBiCi formed by the localization unit in set N. If the actual distance from u to beacon nodes Ai, Bi, and Ci is smaller, then, iteration error will be smaller when using the single hop size and hops to estimate the distance. Otherwise, the localization error will be larger [14]. Therefore, calculate the area of topological triangles in set N and take the combination of beacon nodes with the smallest area as the localization unit of unknown node u.InΔAiBiCi, the coordinates of beacon nodes Ai, Bi, and Ci are AixAi,yAi,BixBi,yBi,CixCi,yCi; the sides of the triangle are a, b, and c, respectively; S is the area of the triangle:(14)a=xBi−xCi2+yBi−yCi2,(15)b=xAi−xCi2+yAi−yCi2,(16)c=xAi−xBi2+yAi−yBi2,(17)P=12×a+b+c,(18)Si=pp−ap−bp−c.So,Sk=min…Si…; assuming that the three vertices are Ak, Bk, and Ck of the triangle whose area is Sk, then the sensor nodes AkxAk,yAk, BkxBk,yBk, and CkxCk,yCk are regarded as the localization unit of unknown sensor node u.(4)
Estimate the Euclidean distance of the unknown nodeu to beacon nodes Ak, Bk, and Ck; then, preliminarily locate node u.① Estimate the Euclidean distance of the nodeu to beacon nodes Ak, Bk, and Ck.The sensor nodeu is inside triangle which consists of the beacon nodes which are in the localization unit, improving the single hop size in DV-hop sensor node localization method; in the case of only considering the distances and the number of hops between beacon nodes in the localization unit, calculate the local single hop size to estimate the distance. Moreover, because the topological triangle area constituted by the localization unit of unknown node u is the smallest among all triangles meeting (12), the calculation method of local single hop size can greatly improve the accuracy of distance estimation. The calculation method of local single hop size and distance estimation is as follows:(19)LocalHopsize=∑i≠jxi−xj2+yi−yj2hopij,xi,xj∈xAk,xBk,xCk,(20)LocalHopsize∗hopiu=diu,i∈A,B,C.If the estimated distance fromu to Ak, Bk, or Ck is larger than the longest side of the triangle, then the value of this distance is modified to the value of the longest side of the triangle. This is because when u is inside the triangle, the distance from u to any vertex cannot be larger than the longest side of the triangle. If(21)diu>maxabc,thendiu=maxabc.② Preliminary localization of unknown nodeu:(22)xAk−xu2+yAk−yu2=dAu2,xBk−xu2+yBk−yu2=dBu2,xCk−xu2+yCk−yu2=dCu2.Through carrying out the maximum likelihood estimation of (22), get(23)xAk2−xCk2−2xuxAk−xCk+yAk2−yCk2−2yuyAk−yCk=dAu2−dCu2,xBk2−xCk2−2xuxBk−xCk+yBk2−yCk2−2yuyBk−yCk=dBu2−dCu2.Transform (23) into a matrix:(24)B=xAk2−xCk2+yAk2−yCk2+dCu2−dAu2xBk2−xCk2+yBk2−yCk2+dCu2−dBu2,(25)A=2xAk−xCk2yAk−yCk2xBk−xCk2yBk−yCk.According to the least square method,(26)X=ATA−1ATB,(27)X=xuyu.(5)
Promote nodeu to anchor node and give it a low credibility, in the next round of localization; when anchor nodes are insufficient or the K-value of all localization units does not meet (12), node u will participate in locating as a beacon node.(6)
If the execution time of the localization algorithm is less thanTmax, then select the next unknown node and execute step (1). Otherwise, the loop ends. When the execution times of the localization algorithm are equal to Tmax, there are still unknown nodes that have not been located; then, regard this part of unknown nodes as boundary nodes and execute step (7).(7)
Dealing with boundary nodes, diffuse the beacon nodes in one-hop range of the boundary node by using(28)xi=a·rcos2πb+xAi,yi=a·rcos2πb+yAi,a<1,b<1.The beacon node’s original coordinate isxAi,yAi, and xi,yi is the random coordinate after diffusion. After diffusion, reexecute the above DC-K algorithm to infer the coordinate of the boundary nodes.So far, the localization algorithm of the first stage has been completed.


## 2.1. Error Analysis

After obtaining the Euclidean distance which is from beacon nodes to unknown node, localization algorithms perform the trilateral measurement or maximum likelihood method to infer the coordinate of unknown sensor nodes. In the process of location estimation, the location topology between beacon sensor nodes and topology shape from beacon nodes to unknown nodes will greatly affect the localization accuracy [9]. Generally, the more uniform the distribution of beacon nodes is, the more accurate the localization will be. In the following, we take three beacon nodes as an example to discuss the influence of location topology between nodes on localization accuracy.Figure 1
Two beacon nodes in the localization unit are close to each other.Figure 2
Beacon nodes in localization units are collinear or approximately collinear.Figure 3
Three beacon nodes in the localization unit are close to each other.Case 1.
When any two of the three beacon nodes of the localization unit are too close to each other, meanwhile, the unknown sensor node is very far from the two beacon sensor nodes and there will be a large localization error. As is displayed in Figure1, A, B, and C are beacon sensor nodes and D is unknown sensor node in the localization unit, compared with the distance from node D to the localization unit; the distance between B and C is easy to be ignored; therefore, the localization result of the unknown node D may appear at the location of D′, which causes a large localization error.Case 2.
When the beacon nodes in the localization unit are collinear or close to collinear, the localization matrix is irreversible, resulting in a large localization error and even leading to the localization failure. From Figure2 we could get that when the beacon nodes A, B, and C are close to collinear, then the unknown node D is located that will lead to the localization result which may be at the location of D′.Case 3.
When the three beacon nodes in the localization unit are very close to each other and the unknown node is very far away from the localization unit, it will cause a large localization error. As shown in Figure3, A, B, and C are beacon nodes, D is unknown sensor node, and D′ is localization result that may occur.


## 2.2. Degree of Collinearity Based on Minimum Height (DC-H) and Minimum Cosine of Interior Angle (DC-A)

In [8], the authors came up with the concept of collinearity. According to the collinearity estimate for whether the topological shape between beacon nodes is suitable for localization, this came up with the concept of DC-H. As shown in Figure 4, ΔABC is a triangle formed by beacon nodes A, B, and C. The minimum height is the minimum value of three heights in ΔABC (the height on the longest side). Therefore, the value of minimum height is the collinearity of the three beacon nodes:(1)DC−H=minhi,i=1,2,3.Figure 4
Diagram of DC-H.Under this definition, the value range of collinearity is0,3/2R; the communication radius of the nodes is R, which is in the network. When the degree of collinearity is equal to 0, it indicates that the nodes A, B, and C are collinear and the localization accuracy is the worst; when the degree of collinearity is equal to 3/2R, beacon sensor nodes A, B, and C constitute an equilateral triangle, which is most suitable for locating unknown node. In summary, when the minimum height is closer to 3/2R, the localization accuracy is higher.According to [7], the interior angle size of a triangle can better reflect the shape of a triangle; therefore, the degree of collinearity is defined by the cosine of the minimum interior angle, as shown in Figure 5. ΔABC is a triangle formed by beacon nodes A, B, and C:(2)DC−A=maxcosA,cosB,cosC.Figure 5
Diagram of DC-A.InΔABC, the cosine of the three interior angles is(3)cosA=b2+c2−a22×b×c,(4)cosB=a2+c2−b22×a×c,(5)cosC=a2+b2−c22×a×b.In a triangle, the value range of the minimum interior angle is0,π/3; therefore, the value range of the cosine of the minimum internal angle is 0.5,1, which is inversely proportional to the angle. When the degree of collinearity is equal to 0.5, it means that the topology formed by the localization unit is an equilateral triangle; when the degree of collinearity is equal to 1, it means that the beacon nodes in the localization unit are collinear. In summary, the closer the DC-A is to 0.5, the higher the localization accuracy is and vice versa.In [6], the authors considered the minimum height and the minimum angle at the same time and came up with the concept of Degree of Aggregation-Collinearity (DAC). However, in the first stage, it still uses the RSSI algorithm and needs to add peripheral devices to the nodes; it belongs to the category of the range-based algorithm, so it will not be described in this paper.


## 2.3. Defects of DC-H and DC-A

### 2.3.1. Defects of DC-H

Through the above research, it is not difficult to find that the collinearity localization algorithm based on the minimum height cannot accurately reflect the topological shape of the triangle. When the area of a triangle is also larger, the minimum height of the triangle is larger, but the topological shape may not be closer to an equilateral triangle. As shown in Figure6, the minimum height of ΔABC is obviously larger than the minimum height of ΔA1B1C1; however, ΔA1B1C1 is an equilateral triangle with better localization effect, which is contrary to the statement in [8].Figure 6
Schematic diagram of the minimum height contrast of a triangle.


### 2.3.2. Defects of DC-A

If the topological shape of the three beacon nodes of a localization unit is an equilateral triangle, so, the DC-A is equal to 0.5; according to [7], the localization effect is the best. However, if the three beacon sensor nodes are close to each other, the unknown sensor nodes are far away from the beacon sensor nodes; as described in Case 3 of the above error analysis, the localization accuracy is very low.At the same time, whether it is DC-H or DC-A, the DAC localization algorithm will have the following disadvantages: once a group of optimal localization units is found, the unknown nodes of the whole network will use it for location estimated. It can not only effectively make full use of other beacon sensor nodes’ coordinate conditions which are in the WSN, but also cause large localization error.


## 2.3.1. Defects of DC-H

Through the above research, it is not difficult to find that the collinearity localization algorithm based on the minimum height cannot accurately reflect the topological shape of the triangle. When the area of a triangle is also larger, the minimum height of the triangle is larger, but the topological shape may not be closer to an equilateral triangle. As shown in Figure6, the minimum height of ΔABC is obviously larger than the minimum height of ΔA1B1C1; however, ΔA1B1C1 is an equilateral triangle with better localization effect, which is contrary to the statement in [8].Figure 6
Schematic diagram of the minimum height contrast of a triangle.


## 2.3.2. Defects of DC-A

If the topological shape of the three beacon nodes of a localization unit is an equilateral triangle, so, the DC-A is equal to 0.5; according to [7], the localization effect is the best. However, if the three beacon sensor nodes are close to each other, the unknown sensor nodes are far away from the beacon sensor nodes; as described in Case 3 of the above error analysis, the localization accuracy is very low.At the same time, whether it is DC-H or DC-A, the DAC localization algorithm will have the following disadvantages: once a group of optimal localization units is found, the unknown nodes of the whole network will use it for location estimated. It can not only effectively make full use of other beacon sensor nodes’ coordinate conditions which are in the WSN, but also cause large localization error.


## 2.4. K-Value Collinearity (DC-K) Based on APIT Algorithm

The theory of APIT (approximate point-in-triangulation test) is triangular coverage approximation [10], as shown in Figure 7. The unknown node randomly selects three beacon nodes from the whole sensor network and then determines whether it is located in the triangular topology formed by the three beacon nodes, repeating the process until enumerating all the beacon nodes units; finally, the center of mass of all the overlapped triangles that can make the unknown node inside is taken as its estimated location [11]. How to control the unknown sensor node is located inside the triangle which consists of the beacon sensor nodes, being key of APIT algorithm. APIT algorithm adopts PIT test method; the principle of PIT is as follows: Figure 8 shows that A, B, and C are beacon nodes and D is unknown node; if there is a direction that enables the unknown node D to move in this direction, approaching or being away from the beacon sensor nodes A, B, and C at the same time, it indicates that D is located outside of the triangle; if it does not exist, this indicates that the unknown sensor node D is located inside of the triangle. In practice, it is impossible to test all directions [12]; so, T. HE came up with the APIT algorithm based on PIT; the principle of APIT is as follows: if there is a neighbor node away from or close to the beacon nodes at the same time relatively to D, it indicates that the unknown node is outside of the triangle; or, else, D is in the triangle [13].Figure 7
Schematic diagram of APIT algorithm.Figure 8
Example of APIT algorithm.In the above error analysis, it is pointed out that although the topological shape of beacon nodes in the localization unit is equilateral triangle or close to equilateral triangle, the Euclidean distance of the three beacon nodes is very close to the unknown sensor node which is very far away from the beacon nodes; it will cause a large localization error. This is a problem that has not been solved in previous research of DC algorithm. In this paper, aiming at the shortcomings and limitations of the existing DC algorithm, we came up with the K-value collinearity based on APIT algorithm; its basic principle is as follows: by executing APIT algorithm, we found the localization unit which could locate the unknown node inside the triangle and meet the K-value condition; then, these beacon nodes are used to locate the unknown node’s coordinate in the localization unit. In this way, the unknown node could be controlled inside the triangle and consists of the three beacon nodes in the localization unit, which not only make full use of the location information of beacon nodes in the WSN, but also avoid the situation described in the error analysis above and make up for the common defects of other DC algorithms.The calculation method of K-value is as follows:(6)K=2h3l−1,h is the minimum height (the height corresponding to the longest side or the largest interior Angle) and l is the value of the longest side in the triangle. When K is equal to the minimum value of 0, (7)2h3l−1=0,(8)2h3l=1,(9)hl=32.So, whenK=0, the topological shape of beacon nodes is an equilateral triangle. In summary, when K-value is smaller, the distribution of beacon nodes A, B, and C is closer to equilateral triangle and the localization accuracy is higher. Using 2h/3l, the influence of the maximum angle and the minimum height on the shape of the triangle is considered as shown in Figure 9.Figure 9
Diagram of DC-A.Each time the algorithm is executed, an unknown node is located, so the maximum number of the iteration is set as(10)Tmax=UNAmountthe count of unknown nodes.The steps of wireless sensor node location algorithm based on K-value collinearity are as follows:(1)
Execute the APIT algorithm, enumerate all locating units, and record the localization units inM set which can make the unknown sensor node u located inside topological triangle. If the set is empty, execute step (6) directly; otherwise, execute the next step:(11)M=…ΔAiBiCi….(2)
For the unknown nodeu, enumerate all the localization unit combinations which are in M set: ΔA1B1C1…ΔAiBiCi…ΔAnBnCn. According to (6), respectively, calculate the K-value of this localization unit; if the K-value meets (12), then record the localization units in N set. If N is empty, then execute step (6) directly. Otherwise, execute the next step:(12)0≤K≤0.3,(13)N=…ΔAiBiCi….(3)
At this moment, the unknown nodeu is inside the ΔAiBiCi formed by the localization unit in set N. If the actual distance from u to beacon nodes Ai, Bi, and Ci is smaller, then, iteration error will be smaller when using the single hop size and hops to estimate the distance. Otherwise, the localization error will be larger [14]. Therefore, calculate the area of topological triangles in set N and take the combination of beacon nodes with the smallest area as the localization unit of unknown node u.InΔAiBiCi, the coordinates of beacon nodes Ai, Bi, and Ci are AixAi,yAi,BixBi,yBi,CixCi,yCi; the sides of the triangle are a, b, and c, respectively; S is the area of the triangle:(14)a=xBi−xCi2+yBi−yCi2,(15)b=xAi−xCi2+yAi−yCi2,(16)c=xAi−xBi2+yAi−yBi2,(17)P=12×a+b+c,(18)Si=pp−ap−bp−c.So,Sk=min…Si…; assuming that the three vertices are Ak, Bk, and Ck of the triangle whose area is Sk, then the sensor nodes AkxAk,yAk, BkxBk,yBk, and CkxCk,yCk are regarded as the localization unit of unknown sensor node u.(4)
Estimate the Euclidean distance of the unknown nodeu to beacon nodes Ak, Bk, and Ck; then, preliminarily locate node u.① Estimate the Euclidean distance of the nodeu to beacon nodes Ak, Bk, and Ck.The sensor nodeu is inside triangle which consists of the beacon nodes which are in the localization unit, improving the single hop size in DV-hop sensor node localization method; in the case of only considering the distances and the number of hops between beacon nodes in the localization unit, calculate the local single hop size to estimate the distance. Moreover, because the topological triangle area constituted by the localization unit of unknown node u is the smallest among all triangles meeting (12), the calculation method of local single hop size can greatly improve the accuracy of distance estimation. The calculation method of local single hop size and distance estimation is as follows:(19)LocalHopsize=∑i≠jxi−xj2+yi−yj2hopij,xi,xj∈xAk,xBk,xCk,(20)LocalHopsize∗hopiu=diu,i∈A,B,C.If the estimated distance fromu to Ak, Bk, or Ck is larger than the longest side of the triangle, then the value of this distance is modified to the value of the longest side of the triangle. This is because when u is inside the triangle, the distance from u to any vertex cannot be larger than the longest side of the triangle. If(21)diu>maxabc,thendiu=maxabc.② Preliminary localization of unknown nodeu:(22)xAk−xu2+yAk−yu2=dAu2,xBk−xu2+yBk−yu2=dBu2,xCk−xu2+yCk−yu2=dCu2.Through carrying out the maximum likelihood estimation of (22), get(23)xAk2−xCk2−2xuxAk−xCk+yAk2−yCk2−2yuyAk−yCk=dAu2−dCu2,xBk2−xCk2−2xuxBk−xCk+yBk2−yCk2−2yuyBk−yCk=dBu2−dCu2.Transform (23) into a matrix:(24)B=xAk2−xCk2+yAk2−yCk2+dCu2−dAu2xBk2−xCk2+yBk2−yCk2+dCu2−dBu2,(25)A=2xAk−xCk2yAk−yCk2xBk−xCk2yBk−yCk.According to the least square method,(26)X=ATA−1ATB,(27)X=xuyu.(5)
Promote nodeu to anchor node and give it a low credibility, in the next round of localization; when anchor nodes are insufficient or the K-value of all localization units does not meet (12), node u will participate in locating as a beacon node.(6)
If the execution time of the localization algorithm is less thanTmax, then select the next unknown node and execute step (1). Otherwise, the loop ends. When the execution times of the localization algorithm are equal to Tmax, there are still unknown nodes that have not been located; then, regard this part of unknown nodes as boundary nodes and execute step (7).(7)
Dealing with boundary nodes, diffuse the beacon nodes in one-hop range of the boundary node by using(28)xi=a·rcos2πb+xAi,yi=a·rcos2πb+yAi,a<1,b<1.The beacon node’s original coordinate isxAi,yAi, and xi,yi is the random coordinate after diffusion. After diffusion, reexecute the above DC-K algorithm to infer the coordinate of the boundary nodes.So far, the localization algorithm of the first stage has been completed.


## 3. Improved Grey Wolf Optimization Algorithm

The Grey Wolf Optimizer (GWO) is a swarm intelligence optimization algorithm. The paper [15] simulated the hierarchy and predation activities of wolves, proposing and analyzing the GWO algorithm. This algorithm has the characteristics of having a few parameters, strong convergence, and easy implementation. The principle of the GWO algorithm is as follows: all grey wolves were divided into groups of α, β, δ, and ω; according to the level of the social hierarchy, when hunting prey, α, β, and δ will guide the lowest level of ω wolf to search for prey, and the location of α wolf is the final result at the end of hunting.The classical DV-hop algorithm uses the least square method to get the solution of (22), and according to the estimated distance this completes the localization calculation [16]. In this paper, in the second stage, the three beacon nodes in the localization unit and the estimated distance obtained by DC-K algorithm participate in the iterative calculation, and the improved GWO is used to obtain the optimal solution of the (22). In order to reduce the impact of the Euclidean distance estimation error in the first stage on the final localization result, in this paper, the distance (dAu,dBu,dCu) of the beacon nodes and the sensor node u in the localization unit is included in the vector of each individual for synchronous iteration, according to the vector to design the fitness function. This method can not only solve the influence of distance estimation errors on the final localization results, but also add constraints of the fitness function, thereby greatly reducing the times of iterations [17]. In this paper, the specific steps of applying the improved grey wolf optimization algorithm to wireless sensor node location are as follows:(1)
The coordinates of the unknown sensor nodes in the first stage and the three distances to the beacon nodes of the localization unit constitute such a 5-dimensional vector:xu,yu,dAu,dBu,dCu.(2)
Calculating the fitness function about each individual wolf,(29)Fitnessu=∑ixi−xu2+yi−yu2−diu2,xu,yu is the coordinate of the sensor node u, xi,yi is the coordinate of the beacon node in localization unit of the unknown node u, and diu is the estimated Euclidean distance of the beacon node to unknown sensor node which is in localization unit. The three unknown nodes with the smallest fitness are α wolf, β wolf, and δ wolf, respectively, and the rest are ω wolves.(3)
The iterative model is as follows (max=20):(30)a=2−2tmax,C=2r1,A=2ar2−a,(31)X1=Xαt−A1C1Xαt−Xωt−1,X2=Xβt−A2C2Xβt−Xωt−1,X3=Xδt−A3C3Xδt−Xωt−1,(32)Xωt=X1+X2+X3.A is the convergence factor; r1,r2 are random numbers in 0,1; and C is the swing factor; Xt is the vector of the wolf when the times of iteration are equal to t; Xt−1 is the vector of the wolf when the times of iteration are equal to t−1. In each iteration, the location of α wolf changes according to (30)–(32). The process of ω wolf location changes is the process of hunting, which is the process of looking for the optimal solution.(4)
After the iteration of step (3) is completed, the five-dimensional solution vector of theα wolf is output and the solution vector is xα,yα,dAα,dBα,dCα; xα,yα in the solution vector is taken as the ultimate location of the unknown sensor node u.(5)
Back to step (2), calculate the fitness value of all individuals again according to (29) and select the new α wolf, β wolf, and δ wolf. Until the output of all individuals (the localization of all unknown nodes is completed), the algorithm ends.


## 4. Experimental Results and Analysis

The experiment was conducted with Windows10 computer operating system, and the simulation experiment was carried out with matlab2016a. Randomly deploy 100 sensor nodes in a 100× 100 square area, compare and analyze the performance of the wireless sensor node localization algorithm from different communication radius and beacon node ratio, and compare with the DC-H, DC-A, GWO, and DV-hop. Average localization error is defined as(33)average error=1T∑∑ux−xu2+y−yu2RNAmount−BAmount,T is the time of the experiment; x,y is the actual coordinate of the sensor node u; R is the communication radius; the amount of sensor nodes is NAmount, located in this network; BAmount is the number of beacon sensor nodes. When the beacon sensor node ratio is 20%, the distribution diagram about the nodes is shown in Figure 10.Figure 10
Diagram of node distribution.


### 4.1. Influences of Beacon Node Ratio on Algorithm

Under the same communication radiusR=35m, the influence of different beacon node ratio on each algorithm is shown in Figure 11:Figure 11
Average localization error with different beacon node ratio.(1)
As shown in the figure, compared with DV-hop, the localization results accuracy of the other four localization algorithms is higher, especially when the beacon node ratio is more than 20%.(2)
Using the localization method of intelligent optimization algorithm GWO, when beacon sensor node ratio is 10%, the average localization error is more than 50%.(3)
The two-stage GWO algorithm has better localization accuracy than other algorithms and solves the problem that GWO algorithm cannot converge when the beacon node ratio is low. As shown in Figure10, although the localization accuracy of DC-A and DC-H algorithms is less affected by the anchor node ratio, the localization error is large. This is because once the best localization unit in DC-A or DC-H is founded, all unknown nodes will use it to locate, and the coordinates of other beacon nodes in this network cannot be effectively utilized, resulting in a large localization error [18]. In this paper, based on the APIT algorithm, we came up with the DC-K algorithm, by controlling the unknown nodes in the topological triangle formed by beacon nodes in the localization unit, which solves this problem effectively.


### 4.2. Influences of Communication Radius on Algorithm

Under the same beacon node ratioBeacon/100=25%, the influence of different communication radius on the localization result of each algorithm is shown in Figure 12:Figure 12
Average error with the different communication radius.(1)
As shown in Figure11, the DV-hop’s localization error decreases when the communication radius increases; hence, the DV-hop’s performance is greatly affected by the communication radius. Because of using the distance estimation method of single hop size and hops, when the communication radius decreases, the minimum hops from beacon nodes to unknown node increase, resulting in a large distance estimation error.(2)
The DC-A and DC-H were improved in the localization stage but still fully use the distance estimation method of DV-hop localization method in the first stage. Therefore, the localization accuracy will be greatly affected by the communication radius. Because of the shortcomings of the collinearity algorithm, the overall localization error is still large.(3)
Although GWO algorithm is less affected by the communication radius, the fitness function lacks constraints, resulting in the poor localization accuracy.(4)
With the same beacon node ratio, the two-stage degree of K-value collinearity GWO algorithm integrates the advantages of DC-A, DC-H, and GWO, reducing the impact of node communication radius on the performance of the algorithm, and improves the localization accuracy.


## 4.1. Influences of Beacon Node Ratio on Algorithm

Under the same communication radiusR=35m, the influence of different beacon node ratio on each algorithm is shown in Figure 11:Figure 11
Average localization error with different beacon node ratio.(1)
As shown in the figure, compared with DV-hop, the localization results accuracy of the other four localization algorithms is higher, especially when the beacon node ratio is more than 20%.(2)
Using the localization method of intelligent optimization algorithm GWO, when beacon sensor node ratio is 10%, the average localization error is more than 50%.(3)
The two-stage GWO algorithm has better localization accuracy than other algorithms and solves the problem that GWO algorithm cannot converge when the beacon node ratio is low. As shown in Figure10, although the localization accuracy of DC-A and DC-H algorithms is less affected by the anchor node ratio, the localization error is large. This is because once the best localization unit in DC-A or DC-H is founded, all unknown nodes will use it to locate, and the coordinates of other beacon nodes in this network cannot be effectively utilized, resulting in a large localization error [18]. In this paper, based on the APIT algorithm, we came up with the DC-K algorithm, by controlling the unknown nodes in the topological triangle formed by beacon nodes in the localization unit, which solves this problem effectively.


## 4.2. Influences of Communication Radius on Algorithm

Under the same beacon node ratioBeacon/100=25%, the influence of different communication radius on the localization result of each algorithm is shown in Figure 12:Figure 12
Average error with the different communication radius.(1)
As shown in Figure11, the DV-hop’s localization error decreases when the communication radius increases; hence, the DV-hop’s performance is greatly affected by the communication radius. Because of using the distance estimation method of single hop size and hops, when the communication radius decreases, the minimum hops from beacon nodes to unknown node increase, resulting in a large distance estimation error.(2)
The DC-A and DC-H were improved in the localization stage but still fully use the distance estimation method of DV-hop localization method in the first stage. Therefore, the localization accuracy will be greatly affected by the communication radius. Because of the shortcomings of the collinearity algorithm, the overall localization error is still large.(3)
Although GWO algorithm is less affected by the communication radius, the fitness function lacks constraints, resulting in the poor localization accuracy.(4)
With the same beacon node ratio, the two-stage degree of K-value collinearity GWO algorithm integrates the advantages of DC-A, DC-H, and GWO, reducing the impact of node communication radius on the performance of the algorithm, and improves the localization accuracy.


## 5. Conclusion

In order to increase the localization accuracy of wireless sensor nodes, this paper studies the shortcomings of the existing collinearity algorithm and the disadvantages of intelligent optimization algorithm in WSN localization and proposes a two-stage wireless sensor grey wolf optimization node location algorithm based on K-value collinearity. Based on the APIT algorithm and putting forward the concept of DC-K, organically combined with the improved grey wolf optimization algorithm, this not only makes up for the shortcomings of previous DC algorithms, but also solves the problem that intelligent optimization localization algorithm is easy to fall into the local optimization and reduces the times of iteration. The experimental results show that the two-stage DC-K localization algorithm with the better localization accuracy and strong robustness can greatly decrease the calculation energy consumption in the localization process and extend the service life of the sensor nodes.The DC-K algorithm is suitable for the regions with random distribution of nodes. However, in concave regions, the shortest distance between sensor nodes is easily affected by concave boundaries, which will increase the error of distance estimation and affect the localization accuracy. In the next research, the localization algorithm with higher accuracy in concave regions will be studied; in the second stage, dynamic changes or other improvements to the weight factor of prey localization will be considered.



---

*Source: 7217595-2020-07-25.xml*