#### Abstract

Mobile node localization is one of the key technologies in wireless sensor network applications. Aiming at the shortcomings of Monte Carlo algorithm (MCL) in mobile wireless sensor network node localization in nonideal environments, such as low accuracy and low sampling rate, in the prediction phase and filtering phase of MCL, the communication radius of the unknown node is determined according to the size of the irregularity of the node. Perform layering, assign adaptive weights to anchor nodes of different layers according to the area where they are located, and propose an adaptive improved Monte Carlo algorithm. After simulation analysis, the algorithm has an average localization error of nodes under different regularity conditions. It has dropped by about 12%, and the localization error has dropped by about 10% on average under different speed conditions. Aiming at the shortcomings of the MCL algorithm in mobile wireless sensor mobile networks such as low localization accuracy, large sample demand, and long localization time, the communication radius of the node is fuzzified to reduce the sampling area of the node, and an improved Monte Carlo localization algorithm based on fuzzy theory is proposed. The improved Monte Carlo localization algorithm, after simulation analysis, is about 50% shorter than the traditional MCL algorithm in localization time, and the localization accuracy is up to about 30% higher than the traditional MCL algorithm.

#### 1. Introduction

In recent years, with the widespread application of wireless sensor networks (WSN), the localization technology of wireless sensor network nodes has become a hot issue of research. At present, the static WSN localization technology is relatively mature. Representative algorithms include centroid localization algorithm [1], SPA relative positioning algorithm [2], convex programming localization algorithm [3], and DV-Hop localization algorithm [4, 5]. Most of these node localization algorithms do not consider the mobility of the nodes and can no longer meet the localization requirements in the actual environment. How to design a location algorithm suitable for WSN mobile nodes has become a hot issue in research.

For the localization of mobile nodes, some WSN dynamic localization algorithms have been proposed by the academic community, such as DSL localization algorithm [6], DRL localization algorithm [7], Landscape-3D algorithm [8], and MBL-MDS localization algorithm [9]. However, these algorithms generally have problems such as large amount of calculation, high hardware requirements, or more beacon nodes. Because the MCL method uses the mobility of nodes to help in positioning, it provides a new idea to solve the problem of node localization in mobile wireless sensor networks, and more and more scholars derive their own improvement schemes based on this algorithm. For example, the Monte Carlo Box Positioning Algorithm (MCB) proposed in literature [10] introduces anchor boxes and sample boxes to reduce the sampling area; the MSL algorithm proposed in literature [11] introduces one-hop and two-hop common nodes and anchor nodes together position. Literature [12] combines Monte Carlo node localization algorithm with RSSI. Literature [13] proposes Monte Carlo node localization based on timing, which uses the order of anchor node feedback signals within one-hop to form a sampling area. Literature [14] proposed a Monte Carlo node location algorithm based on Markov chain, which uses Markov chain to calculate the weight of particles in the process of predictive filtering. Literature [15] proposed a Monte Carlo mobile node location algorithm based on Newton interpolation. Literature [16] proposed wavelet transform to predict mobile node location algorithm, using wavelet transform method to predict node location through historical trajectory. Literature [17] combined differential evolution algorithm with Monte Carlo node localization algorithm. Literature [18] shows that the combination of particle swarm optimization and Monte Carlo node localization algorithm reduces the number of invalid samples and enhances the robustness of the algorithm. The above improved algorithms are all tested in an ideal environment. The localization accuracy of nodes is too dependent on anchor nodes, and the localization results are not ideal when the number of anchor nodes is small. High localization accuracy is based on a large amount of communication energy consumption, which does not comply with the WSN principle of low cost and low energy consumption.

Therefore, based on the Monte Carlo node localization algorithm, this paper changes the size of the filter radius in real time according to the size of the irregularity and provides the weight of the sampling particles that changes with the irregularity. The center of the sampling circle is improved from the estimated position of the original algorithm to the sampled particle position at the last moment, and this algorithm is applied to the WSN mobile node localization and strives to solve the problem of node localization in nonideal environments [19]. Through fuzzy theory, the node signal energy value is fuzzified, and the filtering conditions are accurate to make up for the shortcomings of MCL localization, such as large demand for samples, low positioning accuracy, and long positioning time.

#### 2. Principles of Monte Carlo Algorithm

The Monte Carlo method is based on the Bayesian filtering method. The core idea of the algorithm is to use weighted discrete samples to estimate the posterior probability density, and use importance sampling to iteratively update [20]. Including the prediction stage and the filtering stage, the basic operation steps are as follows:
(1)*Initialize the Node Position*. According to the one-hop and two-hop anchor nodes of the position node, use the centroid method to estimate the position of the unknown node(2)*Prediction Stage*. The motion speed and direction of the node to be determined are unknown, only the maximum motion speed is known. Suppose is the position of the node at the previous moment, then the position of the node at the current moment is in the circle with as the center and as the radius, as shown in Figure 1.

Assuming that the velocity of node satisfies uniform distribution on , represents the Euclidean distance between nodes at adjacent times. Then the probability of node position estimation at time is:

In the formula, is called the transition equation, which is used to represent the node position distribution at time to predict the position distribution at time .
(3)*Filter Stage*. Filter the sampled samples according to the information of the first-hop and second-hop anchor nodes received by the node, and filter out the samples that do not meet the requirements. If is a set of one-hop anchor nodes, as shown in the shaded area in Figure 2, is a set of two-hop anchor nodes, as shown in the shaded area in Figure 3, is the communication radius of the anchor node, is the sampling particle, is a one-hop anchor node, and is the Euclidean distance of point , then the filter condition of the node can be expressed as(4)*Resampling Stage*. After the filtering stage is completed, the number of remaining samples may be very small. Generally, it is not possible to directly sample from the posterior distribution. It is necessary to use nonstrict filtering conditions, that is, the distance between the sampling node and the one-hop anchor node is moderately expanded to meet the filtering requirements. The conditional particle is called a sampled particle. When 50 sampled particles are obtained, the average of the position coordinates of all sampled particles is calculated as the estimated position of the node

#### 3. Principle of Adaptive Improved Monte Carlo Algorithm

Although the MCL algorithm solves the localization problem when the node moves to a certain extent, it cannot achieve better positioning accuracy when the radio range of the node is not ideal or the node is fast. Therefore, in this paper, the communication radius of the unknown node is stratified according to the size of the irregularity, and the anchor nodes in different layers are given corresponding weights according to the region where they are located. The weights of the sampling nodes are adaptively adjusted by using an adaptive algorithm to achieve the optimal weight. The MCL algorithm is improved from the prediction stage and the filtering stage to improve the accuracy of mobile node localization algorithm in wireless sensor networks.

##### 3.1. Prediction Stage

The MCL algorithm sampling uses importance sampling, that is, sampling from an area with high particle density. The basic idea is to choose a proposed density to replace the real probability density that is difficult to sample, then the MCL integration problem can be transformed into:

In the formula, is the actual density, is the estimated density instead of . Suppose that the shape of covers the shape of , that is, the definition of is greater than or equal to the domain of definition of .

Importance sampling in the MCL algorithm uses the weighting of multiple independent samples to approximate

In the formula, is the number of sampling particles, is the weight, since the normalization of is unknown, in order to make ,

In the formula, is a normalized weight whose variance is

In order to improve the positioning accuracy, the variance value needs to be reduced. It can be seen from formula (6) that when the shapes of and are more similar, the variance is smaller and the precision is higher. MCL algorithm is that the estimated position of the node at the above moment is sampled by the center. This algorithm uses the sampling point at the above moment as the center to sample, so that the shape of and is more similar so as to improve the positioning accuracy.

##### 3.2. Filtering Phase

The premise of the MCL algorithm is an ideal environment, that is, the wireless ranges of unknown nodes and anchor nodes are fixed values, DOI, It means that the radio range is the same value in different locations, different transmission directions, and different transmission times [21]. However, in the actual environment, the value of the radio range is different in all directions, that is, , and the radio range of the node is not an ideal circle. The schematic diagram is shown in Figure 4.

In the figure, the dotted line represents the radio range when , and the solid line represents the radio range when , where the communication radius is .

Since in the actual environment, as shown in Figure 5, point A is a jump anchor node, point B and point C are sampling points after the prediction stage, the dotted circle b is the ideal radio range, and the irregular solid line is the actual anchor node radio range. The improved algorithm modifies the filtering condition according to the influence of DOI on communication radius, which is expressed as formula (7). where is the set of one-hop anchor nodes, is the set of two-hop anchor nodes, is the communication radius, is the sampling particle, is the anchor node, is the Euclidean distance between point and point , for the sampling of one-hop anchor node particle, the distance between the sampled particle and the anchor node is less than the sum of the radius and of the anchor node, as shown in the circle a in Figure 5, the circle c is the inscribed circle of the wireless range of the actual anchor node, indicating that there must be a jump anchor A collection of points within the range of node A.

It can be seen from the adaptive filtering conditions that the improved MCL algorithm considers that the anchor nodes in different regions will affect the size of the positioning error. When the sampling nodes are in the sampling regions with different wireless ranges of the anchor nodes, the impact on the unknown nodes is different. In Figure 5, point C is definitely within the wireless range of the anchor node, and the weight is set to 1; while point B is not necessarily within the range of the anchor node due to the influence of irregularity, and its impact on unknown nodes and nodes to be positioned, unlike point C. Based on this, the algorithm adjusts the sample weights of the sampled particles. Considering the change of the filtering conditions, if the weights of all particles are the same, it is not in line with the actual situation, so the corresponding weights are assigned to the sampled particles that meet different filtering conditions. When the sampling point absolutely satisfies the wireless range of the node, that is, in the circle c, the weight is set to 1. When the condition after the relaxation of the restriction is satisfied, that is, between the circle a and the circle c, the weight of the node changes with the DOI. However, since the area between the circle a and the circle c is positively correlated with the DOI of the node, in order to simplify, this algorithm defines the weight of the sampling point between the circle a and the circle c as , then the comprehensive weight condition of the node is set as follows:

This algorithm takes the influence of irregularity into account, and the sampling particles in different regions have different influences on node positioning. Therefore, the adaptive filtering and adaptive weight improvement in the filtering stage just make up for the defects of the original algorithm and improve the positioning accuracy.

#### 4. Simulation Analysis

Under the MCL-simulator, setting the WSN area size to 500500m, the total number of nodes to 320, including 32 anchor nodes, the communication radius of the anchor node and the unknown node are both 50 m, the speed of the anchor node , and and represent the minimum and maximum speeds of the anchor nodes, respectively; the speeds , and of the nodes represent the minimum and maximum speeds of the nodes, respectively. 10 experiments are carried out for each algorithm, and the node moves 80 steps in each round, and finally the average value of the 80 positioning errors is obtained. The node has the ability to judge whether a node is within the communication range, but has no ranging ability. It has the ability to perceive its own speed, but does not have the ability to perceive the direction of movement, the positioning error uses the Euclidean distance between the estimated position and the actual position. It is expressed as the ratio of the communication radius. Figure 6 is the positioning error graph of the MCL algorithm and the adaptive MCL algorithm (N-MCL), and the CRMCL and PRMCL algorithm in literature [18] under different DOIs, where the maximum speed of the anchor node and the unknown node is 50 m/s.

It can be seen from Figure 6 that as the DOI increases, the radio propagation model of the node becomes more and more irregular, but the positioning accuracy of the new-MCL is always better than that of the MCL, and the average positioning error decreases by about 12%. With the gradual increase of DOI, the positioning errors of the four algorithms all increase to a certain extent, but the positioning error of the N-MCL algorithm is smaller than other algorithms, and the positioning accuracy of N-MCL is highest when the irregularity is 0.1.

Figure 7 shows the comparison of the average positioning error curves of new-MCL and MCL with the increase of . Assuming that the maximum velocity of the unknown node and the anchor node is the same, both are , and the actual velocity of the two is evenly distributed in interval . It can be seen from the figure that with the gradual increase of , the positioning error of N-MCL gradually decreases. When is more than 30 m/s, the positioning error of the algorithm is the lowest, and the average positioning error is reduced by about 10% compared with the MCL algorithm.

Figure 8 shows the node movement in 50 steps, and the number of nodes that cannot be positioned in each step. It can be seen from Figure 8 that the number of nodes that cannot be located by the improved algorithm is lower than that of the other three algorithms. After 46 times, the number of improved localizability is about 100%. The average number of nodes that cannot be located for 50 times is as follows: that the number of nodes that cannot be located by MCL is about 7.67, the number of nodes that cannot be located by CRMCL algorithm is about 3.26, the number of nodes that cannot be located by PRMCL algorithm is about 2.85, and the number of nodes that cannot be located by N-MCL algorithm is 2.33. The network coverage rate of the MCL algorithm is 97.36%, and the network coverage rate of the new-MCL algorithm is 99.19%. This is due to the relaxation of the filtering conditions, which increases the number of sampling particles that satisfy the conditions under the same sampling times, thereby increasing the number of locatable nodes.

#### 5. Improved Monte Carlo Algorithm Based on Fuzzy Theory

Although the MCL algorithm has high positioning accuracy and computational efficiency for dynamic wireless sensor networks with limited node energy and low anchor node density, the value of the posterior probability density in the sample prediction area is small, and positioning requires a large number of samples. A sufficiently good positioning accuracy can be obtained. The nodes are sampled in a circle with the maximum speed as the radius each time, and the positioning time is long. Therefore, an MCL algorithm based on fuzzy theory is proposed, which makes up for the deficiencies of MCL by fuzzing the node signal energy value and making the filtering conditions more precise.

##### 5.1. Algorithm Principle

Fuzzy theory is based on fuzzy sets and is the best way to solve problems with ambiguous boundaries. For a fuzzy set, in addition to the ordinary membership values that belong to *0* and do not belong to *1*, the elements in the set are assigned to any value between 0-1 to represent the degree of membership [22]. Li et al. generalized that the characteristic function of classical sets can only take two numbers 0 and 1, and generalized it to all numbers in the closed interval of 0 and 1 [23]. And such characteristic function is called membership function , , and the set determined by is called the fuzzy set on . The membership function represents the degree to which belongs to . In this way, all intermediate values between “belongs to” and “does not belong to” can be represented.

The processing of fuzzy logic has been applied to robot localization [24], which redefines the classical set theory and makes it have nonstrict set boundaries. The so-called fuzzy sets use membership functions to describe a certain set element. Whether the feature belongs to the fuzzy set. An element can belong to one or two fuzzy sets at the same time [25]. Unlike traditional numbers that can only represent a single value, a fuzzy number can represent multiple values or an indeterminate relationship. RSSI is roughly proportional to the distance between the unknown node and the anchor node, and the triangular membership function is simple and easy to understand, so this algorithm uses the most common membership function such as formula (9): where is a triangular geometry, as shown in Figure 9, set can be represented by and by , for example, a certain value has a membership degree of 0.25 in and a membership degree of 0.75 in .

The coordinate position of the node can be represented by , where and are both fuzzy numbers. Divide the signal strength into three levels: “,” “,” and “.” Suppose the unknown node has one-hop anchor nodes. The coordinates of node represent .The coordinates of the one-hop anchor nodes are represented as , ,,, respectively. Then the coordinates of the nodes can be expressed as:

Equation (10) defines a nonlinear equation to describe the distance relationship between unknown nodes and anchor nodes. Where , , and are the fuzzy numbers and is the exact number, the result minimizes the squared difference of this series of equations.

Fuzzy theory makes quantitative, systematic, and hierarchical analysis of nonquantitative events [26]. This method can simplify complex problems, and this paper applies it to the wireless sensor network mobile node location algorithm. The propagation area of nodes in mobile node positioning is divided into several levels, and an orderly hierarchical model is established between the levels according to the affiliation. The judgment of certain objective facts in each layer reflects the importance of each layer in a quantitative form.

##### 5.2. Algorithm Description

(1)*Initialize the Node Position*. According to the one-hop and two-hop anchor nodes of the position node, use the centroid method to estimate the position of the unknown node.(2)*Sampling Stage*. First, establish fuzzy rules : “If RSSI is W, then DIST is L”; : “If RSSI is M, then DIST is M”. When the anchor node receives the exact value of sent by the unknown node, it converts it into a fuzzy number of the distance between the anchor node and the unknown node. As shown in Figure 10, when is , the membership function , and have different degrees of membership, which are mapped to the fuzzy sets and of the distance through the corresponding fuzzy rules and , respectively. Where and are the centroid of the trapezoidal region formed after is mapped to .

For the value of RSSI, the range of its abstraction is narrowed by fuzzy rules, such as is in the ring 18 and 28 away from the anchor node . Then compare whether 18 and 28 belong to the same fuzzy number of , if not, take the fuzzy number with the larger membership degree. As shown in the figure, corresponds to the “L” of in Anchor1. Then, the area composed of multiple one-hop anchor nodes is ABCD, and sampling is performed in this area, as shown in Figure 11.
(3)*Filtering Stage*. The limit condition of one-hop anchor node is to judge the distance between the node and the anchor node according to the corresponding fuzzy number of . For example, with an anchor node is , then the distance between the node and the anchor node is in , where is the communication radius of the anchor node. In this way, the area where the particles are located is limited, so that the positioning time of the node is shorter, the accuracy is higher, and the algorithm is more complete.

##### 5.3. Motion Model of Mobile Nodes

The mobile model is also an important factor affecting mobile node localization in WSN. In this paper, the random model of moving waypoint is used. Assume that the speed of the mobile node at time is , the direction angle is , the coordinate is , and is the time interval from time to time . The position of the current node is estimated according to the movement speed and state of the node at the last moment. The formula is expressed as follows:

Among them, is the inertia weight, which can adjust the search ability of the algorithm, is the acceleration constant, is the directional random motion setting of the node, and is a random number between .

The steps of the model are described as follows: (1)All nodes are randomly deployed in the wireless sensor network area, and then each node arbitrarily selects a point within the speed range as the destination(2)The node moves randomly and at a constant speed within the interval at any speed less than or equal to the maximum speed(3)After reaching the destination, the mobile node stops for time, and then reselects the movement speed and destination, and starts to move

Repeat steps (2) and (3) until the simulation ends. The block diagram of the simulation program composed of OMNET++ is shown in Figure 12.

##### 5.4. Simulation Results

The simulation experiment using OMNET++ (Objective Modular Network Tested in C++) and the sensor nodes are randomly placed in a square area of 500 m500 m, and there are no obstacles in the area. The irregularity of node communication is 0, and the communication radius of the nodes is 100 m. The maximum speed of the nodes and the anchor nodes are , the movement speed of the nodes and the anchor nodes are arbitrarily selected in , and the movement of the nodes adopts the Random Waypoint model. For the convenience of the experiment, the study sets a total of 20 nodes, including 18 anchor nodes and 2 nodes. The effect of the maximum speed of the node on the distance error is shown in Figure 13.

The speed of the node has a great influence on the positioning accuracy. First, the increase of the speed of the node leads to the increase of the distribution area of possible positions at the next moment. Secondly, the increase of the speed of the node also enables the node to detect more location information of the anchor node, filter out impossible positions, and assist positioning. Figure 13 shows that with the increasing of the speed of the node, the positioning error is increasing too. The distance error of the MCL algorithm, CRMCL algorithm, and PRMCL algorithm was generally increasing with the increasing of the speed; for the N-MCL algorithm, the distance error is minimized while the node speed is maximum at 40 m/s. When the speed of the node continues to increase and is greater than 50 m/s, due to the serious particle degradation problem, a sufficient number of samples cannot be collected, and the positioning accuracy decreases.

In addition to the positioning accuracy, the time required for positioning is also an important indicator to measure the quality of a positioning algorithm. Figure 14 reflects the influence of the maximum speed on the positioning time, indicating that the time spent by N-MCL on positioning is less than the other three algorithms. With the increase of the node moving speed, the positioning time of MCL algorithm and CRMCL algorithm increases, while the PRMCL algorithm and N-MCL algorithm basically changed a little. When the maximum speed is 50 m/s, the time taken by the two algorithms reaches the minimum.

Experiments show that the N-MCL achieves the best localization effect when the speed is between 45-50 m/s. Figure 15 shows the simulation diagram of the 30-round positioning of the node when the speed is , which is the distance error of each round of positioning and the required time. It can be seen from the figure that N-MCL algorithm is superior to MCL algorithm, CRMCL algorithm, and PRMCL algorithm in positioning accuracy and positioning time. According to statistics, the positioning time of N-MCL algorithm is shortened about 50% compared with the traditional MCL algorithm, and the positioning accuracy is improved about 30% compared with the traditional MCL algorithm.

**(a) Positioning accuracy**

**(b) Positioning time**

#### 6. Conclusion

This paper aims at the shortcomings of the MCL algorithm’s poor positioning accuracy in nonideal environments, and the filtering stages were improved. In the prediction stage, the sampling point at the previous moment is used as the center of the circle for sampling, and the filtering stage adaptively changes the weight of the sampled particles in different regions according to different DOIs, thereby improving the positioning accuracy and network coverage of WSN nodes in nonideal environments. Finally, in view of the shortcomings of the Monte Carlo algorithm (MCL) in the mobile node positioning, the demand for samples is large, the positioning accuracy is not high, and the positioning time is long. An improved Monte Carlo mobile node positioning algorithm based on fuzzy theory is proposed. The algorithm improves the positioning accuracy and shortens the time required for positioning by introducing fuzzy rules in the sampling and filtering stages of nodes.

#### Data Availability

The datasets used and/or analyzed during the current study are available from the corresponding author on reasonable request.

#### Conflicts of Interest

The author declares that they have no conflicts of interest.

#### Acknowledgments

This work is supported in part by the Shaanxi Provincial Department of Education 2019 Special Scientific Research Plan Project under Grant 19JK0261, 2021 regular project of Shaanxi Provincial Sports Bureau under Grant 2021324, Special Project of Shangluo University Serving Local Scientific Research under Grant 19FK002.