1 Introduction

In a wireless sensor network (WSN), a large number of applications require the information on geographical location of the node within the network in order to get the accurate location of the information source. In most cases, without the location information of nodes, the data collected by the sensor nodes become meaningless [1]. In order to address node localization problems in the WSN, many studies on localization methods and algorithms have been conducted. Generally, there are two types of node localization algorithms, one is the range-based localization algorithm and the other is the range-free localization algorithm [2, 3]. The range-based localization algorithm, such as radio signal strength indicator (RSSI), time of arrival (TOA), time difference of arrival (TDOA), and angle of arrival (AOA), requires the information on distance or angle in order to provide the node localization. According to that, all these range-based localization algorithms must have a distance-measuring device on the sensor nodes. The localization accuracy obtained by the range-based algorithm is high, but the costs of localization algorithm are high [4, 5]. On the other hand, the range-free localization algorithm, such as the centroid algorithm and the DV-hop algorithm, provides the node localization though the network connectivity. Although the localization accuracy of the range-free algorithm is lower than accuracy of the range-based algorithm, range-free algorithms are widely used because of their low costs [6, 7].

Least squares support vector regression (LSSVR) is a machine learning technology based on a structure risk minimization [8]. LSSVR transforms the localization problem into the constraint optimization problem of the quadratic programming, which can greatly reduce the computational complexity and improve the computational efficiency. Meanwhile, LSSVR uses all learning samples as support vectors, which can greatly improve the regression modeling ability of the learning samples. In addition, LSSVR can obtain better location effect by optimizing the parameters of LSSVR. Hence, LSSVR algorithm has the unique advantage in the node localization for WSN [9]. For instance, the WSN node localization method based on the LSSVR modeling was proposed by Guixiong et al. [10]. In addition, the WSN node target tracking method based on the LSSVR algorithm was proposed by Kim W et al. [11]. Also, Samira Afzal proposed a large-scale mobile node localization method based on the machine learning [12]. Moreover, an improved LSSVR WSN three-dimensional mobile node localization method in an obstacle condition was proposed by Lieping et al. [13].

The Kalman filter (KF) algorithm can remove the influence of the noise. KF algorithm uses the dynamic information of the target to obtain a more accurate target location estimation, which can improve the localization accuracy [14]. Dazhong et al. used traditional KF algorithm to implement mobile node localization [15]. For instance, Hui Long et al. proposed a WSN node localization method based on the distributed extended KF algorithm [16]. Jianping et al. used the KF algorithm for mobile node localization in the complex mine environment [17]. Moreover, Rafiullah Khan et al. proposed a localization method based on extended KF algorithm [18].

All presented localization algorithms have superiorities but also have many limitations. Especially in the complex environment, the localization effects have obvious limitations because of signal non-linear attenuation, non-line-of-sight propagation, multipath effect, noise, and mobile node randomness. For example, traditional LSSVR localization method uses the least squares method to eliminate the influence of measurement errors and can obtain a better localization effect. But for mobile nodes, it will be unable to predict the motion states of nodes. Hence, if sometimes the desired localization accuracy is high and just one algorithm is used for the node localization, it may be difficult to achieve the desired localization accuracy. However, if a combination of several algorithms is used to solve the localization problem, it will be possible to achieve a better balance between quality and efficiency and can obtain a solution that meets the different localization needs. For instance, Xuewen et al. proposed a three-dimensional node localization method for WSN based on LSSVR and RSSI algorithm [19]. Moreover, Tarik Ljouad et al. proposed a method for mobile target localization based on the improved cuckoo search algorithm and KF algorithm [20]. In addition, Weidong et al. proposed a node localization method based on the least square method and extended KF algorithm [21]. In these hybrid localization methods, the obtained localization effects were better than in the single localization algorithm.

In the actual environment, the majority of nodes is not distributed only in the three-dimensional environment, but also may be mobile. In this paper, we propose a method based on LSSVR and KF algorithm to take advantage of both techniques to locate mobile nodes in three-dimensional environment. In this algorithm, KF algorithm was used to filter and estimate the position, and LSSVR algorithm was used to model and locate. The paper is organized as follows. In Section 2, a mobile node localization method in three-dimensional environment based on LSSVR algorithm is introduced. In Section 3, a distance estimation method based on KF method is introduced. In Section 4, a three-dimensional mobile node localization method based on KF-LSSVR algorithm is presented. In Section 5, localization effects of KF algorithm, LSSVR algorithm, and KF-LSSVR algorithm have been compared in the same environment and parameters. We end the paper with some conclusions concerned effectiveness and limitations of the proposed algorithm in Section 6.

2 Mobile node 3-D localization based on LSSVR algorithm

The two-dimensional LSSVR localization principle is extended to the three-dimensional environment. We assume that there are N anchor nodes S i (x i , y i , z i )(i = 1, 2, …, N), and M unknown nodes S j (x j , y j , z j )(j = 1, 2, …, M) in the three-dimensional environment. We also assume that the communication radius of all nodes and the ranging error factor are the same,and the unknown nodes can move randomly.

If the actual distance between the anchor node S i and the unknown node E is d iE , then the distance vector is composed of the actual distance from N anchor nodes to the unknown node E, V = [d1E, d2E, …, d NE ]. Since the unknown node moves randomly, the coordinates of the unknown node E also change randomly, and the distance vector V is also changed. It can be concluded that there is a non-linear mapping between the unknown node coordinates and the distance vector. In this paper, the LSSVR is used to establish the mapping model between the unknown node coordinates and the distance vector. The three-dimensional mobile node localization algorithm based on LSSVR is as follows.

  1. (1)

    Construction of the training set with virtual nodes

Due to complexity of three-dimensional mobile node localization, the three-dimensional environment is meshed into small cubes with a length of l x . Assume that the K grid points are regarded as K virtual nodes after three-dimensional space is meshed into cubes. The coordinates of each virtual node can be described as \( {S}_l^{\prime}\left({x}_l^{\prime },{y}_l^{\prime },{z}_l^{\prime}\right)\left(\mathrm{l}=1,2,\dots, K\right) \). Hence, d il is the actual distance of anchor node S i to the virtual node \( {S}_l^{\prime } \), and the corresponding distance vector is V l  = [d1l, d2l, …, d Nl ]. The training sets U x , U y and U z , shown in Eq. (1), were constructed of V l and \( {S}_l^{\prime } \). The training sets are preprocessed by the input vector standard normalization, and then the output coordinates of the unbiased regression model are obtained.

$$ \left\{\begin{array}{l}{U}_x=\left\{\left({V}_l,{x}_l^{\prime}\right)|l=1,2,\dots, K\right\}\\ {}{U}_y=\left\{\left({V}_l,{y}_l^{\prime}\right)|l=1,2,\dots, K\right\}\\ {}{U}_z=\left\{\left({V}_l,{z}_l^{\prime}\right)|l=1,2,\dots, K\right\}\end{array}\right. $$
(1)
  1. (2)

    Training of the LSSVR localization model

There are many LSSVR kernel functions, but the most commonly used function is the radial basis function (RBF), the expression of RBF can be described as follows.

$$ Y\left({u}_i,{u}_j\right)=\exp \left(-\frac{{\left\Vert {u}_i-{u}_j\right\Vert}^2}{\sigma^2}\right),\left(i,j=1,2,\dots, K\right) $$
(2)

The LSSVR is used for training the sample sets U x , U y and U z . For U x , the optimization problem is constructed and solved by Eq. (3).

$$ \left\{\begin{array}{l}{\min}_{\omega, \xi, b}\frac{1}{2}{\left\Vert \omega \right\Vert}^2+\gamma \frac{1}{2}{\sum}_{i=1}^m{\xi}_i^2\\ {}s.t.{x}_l^{\prime }={\omega}^T\phi \left({V}_l\right)+b+{\xi}_i,i=1,2,\dots, K\end{array}\right. $$
(3)

In Eq. (3), \( \phi \left(\cdot \right):{R}^n\to {R}^{n_k} \) represents the nonlinear mapping function, b is the deviation, ω is the weight, γ is the regularization parameter, and ξ i is the random error.

Using Eq. (2) and Eq. (3), the problem can be converted to the solution of the Lagrange operators α and b by Eq. (4).

$$ \left[\begin{array}{cc}0& {1}^{-T}\\ {}\overline{1}& \Omega +{\gamma}^{-1}I\end{array}\right]\left[\begin{array}{c}b\\ {}\alpha \end{array}\right]=\left[\begin{array}{c}0\\ {}{x}^{\prime}\end{array}\right] $$
(4)

where \( {x}^{\prime }=\left[{x}_1^{\prime },{x}_2^{\prime },\dots, {x}_K^{\prime}\right] \), α = [α1, α2, …, α K ]T, \( \overline{1}={\left[{1}_1,{1}_2,\dots, {1}_K\right]}^T \), and Ω ij  = Y(V i , V j ).

Parameters α and b can be obtained by \( \left[\begin{array}{c}b\\ {}\alpha \end{array}\right]=\left[\begin{array}{cc}0& {1}^{-T}\\ {}\overline{1}& \Omega +{\gamma}^{-1}I\end{array}\right]\left[\begin{array}{c}0\\ {}v\end{array}\right] \). Thus, the decision function is obtained.

$$ {f}_x\left({V}_l\right)={\sum}_{i=1}^K{\alpha}_iY\left({V}_i,{V}_j\right)+b $$
(5)

where f x (V l ) represents the X-LSSVR localization model. Similarly, f y (V l ) and f Z (V l ) can be obtained, which represent the Y-LSSVR and Z-LSSVR localization models.

  1. (3)

    Optimization of the kernel function parameter σ and regularization parameter γ

The kernel function parameter and regularization parameter directly affect the model performance, so the particle-swarm optimization algorithm is used for optimization of the LSSVR regularization parameter and the kernel function parameter, the fitness function is defined as Eq. (6) [22].

$$ {f}_{\mathrm{fitness}}=\sqrt{\sum \limits_{i=1}^M\left({\left({f}_X\left({V}_l\right)-{x}_l^{\prime}\right)}^2+{\left({f}_Y\left({V}_l\right)-{y}_l^{\prime}\right)}^2+{\left({f}_Z\left({V}_l\right)-{z}_l^{\prime}\right)}^2\right)} $$
(6)

Here, \( {x}_l^{\prime } \), \( {y}_l^{\prime } \), and \( {z}_l^{\prime } \) are the actual location coordinates of the virtual sampling point \( {S}_l^{\prime } \) in the detection area, V l is the distance vector from the sampling point to the anchor node, and f x , f y , f z are the estimated values of the regression model established by the optimization model parameter.

  1. (4)

    Localization of mobile node

The distance between the anchor node S i to the unknown node E is defined as measured distance \( {d}_{iE}^{\prime } \). Distance vector \( {V}^{\prime }=\left[{d}_{1E}^{\prime },{d}_{2E}^{\prime },\dots .,{d}_{NE}^{\prime}\right] \) is composed of the measured distances \( {d}_{iE}^{\prime } \), where i = 1, 2, …, N. In order to simplify the calculation, the distance vector V is normalized. Then, the distance vector is used as the input of the localization model. Through the anti-standardized output value, the estimated coordinates of the unknown node \( \left({x}_E^{\prime },{y}_E^{\prime },{z}_E^{\prime}\right) \) are obtained. Therefore, the three-dimensional mobile node localization based on LSSVR is achieved.

3 Distance estimation based on KF method

KF algorithm is one of the best predictive algorithms, especially for noise processing and motion prediction. Moreover, KF algorithm continually obtains new information from the predicted estimate. KF algorithm gradually eliminates the measurement errors and adjusts the posterior estimate until the estimated value is close to the actual value of the system motion state. Multi-hop ranging method is suitable in the three-dimensional static network. But in this study, there is obstacle in the environment and the unknown nodes are moving. So in the localization process, the measurement errors of the multi-hop ranging might affect the localization accuracy and cause a less accurate result. Therefore, in order to obtain the measurement distance with less error, the system error should be filtered by the KF algorithm.

Assume that the measurement error of the distance contains system error and random noise, which can be formulated as Δd i  = β + V(i), where β is the system error, and it is a slowly variable constant value, and V(i) is the random noise. In order to decrease the system errors, a KF model is used [23]. In this model, V(i) is zero mean Gauss white noise. The model is as follows.

State equation can be described as follows:

$$ X\left(i+1\right)= FX(i) $$
(7)

Among them, \( X(i)=\left[\begin{array}{c}{\widehat{\beta}}_n\\ {}\Delta {d}_i\end{array}\right] \), \( F=\left[\begin{array}{cc}1& 0\\ {}0& 1\end{array}\right] \).

Measurement equation can be written as follows:

$$ \Delta \widehat{d}(i)={\tilde{d}}_i-{\widehat{d}}_i= HX(i)+V(i) $$
(8)

where H = [1 1] and \( \Delta \widehat{d}(i) \) is the difference between the LSSVR estimated value and the actual value of the distance between nodes, \( {\tilde{d}}_i \) is the measured value of the distance between nodes, and \( {\widehat{d}}_i \) is the LSSVR estimated value of the distance between nodes.

Prediction equation can be described as follows:

$$ V(i)=\Delta \widehat{d}(i)-H\widehat{X}\left(i-1\right) $$
(9)

State update equation can be described as follows:

$$ \widehat{X}(i)=\widehat{X}\left(i-1\right)+K(i)V(i) $$
(10)

Gain equation can be described as follows:

$$ K(i)=P\left(i-1\right)H{{}^T\left[R(i)+ HP\left(i-1\right){H}^T\right]}^{-1} $$
(11)

Covariance update equation can be described as follows:

$$ P(i)=P\left(i-1\right)-P\left(i-1\right){H}^T HP\left(i-1\right){\left[R(i)+ HP\left(i-1\right){H}^T\right]}^{-1} $$
(12)

4 Mobile node 3-D localization based on KF-LSSVR algorithm

In the three-dimensional mobile node localization algorithm presented in this paper, the distance measurement error included system errors and random noise. In addition, the LSSVR algorithm is used only to overcome the random error problem, which means if there is no system errors or the measurement errors is zero mean Gauss white noise, this method can provide better localization accuracy. However, when there is a system error and the calculated distance is directly introduced into the LSSVR localization model, the coordinates obtained by the anti-standardization will have a great impact on the accuracy. According to what is mentioned, the KF algorithm is used to filter the measurement distance. By combining the KF and LSSVR algorithm, a three-dimensional localization algorithm for mobile nodes based on KF-LSSVR is proposed.

The main steps of the KF-LSSVR algorithm are as follows.

  • Step 1: initialize the environment and parameters.

  • Step 2: deploy the anchor nodes, unknown nodes, and virtual nodes and redeploy them if there are nodes deployed in the obstacle area.

  • Step 3: calculate the shortest multi-hop distance between the virtual node and the anchor node.

  • Step 4: use the particle-swarm optimization algorithm to optimize the kernel function parameter and regularization parameter of the LSSVR localization algorithm.

  • Step 5: train the sample set of virtual sampling point separately and combine it with the radial basis kernel function to obtain the Lagrange multipliers α and b. Then, determine the X-LSSVR, Y-LSSVR, and Z-LSSVR localization models.

  • Step 6: calculate the shortest multi-hop distance between the unknown nodes and the anchor nodes.

  • Step 7: construct the distance vector with the distance measured by the node and use the distance vector in KF model to obtain the more accurate distance vector between unknown nodes and anchor nodes.

  • Step 8: use the distance vector obtained in the seventh step to obtain the estimated location of the unknown nodes.

5 Experimental simulation and result discussion

5.1 Setup of experimental environment and algorithm parameters

MATLAB 2009a software environment is used to simulate different localization algorithms and compare their performance. In the simulation experiment, the WSN localization space is defined as a three-dimensional environment, whose each dimension is 100 m. In order to make the environment more similar to the actual environment, a cube obstacle with a length of 14 m is set up and distributed in the way that its coordinates satisfy the following condition 48m ≤ x, y, z ≤ 62m. During the environment initialization, 200 sensor nodes are randomly generated in the three-dimensional environment. If the anchor nodes and unknown nodes are deployed in the obstacle area, they will be redeployed. The 25% of the sensor nodes are randomly selected as anchor nodes, and the remaining nodes are selected as the unknown nodes. The communication radius of all nodes is 30 m, and ranging error factor is 5%. Three-dimensional environment is meshed with spacing t = 10 m, and the mesh nodes are set as the virtual nodes. If the virtual nodes are deployed in the obstacle area, they will be discarded. Furthermore, the optimal regularization parameter γ and kernel function parameter σ are obtained by the particle-swarm optimization algorithm. In order to reduce the effect of random distribution, the accident error, and other error factors, the simulation results are represented by the average value of 100 times of simulation, and the simulation experiment is conducted in the same condition. Before the simulation, all nodes are deployed randomly. The anchor nodes are in a fixed location after the deployment. And the unknown nodes are randomly moving with the speed of 0.4 m/s. The initial location distribution of the nodes is shown in Fig. 1, where the red dots represent the anchor nodes, the green dots represent the unknown nodes, and the color region represents the obstacle area. The localization results of KF, LSSVR, and KF-LSSVR algorithms are compared according to ranging errors, anchor node density, communication radius, moving speed, and node localization errors.

Fig. 1
figure 1

Initial location distribution of nodes

5.2 Influence of ranging errors on average localization errors

In practice, the measurement results of the anchor nodes and the unknown nodes have errors, because of the external factors and the multi-hop ranging errors, which make the measurement results different from the real state. In order to make the experimental results closer to the actual situation, the Gauss error is added to the hop distance, as shown in Eq. (13).

$$ {D}_i={d}_{ij}\left(1+ randn\times \eta \right) $$
(13)

In the following, d ij represents the real distance between two nodes, η is the error factor related to the distance measurement accuracy, and randn is a random variable obeying a standard normal distribution, whose variance is equal to 1, and its mean-value is equal to 0.

Therefore, Eq. (13) provides the distance between nodes. In the simulation, the error factor η was changed in order to decrease the ranging errors. In this paper, we do the simulation experiment in the premise of the distance error which is less than 1–10% with step 1%. The relationship between the average localization errors and the ranging errors is presented in Fig. 2. As it can be seen in Fig. 2, the average localization error of the KF-LSSVR algorithm is the smallest.

Fig. 2
figure 2

Relationship between average localization errors and ranging errors

5.3 Influence of anchor node density on localization errors

The anchor node density has a great influence on the localization errors. The higher the anchor node density is, the smaller the localization errors are, and the higher the accuracy is. However, the increase of the anchor node density will lead to the hardware cost and power consumption, which is in contrary to the low-cost and low-power consumption characteristics of the wireless sensor networks. Therefore, a compromise should be found to ensure certain accuracy and to reduce the anchor node density. The relationship between the anchor node density and the average localization errors, when the node communication radius is 30 m, is shown in Fig. 3. From the curve in Fig. 3, it can be noticed that when the anchor node density increases, the average localization errors of the KF, LSSVR, and KF-LSSVR algorithm decrease obviously, but the average localization error of KF-LSSVR algorithm represents the minimal errors.

Fig. 3
figure 3

Relationship between average localization errors and anchor node density

5.4 Influence of communication radius on average localization error

The node communication radius has a direct impact on localization errors. If the communication radius decreases, the area covered by the nodes and the number of anchor nodes in the communication radius also decrease, but the localization errors increase. The relationship between the communication radius and the average localization errors is presented in Fig. 4. As shown in Fig. 4, with the increase of the communication radius of the anchor nodes, the average localization errors of all three algorithms decrease. Although the average localization errors of the KF algorithm decrease obviously, the average localization errors of the KF-LSSVR algorithm are the minimal errors.

Fig. 4
figure 4

Relationship between average localization errors and communication radius

5.5 Influence of node speed on average localization errors

Node speed is also one of the important factors that affect the localization errors directly. If node speed is small, the localization errors will be also small, and the localization accuracy will be high. The relationship between node speed and the average localization errors is presented in Fig. 5. Figure 5 shows that, with the increase of speed, the average localization errors of all three algorithms do not change significantly. However, the average localization error of KF algorithm is very high, about 8.0 m. On the other hand, the average localization error of LSSVR algorithm is about 3.5 m, while the average localization error of KF-LSSVR algorithm is about 1.4 m.

Fig. 5
figure 5

Relationship between moving speed and average location errors

5.6 Node localization errors

The comparison of localization errors of all three localization algorithms for each unknown node is presented in Fig. 6. As shown in Fig. 6, the fluctuating range of KF algorithm localization errors is large and there are many nodes with large errors, which means that the localization algorithm stability needs to be improved. Compared with the KF algorithm, the LSSVR algorithm is relatively stable. In addition, compared with two previous localization algorithms, the fluctuating range of the KF-LSSVR localization error is smaller, which indicates that the overall stability of the KF-LSSVR algorithm is good. Furthermore, in Fig. 6, it can be seen that the KF-LSSVR algorithm has the smallest localization error among all presented localization algorithms.

Fig. 6
figure 6

Errors of three kinds of algorithm

6 Conclusions

According to the mobile node characteristics in a complex environment, a three-dimensional localization algorithm for mobile node based on the KF-LSSVR algorithm, is proposed. (1) In the proposed algorithm, the KF model was used to filter and estimate the position, which can provide higher accuracy distance measuremnet. The simulation results have shown that the ranging errors can be reduced by this way. (2) A method was presented that LSSVR model was used to mobile node localization. Mobile node localization accuracy can be improved through the LSSVR localization model. (3) A mobile node localization algorithm using a joint KF and LSSVR algorithm was proposed in this paper. Simulation results have shown that, compared with the KF localization algorithm or LSSVR localization algorithm, the overall localization ability of the proposed localization algorithm is improved.

However, the localization error of the proposed algorithm is smaller but still a little bit large, so the algorithm needs to be further improved. The ranging factor η and the grid spacing t of LSSVR localization model are fixed. In our further work, we will study the RSSI ranging method to reduce the range errors and used extended Kalman filter (EKF) localization algorithm to improve localization accuracy. And proposing a method that can choose the appropriate ranging factor η and grid spacing t in order to obtain smaller localization error will also be the subject of our further research. Moreover, in order to evaluate the mobility and the influence of the speed, it needs to be evaluated with higher speeds or with a ranging error model (TOA or RSSI based) that depends on the mobility of nodes, and this should be considered in our further studies.