Localization Algorithm Based on Maximum a Posteriori in Wireless Sensor Networks

Many applications and protocols in wireless sensor networks need to know the locations of sensor nodes. A low-cost method to localize sensor nodes is to use received signal strength indication (RSSI) ranging technique together with the least-squares trilateration. However, the average localization error of this method is large due to the large ranging error of RSSI ranging technique. To reduce the average localization error, we propose a localization algorithm based on maximum a posteriori. This algorithm uses the Baye's formula to deduce the probability density of each sensor node's distribution in the target region from RSSI values. Then, each sensor node takes the point with the maximum probability density as its estimated location. Through simulation studies, we show that this algorithm outperforms the least-squares trilateration with respect to the average localization error.


Introduction
The process of determining the physical locations of sensor nodes is known as localization, which is a fundamental problem in wireless sensor networks [1,2].The locations of sensor nodes are essential in many applications and protocols.For example, the sensed information about an event without the location where it takes place is often meaningless.Similarly, geographic routing relies on the locations of nodes to forward packets [3].
The locations of sensor nodes can be directly obtained by preconfiguration or global positioning system (GPS).Preconfiguration requires each sensor node being placed at a known location, which is only suitable for the case that sensor nodes are easy to be placed and their number is small.On the other hand, a sensor node equipped with a GPS receiver is costly and does not work indoors.Therefore, both the above two methods are impractical for large-scale lowcost wireless sensor networks.It is desired that the locations of sensor nodes can be induced from their interactions, such as the detections of the distances between neighbors.
Many localization algorithms first use a ranging technique to estimate the Euclidean distances between nodes, and then use the least-squares trilateration to determine the locations of sensor nodes by these estimated distances.Some conventional ranging techniques are received signal strength indication (RSSI), time of arrival (TOA), time difference of arrival (TDOA), angle of arrival (AOA), and so forth [4].Among them, RSSI ranging technique has the least requirement for hardware, as the radio chip of current sensor node usually has a built-in function of reading RSSI value.But RSSI value is vulnerable to being disturbed by the surrounding environment and the ranging error of RSSI ranging technique may be at most ±50% [5].Furthermore, the least-squares trilateration is sensitive to ranging errors [2].If using RSSI ranging technique together with the leastsquares trilateration to localize sensor nodes, the average localization error is very large.
To reduce the average localization error, we propose a localization algorithm based on maximum a posteriori.This algorithm uses the probability approach to estimate the location of each sensor node directly from RSSI values.Extensive simulation results have shown that the average localization error of this algorithm is less than that of the least-squares trilateration.

International Journal of Distributed Sensor Networks
The remainder of this paper is organized as follows.Related work is discussed in Section 2, the network model is defined in Section 3, and our proposed localization algorithm is described in Section 4. Simulation results that illustrate the performance are included in Section 5, and Section 6 is the conclusion.

Related Work
Since localization is a fundamental problem in wireless sensor networks, there are many research works focusing on it recently.Localization algorithms can be divided into two categories: anchor-based localization algorithms and nonanchor-based localization algorithms.An anchor is a special node which has a priori knowledge of its location.
In anchor-based localization algorithms, the location of each sensor node is determined only by its distances from anchors.Priyantha et al. developed the cricket location support system which provides localization services for indoor mobile node [6].Bulusu et al. proposed a GPS-less localization algorithm in which each mobile node localizes itself to the centroid of its adjacent connecting anchors [7].Niculescu and Nath proposed a family of distributed localization algorithms "adhoc positioning system" (APS) [8,9].In these algorithms, each node measures its distances from anchors by performing multihop propagation of distances to anchors throughout the network.Kumar et al. used RSSI-based weighted centroid to improve the localization algorithm proposed by Bulusu et al. [10].Li and Liu proposed the rendered path (REP) protocol for locating nodes in anisotropic sensor networks with holes [11].Lederer et al. also studied the problem of localizing a large sensor network having a complex shape, possibly with holes [12].
In nonanchor-based localization algorithms, the location of each sensor node is determined also by the distances between sensor nodes.Doherty et al. proposed a constraintbased localization scheme using semidefinite programming (SDP) to find a solution to the localization problem [13].Shang et al. proposed an algorithm using classical multidimensional scaling (MDS) technique to calculate the locations of nodes given a set of distances [14].Kwon [18].
Many of the above-mentioned algorithms [12,14,15,17] have a similar optimization objective as the least-squares trilateration, that is, minimizing the (weighted) sum of all squared differences between each estimated distance and the corresponding distance calculated by the estimated locations of nodes.But when the distances are estimated by RSSI ranging technique, this optimization objective is likely subject to a large average localization error.In this paper, we present another optimization objective with which sensor nodes can be localized more accurately.

Network Model
Before describing our proposed localization algorithm, we first assume the model of wireless sensor network as follows.
(1) A wireless sensor network is deployed in a planar region B. Suppose that B is a rectangle, whose length is l and width is w.But later we will see that the proposed algorithm is not dependent on the shape of B. Without loss of generality, we assume that the lower left corner of B is the origin and the coordinate of the upper-right corner of B is (l, w).
(2) All sensor nodes are uniformly distributed in B.
Anchors have a larger transmission range than sensor nodes.Each sensor node and anchor is denoted by a point in B. Let n denote the total number of anchors, a i denote the ith anchor, and (x i , y i ) denote the coordinate of a i .
(3) Initially each anchor broadcasts a beacon containing its location information.Then, each sensor node collects the RSSI values of all its neighbor anchors through these beacons.The RSSI value read by a sensor node obeys the wide log-normal shadowing radio signal propagation model [19]: In (1), R(d) denotes the RSSI value when the distance between the receiver and the transmitter is d; P T is the power of the transmitter; PL(d 0 ) is a known reference power value at a reference distance d 0 from the transmitter; η is the path loss exponent that measures the rate at which the RSSI value decreases with distance; X σ is a zero mean Gaussian distributed random variable with standard deviation and it accounts for the random effect of shadowing, that is, Given these known RSSI values, the locations of sensor nodes can be estimated by a localization algorithm.The major measurement of a localization algorithm is the average localization error, defined as the average distance between the actual location and the estimated location of each sensor node [5].Because wireless sensor networks often work in unfriendly environments, some anchors may be faulty, which means they have incorrect information about their own locations.Therefore, fault tolerance is also important to a localization algorithm.In this paper, we define it as the ability to maintain a good localization result even if some anchors are faulty.Besides, execution time is also a common measurement of a localization algorithm.

Algorithm Description
In this section, we will describe our proposed localization algorithm based on maximum a posteriori.Consider a sensor node s.Let (x s , y s ) denote the coordinate of s and r k denote the random variable of the RSSI value of a k read by s, where 0 ≤ k < n.Assume that the values of r 1 , r 2 , . . ., r n in a test are R 1 , R 2 , . . ., R n , respectively.The basic idea of our proposed localization algorithm is as follows.First, the target region B is divided into small grids of the same size.Next, the probability of s being in each grid is calculated from R 1 , R 2 , . . ., R n .Then, the center of the grid with the largest probability is taken as the estimated value of (x s , y s ).Let g denote the side length of each grid.Without loss of generality, assume that the target region B has exact l/g grids in the horizontal direction and w/g grids in the vertical direction.Let G i j denote the grid locating at the ith row and the jth column, where 0 ≤ i < w/g, 0 ≤ j < l/g.
Let E i j denote the event of s being in G i j , whose probability is denoted by P{E i j }.Let the conditional probability denote the probability that for all 0 ≤ k < n, r k = R k under the condition of s being in G i j .Now we have the condition that for all 0 ≤ k < n, r k = R k and want to compute the conditional probability That is, to compute the a posteriori probability from priori probability.By the Bayes formula, we obtain P{E i j | r k = R k , 0 ≤ k < n} as follows: Because each sensor node is uniformly distributed in B, s has the same probability in each grid, that is, for all 0 ≤ u < w/g and 0 ≤ v < l/g, P{E uv } is equal.So (2) can be simplified as follows: is equal to the average probability that for all 0 ≤ k < n, r k = R k under the condition of s being at each point in G i j .Then, we obtain the following equation: When s is at a certain point in B, the RSSI value of each anchor read by s is not interfered with the RSSI values of other anchors.Therefore, under the condition that x b = x and y b = y, the events Combine it with (3) and ( 4), and we obtain the following equation: According to (5), we need to calculate x, y b = y}, 0 ≤ k < n.However, it can be seen from ( 1) that r k is a continuous random variable, so we cannot directly obtain (5).But we can compute the probability of r k being in the interval [R k , R k + ε) under the condition of s being at a point (x, y), which is denoted by x, y b = y}.So we can obtain the following equation: Let d k denotes the distance between the point (x, y) and a k , that is, whose probability is as follows: Combine ( 6) and ( 7), and we obtain the following equation: International Journal of Distributed Sensor Networks We have lim ε → 0 2)(βk +10ηlog 10 dk) 2 and substitute it into (8).Then, we obtain the following equation: g vg e −(1/2) 0≤k<n (βk+10ηlog 10 dk) 2 dx dy . ( It can been seen from ( 9) that if G i j has the largest value of (i+1)g ig ( j+1)g jg e −(1/2) 0≤k<n (βk+10ηlog 10 dk) 2 dx dy among all grids, then s has the largest probability in G i j among all grids.If the size of grid is small enough, we have lim g → 0 (i+1)g ig ( j+1)g jg e −(1/2) 0≤k<n (βk+10ηlog 10 dk) 2 dx dy = g 2 e −(1/2) 0≤k<n (βk+10ηlog 10 dk) 2 .Therefore, we can select the point with the smallest value of 0≤k<n (β k + 10ηlog 10 d k ) 2 in the target region B as the estimated location of s.We define the function f (x, y) as follows: That is for the variable (x, y) whose domain is the target region B, to find a point ( x, y) with the minimum value of f (x, y).However, the function f (x, y) is relatively complicated, so we cannot obtain the analytic expression of ( x, y) by the partial differential method.Alternatively, we adopt an approximation method described as follows.First, the target region is divided into small grids and the value of f (x, y) at the center of each grid is computed.Then, the center of the grid with the minimum value of f (x, y) is taken as the approximation of ( x, y).If the size of grid is g × g, then the total number of grids is lw/g 2 and the time complexity of localizing a node is O(nlw/g 2 ).Obviously, when the target region is fixed, the execution time will become longer as the size of grid become smaller.For large wireless sensor networks, we can use the multi-grid method to reduce the execution time.First, the target region is divided into larger grids and the value of f (x, y) at each grid point is computed.Next, those grids with relatively larger value of f (x, y) are discarded.Then, the remaining grids are repeatedly divided into smaller grids until the size of grid reaches the required accuracy.
Furthermore, we analyze (10).Let d k denote the estimated distance between s and a k only estimated from R k .It is easy to known that d k should be equal to d in (1) when X σ is 0: Combine ( 10) and ( 11), and we obtain the following equation: Equation ( 12) illuminates that the optimum estimated location of s should be the point with the minimum value of 0≤k<n (ln In the simulation, the target region B is a square region of 1000 m × 1000 m.The transmission range of anchors is 1500 m.Sensor nodes and anchors are randomly and uniformly distributed in B. The RSSI value read by a sensor node is simulated according to (1).The value of each parameter is taken from a typical wireless sensor network [19]: P T is set to 4 dBm, d 0 is set to 1 m, PL(d 0 ) is set to 55 dB, η is set to 4, and the range of σ is set to [2,14].The Gaussian distributed random number X σ is generated by the Box-Muller method.The platform has Intel Dual Core 2.80 GHz CPU and 1 GB memory.To make simulation results more accurate, for each simulation we perform 100 times and take the average result.

Grid Size.
In MAP algorithm, the target area is divided into small grids to approximately obtain the point with the maximum probability density.The smaller the grid is, the closer the approximate solution is to the accurate solution, but the larger the amount of calculation is.Therefore, we first need to select the appropriate grid size.In the simulation, σ is set to 5, the number of anchors is set to 20, the number of sensor nodes is set to 100, and the side length of grid varies from 5 m to 100 m. Figure 1 shows the average localization errors of MAP algorithm.It can be seen that when the grid size is relatively large, the average localization error is significantly impacted by the grid size.But when the grid size of grid is small to a certain extent, this impact is almost  negligible.In the following, we will take the grid size as 10 m × 10 m.

Localization Error.
Figure 2 shows a localization result of MAP algorithm and LST algorithm.Both algorithms have the same inputs: σ is set to 5, the number of anchors is set to 20, and the number of sensor nodes is set to 100.It can be seen that the estimated location of most sensor nodes computed by MAP algorithm are closer to their actual locations.Accordingly, MAP algorithm has a smaller average localization error than LST algorithm.
Next, we test how the localization error is impacted by the number of anchors.In the simulation, σ is set to 5, the number of sensor nodes is set to 100, and the number of anchors varies from 5 to 25.It can be seen from Figure 3 that with the number of anchors increasing, the average localization errors of both algorithms are reduced.But MAP algorithm can achieve a smaller average localization error, which is reduced by nearly 34.8% compared with the leastsquares trilateration.
Then, we test how the location error is impacted by the layout of anchor nodes.In the simulation, σ is set to 5, the number of sensor node is set to 100, the number of anchors varies among 4, 9, 16, 25, 36, and 49, and anchors are placed by the random layout and the grid layout, respectively.Figure 4 shows the average location errors of MAP algorithm under these two layouts.The average location error under the grid layout is nearly 87.8% of that under the random layout.Therefore, anchor nodes should be placed by the grid layout in practice.
The ranging error is a primary cause of the localization error, which depends on σ: the larger σ is, the larger the ranging error is.In the simulation, the number of anchors is set to 20, the number of sensor nodes is set to 100, and σ varies from 2 to 14. Figure 5 shows the average localization errors of MAP algorithm and LST algorithm.It can be seen that the average localization errors of both algorithms are approximately proportional to σ.

Fault Tolerance.
In MAP algorithm, the location of each sensor node is determined by all its neighbor anchors.If only a small number of anchors are faulty, the estimated location of each sensor node cannot have a big change.In the simulation, σ is set to 5, the number of anchors is set to 20, the number of sensor nodes is set to 100, and the number of faulty anchors varies from 0 to 10. Figure 6 shows the average location errors of MAP algorithm and LST algorithm.It can be seen that when less than 25% of anchors are faulty, the average localization error of MAP algorithm increase less than 85%.

Execution
Time.Finally, we analyze the average execution time of MAP algorithm by simulation.In the simulation, the number of sensor nodes is set to 100. Figure 7 shows the average execution times of the two algorithms under different numbers of anchor nodes when the size of grid is 10 m × 10 m. Figure 8 shows the average execution times of the two algorithms under different grid sizes when the number of anchors is 20.It can be seen that the execution times of both algorithms are approximately proportional to the number of anchor nodes and are approximately inversely proportional to the acreage of grid.This result is consistent with the analysis in Section 4. In a general case, MAP algorithm can  localize a sensor node in a short time.Since MAP algorithm has a more complicated calculation than LST algorithm, the execution time of MAP algorithm is longer.

Conclusion
RSSI ranging-based localization is regarded as a cost-effective solution for sensor node localization.But RSSI ranging technique has a large ranging error, which will bring a large average localization error to the general least-squares trilateration.In this paper, we propose a localization algorithm based on maximum a posteriori probability (MAP).In this algorithm, the point with the maximum probability density in the target region is taken as the estimated location of a sensor node.Extensive simulation results demonstrate the effectiveness of MAP algorithm.This algorithm reduces the average localization error by nearly 34.8% compared with the least-squares trilateration.Even if the number of anchors is small, this algorithm can also achieve a relatively small average localization error.In addition, the execution time of this algorithm is very short.
As a future work, we are currently studying when anchors are absent, how to determine the probability density of the distribution of a sensor node only by the RSSI values of sensor nodes.Moreover, we plan to conduct some practical experiments to confirm the effectiveness of our proposed algorithm.

5. 1 .
Simulation Environment.To evaluate the performance of our proposed localization algorithm based on maximum a posteriori (MAP), we developed a simulation program realizing MAP algorithm.We compare MAP algorithm with the least-squares trilateration (LST) in which the point with the minimum value of 0≤k<n (d k − d k ) 2 in the target region is taken as the estimated location of a node.

Figure 1 :
Figure 1: Average localization errors of MAP algorithm under different grid sizes.

Figure 2 :
Figure 2: A localization result of MAP algorithm and LST algorithm.In the figure, the solid points represent the actual locations of sensor nodes, the hollow points represent the estimated locations of sensor nodes computed by MAP algorithm, and the cross points represent the estimated locations of sensor nodes computed by LST algorithm.

Figure 3 :Figure 4 :
Figure 3: Average localization errors of MAP algorithm and LST algorithm under different numbers of anchors.

Figure 6 :
Figure 6: Average localization errors of MAP algorithm and LST algorithm under different numbers of faulty anchors.

Figure 7 :
Figure 7: Execution times of MAP algorithm and LST algorithm under different number of anchors.

Figure 8 :
Figure 8: Execution times of MAP algorithm and LST algorithm under different grid sizes.