# A Node Location Algorithm Based on Improved Whale Optimization in Wireless Sensor Networks

Authors: Pingzhang Gou; Bo He; Zhaoyang Yu
Journal: Wireless Communications and Mobile Computing
 (2021)

---

## Abstract

With the popularity of swarm intelligence algorithms, the positioning of nodes to be located in wireless sensor networks (WSNs) has received more and more attention. To overcome the disadvantage of large ranging error and low positioning accuracy caused by the positioning algorithm of the received signal strength indication (RSSI) ranging model, we use the RSSI modified by Gaussian to reduce the distance measurement error and introduce an improved whale optimization algorithm to optimize the location of the nodes to be positioned to improve the positioning accuracy. The experimental results show that the improved whale algorithm performs better than the whale optimization algorithm and other swarm intelligence algorithms under 20 different types of benchmark function tests. The positioning accuracy of the proposed location algorithm is better than that of the original RSSI algorithm, the hybrid exponential and polynomial particle swarm optimization (HPSO) positioning algorithms, the whale optimization, and the quasiaffine transformation evolutionary (WOA-QT) positioning algorithm. It can be concluded that the cluster intelligence algorithm has better advantages than the original RSSI in WSN node positioning, and the improved algorithm in this paper has more advantages than several other cluster intelligence algorithms, which can effectively solve the positioning requirements in practical applications.


---

## Body

## 1. Introduction

Wireless sensor networks (WSNs) are multihop wireless networks composed of sensor nodes deployed in the detection area in a wireless self-assembling manner [1, 2]. It can be defined as a network of tiny, small, expensive, and highly intelligent devices of sensor nodes. These sensors are capable of cooperatively sensing the environment, collecting and processing information about the sensed objects in the network coverage area, and eventually transmitting the information to the observer. This dynamic and cooperative ability of WSNs to sense, process, and transmit information allows them to be used in a large number of applications that need to reflect certain features of the real world, such as smart factories, environmental monitoring, smart homes, and military reconnaissance. In these applications, WSNs node localization techniques are very important, both for finding data sources and for tracking moving targets. The definition of the WSNs localization problem is to find the exact location of unknown target sensor nodes randomly deployed in the monitoring environment by using the existing exact location of sensor nodes (represented as anchor nodes).In recent years, with the rise of swarm intelligence algorithms derived from traditional algorithms, combined with the principle of bionics, researchers mathematically model swarm intelligence algorithms according to biological evolution mechanisms. The swarm intelligence optimization algorithm is an adaptive artificial intelligence technology for solving extreme value problems. Therefore, this algorithm is widely used in various industries. For example, the butterfly optimization algorithm (BOA) is used to optimize the coupling problem of the bolted rim to obtain the implementation of the latest optimization method for a light vehicle design [3]. A robot clamping mechanism is designed by combining the grasshopper optimization algorithm (GOA) and the Nelder-Mead algorithm [4]. A new hybrid Taguchi salt swarm algorithm is used to accelerate the optimization process of industrial structure design problems and seek the global optimal solution [5]. The seagull optimization algorithm (SOA) is used to solve the shape optimization problem of vehicle support [6]. A new metaheuristic algorithm equilibrium optimization algorithm (EOA) is used to solve the structural design optimization problem of automobile seat support [7]. Nine latest metaheuristic algorithms are used to seek the optimal design of automatic planetary gear train [8]. The swarm intelligence optimization algorithms play an important role in solving these problems. The localization problem in WSNs can also be regarded as a complex mathematical model to a certain extent, so a swarm intelligence algorithm is also suitable for the localization problem in WSNs. According to previous studies, we optimize the position coordinates of the positioning node in the optimization stage of the positioning algorithm to get the position coordinates closer to the real value.An effective node positioning method must consider the following two points: (1) Which positioning algorithm should be used to obtain higher positioning accuracy? (2) What kind of swarm intelligence method should be used to optimize its positioning and get a closer approximation to the true distance? Based on whether the physical distance between nodes is measured during the positioning process, the positioning algorithm is divided into two categories: range-based and range-free [9, 10]. Because the received signal strength indication (RSSI) [11, 12] technology-based on ranging does not require much hardware for sensor nodes, it is easy to implement and has become a widely used ranging technology in WSNs node positioning. Therefore, this paper adopts the distance measurement method based on RSSI to meet the principle of low power consumption and low cost. However, when transmitted in the real physical environment, the wireless signal is unavoidably interfered with by noise such as multipath fading, diffraction, antenna gain, and nonline-of-sight and produces uncertain propagation loss, resulting in large positioning error of RSSI algorithm. We use the Gauss function to correct the collected RSSI values to solve this problem. What kind of swarm intelligence algorithm can better optimize the location of nodes to be located? The whale optimization algorithm (WOA) is selected because it has a simple structure, few parameters, and strong active searchability. WOA has been proved to be superior to some advanced optimization algorithms. It is faster and more accurate than the traditional particle swarm optimization (PSO) algorithm in solving multivariate functions [13]. However, the WOA still has the disadvantage of slow convergence and is easy to fall into local optimum. We introduce hierarchy and feedback mechanisms in the contraction encirclement stage and random walk stage of the WOA to improve the globality and convergence speed.Based on the above problems, we integrate the RSSI ranging and trilateral centroid positioning algorithm after Gaussian preprocessing, which can improve the positioning accuracy to a certain extent. In this paper, the proposed improved WOA algorithm is used to optimize the positioning nodes to further reduce the positioning error. The main contributions of this paper are as follows:(1)
We introduce the hierarchy of the GWO in the contraction encirclement stage to improve the global search ability of the WOA. In the random walk stage, the feedback mechanism is introduced to increase the diversity of the population to improve the convergence speed. The improved WOA is applied to the RSSI location problem of WSNs(2)
The objective function is redesigned to obtain the location of the node to be located closer to the real value. To further save the optimization time, the auxiliary strategy of the bounding-box search space is used in the early stage of the algorithmThe rest of this paper is organized as follows. Section2 reviews the related work. Section 3 introduces the RSSI model. The Section 4 mainly introduces the principle of the WOA algorithm and the improvement of the WOA algorithm in this paper. Section 5 discusses the implementation of the improved WOA in RSSI location in detail. Section 6 gives the experimental results and corresponding analysis, and Section 7 summarizes the conclusions and general discussion.


## 2. Related Work

This section focuses on the work done in the RSSI positioning algorithm and node optimization to improve positioning accuracy.


### 2.1. RSSI Localization Algorithm

The RSSI algorithm is a range-based algorithm that is widely used because it does not need additional hardware facilities and low power consumption. However, the accuracy of RSSI ranging is easily disturbed by uncertain factors such as multipath propagation and obstacles. Therefore, many researchers use different algorithms to improve positioning accuracy. Bianchi et al. analyzed the influence of RSSI samples, anchor node number, and location according to the threshold algorithm of receiver operating characteristics. Mobile node power consumption is reduced and localization accuracy is improved, but the hardware cost is high [14]. Newton Gauss’ iterative method to solve the node position can effectively reduce the amount of iterative calculation, but the positioning accuracy is poor in a high noise environment [15]. Some studies incorporate deep learning, such as combined hierarchical analysis and weighted nearest neighbor algorithm for indoor localization in the literature [16]. The hierarchical analysis method can reasonably extend the influence of RSSI differences between reference points on the weights, resulting in better localization performance. The adaptive Kalman filter noise reduction method is also improved, and the output is corrected according to the error between the RSSI measurement and the desired output. The localization accuracy is effectively improved, but the time complexity of the algorithm is too high. The RSSI signals emitted by the anchor node to the node to be located were clustered by a fuzzy C-mean clustering algorithm, which reduced the RSSI ranging error and improved the localization accuracy of the node [17]. Ahmadi et al. combined the learning regression tree method and the filtering method using the RSSI metric to propose a novel target tracking algorithm that produces more accurate results. The results show the relevance and effectiveness of the method [18]. In addition, Shah et al. proposed a 3D weighted centroid algorithm and RSSI ranging model strategy for WSNs node localization based on smart devices [19]. Ahmad et al. proposed a parametric loop division (PLD) algorithm for 3D localization in WSNs. In this scheme, the sensor nodes are located in the area defined by the anchor node network. By iteratively shrinking that region towards its center point, this scheme provides better positioning accuracy compared with the existing scheme [20]. Some other studies have combined two localization algorithms, such as the DV-Hop improvement algorithm based on RSSI hop quantization with error correction, which can effectively reduce the impact of accumulated errors on distance estimation and improve the localization accuracy of the node to be located [21].These algorithms improve the positioning accuracy of the nodes to be positioned to a certain extent. We use the trilateral centroid location algorithm based on RSSI to locate the positioning nodes initially. It is less affected by the change of transmission environment and does not require the interaction between nodes in the positioning process. However, because RSSI values are susceptible to air or occlusion in the environment, when the distance is constant, the RSSI values received by the same unknown node will fluctuate to varying degrees. Furthermore, the RSSI values of nodes closer to each other are usually smaller than those of nodes farther away. Therefore, this paper corrects the RSSI values to avoid the accuracy of the data in the case of individual anomalies.


### 2.2. Node Optimization Algorithm

WSNs range-based positioning algorithms usually measure the distance or angle between nodes according to the spatial geometry principle to achieve the localization of nodes, which can be divided into the trilateral localization method, triangular localization method, minimum-maximum method, maximum likelihood method, etc. The trilateral localization method is widely used due to the small time complexity of the algorithm, low power consumption, and low cost. Although the trilateral localization method can accurately locate the position when three anchor nodes cross (see Figure1), the accuracy of their position estimation is low when there is no cross (see Figure 2).Figure 1
The situation where three anchor nodes cross.Figure 2
The situation where the three anchor nodes do not cross.We use a swarm intelligence optimization algorithm to optimize the initial position of the positioning node to make up for the low accuracy mentioned above. The optimization algorithm based on swarm intelligence considers the calculation of nodes to be located as an optimization problem. By setting the objective function, a conditional optimal solution is found in the solution space, that is, the coordinate value of the nodes to be located. For example, genetic algorithms (GA) [22], ant colony optimization (ACO) [23], firefly algorithm (FA) [24], grey wolf optimizer (GWO) [25], particle swarm optimization (PSO) [26], and recently developed swarm intelligence algorithms can produce higher accuracy, such as whale optimization algorithm (WOA) [27], slime mould algorithm (SMA) [28], Hunger games search (HGS) [29], and Harris Hawks optimizer (HHO) [30].Due to the optimization capability of the particle swarm algorithm, many researchers have used it in the localization process of WSNs. Songyut et al. improved distance estimation by node selection and the PSO. The estimation error of each hop is considered to reduce the error between the actual distance and the estimated distance, and different methods are used to solve the problem of localization on the line or approximate line [31]. Wu et al. proposed a hybrid adaptive particle swarm optimization and Monte Carlo combination of node localization algorithm for 3D mobile wireless sensor networks, which considers the random mobility of anchor points and unknown nodes. And an improved particle swarm optimization method and Monte Carlo are used to localize the mobile nodes. The algorithm works well in various cases with the highest localization accuracy, least time consuming, and highest localization rate [32]. Meng et al. used a particle swarm optimization algorithm to optimize the nodes to be localized to improve the accuracy of the localized nodes. Due to the convergence conditions and initial search space characteristics of the particle swarm algorithm in WSN localization, the particle swarm algorithm was improved, and the improved particle swarm algorithm did not increase the time complexity and space complexity of the algorithm compared to the original particle swarm algorithm [33]. In addition, there are some applications of new swarm intelligence algorithms. A hybrid algorithm is presented, SMA combined with adaptive guided differential evolution (AGDE) (SMA-AGDE). The AGDE mutation method was used to enhance the local search ability of population agents, increase the diversity of the population, and avoid premature convergence. Using the AGDE mutation method to enhance the local search ability of population agents, increase the diversity of the population, and avoid premature convergence [34]. This paper presents a node location method based on the salp group algorithm (SSA). Under different wireless sensor network deployments, the algorithm is compared with the well-known optimization algorithms, namely, PSO, butterfly optimization (BOA), FA, and GWO. The simulation results show that this location algorithm is superior to other algorithms in terms of an average positioning error, calculation time, and some positioning nodes [35]. Based on the principle of hexagonal geometry, the unknown node is located at the centroid of the partition area. The routing mechanism is enhanced by the modified enhanced flower pollination algorithm (EFPA), which effectively reduces network traffic and energy consumption [36].Owing to the limited hardware resources of WSNs nodes, the location algorithms using cluster intelligence optimization still need to keep the time and space complexity low, have a simple structure, be easy to implement, and do not require much parameter tuning. Among the various schemes mentioned above, a considerable number of algorithms do not meet this requirement. The WOA is a group intelligence optimization algorithm proposed by Seyedali Mirjalili in 2016 to find the best solution by mimicking the search process of whales catching food in the ocean. Pan et al. combined the advantages of the two algorithms of whale optimization and quasiaffine transformation evolution algorithm which not only retains the unique framework advantages of whale optimization but also has the excellent coevolution ability of the quasiaffine transformation evolution algorithm. At the same time, the search space is dynamically reduced to further save the optimization space and got a satisfactory positioning accuracy [37]. A new communication mechanism (CM) is embedded in the basic WOA to improve the global optimal searchability and development trend of WOA. Then, the optimization (BBO) algorithm based on biogeography is used to coordinate the exploration and development trends [38]. Three strategies are added to the original method to further improve its exploration and development performance and to better balance the exploration and development trend. The chaos initialization phase is introduced into the optimizer to start the whale group triggered by chaos. Gaussian variation is used to enhance the diversity level of the evolutionary population. Chaotic local search and “shrinkage” strategies are adopted to enhance the development tendency of the basic optimizer [39]. In the whale optimization algorithm (WOA), two new effective strategies, Levy flight and chaotic local search, are synchronously introduced to guide the group, further promote the coordination between the inclusive exploration ability and neighborhood information ability of traditional technologies, and study the ability of core search WOA to deal with optimization tasks [40].We further improve the WOA algorithm to overcome the shortcomings of slow convergence and easy to fall into local optimization. In the optimization stage, the preliminary position of the positioning node is optimized to improve the positioning accuracy.


## 2.1. RSSI Localization Algorithm

The RSSI algorithm is a range-based algorithm that is widely used because it does not need additional hardware facilities and low power consumption. However, the accuracy of RSSI ranging is easily disturbed by uncertain factors such as multipath propagation and obstacles. Therefore, many researchers use different algorithms to improve positioning accuracy. Bianchi et al. analyzed the influence of RSSI samples, anchor node number, and location according to the threshold algorithm of receiver operating characteristics. Mobile node power consumption is reduced and localization accuracy is improved, but the hardware cost is high [14]. Newton Gauss’ iterative method to solve the node position can effectively reduce the amount of iterative calculation, but the positioning accuracy is poor in a high noise environment [15]. Some studies incorporate deep learning, such as combined hierarchical analysis and weighted nearest neighbor algorithm for indoor localization in the literature [16]. The hierarchical analysis method can reasonably extend the influence of RSSI differences between reference points on the weights, resulting in better localization performance. The adaptive Kalman filter noise reduction method is also improved, and the output is corrected according to the error between the RSSI measurement and the desired output. The localization accuracy is effectively improved, but the time complexity of the algorithm is too high. The RSSI signals emitted by the anchor node to the node to be located were clustered by a fuzzy C-mean clustering algorithm, which reduced the RSSI ranging error and improved the localization accuracy of the node [17]. Ahmadi et al. combined the learning regression tree method and the filtering method using the RSSI metric to propose a novel target tracking algorithm that produces more accurate results. The results show the relevance and effectiveness of the method [18]. In addition, Shah et al. proposed a 3D weighted centroid algorithm and RSSI ranging model strategy for WSNs node localization based on smart devices [19]. Ahmad et al. proposed a parametric loop division (PLD) algorithm for 3D localization in WSNs. In this scheme, the sensor nodes are located in the area defined by the anchor node network. By iteratively shrinking that region towards its center point, this scheme provides better positioning accuracy compared with the existing scheme [20]. Some other studies have combined two localization algorithms, such as the DV-Hop improvement algorithm based on RSSI hop quantization with error correction, which can effectively reduce the impact of accumulated errors on distance estimation and improve the localization accuracy of the node to be located [21].These algorithms improve the positioning accuracy of the nodes to be positioned to a certain extent. We use the trilateral centroid location algorithm based on RSSI to locate the positioning nodes initially. It is less affected by the change of transmission environment and does not require the interaction between nodes in the positioning process. However, because RSSI values are susceptible to air or occlusion in the environment, when the distance is constant, the RSSI values received by the same unknown node will fluctuate to varying degrees. Furthermore, the RSSI values of nodes closer to each other are usually smaller than those of nodes farther away. Therefore, this paper corrects the RSSI values to avoid the accuracy of the data in the case of individual anomalies.


## 2.2. Node Optimization Algorithm

WSNs range-based positioning algorithms usually measure the distance or angle between nodes according to the spatial geometry principle to achieve the localization of nodes, which can be divided into the trilateral localization method, triangular localization method, minimum-maximum method, maximum likelihood method, etc. The trilateral localization method is widely used due to the small time complexity of the algorithm, low power consumption, and low cost. Although the trilateral localization method can accurately locate the position when three anchor nodes cross (see Figure1), the accuracy of their position estimation is low when there is no cross (see Figure 2).Figure 1
The situation where three anchor nodes cross.Figure 2
The situation where the three anchor nodes do not cross.We use a swarm intelligence optimization algorithm to optimize the initial position of the positioning node to make up for the low accuracy mentioned above. The optimization algorithm based on swarm intelligence considers the calculation of nodes to be located as an optimization problem. By setting the objective function, a conditional optimal solution is found in the solution space, that is, the coordinate value of the nodes to be located. For example, genetic algorithms (GA) [22], ant colony optimization (ACO) [23], firefly algorithm (FA) [24], grey wolf optimizer (GWO) [25], particle swarm optimization (PSO) [26], and recently developed swarm intelligence algorithms can produce higher accuracy, such as whale optimization algorithm (WOA) [27], slime mould algorithm (SMA) [28], Hunger games search (HGS) [29], and Harris Hawks optimizer (HHO) [30].Due to the optimization capability of the particle swarm algorithm, many researchers have used it in the localization process of WSNs. Songyut et al. improved distance estimation by node selection and the PSO. The estimation error of each hop is considered to reduce the error between the actual distance and the estimated distance, and different methods are used to solve the problem of localization on the line or approximate line [31]. Wu et al. proposed a hybrid adaptive particle swarm optimization and Monte Carlo combination of node localization algorithm for 3D mobile wireless sensor networks, which considers the random mobility of anchor points and unknown nodes. And an improved particle swarm optimization method and Monte Carlo are used to localize the mobile nodes. The algorithm works well in various cases with the highest localization accuracy, least time consuming, and highest localization rate [32]. Meng et al. used a particle swarm optimization algorithm to optimize the nodes to be localized to improve the accuracy of the localized nodes. Due to the convergence conditions and initial search space characteristics of the particle swarm algorithm in WSN localization, the particle swarm algorithm was improved, and the improved particle swarm algorithm did not increase the time complexity and space complexity of the algorithm compared to the original particle swarm algorithm [33]. In addition, there are some applications of new swarm intelligence algorithms. A hybrid algorithm is presented, SMA combined with adaptive guided differential evolution (AGDE) (SMA-AGDE). The AGDE mutation method was used to enhance the local search ability of population agents, increase the diversity of the population, and avoid premature convergence. Using the AGDE mutation method to enhance the local search ability of population agents, increase the diversity of the population, and avoid premature convergence [34]. This paper presents a node location method based on the salp group algorithm (SSA). Under different wireless sensor network deployments, the algorithm is compared with the well-known optimization algorithms, namely, PSO, butterfly optimization (BOA), FA, and GWO. The simulation results show that this location algorithm is superior to other algorithms in terms of an average positioning error, calculation time, and some positioning nodes [35]. Based on the principle of hexagonal geometry, the unknown node is located at the centroid of the partition area. The routing mechanism is enhanced by the modified enhanced flower pollination algorithm (EFPA), which effectively reduces network traffic and energy consumption [36].Owing to the limited hardware resources of WSNs nodes, the location algorithms using cluster intelligence optimization still need to keep the time and space complexity low, have a simple structure, be easy to implement, and do not require much parameter tuning. Among the various schemes mentioned above, a considerable number of algorithms do not meet this requirement. The WOA is a group intelligence optimization algorithm proposed by Seyedali Mirjalili in 2016 to find the best solution by mimicking the search process of whales catching food in the ocean. Pan et al. combined the advantages of the two algorithms of whale optimization and quasiaffine transformation evolution algorithm which not only retains the unique framework advantages of whale optimization but also has the excellent coevolution ability of the quasiaffine transformation evolution algorithm. At the same time, the search space is dynamically reduced to further save the optimization space and got a satisfactory positioning accuracy [37]. A new communication mechanism (CM) is embedded in the basic WOA to improve the global optimal searchability and development trend of WOA. Then, the optimization (BBO) algorithm based on biogeography is used to coordinate the exploration and development trends [38]. Three strategies are added to the original method to further improve its exploration and development performance and to better balance the exploration and development trend. The chaos initialization phase is introduced into the optimizer to start the whale group triggered by chaos. Gaussian variation is used to enhance the diversity level of the evolutionary population. Chaotic local search and “shrinkage” strategies are adopted to enhance the development tendency of the basic optimizer [39]. In the whale optimization algorithm (WOA), two new effective strategies, Levy flight and chaotic local search, are synchronously introduced to guide the group, further promote the coordination between the inclusive exploration ability and neighborhood information ability of traditional technologies, and study the ability of core search WOA to deal with optimization tasks [40].We further improve the WOA algorithm to overcome the shortcomings of slow convergence and easy to fall into local optimization. In the optimization stage, the preliminary position of the positioning node is optimized to improve the positioning accuracy.


## 3. RSSI Ranging Model

According to the transmission loss between the transmitter and receiver, RSSI transforms the transmission loss into the distance by using the theoretical model or empirical model [11]. The channel attenuation has a great influence on the localization accuracy of RSSI. The Log-distance distribution model used in this paper is as follows:
(1)PLd=PLd0+10nlogdd0+ε,where PLd is the signal strength of the node to be located received by the base station, and PLd0 is the signal strength of the anchor node d0 received by the base station; n is the proportional factor of path length and path loss; d0 is the distance between the anchor node and the base station; d represents the distance between the node to be located and the base station to be calculated; and ε is Gaussian noise with zero means.According to Equation (1), the estimated distance between the anchor node and the node to be located is as follows:
(2)d=10PLd−PLd0−ε/10n.


## 4. Improved Whale Algorithm

### 4.1. Whale Optimization Algorithm

The WOA is a class of stochastic swarm intelligence optimization algorithms constructed by simulating the whale feeding process. The individual whales in the algorithm update their position and estimate the position of the prey through certain optimization strategies to achieve the algorithm to find the optimal and converge to the optimal solution, which is the coordinate value of the node to be located. WOA includes three ways to update the position: surround prey, random search, and spiral search. Firstly, we initialize the positionWi=1,2,⋯,n and fitness values for each whale and then evolve each individual in the population separately, calculate the coefficient vectors A⟶ and C⟶, and generate a uniformly distributed decision random number p.
(3)A⟶=2ar1⟶−a,C⟶=2r2⟶,where a decreases from 2 to 0 as the number of iterations increases throughout the iteration period and r1⟶ andr2⟶ are random vectors on 0,1.


#### 4.1.1. Encircle the Prey

When the decision coefficientp<0.5 (p is a random number, and the legend in this paper takes 0.5) and ∣A⟶∣≤1, it indicates that the current humpback whale has found the prey XP and is in the process of shrinking encircling (see Figure 3). At this time, the current global optimal whale position is regarded as the target prey position (or the position closest to the target prey), and the whale updates the position based on the current global optimal whale position. The mathematical model of this process is as follows:
(4)X⟶t+1=X⟶∗t−A⟶C⟶X⟶∗t−X⟶t,where t is the number of iterations, X⟶t is the whale position, and X⟶∗t is the current global optimal whale individual location.Figure 3
Location update strategy of surrounding prey and random search.


#### 4.1.2. Random Search

When the decision coefficientp<0.5 and ∣A⟶∣>1, the current whales are randomly walking in the global space for foraging, and the survey range is wide (see Figure 3). The mathematical model of this strategy is as follows:
(5)X⟶t+1=Xr⟶−A⟶C⟶Xr⟶−X⟶t,where t is the current number of iterations, Xr⟶ is the position vector of the randomly selected individuals in the current population, and the positions of the current whale individuals in the t and t+1 generations are X⟶tand X⟶t+1, respectively.


#### 4.1.3. Spiral Search

When the decision-making coefficientp≥0.5, it means that the whale is engaged in spiral bubble predation (see Figure 4). Firstly, the distance between the current whale and the current optimal p≥0.5 whale is calculated, and then, a spiral equation is established between the two positions, that is, the whale preys on its prey with a spiral bubble net. The mathematical model for simulating the spiral predation behavior of humpback whales is as follows:
(6)X⟶t+1=X⟶∗t+Dp⟶eblcos2πl,(7)Dp⟶=X⟶∗t−X⟶t,where Dp⟶ is the distance from the whale in the current position to the whale in the current global optimal position, b is the constant used to define the shape of the logarithmic spiral, and l is a uniformly distributed random number between -1 and 1.Figure 4
Location update strategy during the spiral search.The original WOA in the process of random walk foraging, the position of a whale, is randomly selected for updating. This complete randomness increases the uncertainty of the algorithm, leads to poor stability of the algorithm, and slows down the convergence speed. This paper adopts the feedback mechanism to improve the convergence speed of the algorithm by combining the current optimal whale position. In the process of shrinking and surrounding prey, only the optimal whale position in the current state is considered, and the suboptimal solution is not considered, so it is easy to fall into local optimization. However, the hierarchy used in the grey wolf optimization algorithm can better solve this problem. Therefore, the grey wolf optimization algorithm is combined to further solve the optimal whale position.


### 4.2. Improve the Globality of the Surrounding Contraction Phase

In the process of circling the whale, the group will only consider the best whale position in the current state. Therefore, it belongs to local optimization. We consider other suboptimal solutions to solve this problem to increase the communication between groups. The hierarchy strategy of the grey wolf optimizer (GWO) is introduced to select the first three historical optimal positions {Xα⟶, Xβ⟶, Xγ⟶}. We can obtain the potential optimal solution from Equation (8):
(8)Xα⟶t+1=Xα⟶∗t−A⟶C⟶Xα⟶∗t−X⟶t,Xβ⟶t+1=Xβ⟶∗t−A⟶C⟶Xβ⟶∗t−X⟶t,Xγ⟶t+1=Xγ⟶∗t−A⟶C⟶Xγ⟶∗t−X⟶t.The new location is updated to(9)Xnew⟶t+1=∑i=α,β,γfXit∑j=α,β,γfXjtX⟶t+1.


### 4.3. Improve the Convergence Speed of Random Walk Stage

In the random walk foraging strategy of the whale optimization algorithm, the position of a whale in the population is randomly selected as the basic solution to update the position. Although this completely random selection can maintain the activity of the population, it also increases the uncertainty of the algorithm, resulting in the poor stability of the algorithm and slowing down the convergence speed. The feedback mechanism can increase the diversity of the population and exchange information with the whale in the current optimal position. In this way, the whale does not need to go for no purpose, and it can also avoid the blindness of randomly selected individuals. The mathematical model is as follows:(10)Xnew⟶=Xr⟶+rand∗Xr⟶−X⟶∗t,where Xr⟶ is for the randomly selected individuals and X⟶∗t is the optimal location. It can be seen from Equation (10) that the position of the new whale is determined by the random whale position and the optimal whale position, which can ensure the population activity and accelerate the convergence speed. After introducing the feedback mechanism, the whale random walk formula is as follows:
(11)Xnew⟶t+1=Xnew⟶−A⟶C⟶Xr⟶−X⟶t.


## 4.1. Whale Optimization Algorithm

The WOA is a class of stochastic swarm intelligence optimization algorithms constructed by simulating the whale feeding process. The individual whales in the algorithm update their position and estimate the position of the prey through certain optimization strategies to achieve the algorithm to find the optimal and converge to the optimal solution, which is the coordinate value of the node to be located. WOA includes three ways to update the position: surround prey, random search, and spiral search. Firstly, we initialize the positionWi=1,2,⋯,n and fitness values for each whale and then evolve each individual in the population separately, calculate the coefficient vectors A⟶ and C⟶, and generate a uniformly distributed decision random number p.
(3)A⟶=2ar1⟶−a,C⟶=2r2⟶,where a decreases from 2 to 0 as the number of iterations increases throughout the iteration period and r1⟶ andr2⟶ are random vectors on 0,1.


### 4.1.1. Encircle the Prey

When the decision coefficientp<0.5 (p is a random number, and the legend in this paper takes 0.5) and ∣A⟶∣≤1, it indicates that the current humpback whale has found the prey XP and is in the process of shrinking encircling (see Figure 3). At this time, the current global optimal whale position is regarded as the target prey position (or the position closest to the target prey), and the whale updates the position based on the current global optimal whale position. The mathematical model of this process is as follows:
(4)X⟶t+1=X⟶∗t−A⟶C⟶X⟶∗t−X⟶t,where t is the number of iterations, X⟶t is the whale position, and X⟶∗t is the current global optimal whale individual location.Figure 3
Location update strategy of surrounding prey and random search.


### 4.1.2. Random Search

When the decision coefficientp<0.5 and ∣A⟶∣>1, the current whales are randomly walking in the global space for foraging, and the survey range is wide (see Figure 3). The mathematical model of this strategy is as follows:
(5)X⟶t+1=Xr⟶−A⟶C⟶Xr⟶−X⟶t,where t is the current number of iterations, Xr⟶ is the position vector of the randomly selected individuals in the current population, and the positions of the current whale individuals in the t and t+1 generations are X⟶tand X⟶t+1, respectively.


### 4.1.3. Spiral Search

When the decision-making coefficientp≥0.5, it means that the whale is engaged in spiral bubble predation (see Figure 4). Firstly, the distance between the current whale and the current optimal p≥0.5 whale is calculated, and then, a spiral equation is established between the two positions, that is, the whale preys on its prey with a spiral bubble net. The mathematical model for simulating the spiral predation behavior of humpback whales is as follows:
(6)X⟶t+1=X⟶∗t+Dp⟶eblcos2πl,(7)Dp⟶=X⟶∗t−X⟶t,where Dp⟶ is the distance from the whale in the current position to the whale in the current global optimal position, b is the constant used to define the shape of the logarithmic spiral, and l is a uniformly distributed random number between -1 and 1.Figure 4
Location update strategy during the spiral search.The original WOA in the process of random walk foraging, the position of a whale, is randomly selected for updating. This complete randomness increases the uncertainty of the algorithm, leads to poor stability of the algorithm, and slows down the convergence speed. This paper adopts the feedback mechanism to improve the convergence speed of the algorithm by combining the current optimal whale position. In the process of shrinking and surrounding prey, only the optimal whale position in the current state is considered, and the suboptimal solution is not considered, so it is easy to fall into local optimization. However, the hierarchy used in the grey wolf optimization algorithm can better solve this problem. Therefore, the grey wolf optimization algorithm is combined to further solve the optimal whale position.


## 4.1.1. Encircle the Prey

When the decision coefficientp<0.5 (p is a random number, and the legend in this paper takes 0.5) and ∣A⟶∣≤1, it indicates that the current humpback whale has found the prey XP and is in the process of shrinking encircling (see Figure 3). At this time, the current global optimal whale position is regarded as the target prey position (or the position closest to the target prey), and the whale updates the position based on the current global optimal whale position. The mathematical model of this process is as follows:
(4)X⟶t+1=X⟶∗t−A⟶C⟶X⟶∗t−X⟶t,where t is the number of iterations, X⟶t is the whale position, and X⟶∗t is the current global optimal whale individual location.Figure 3
Location update strategy of surrounding prey and random search.


## 4.1.2. Random Search

When the decision coefficientp<0.5 and ∣A⟶∣>1, the current whales are randomly walking in the global space for foraging, and the survey range is wide (see Figure 3). The mathematical model of this strategy is as follows:
(5)X⟶t+1=Xr⟶−A⟶C⟶Xr⟶−X⟶t,where t is the current number of iterations, Xr⟶ is the position vector of the randomly selected individuals in the current population, and the positions of the current whale individuals in the t and t+1 generations are X⟶tand X⟶t+1, respectively.


## 4.1.3. Spiral Search

When the decision-making coefficientp≥0.5, it means that the whale is engaged in spiral bubble predation (see Figure 4). Firstly, the distance between the current whale and the current optimal p≥0.5 whale is calculated, and then, a spiral equation is established between the two positions, that is, the whale preys on its prey with a spiral bubble net. The mathematical model for simulating the spiral predation behavior of humpback whales is as follows:
(6)X⟶t+1=X⟶∗t+Dp⟶eblcos2πl,(7)Dp⟶=X⟶∗t−X⟶t,where Dp⟶ is the distance from the whale in the current position to the whale in the current global optimal position, b is the constant used to define the shape of the logarithmic spiral, and l is a uniformly distributed random number between -1 and 1.Figure 4
Location update strategy during the spiral search.The original WOA in the process of random walk foraging, the position of a whale, is randomly selected for updating. This complete randomness increases the uncertainty of the algorithm, leads to poor stability of the algorithm, and slows down the convergence speed. This paper adopts the feedback mechanism to improve the convergence speed of the algorithm by combining the current optimal whale position. In the process of shrinking and surrounding prey, only the optimal whale position in the current state is considered, and the suboptimal solution is not considered, so it is easy to fall into local optimization. However, the hierarchy used in the grey wolf optimization algorithm can better solve this problem. Therefore, the grey wolf optimization algorithm is combined to further solve the optimal whale position.


## 4.2. Improve the Globality of the Surrounding Contraction Phase

In the process of circling the whale, the group will only consider the best whale position in the current state. Therefore, it belongs to local optimization. We consider other suboptimal solutions to solve this problem to increase the communication between groups. The hierarchy strategy of the grey wolf optimizer (GWO) is introduced to select the first three historical optimal positions {Xα⟶, Xβ⟶, Xγ⟶}. We can obtain the potential optimal solution from Equation (8):
(8)Xα⟶t+1=Xα⟶∗t−A⟶C⟶Xα⟶∗t−X⟶t,Xβ⟶t+1=Xβ⟶∗t−A⟶C⟶Xβ⟶∗t−X⟶t,Xγ⟶t+1=Xγ⟶∗t−A⟶C⟶Xγ⟶∗t−X⟶t.The new location is updated to(9)Xnew⟶t+1=∑i=α,β,γfXit∑j=α,β,γfXjtX⟶t+1.


## 4.3. Improve the Convergence Speed of Random Walk Stage

In the random walk foraging strategy of the whale optimization algorithm, the position of a whale in the population is randomly selected as the basic solution to update the position. Although this completely random selection can maintain the activity of the population, it also increases the uncertainty of the algorithm, resulting in the poor stability of the algorithm and slowing down the convergence speed. The feedback mechanism can increase the diversity of the population and exchange information with the whale in the current optimal position. In this way, the whale does not need to go for no purpose, and it can also avoid the blindness of randomly selected individuals. The mathematical model is as follows:(10)Xnew⟶=Xr⟶+rand∗Xr⟶−X⟶∗t,where Xr⟶ is for the randomly selected individuals and X⟶∗t is the optimal location. It can be seen from Equation (10) that the position of the new whale is determined by the random whale position and the optimal whale position, which can ensure the population activity and accelerate the convergence speed. After introducing the feedback mechanism, the whale random walk formula is as follows:
(11)Xnew⟶t+1=Xnew⟶−A⟶C⟶Xr⟶−X⟶t.


## 5. Node Location Algorithm Based on Improved WOA

### 5.1. Trilateral Centroid Localization Algorithm Based on RSSI Modification

In this section, the Gaussian fitting function is used to correct the collected RSSI values and screen out outliers. Then, the RSSI ranging model calculates the initial distance from the revised RSSI value to make the initial distance closer to the real distance. The trilateral centroid location algorithm calculates the estimated position of the node to be located.


#### 5.1.1. Gaussian Fitting of RSSI Values

Commonly used preprocessing filtering models include maximum likelihood filtering, mean filtering, least-squares estimation filtering, and Gaussian filtering. Most variables in the natural environment obey normal or similar distributions, so Gaussian functions are often used when dealing with some data variables. We use Gaussian filtering in preprocessing the collected RSSI values and filtering the abnormal data. The optimized RSSI values are closer to the real values. Among the collected signal values, the data with large errors are generally small probability events, and most of the data still fluctuate within a reasonable range. Gaussian filtering can screen out the data in the high-probability occurrence area and output it as the average value. This effectively eliminates mutant data. The Gaussian fitting function is as follows [41]:
(12)fxi=x0+Aσπ/2×e−2xi−μ2/σ2,where the mean μ=∑i=1NRSSIi/N, standard deviationσ=∑i=1NRSSIi−μ2/N−1, x0, and A are undetermined coefficients, and the position and signal value relationship of anchor node are used to determine. xi represents the ith signal value received by the node, and N is the total number of RSSI values received by the node.According to the characteristics of Gaussian function, most RSSI values are distributed inμ−σ,μ+σ. The average value of this interval indicates the high-density distribution of the RSSI values, which means that the closer the measured value is to the actual value. After Gauss filtering, the current RSSI value is output as follows:
(13)RSSI¯=1n∑i=1nxixi∈μ−σ,μ+σ,where n is in the interval μ−σ,μ+σ and the number of the RSSI values in.The modified distance measure by Gaussian fitting is(14)dnew=10RSSI¯−PLd0−ε/10n


#### 5.1.2. Trilateral Centroid Localization and Node Location Estimation

It is assumed that the corresponding distancesd1, d2, and d3 of the node Ux,y to be located are calculated by receiving RSSI signals sent by three anchor nodes A1x1,y1, A2x2,y2, and A3x3,y3. Take A1, A2, and A3 as the center of the circle, and the distances d1, d2, and d3 as the radius as the circle (see Figure 5).Figure 5
Principle of the trilateral localization algorithm.In Figure5, points S1x1,y1, S2x2,y2, and S3x3,y3 are the intersection points of three circles, that is, the three vertices in the trilateral centroid localization algorithm.According to the distance formula between two points, the equations are established:(15)x−x12+y−y12=d1^,x−x22+y−y22=d2^,⋮x−xn2+y−yn2=dn^.Equation (15) is transformed into a system of linear equations:
(16)AX=b.Among are the following:(17)A=−2x1−xny1−ynx2−xny1−yn⋮⋮xn−1−xny1−yn,X=xy,b=x12−x22+y12−yn2−d1∧2+dn∧2x22−x22+y22−yn2−d2∧2+dn∧2⋮xn−12−xn2+yn−12−yn2−dn−1∧2+dn∧2.The estimated coordinates of the nodes to be located are obtained:(18)X=ATA−1ATbBecause the RSSI values are easy to be interfered with by noise, environment, and other factors, the centers of three localization circles sometimes do not intersect at one point but intersect each other to form three intersections:S1x1,y1, S2x2,y2, and S3x3,y3. The trilateral centroid localization algorithm can be used to estimate the location of the unknown node.The estimated location of the nodeUx,y to be located is as follows:
(19)x=1m∑i=1mxi,y=1m∑i=1mxi.m=3,i=1,2,3,


### 5.2. Location Optimization Based on Improved Whale Algorithm

To further reduce the localization error, we get the estimated distance between the anchor node and the node to be located is obtained through the above correction calculation. (1) The search scope is created through the bounding box. (2) The fitness value is improved. (3) The improved whale algorithm is applied to optimize the location coordinates of the nodes to be located.


#### 5.2.1. Bounding-Box and Search Space

The main idea of the bounding box algorithm is that in a two-dimensional area, the location of the neighbor anchor node of the unknown node and the communication radius of the sensor node can be used to obtain a two-dimensional square area where the unknown node is located.We restrict the two-dimensional search space of the locations of the nodes to be located according to the minimum-maximum method. First, we calculate the distancedi between the anchor node and the node to be located i (distance from the ith anchor node to the node to be located, i=1,2,⋯,n). Each anchor node is used as the center of the circle (2di) is the radius and draws a square parallel to the x-axes and y-axes. The search space for the location of the node is to be located in the intersection of all the bounding-boxes (shown in the red box in Figure 6).Figure 6
Bounding-box principle.The overlapping areas are(20)maxxi−di,maxyi−di×maxxi+di,maxyi+di,where i=1,2,⋯,n.


#### 5.2.2. Determination of Fitness Function

The fitness function is improved by the difference between the approximate distance from the anchor node to the node to be located, and the actual distance from the whale to the anchor node. The three anchor nodes are supposed asA1, A2, and A3, respectively, and U is the node to be located (see Figure 7).Figure 7
Node localization based on improved fitness value.To get the estimated position close to the actual position, the difference between the approximate distance from the anchor node to the unknown node and the actual distance from the whale to the anchor node is minimal. That is,fxkt,Ai=xkt−xAi,yAi−dnewi,j is the smallest, where xAi,yAi is the coordinate of the ith anchor node,dnewi,j is the estimated distance from the ith anchor node to the jth anchor node after RSSI correction, and xkt is the position coordinate of the whale at time t.Then set the fitness function value as(21)fxkt=1N∑i=1Nfxkt,Ai,where N is the number of anchor nodes.


#### 5.2.3. Improved WOA to Optimize Nodes to Be Located

Firstly, the location area is narrowed by bounding-box, and the location of the whale is initialized within this area. Then, the global optimal position of the whale is updated based on the improved fitness function of Equation (21). Finally, the location of the whale is updated according to three different situations. If the current whale is the optimal solution, the optimal location of the node to be located is obtained.According to the above description, the pseudocode of the improved whale optimization algorithm is given in Algorithm1.Algorithm 1: Improved optimization of node coordinates.
Input Anchor node coordinates and estimated distance of nodes to be located.Output The optimized coordinate value XP of the node is to be located.1. Initial number of whale:W=X1,X2,⋯,XN;2. Computing fitness (Xi) by Equation (21);3.XP = best;4.whilet<tMaxdo5.for all Xi in W do6.  Updatea, A, D, l, p;7.ifp<0.5then8.if∣A∣≤1then9.   Update location by Equation (9);10.else if∣A∣>1then11.   Update location by Equation (11);12.end if13.else ifp≥0.5then14.   Update location by Equation (6);15.end if16.end for17.end while18. Computing fitness (Xi) by Equation (21);19. UpdateXP;20.t⟵t+1;21.ReturnXP;


## 5.1. Trilateral Centroid Localization Algorithm Based on RSSI Modification

In this section, the Gaussian fitting function is used to correct the collected RSSI values and screen out outliers. Then, the RSSI ranging model calculates the initial distance from the revised RSSI value to make the initial distance closer to the real distance. The trilateral centroid location algorithm calculates the estimated position of the node to be located.


### 5.1.1. Gaussian Fitting of RSSI Values

Commonly used preprocessing filtering models include maximum likelihood filtering, mean filtering, least-squares estimation filtering, and Gaussian filtering. Most variables in the natural environment obey normal or similar distributions, so Gaussian functions are often used when dealing with some data variables. We use Gaussian filtering in preprocessing the collected RSSI values and filtering the abnormal data. The optimized RSSI values are closer to the real values. Among the collected signal values, the data with large errors are generally small probability events, and most of the data still fluctuate within a reasonable range. Gaussian filtering can screen out the data in the high-probability occurrence area and output it as the average value. This effectively eliminates mutant data. The Gaussian fitting function is as follows [41]:
(12)fxi=x0+Aσπ/2×e−2xi−μ2/σ2,where the mean μ=∑i=1NRSSIi/N, standard deviationσ=∑i=1NRSSIi−μ2/N−1, x0, and A are undetermined coefficients, and the position and signal value relationship of anchor node are used to determine. xi represents the ith signal value received by the node, and N is the total number of RSSI values received by the node.According to the characteristics of Gaussian function, most RSSI values are distributed inμ−σ,μ+σ. The average value of this interval indicates the high-density distribution of the RSSI values, which means that the closer the measured value is to the actual value. After Gauss filtering, the current RSSI value is output as follows:
(13)RSSI¯=1n∑i=1nxixi∈μ−σ,μ+σ,where n is in the interval μ−σ,μ+σ and the number of the RSSI values in.The modified distance measure by Gaussian fitting is(14)dnew=10RSSI¯−PLd0−ε/10n


### 5.1.2. Trilateral Centroid Localization and Node Location Estimation

It is assumed that the corresponding distancesd1, d2, and d3 of the node Ux,y to be located are calculated by receiving RSSI signals sent by three anchor nodes A1x1,y1, A2x2,y2, and A3x3,y3. Take A1, A2, and A3 as the center of the circle, and the distances d1, d2, and d3 as the radius as the circle (see Figure 5).Figure 5
Principle of the trilateral localization algorithm.In Figure5, points S1x1,y1, S2x2,y2, and S3x3,y3 are the intersection points of three circles, that is, the three vertices in the trilateral centroid localization algorithm.According to the distance formula between two points, the equations are established:(15)x−x12+y−y12=d1^,x−x22+y−y22=d2^,⋮x−xn2+y−yn2=dn^.Equation (15) is transformed into a system of linear equations:
(16)AX=b.Among are the following:(17)A=−2x1−xny1−ynx2−xny1−yn⋮⋮xn−1−xny1−yn,X=xy,b=x12−x22+y12−yn2−d1∧2+dn∧2x22−x22+y22−yn2−d2∧2+dn∧2⋮xn−12−xn2+yn−12−yn2−dn−1∧2+dn∧2.The estimated coordinates of the nodes to be located are obtained:(18)X=ATA−1ATbBecause the RSSI values are easy to be interfered with by noise, environment, and other factors, the centers of three localization circles sometimes do not intersect at one point but intersect each other to form three intersections:S1x1,y1, S2x2,y2, and S3x3,y3. The trilateral centroid localization algorithm can be used to estimate the location of the unknown node.The estimated location of the nodeUx,y to be located is as follows:
(19)x=1m∑i=1mxi,y=1m∑i=1mxi.m=3,i=1,2,3,


## 5.1.1. Gaussian Fitting of RSSI Values

Commonly used preprocessing filtering models include maximum likelihood filtering, mean filtering, least-squares estimation filtering, and Gaussian filtering. Most variables in the natural environment obey normal or similar distributions, so Gaussian functions are often used when dealing with some data variables. We use Gaussian filtering in preprocessing the collected RSSI values and filtering the abnormal data. The optimized RSSI values are closer to the real values. Among the collected signal values, the data with large errors are generally small probability events, and most of the data still fluctuate within a reasonable range. Gaussian filtering can screen out the data in the high-probability occurrence area and output it as the average value. This effectively eliminates mutant data. The Gaussian fitting function is as follows [41]:
(12)fxi=x0+Aσπ/2×e−2xi−μ2/σ2,where the mean μ=∑i=1NRSSIi/N, standard deviationσ=∑i=1NRSSIi−μ2/N−1, x0, and A are undetermined coefficients, and the position and signal value relationship of anchor node are used to determine. xi represents the ith signal value received by the node, and N is the total number of RSSI values received by the node.According to the characteristics of Gaussian function, most RSSI values are distributed inμ−σ,μ+σ. The average value of this interval indicates the high-density distribution of the RSSI values, which means that the closer the measured value is to the actual value. After Gauss filtering, the current RSSI value is output as follows:
(13)RSSI¯=1n∑i=1nxixi∈μ−σ,μ+σ,where n is in the interval μ−σ,μ+σ and the number of the RSSI values in.The modified distance measure by Gaussian fitting is(14)dnew=10RSSI¯−PLd0−ε/10n


## 5.1.2. Trilateral Centroid Localization and Node Location Estimation

It is assumed that the corresponding distancesd1, d2, and d3 of the node Ux,y to be located are calculated by receiving RSSI signals sent by three anchor nodes A1x1,y1, A2x2,y2, and A3x3,y3. Take A1, A2, and A3 as the center of the circle, and the distances d1, d2, and d3 as the radius as the circle (see Figure 5).Figure 5
Principle of the trilateral localization algorithm.In Figure5, points S1x1,y1, S2x2,y2, and S3x3,y3 are the intersection points of three circles, that is, the three vertices in the trilateral centroid localization algorithm.According to the distance formula between two points, the equations are established:(15)x−x12+y−y12=d1^,x−x22+y−y22=d2^,⋮x−xn2+y−yn2=dn^.Equation (15) is transformed into a system of linear equations:
(16)AX=b.Among are the following:(17)A=−2x1−xny1−ynx2−xny1−yn⋮⋮xn−1−xny1−yn,X=xy,b=x12−x22+y12−yn2−d1∧2+dn∧2x22−x22+y22−yn2−d2∧2+dn∧2⋮xn−12−xn2+yn−12−yn2−dn−1∧2+dn∧2.The estimated coordinates of the nodes to be located are obtained:(18)X=ATA−1ATbBecause the RSSI values are easy to be interfered with by noise, environment, and other factors, the centers of three localization circles sometimes do not intersect at one point but intersect each other to form three intersections:S1x1,y1, S2x2,y2, and S3x3,y3. The trilateral centroid localization algorithm can be used to estimate the location of the unknown node.The estimated location of the nodeUx,y to be located is as follows:
(19)x=1m∑i=1mxi,y=1m∑i=1mxi.m=3,i=1,2,3,


## 5.2. Location Optimization Based on Improved Whale Algorithm

To further reduce the localization error, we get the estimated distance between the anchor node and the node to be located is obtained through the above correction calculation. (1) The search scope is created through the bounding box. (2) The fitness value is improved. (3) The improved whale algorithm is applied to optimize the location coordinates of the nodes to be located.


### 5.2.1. Bounding-Box and Search Space

The main idea of the bounding box algorithm is that in a two-dimensional area, the location of the neighbor anchor node of the unknown node and the communication radius of the sensor node can be used to obtain a two-dimensional square area where the unknown node is located.We restrict the two-dimensional search space of the locations of the nodes to be located according to the minimum-maximum method. First, we calculate the distancedi between the anchor node and the node to be located i (distance from the ith anchor node to the node to be located, i=1,2,⋯,n). Each anchor node is used as the center of the circle (2di) is the radius and draws a square parallel to the x-axes and y-axes. The search space for the location of the node is to be located in the intersection of all the bounding-boxes (shown in the red box in Figure 6).Figure 6
Bounding-box principle.The overlapping areas are(20)maxxi−di,maxyi−di×maxxi+di,maxyi+di,where i=1,2,⋯,n.


### 5.2.2. Determination of Fitness Function

The fitness function is improved by the difference between the approximate distance from the anchor node to the node to be located, and the actual distance from the whale to the anchor node. The three anchor nodes are supposed asA1, A2, and A3, respectively, and U is the node to be located (see Figure 7).Figure 7
Node localization based on improved fitness value.To get the estimated position close to the actual position, the difference between the approximate distance from the anchor node to the unknown node and the actual distance from the whale to the anchor node is minimal. That is,fxkt,Ai=xkt−xAi,yAi−dnewi,j is the smallest, where xAi,yAi is the coordinate of the ith anchor node,dnewi,j is the estimated distance from the ith anchor node to the jth anchor node after RSSI correction, and xkt is the position coordinate of the whale at time t.Then set the fitness function value as(21)fxkt=1N∑i=1Nfxkt,Ai,where N is the number of anchor nodes.


### 5.2.3. Improved WOA to Optimize Nodes to Be Located

Firstly, the location area is narrowed by bounding-box, and the location of the whale is initialized within this area. Then, the global optimal position of the whale is updated based on the improved fitness function of Equation (21). Finally, the location of the whale is updated according to three different situations. If the current whale is the optimal solution, the optimal location of the node to be located is obtained.According to the above description, the pseudocode of the improved whale optimization algorithm is given in Algorithm1.Algorithm 1: Improved optimization of node coordinates.
Input Anchor node coordinates and estimated distance of nodes to be located.Output The optimized coordinate value XP of the node is to be located.1. Initial number of whale:W=X1,X2,⋯,XN;2. Computing fitness (Xi) by Equation (21);3.XP = best;4.whilet<tMaxdo5.for all Xi in W do6.  Updatea, A, D, l, p;7.ifp<0.5then8.if∣A∣≤1then9.   Update location by Equation (9);10.else if∣A∣>1then11.   Update location by Equation (11);12.end if13.else ifp≥0.5then14.   Update location by Equation (6);15.end if16.end for17.end while18. Computing fitness (Xi) by Equation (21);19. UpdateXP;20.t⟵t+1;21.ReturnXP;


## 5.2.1. Bounding-Box and Search Space

The main idea of the bounding box algorithm is that in a two-dimensional area, the location of the neighbor anchor node of the unknown node and the communication radius of the sensor node can be used to obtain a two-dimensional square area where the unknown node is located.We restrict the two-dimensional search space of the locations of the nodes to be located according to the minimum-maximum method. First, we calculate the distancedi between the anchor node and the node to be located i (distance from the ith anchor node to the node to be located, i=1,2,⋯,n). Each anchor node is used as the center of the circle (2di) is the radius and draws a square parallel to the x-axes and y-axes. The search space for the location of the node is to be located in the intersection of all the bounding-boxes (shown in the red box in Figure 6).Figure 6
Bounding-box principle.The overlapping areas are(20)maxxi−di,maxyi−di×maxxi+di,maxyi+di,where i=1,2,⋯,n.


## 5.2.2. Determination of Fitness Function

The fitness function is improved by the difference between the approximate distance from the anchor node to the node to be located, and the actual distance from the whale to the anchor node. The three anchor nodes are supposed asA1, A2, and A3, respectively, and U is the node to be located (see Figure 7).Figure 7
Node localization based on improved fitness value.To get the estimated position close to the actual position, the difference between the approximate distance from the anchor node to the unknown node and the actual distance from the whale to the anchor node is minimal. That is,fxkt,Ai=xkt−xAi,yAi−dnewi,j is the smallest, where xAi,yAi is the coordinate of the ith anchor node,dnewi,j is the estimated distance from the ith anchor node to the jth anchor node after RSSI correction, and xkt is the position coordinate of the whale at time t.Then set the fitness function value as(21)fxkt=1N∑i=1Nfxkt,Ai,where N is the number of anchor nodes.


## 5.2.3. Improved WOA to Optimize Nodes to Be Located

Firstly, the location area is narrowed by bounding-box, and the location of the whale is initialized within this area. Then, the global optimal position of the whale is updated based on the improved fitness function of Equation (21). Finally, the location of the whale is updated according to three different situations. If the current whale is the optimal solution, the optimal location of the node to be located is obtained.According to the above description, the pseudocode of the improved whale optimization algorithm is given in Algorithm1.Algorithm 1: Improved optimization of node coordinates.
Input Anchor node coordinates and estimated distance of nodes to be located.Output The optimized coordinate value XP of the node is to be located.1. Initial number of whale:W=X1,X2,⋯,XN;2. Computing fitness (Xi) by Equation (21);3.XP = best;4.whilet<tMaxdo5.for all Xi in W do6.  Updatea, A, D, l, p;7.ifp<0.5then8.if∣A∣≤1then9.   Update location by Equation (9);10.else if∣A∣>1then11.   Update location by Equation (11);12.end if13.else ifp≥0.5then14.   Update location by Equation (6);15.end if16.end for17.end while18. Computing fitness (Xi) by Equation (21);19. UpdateXP;20.t⟵t+1;21.ReturnXP;


## 6. Simulation Results and Analysis

### 6.1. Performance Evaluation of Improved Whale Algorithm

We compare the improved whale algorithm with HPSO [42] and WOA-QT [37]. The parameter settings of the three algorithms are shown in Table 1. 20 benchmark functions are selected to evaluate the performance of the improved whale algorithm in this part, as shown in Tables 2 and 3. Most benchmark functions come from the literature [43], including unimodal and multimodal functions.Table 1
Parameter settings of three algorithms.
Algorithm nameHPSOWOA-QTImproved WOANumber of individuals303030Maximum number of iterations500500500Logarithmic helix linear constant b11Two learning factorse1=1.2e2=1.2Table 2
Details of 10 unimodal functions.
NumberFunctionDimensionRangeMinimum value1F1x=∑i=1nxi230100,10002F2x=∑i=1nixi230−10,1003F3x=∑i=1nx+∏i+1n30−10,1004F4x=∑i=1n∑j−1ixj230100,10005F5x=maxixi,iϵ1,m30100,10006F6x=∑i=1n−1100xx+12−xi2+xi−1230−30,3007F7x=∑i=1n−1xi+0.5230100,10008F8x=∑i=1nixi4+rand0,130−1.28,−1.2809F9x=∑i=1nixi430−1.28,1.28010F10x=∑i=1nxi230−1,10Table 3
Details of 10 multimodal functions.
NumberFunctionDimensionRangeMinimum value1F11x=1−cos2∏∑i=1nxi2+0.1∑i=1nxi230−100,10002F12x=∑i=1nxi2−10cos2πxi+1030−5.12,5.1203F13x=−208exp−0.21/m∑inxi2−exp1/m∑i=1ncos2πxi+20−2.71830−32,3204F14x=1/4000+∑inxi2−∏i=1ncosxi/i+130−600,60005F15x=π/n×10sinπy1+∑i−1n−1yi−121+10sin2πyi+130−50,5006F16x=∑i=1n∣xisinxi+0.1xi∣30−100,10007F17x=0.59+sin2∑i=1nxi2−0.5/1+0.0001∑i=1nx4230−100,10008F18x=∑i=1n0.1n−0.1∑i=1ncos5πxi−∑i=1nxi−π230−10,1009F19x=∑i=1n−10.1nxi2+xx+120.25×1+sin250xi2+xx+120.130−1,1010F20x=∑i=1n106i−1/n−1xi230−10,100The dimension is set to 30, and the selected comparison indexes include the minimum value (the best value), the median value, the maximum value, the average value, and the standard deviation value of each experiment. Figures8–27 show the convergence curve for each function.Figure 8
The convergence curve ofF1.Figure 9
The convergence curve ofF2.Figure 10
The convergence curve ofF3.Figure 11
The convergence curve ofF4.Figure 12
The convergence curve ofF5.Figure 13
The convergence curve ofF6.Figure 14
The convergence curve ofF7.Figure 15
The convergence curve ofF8.Figure 16
The convergence curve ofF9.Figure 17
The convergence curve ofF10.Figure 18
The convergence curve ofF11.Figure 19
The convergence curve ofF12.Figure 20
The convergence curve ofF13.Figure 21
The convergence curve ofF14.Figure 22
The convergence curve ofF15.Figure 23
The convergence curve ofF16.Figure 24
The convergence curve ofF17.Figure 25
The convergence curve ofF18.Figure 26
The convergence curve ofF19.Figure 27
The convergence curve ofF20.In the test of 10 unimodal functions, we compared with the HPSO algorithm and WOA-QT algorithm, the improved whale algorithm shows excellent local search ability in addition to theF7 function. From the experimental results of 10 multimodal functions, it can be seen that the improved whale algorithm has an absolute advantage in the ranking of all indicators. This shows that it can effectively avoid falling into local optimization.


### 6.2. Experimental Results and Analysis of Node Location Algorithm

To test the impact of prediction errors of this algorithm on sensor node positioning, the performance of the proposed positioning algorithm is evaluated in this section. The original RSSI location algorithm without error correction, HPSO algorithm, and WOA-QT algorithm are selected for comparative analysis. The positioning accuracy of the three algorithms is analyzed by comparing the relationship between the number of anchor nodes, the communication distance and the ranging error, and the average positioning error.


#### 6.2.1. Experimental Parameter Setting

The simulation experiment is carried out in Matlab R2018b. The experimental parameters are shown in Table4.Table 4
Parameter setting of a simulation experiment.
Parameter nameValueSimulation area50m∗50mNumber of anchor nodes10-40Total number of nodes50-100Reference distanced01 mReference range signal strengthPd0-15 dbmSignal measurement times50-20The standard deviation of signal noiseε0.5-4In the same case, each algorithm runs 40 times, and the other parameters of the optimization algorithm are the same as those in Table1. The simulation area is set as 50m∗50m, and 100 sensor network nodes including nodes to be located, and anchor nodes are randomly generated in the setting area. The communication radius of nodes to be located and anchor nodes is the same. We use the average positioning error index to evaluate the positioning performance of the model:
(22)Eavg=1N∑i=1Nx−xi2+y−yi2,where N is the total number of nodes in the test area, x,y is the actual value of the nodes to be located, and xi,yi is the estimated value of the nodes to be located.


#### 6.2.2. Comparative Analysis of RSSI Measurement and Localization Error before and after Gaussian Fitting

From Figure28, the curve of the change of the localization error between the RSSI measurement before Gaussian fitting and the RSSI measurement after Gaussian fitting can be seen. The results show that the localization error decreases with the increase of distance. However, compared with the RSSI measurement before Gaussian fitting, the RSSI measurement after Gaussian fitting can improve the localization accuracy, especially for the near distance RSSI measurement. It is found that Gaussian filtering can effectively reduce the influence of short-term interference on the RSSI measurement value and improve the anti-interference, stability, and ranging accuracy of range.Figure 28
Comparison of RSSI measurement values and localization errors before and after Gaussian fitting.


#### 6.2.3. Analysis of the Influence of the Number of Anchor Nodes on the Average Localization Error

From Figure29, the curve of the average positioning error with the number of anchor nodes can be seen. We classified the different proportions of anchor nodes into four groups. With the increase of the number of anchor nodes and the connectivity of WSNs, the average positioning error of the four positioning algorithms is decreasing. In the case of the same anchor nodes, the average positioning error of this algorithm is smaller. The average positioning errors of the original RSSI algorithm, HPSO algorithm, WOA-QT algorithm, and the node location algorithm in this paper are 0.45, 0.30, 0.29, and 0.27, respectively, and the positioning errors of this algorithm is reduced by about 40.15%, 10.43%, and 6.91% compared with the original RSSI algorithm, HPSO algorithm, and WOA-QT algorithm. It is proved that the localization effect of this paper is better than the other three localization algorithms.Figure 29
Comparison and analysis of localization errors with a different number of anchor nodes.


#### 6.2.4. Analysis of the Influence of Communication Distance on Average Localization Error

From Figure30, the curve of the average positioning error varying with the communication distance can be seen. As the radius enlarges, the positioning error decreases gradually, but after reaching a certain degree, the positioning error increases gradually due to the environmental impact of RSSI. The average positioning error of the four algorithms decreases with the increase of communication distance between 15 m and 30 m and increases with the increase of communication distance after more than 30 m. The average positioning errors of the original RSSI algorithm, HPSO algorithm, WOA-QT algorithm, and the node location algorithm in this paper are 0.57, 0.41, 0.38, and 0.32, respectively, and the positioning errors of this algorithm is reduced by 45.06%, 21.95%, and 15.73% compared with the original RSSI algorithm, HPSO algorithm, and WOA-QT algorithm. When the communication radius is small, the performance of the localization algorithm in this paper has obvious advantages over the other three algorithms, but when the radius increases gradually, the advantages are not obvious before.Figure 30
Comparison of localization errors of different communication distances.


#### 6.2.5. Analysis of the Influence of Ranging Error and Average Localization Error

It can be seen from Figure31 that the average positioning error of the four algorithms gradually increases as the ranging error increases. The average positioning errors of the original RSSI algorithm, HPSO algorithm, WOA-QT algorithm, and the node location algorithm in this paper are 0.82, 0.57, 0.51, and 0.39, respectively, and the positioning errors of this algorithm is reduced by 52.43%, 30.96%, and 22.83% compared with the original RSSI algorithm, HPSO algorithm, and WOA-QT algorithm. When the ranging error is 0.3, the average positioning error of the four algorithms increases greatly. However, no matter how the ranging error changes, the localization error of the algorithm in this paper is always smaller than that of the original RSSI, HPSO, and WOA-QT algorithm.Figure 31
Comparison of different ranging errors and average localization errors.


## 6.1. Performance Evaluation of Improved Whale Algorithm

We compare the improved whale algorithm with HPSO [42] and WOA-QT [37]. The parameter settings of the three algorithms are shown in Table 1. 20 benchmark functions are selected to evaluate the performance of the improved whale algorithm in this part, as shown in Tables 2 and 3. Most benchmark functions come from the literature [43], including unimodal and multimodal functions.Table 1
Parameter settings of three algorithms.
Algorithm nameHPSOWOA-QTImproved WOANumber of individuals303030Maximum number of iterations500500500Logarithmic helix linear constant b11Two learning factorse1=1.2e2=1.2Table 2
Details of 10 unimodal functions.
NumberFunctionDimensionRangeMinimum value1F1x=∑i=1nxi230100,10002F2x=∑i=1nixi230−10,1003F3x=∑i=1nx+∏i+1n30−10,1004F4x=∑i=1n∑j−1ixj230100,10005F5x=maxixi,iϵ1,m30100,10006F6x=∑i=1n−1100xx+12−xi2+xi−1230−30,3007F7x=∑i=1n−1xi+0.5230100,10008F8x=∑i=1nixi4+rand0,130−1.28,−1.2809F9x=∑i=1nixi430−1.28,1.28010F10x=∑i=1nxi230−1,10Table 3
Details of 10 multimodal functions.
NumberFunctionDimensionRangeMinimum value1F11x=1−cos2∏∑i=1nxi2+0.1∑i=1nxi230−100,10002F12x=∑i=1nxi2−10cos2πxi+1030−5.12,5.1203F13x=−208exp−0.21/m∑inxi2−exp1/m∑i=1ncos2πxi+20−2.71830−32,3204F14x=1/4000+∑inxi2−∏i=1ncosxi/i+130−600,60005F15x=π/n×10sinπy1+∑i−1n−1yi−121+10sin2πyi+130−50,5006F16x=∑i=1n∣xisinxi+0.1xi∣30−100,10007F17x=0.59+sin2∑i=1nxi2−0.5/1+0.0001∑i=1nx4230−100,10008F18x=∑i=1n0.1n−0.1∑i=1ncos5πxi−∑i=1nxi−π230−10,1009F19x=∑i=1n−10.1nxi2+xx+120.25×1+sin250xi2+xx+120.130−1,1010F20x=∑i=1n106i−1/n−1xi230−10,100The dimension is set to 30, and the selected comparison indexes include the minimum value (the best value), the median value, the maximum value, the average value, and the standard deviation value of each experiment. Figures8–27 show the convergence curve for each function.Figure 8
The convergence curve ofF1.Figure 9
The convergence curve ofF2.Figure 10
The convergence curve ofF3.Figure 11
The convergence curve ofF4.Figure 12
The convergence curve ofF5.Figure 13
The convergence curve ofF6.Figure 14
The convergence curve ofF7.Figure 15
The convergence curve ofF8.Figure 16
The convergence curve ofF9.Figure 17
The convergence curve ofF10.Figure 18
The convergence curve ofF11.Figure 19
The convergence curve ofF12.Figure 20
The convergence curve ofF13.Figure 21
The convergence curve ofF14.Figure 22
The convergence curve ofF15.Figure 23
The convergence curve ofF16.Figure 24
The convergence curve ofF17.Figure 25
The convergence curve ofF18.Figure 26
The convergence curve ofF19.Figure 27
The convergence curve ofF20.In the test of 10 unimodal functions, we compared with the HPSO algorithm and WOA-QT algorithm, the improved whale algorithm shows excellent local search ability in addition to theF7 function. From the experimental results of 10 multimodal functions, it can be seen that the improved whale algorithm has an absolute advantage in the ranking of all indicators. This shows that it can effectively avoid falling into local optimization.


## 6.2. Experimental Results and Analysis of Node Location Algorithm

To test the impact of prediction errors of this algorithm on sensor node positioning, the performance of the proposed positioning algorithm is evaluated in this section. The original RSSI location algorithm without error correction, HPSO algorithm, and WOA-QT algorithm are selected for comparative analysis. The positioning accuracy of the three algorithms is analyzed by comparing the relationship between the number of anchor nodes, the communication distance and the ranging error, and the average positioning error.


### 6.2.1. Experimental Parameter Setting

The simulation experiment is carried out in Matlab R2018b. The experimental parameters are shown in Table4.Table 4
Parameter setting of a simulation experiment.
Parameter nameValueSimulation area50m∗50mNumber of anchor nodes10-40Total number of nodes50-100Reference distanced01 mReference range signal strengthPd0-15 dbmSignal measurement times50-20The standard deviation of signal noiseε0.5-4In the same case, each algorithm runs 40 times, and the other parameters of the optimization algorithm are the same as those in Table1. The simulation area is set as 50m∗50m, and 100 sensor network nodes including nodes to be located, and anchor nodes are randomly generated in the setting area. The communication radius of nodes to be located and anchor nodes is the same. We use the average positioning error index to evaluate the positioning performance of the model:
(22)Eavg=1N∑i=1Nx−xi2+y−yi2,where N is the total number of nodes in the test area, x,y is the actual value of the nodes to be located, and xi,yi is the estimated value of the nodes to be located.


### 6.2.2. Comparative Analysis of RSSI Measurement and Localization Error before and after Gaussian Fitting

From Figure28, the curve of the change of the localization error between the RSSI measurement before Gaussian fitting and the RSSI measurement after Gaussian fitting can be seen. The results show that the localization error decreases with the increase of distance. However, compared with the RSSI measurement before Gaussian fitting, the RSSI measurement after Gaussian fitting can improve the localization accuracy, especially for the near distance RSSI measurement. It is found that Gaussian filtering can effectively reduce the influence of short-term interference on the RSSI measurement value and improve the anti-interference, stability, and ranging accuracy of range.Figure 28
Comparison of RSSI measurement values and localization errors before and after Gaussian fitting.


### 6.2.3. Analysis of the Influence of the Number of Anchor Nodes on the Average Localization Error

From Figure29, the curve of the average positioning error with the number of anchor nodes can be seen. We classified the different proportions of anchor nodes into four groups. With the increase of the number of anchor nodes and the connectivity of WSNs, the average positioning error of the four positioning algorithms is decreasing. In the case of the same anchor nodes, the average positioning error of this algorithm is smaller. The average positioning errors of the original RSSI algorithm, HPSO algorithm, WOA-QT algorithm, and the node location algorithm in this paper are 0.45, 0.30, 0.29, and 0.27, respectively, and the positioning errors of this algorithm is reduced by about 40.15%, 10.43%, and 6.91% compared with the original RSSI algorithm, HPSO algorithm, and WOA-QT algorithm. It is proved that the localization effect of this paper is better than the other three localization algorithms.Figure 29
Comparison and analysis of localization errors with a different number of anchor nodes.


### 6.2.4. Analysis of the Influence of Communication Distance on Average Localization Error

From Figure30, the curve of the average positioning error varying with the communication distance can be seen. As the radius enlarges, the positioning error decreases gradually, but after reaching a certain degree, the positioning error increases gradually due to the environmental impact of RSSI. The average positioning error of the four algorithms decreases with the increase of communication distance between 15 m and 30 m and increases with the increase of communication distance after more than 30 m. The average positioning errors of the original RSSI algorithm, HPSO algorithm, WOA-QT algorithm, and the node location algorithm in this paper are 0.57, 0.41, 0.38, and 0.32, respectively, and the positioning errors of this algorithm is reduced by 45.06%, 21.95%, and 15.73% compared with the original RSSI algorithm, HPSO algorithm, and WOA-QT algorithm. When the communication radius is small, the performance of the localization algorithm in this paper has obvious advantages over the other three algorithms, but when the radius increases gradually, the advantages are not obvious before.Figure 30
Comparison of localization errors of different communication distances.


### 6.2.5. Analysis of the Influence of Ranging Error and Average Localization Error

It can be seen from Figure31 that the average positioning error of the four algorithms gradually increases as the ranging error increases. The average positioning errors of the original RSSI algorithm, HPSO algorithm, WOA-QT algorithm, and the node location algorithm in this paper are 0.82, 0.57, 0.51, and 0.39, respectively, and the positioning errors of this algorithm is reduced by 52.43%, 30.96%, and 22.83% compared with the original RSSI algorithm, HPSO algorithm, and WOA-QT algorithm. When the ranging error is 0.3, the average positioning error of the four algorithms increases greatly. However, no matter how the ranging error changes, the localization error of the algorithm in this paper is always smaller than that of the original RSSI, HPSO, and WOA-QT algorithm.Figure 31
Comparison of different ranging errors and average localization errors.


## 6.2.1. Experimental Parameter Setting

The simulation experiment is carried out in Matlab R2018b. The experimental parameters are shown in Table4.Table 4
Parameter setting of a simulation experiment.
Parameter nameValueSimulation area50m∗50mNumber of anchor nodes10-40Total number of nodes50-100Reference distanced01 mReference range signal strengthPd0-15 dbmSignal measurement times50-20The standard deviation of signal noiseε0.5-4In the same case, each algorithm runs 40 times, and the other parameters of the optimization algorithm are the same as those in Table1. The simulation area is set as 50m∗50m, and 100 sensor network nodes including nodes to be located, and anchor nodes are randomly generated in the setting area. The communication radius of nodes to be located and anchor nodes is the same. We use the average positioning error index to evaluate the positioning performance of the model:
(22)Eavg=1N∑i=1Nx−xi2+y−yi2,where N is the total number of nodes in the test area, x,y is the actual value of the nodes to be located, and xi,yi is the estimated value of the nodes to be located.


## 6.2.2. Comparative Analysis of RSSI Measurement and Localization Error before and after Gaussian Fitting

From Figure28, the curve of the change of the localization error between the RSSI measurement before Gaussian fitting and the RSSI measurement after Gaussian fitting can be seen. The results show that the localization error decreases with the increase of distance. However, compared with the RSSI measurement before Gaussian fitting, the RSSI measurement after Gaussian fitting can improve the localization accuracy, especially for the near distance RSSI measurement. It is found that Gaussian filtering can effectively reduce the influence of short-term interference on the RSSI measurement value and improve the anti-interference, stability, and ranging accuracy of range.Figure 28
Comparison of RSSI measurement values and localization errors before and after Gaussian fitting.


## 6.2.3. Analysis of the Influence of the Number of Anchor Nodes on the Average Localization Error

From Figure29, the curve of the average positioning error with the number of anchor nodes can be seen. We classified the different proportions of anchor nodes into four groups. With the increase of the number of anchor nodes and the connectivity of WSNs, the average positioning error of the four positioning algorithms is decreasing. In the case of the same anchor nodes, the average positioning error of this algorithm is smaller. The average positioning errors of the original RSSI algorithm, HPSO algorithm, WOA-QT algorithm, and the node location algorithm in this paper are 0.45, 0.30, 0.29, and 0.27, respectively, and the positioning errors of this algorithm is reduced by about 40.15%, 10.43%, and 6.91% compared with the original RSSI algorithm, HPSO algorithm, and WOA-QT algorithm. It is proved that the localization effect of this paper is better than the other three localization algorithms.Figure 29
Comparison and analysis of localization errors with a different number of anchor nodes.


## 6.2.4. Analysis of the Influence of Communication Distance on Average Localization Error

From Figure30, the curve of the average positioning error varying with the communication distance can be seen. As the radius enlarges, the positioning error decreases gradually, but after reaching a certain degree, the positioning error increases gradually due to the environmental impact of RSSI. The average positioning error of the four algorithms decreases with the increase of communication distance between 15 m and 30 m and increases with the increase of communication distance after more than 30 m. The average positioning errors of the original RSSI algorithm, HPSO algorithm, WOA-QT algorithm, and the node location algorithm in this paper are 0.57, 0.41, 0.38, and 0.32, respectively, and the positioning errors of this algorithm is reduced by 45.06%, 21.95%, and 15.73% compared with the original RSSI algorithm, HPSO algorithm, and WOA-QT algorithm. When the communication radius is small, the performance of the localization algorithm in this paper has obvious advantages over the other three algorithms, but when the radius increases gradually, the advantages are not obvious before.Figure 30
Comparison of localization errors of different communication distances.


## 6.2.5. Analysis of the Influence of Ranging Error and Average Localization Error

It can be seen from Figure31 that the average positioning error of the four algorithms gradually increases as the ranging error increases. The average positioning errors of the original RSSI algorithm, HPSO algorithm, WOA-QT algorithm, and the node location algorithm in this paper are 0.82, 0.57, 0.51, and 0.39, respectively, and the positioning errors of this algorithm is reduced by 52.43%, 30.96%, and 22.83% compared with the original RSSI algorithm, HPSO algorithm, and WOA-QT algorithm. When the ranging error is 0.3, the average positioning error of the four algorithms increases greatly. However, no matter how the ranging error changes, the localization error of the algorithm in this paper is always smaller than that of the original RSSI, HPSO, and WOA-QT algorithm.Figure 31
Comparison of different ranging errors and average localization errors.


## 7. Conclusions

Given the problem that RSSI ranging values in WSNs are susceptible to environmental factors, this paper presents a WSNs node location algorithm based on improved whale optimization. The RSSI ranging model is modified by a Gaussian fitting function to obtain the initial position of the node to be located. To further improve the positioning accuracy, it is optimized by the improved whale optimization algorithm. First, create a bounding box search space to narrow the range of nodes to be located. Then, the objective function is redesigned to improve the fitness function by the difference between the approximate distance from the anchor node to the node to be located and the actual distance from the whale to the anchor node to obtain better convergence speed and more accurate cost value. To further improve the convergence speed and search accuracy of the algorithm, hierarchy and feedback mechanisms are introduced into the shrinking and enclosing phases of the whale algorithm and the random walk phases, respectively. The simulation results show that the performance of this algorithm is superior to the original RSSI algorithm, HPSO, and WOA-QT algorithm, with better convergence performance and higher node positioning accuracy under the same hardware conditions. How to further improve the performance of the algorithm is an important research work in the future.



---

*Source: 7523938-2021-09-18.xml*