3.1. Problem Statement
Consider a two-dimensional region of space, where there is a sensor network given by a set of nodes
N = {
N1,
N2, …,
Nm+n}, which consists of m anchor nodes and
n sensor nodes. The coordinates of these nodes can be described with definition (1):
In WSN
N, the positions of
m anchor nodes
Ni ∈
A,
A = {
Ni|
i = 1, ...,
m} are known, while the positions of the
n sensor nodes
Nj ∈
B,
B = {
Nj|
j =
m + 1, ...,
m +
n} are unknown. In the case of multi-hop networks, the hop counts between pair nodes are already known. The Euclidean distance from node
Ni to
Nj (
i ≠
j) can be presented by Equation (2):
The hop counts from node
Ni to
Nj (
i ≠
j) can be expressed as
hij. Taking
Figure 1a as an example, in such a multi-hop network
dij is proportional to
hij, i.e.,
dij ∝
hij. Thus, the localization problem can be formulated as:
where
Ni,
Nj ∈
A,
Nk ∈
B, and
hkt denotes the hop counts between node
Nk and node
Nt (
Nt ∈
A ∪
B). Assume that the distances and hop counts from
Ni to other anchors can be represented by the vectors
yi and
xi, respectively. Our aim is to learn a function
f:
from
m training data
, where
xi ∈
X and
yi ∈
Y. The input space
X (hops), is known as the dependent variable, and the output space
Y (distances) is the independent variable. The function
f is represented by a linear model
where
w is a
m × 1 vector that contains the coefficients of the linear function. Usually, linear least squares (LLS) is used to determine w. It uses the vertical distance between the observed values
yi and the predictions
f(
xi), which are known as the residuals
ri =
yi −
f(
xi) =
yi −
wTxi.
In the LLS case, the sum of the squared residuals is minimized, which in matrix form is
with
X being the
m ×
m design matrix that combines all of the hop-count vectors, and the
m × 1 vector
y combining the distance values:
where each row corresponds to one input/output example. The coefficients could be optimized by minimizing Equation (5) as follows:
The minimizer of the problem (7) is
Thus, to make a prediction for a novel input
xnew, we only need to know the model and its parameters
w, which can be represented as
3.2. Localization Algorithm
The proposed LSRR-LA contains the following three parts: the measurement part, the training part, and the localization part.
Part A (Measurement): Assuming that hi = [h1,i, ..., hm,i]T, i = 1, ..., m is the hop-count vector from anchor Ni ∈ A to the other anchors, we thus can describe the hop-count matrix of all anchors as H1 = [h1, ..., hm]. Accordingly, the Euclidean distance vector and matrix between anchors can be represented as di = [d1,i, ..., dm,i]T, i = 1, ..., m and D1 = [d1, ..., dm], respectively. For any sensor node Nj ∈ B, it has a hop-count vector to all anchors, hj = [h1,j, ..., hm,j]T, j = m + 1, ..., m + n. Consequently, matrix H2 = [hm+1, ..., hm+n] indicates the hop-count vectors from all of the sensor nodes to all of the anchors.
On referring to Formula (10), we express the hop-count matrix
H (or the distance matrix
D) by splitting it into four parts. We denote by
H1 (resp.
D1) the
m ×
m matrix for the anchors versus themselves,
H3 (resp.
D3) the
n ×
m matrix for the anchors versus sensors, and
H4 (resp.
D4) the
n ×
n matrix for the sensors versus themselves. It is easy to know that
H2 =
H3T,
D2 =
D3T.
Note that H1, H3, and H4 are known, while D3 and D4 are unknown. The goal is to predict D3 (or D2) from H and D1.
Part B (Training): Now, we have the input matrix denoted by
H1 and the output matrix represented as
D1, and then we can train our linear model proposed in formula (4). However, as a difference from (4), here the coefficient vector
w becomes a matrix
W with
m ×
m, and the outputs are stored in the matrix
D1. Thus, the LLS solution becomes
In Formula (11), the variation range of the distance matrix D1 is different from that of the hop-count matrix H1. If the raw data is used directly, the calculation results will be affected due to the different variation range. We can eliminate this impact by preprocessing operations, such as normalization, making D1 and H1 have the same scale and to be equally emphasized. In this paper, the normalized matrices of H1 and D1 are represented by and , respectively.
When calculating the model parameter
W, we use the data of anchor nodes. If we include more anchor nodes, we will fit the training data more accurately, which means that our model is capable of minimizing the training errors more effectively. However, the minimization of training errors is not our goal. We hope that the model can accurately estimate the locations of sensor nodes, that is, the model should have a generalization capability. With many anchors, fitting the full model without penalization will result in large prediction intervals, and an LLS regression estimator may not uniquely exist. In order to avoid over-fitting, it is necessary to add a regularization item or a penalty term to the model [
21]. In addition, because the LLS estimates depend upon
, there can be problems in computing
W if
were singular or nearly singular. In this paper, a term
kI (
k > 0) is added to the matrix
for remedying this problem. The method is also called Tikhonov regularization, which is the most commonly used method of regularization of ill-posed problems. Then, the estimated
W can be described as
Here, the matrix
I is an identity matrix. With the regularization term, the model can effectively avoid over-fitting. The
k in the formula is called the hyper-parameters, which is used to balance the training errors and the regularization items [
22]. Considering that
will be an ill-conditioned matrix if
, we simply set the value of parameter
k to be 0.01 in the later simulation part.
Part C (Localization): Now, the normalized hop-count matrix
and the coefficient matrix
are used to estimate the normalized matrix
,
After obtaining the result of Equation (13), we can derive
D3 by using a reverse operation of
, and then the trilateration method or the maximum likelihood method is used to estimate the coordinates of unknown nodes [
23].
The pseudo-code of LSRR-LA is illustrated in Algorithm 1.
Algorithm 1: LSRR-LA |
input: H: hop matrix of the anchors and sensors; D1: distance matrix for the anchors versus themselves; k: hyper-parameters. |
output:: estimated locations of the sensors. |
1 Normalize matrix H1 and D1, output and ; |
2 Calculate the mapping matrix by Equation (12); |
3 Normalize matrix H3, output ; |
4 Calculate matrix by Equation (13); |
5 Derive D3 by using a reverse operation of ; |
6 Estimate coordinates by using maximum likelihood method. |
With respect to step 6 in Algorithm 1, for specific details the reader can refer to [
23].