{'fraction_non_alphanumeric': 0.03342928965293545, 'fraction_numerical': 0.008818520921180668, 'mean_word_length': 4.894956978967495, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Accurate Range-Free Localization Algorithms Based on PSO for Wireless Sensor Networks

Recently, localization accuracy of unknown nodes has become a critical and challenging issue for many Wireless Sensor Networks (WSNs) and Internet of Things (IoT) applications. Without associating the detected event with its precise geographic location will be surely considered meaningless for these applications. Among all localization algorithms, we observe that the DV-Hop localization algorithm is highly recommended to use in many fields of application due to its simplicity, feasibility, low cost, and no extra hardware requirements, but the localization error caused by the DV-Hop algorithm is relatively large. In this current work, based on both the DV-Hop algorithm and the Particle Swarm Optimization algorithm, we proposed four new localization algorithms to overcome the shortcomings of low accuracy that the basic DV-Hop based algorithms produce. The simulation results showed that the proposed localization algorithms can achieve a better localization performance in terms of accuracy in comparison with other existing algorithms such as basic DV-Hop, MDV-Hop and DV-Hop PSO under different random network topologies. We also observed that a significant localization accuracy is achieved by the proposed algorithm HWDV-HopPSO.


I. INTRODUCTION
The Internet of Things (IoT) concept and Micro-Electro-Mechanical Systems [1], [2] allow designing and manufacturing a large amount of small wirelessly interconnected devices, which are able to detect, monitor, process and transmit physical phenomena such as temperature, pressure via Radio Frequency Identification (RFID), Zigbee, Internet, Wi-Fi, Bluetooth, 3G, 5G, and so on. In fact, every sensor node is equipped with a processor, transceiver, and power unit. Every device (i.e., sensor) has the ability to send data to the Base Station (BS) where the gathered information can be analyzed and interpreted as useful information with significant meaning [3], [4]. In addition, these devices are considered to be a key component to deploy a wireless sensor network in different environments and with respect to The associate editor coordinating the review of this manuscript and approving it for publication was Resul Das . WSN design and requirements depending on each application field, such as military, target tracking and environmental applications [5]- [8]. Localization phase is the most required service for most IoT networks' applications including smart cities, health care monitoring, traffic management, road traffic monitoring, disaster detection, geographic routing, and so on [9]- [14] because it helps to understand and analyze detected events by sensor nodes. More precisely, when the sensor is assigned precise roles, the collected events could be then figured out and easy to understand depending on their context or scenario of application [15]; otherwise, the identified event will have no important meaning. For instance, Figure 1 demonstrates the necessity and importance of localization in many applications.
According to Figure 1, finding out the exact location of devices is a crucial challenge in IoT applications. The Global Positioning System (GPS) [16] is one of the most common applications used to determine the location of sensor nodes in many fields. Therefore, equipping all these devices with GPS or a different auto-positioning system will not always be considered as the best solution because they are very costly in terms of additional hardware. This might add further overheads, such as power consumption. Consequently, many localization solutions have been proposed to overcome this issue based on the use of anchors (i.e, nodes whose locations are known) to estimate the positions of unknown nodes (i.e, the rest of the nodes whose locations are not known) deployed in the WSNs [17]. These anchor nodes perform a localization process to estimate the positions of unknown nodes. Indeed, the unknown nodes are randomly organized either because of the immensity or either of the hostility of the area in which nodes will be deployed. Figure 2 presents a descriptive example of the localization process. Over the last few years, localization algorithms have been attracted a great attention and are widely adopted for use for many sensor networks applications. Indeed, several localization algorithms have been proposed to accurately estimate the location of unknown nodes based on known nodes (anchors). These algorithms are generally divided into two major categories: range-based [18]- [20] and range-free [21], [22]. The range-based algorithms have been widely used, and in their turn, they include many algorithms such as ToA (Time of Arrival) [23], TDoA (Time Difference of Arrival) [24], RSSI (Received Signal Strength Intensity) [25] and AoA (Angle of Arrival) [26], respectively. All these localization algorithms try to calculate the distance or the angle between synchronized sensor nodes, and then approximate the location of unknown nodes using trilateration or triangulation techniques. These techniques have higher accuracy, but they require additional hardware and cause an extra overhead. Unfortunately, these techniques are not a good candidate for sensor nodes localization because they require additional hardware support, and thus are very costly to be adopted, especially in large-scale sensor networks [27]. Range-free algorithms require only the connectivity information between sensor nodes. Moreover, the major idea behind these localization algorithms is based on the use of anchor nodes as they are assigned exact geographic positions and belong to the same geographic area. Therefore, unknown nodes try to exploit this advantage to estimate their locations in the wireless sensor network based on the connectivity with nearby anchors. The most popular algorithms that belong to this category include: DV-Hop algorithm [28], Centroid algorithm [29], Approximate Point in Triangle Test (APIT) algorithm [30], and Amorphous [31]. For example, the Centroid algorithm [32] is based on the number of neighboring anchor nodes to anchor nodes to compute the barycenter that will be considered as the estimated location of unknown nodes without additional materials. APIT [30] is a range-free localization algorithm that assumes the use of three anchor nodes to estimate the position of sensor nodes. This algorithm can achieve better results with a large number of anchors. Amorphous [33] is a very similar algorithm of DV-Hop used to determine the locations of unknown nodes with a high accuracy, especially in random WSNs. DV-Hop [34] is the well-known range-free localization algorithm. It's a suitable solution to localize unknown sensor nodes, which have some nearby anchors [17]. In DV-Hop, the sensor node calculates the minimum number of hops towards anchors and average hop size to estimate the positions of unknown nodes. This algorithm is simple, practicable and offers a high quality of coverage, and does not require additional overhead. In addition, DV-Hop has advantages such as capacities to localize unknown nodes that are surrounded by at least three neighbor anchors. In general, range-free algorithms have several advantages over range-based strategies, such as little communication overhead, no requirement of additional equipment, and provide a better localization accuracy.
However, many more efforts are needed to tackle the disadvantages of range-free localization algorithms such as localization accuracy. Therefore, in this paper, we propose four new localization algorithms which are based on DV-Hop and PSO to estimate the position of unknown nodes in WSNs with a higher localization accuracy. The main contributions of the current paper are summarized as follows: • Four new localization algorithms named WDV-Hop, HWDV-Hop, WDV-HopPSO and HWDV-HopPSO, respectively are proposed.
• New steps have been added to increase the localization accuracy of these algorithms.
• Four different kinds of complex network topologies are considered.
• Performance of the proposed localization algorithms was evaluated in terms of localization error and localization accuracy. The results compared to the basic DV-Hop, DV-HopPSO and MDV-Hop according to the total number of nodes, percentage of anchor nodes and communication range.
• Simulation results show the superiority of the proposed algorithms in different scenarios. The rest of this current paper is organized as follows. Section II presents the background on localization algorithms from the literature. In Section III, the localization process of basic DV-Hop algorithm and our proposed algorithms based on DV-Hop and Particle Swarm Optimization are detailed. In Section V, simulation results are investigated and localization performances are discussed. Finally, in Section VI, conclusions and future works are given.

II. BACKGROUND AND RELATED WORKS
In this work, we focus on range-free algorithms and investigate mainly the localization improved algorithms of DV-Hop algorithm. Despite its advantages, the distance between anchor nodes and unknown nodes is prone to be inaccurate due to errors in the distance calculation of the average hop size. Moreover, errors in the computed distance between sensor nodes are the reason for poor localization accuracy. Furthermore, several enhancements of the DV-Hop algorithm have been proposed in the literature to enhance its location accuracy. The authors in [35], introduced a new DV-Hop based localization algorithm using one mobile anchor node and a modified hop count method to reduce the localization errors of the sensor nodes within wireless sensor networks. The performance of the proposed algorithms has been evaluated in terms of both the communication range and number of anchor nodes. Moreover, they assume that all anchor nodes keep fixed, except for one anchor which is considered mobile. This technique is adopted to construct another technique with a fixed anchor node. However, the results demonstrated that the presented technique in this algorithm based on a mobile anchor showed an improvement in the localization error in comparison to the DV-Hop algorithm. In [36], the authors introduced an enhanced algorithm based on the DV-Hop localization technique in order to overcome the decrease in the localization accuracy of the basic DV-Hop, especially in the anisotropic network. In fact, the authors conducted three steps to enhance the basic DV-Hop algorithm. In addition, an improved PSO and SA hybrid algorithms were applied in order to find a solution for the nonlinear equations and optimize initially the calculated locations of unknown nodes. The simulation performance shows that the proposed algorithm has a better performance than the DV-Hop and other algorithms in the literature in terms of accuracy. However, the introduced technique increases the communication overload between sensor nodes in the network when performing a forwarding of information based on multi-hop paths. The authors in [35] introduced a new version of DV-Hop to improve the localization accuracy. This improved algorithm applied the double communication radius method to modify the minimum hop count between sensor nodes. Based on this technique, the algorithm may be able to minimize the error of the estimated distance and the Sparrow Search Algorithm (SSA) is used instead of the least square technique. In addition, the SSA algorithm applies the Levy flight strategy in order to enhance the estimation accuracy of unknown nodes' locations. The simulation performances showed that the proposed localization algorithm had a better performance than the basic DV-Hop. The authors in [37] presented another approach called the online sequential localization algorithm based on the DV-Hop. They introduced an algorithm consists of three main phases. Firstly, they used a new formula to compute the distance of average hop between nodes. Secondly, they converted the basic DV-Hop to an online sequential localization technique, and finally they used a sequential technique with the assistance of a pre-defined set of anchor nodes to calculate the location of target nodes. The results of simulation showed that the localization process of the introduced technique was more efficient than the standard DV-Hop. In [38], another improved version of the DV-Hop algorithm is introduced. The authors used the particle swarm optimization algorithm to minimize the localization error produced by the DV-Hop. Indeed, the three main steps of the basic DV-Hop are kept unchanged, whereas a fourth step has been appended to refine the estimated location of unknown nodes. Many analysis performance scenarios have been carried out in order to confirm that the proposed particle swarm optimization based algorithm can significantly minimize the localization error as compared to the basic DV-Hop. In [39], the authors introduced an improved version of the DV-Hop algorithm. In this version, the Received Signal Strength Indication (RSSI) and the polynomial approximation were used to estimate the distance between unknown nodes and anchor nodes. In addition, a recursive computation process to allow the localization of unknown nodes is applied to enhance the accuracy of sensor nodes' locations. Simulation results show that the introduced version of DV-Hop can significantly improve the accuracy of localization. In [40], a Bat algorithm has been applied to improve an existing improved version of the DV-Hop localization method (named BADV-Hop). In this paper, the main idea is to reduce the error brought by the average distance per hop. Indeed, the Bat algorithm is considered as an intelligent optimization strategy, which is applied to improve the computation of the average distance per hop of anchor nodes.
Simulation results demonstrate that the BADV-Hop can significantly reduce the localization error without the need for additional materials. In [41], an improved based DV-Hop version was introduced. This algorithm performs a localization process based on a combination of two known algorithms to reduce the localization errors: Particle Swarm Optimization (PSO) and shuffled frog leaping algorithm (SFLA). The SFLA algorithm is used to calculate the new average hop size distance and the PSO algorithm is applied to estimate the unknown nodes' positions in WSNs. The simulation results demonstrate that the introduced algorithm can minimize the localization error as compared to the DV-Hop algorithm. In [42], an improvement of the DV-Hop is introduced, the algorithm is denoted as LSDV-Hop. The main idea of this algorithm is based on the use of least squares theory to improve the localization accuracy by extracting a transformation vector between the real and estimated positions of randomly chosen anchor nodes. The obtained least-squares transformation vector is used to update the estimated positions of unknown nodes. The simulation results show that the proposed LSDV-Hop algorithm improves the localization precision of unknown nodes as compared to the DV-Hop. The authors in [43], proposed an improved version of DV-Hop algorithm. The proposed new DV-Hop based algorithm uses a new technique to compute the hop size value in the second step and the 2D Hyperbolic is applied instead of the multitrilateration technique in the third step. Additionally, many simulation scenarios have been conducted to demonstrate that the localization error of the presented algorithm performed better than basic DV-Hop as well as other algorithms. In [44], many enhancements of the DV-Hop algorithm (called iDV-Hop1, iDV-Hop2, and Quad DV-Hop) have been proposed. Accordinally, many geometry techniques have been introduced to minimize the localization error of DV-Hop. The performance of the introduced algorithms have been evaluated under two different network topologies: uniform and c-shaped random networks. The simulation results confirmed that the iDV-Hop1 algorithm could minimize the localization error (up to three times) in scenarios with irregular topologies in comparison with DV-Hop and iDV-Hop2. Hence, with regular topologies, iDV-Hop2 and Quad DV-Hop give better results as compared with DV-Hop. In [45], another DV-Hop based algorithm is proposed. The authors highlight the impact of anchor nodes' mobility on localization error, energy consumption and localization accuracy according to three mobility models: Reference Point Group Mobility (RPGM), Random Waypoint (RWP) and Random Direction (RD) have been sufficiently examined. Several scenarios have been considered to examine the localization performance of introduced algorithms. The simulation results showed that the performance of the proposed algorithms significantly outperformed that of the DV-Hop algorithm regardless of the mobility scenario.
In this current paper, we focus on the range-free approach DV-Hop [28], and we propose four new localization algorithms for WSNs. Here, unknown sensor nodes accurately estimate their locations based on the new formula of average hop-size and Particle Swarm Optimization (PSO) is applied to refine the final position of unknown sensor nodes. Many scenarios have been conducted to verify and study the effectiveness of the proposed localization algorithms when compared to the basic DV-Hop, DV-Hop based PSO [38] (DV-HopPSO), and an improved DV-Hop (MDV-Hop) [43] localization algorithm for WSNs. All algorithms have been developed, implemented in MATLAB simulator and studied for their overall performance in static wireless sensor networks according to four different kinds of complex network topologies which are uniform random, O-shaped, H-shaped and X-shaped topology, respectively by varying the number of total nodes, percentage of anchor nodes and communication range of sensor nodes.
It can be seen from the works of literature that many localization algorithms based on DV-Hop have been designed to minimize the localization errors of each of the estimated unknown sensor nodes, but the accuracy is still not satisfactory and need to be improved. In this paper, four new localization algorithms based on DV-Hop and Particle Swarm Optimization (PSO) have been proposed to enhance the localization accuracy of unknown nodes in Wireless Sensor Networks in order to outfit applications' needs.

III. PROPOSED LOCALIZATION ALGORITHMS
In this section, we introduced four new localization algorithms based on the DV-Hop and Particle Swarm Optimization algorithm. As previously mentioned, the DV-Hop localization algorithm has limitations that make the estimated location inaccurate for most WSNs applications uses, such as health care and environmental applications due to techniques applied to compute the average hop size and location estimation. However, utilizing nature-inspired optimization algorithms such as PSO is one of the most efficient approaches for increasing the DV-Hop algorithm's localization accuracy, Accordingly, we firstly describe the localization process of the original DV-Hop algorithm and our proposed localization algorithms WDV-Hop and HWDV-Hop previously presented in [46], [47], and afterwards we present the localization algorithms based on particle swarm optimization, named as WDV-HopPSO and HWDV-HopPSO, respectively.

A. BASIC DV-HOP
The DV-Hop algorithm [34] has been considered a benchmark for localization in WSNs in recent years. It is a suitable solution to localize devices within IoT applications as well as in WSNs. The DV-Hop algorithm uses some nearby anchors to estimate these devices' locations. The DV-Hop algorithm has three standard stages, which are represented as follows; information broadcasting, computation of average hop size distance, and position estimation. In the first stage, the anchors A i from the network broadcast a hello VOLUME 9, 2021 packet including the exact location information of A i and a hop-count value, which is initialized to 0. This hop-count value will increase with hops increase during the rebroadcasting process of the packet. During the first reception of the packet, every node N (anchor or a normal node) records the anchor A i position, and initializes hc i,N as a hop-count value in the packet. hc i,N is recorded as the minimum number of hops between N and A i . It's worth noting that a normal node, also called an unknown node, is a sensor node with unknown coordinates, which need to be estimated. If the same packet is received again, N updates the hc i,N . If the received packet includes a value of count-hop lower than hc i,N , N updates again hc i,N with this lower value of hop count, and relieves the packet; otherwise, N ignores the packet. During this stage, all sensor nodes report the minimum number of hops to every anchor node. In the second stage, as each anchor has received in the first stage the locations of anchors and its minimum hops to other anchor nodes, A i can calculate its average hop size, denoted AvgHS i . Once AvgHS i is calculated, it will be flooded across the network by A i . The average hop size AvgHS i of each anchor A i , can be calculated according to the following formula.
In the third stage, during the reception of AvgHS i , the normal node N multiplies hc i,N (the number of hops to A i ) by AvgHS i , so that N obtains the approximate distance of each anchor A i , denoted dist i (dist i = AvgHS i × hc i ), where, i ∈ {1, 2, . . . , k} and k is the total number of anchor nodes. Thus, the following equation can be derived, where (x, y) is the estimated position of N : By solving the above equation based on the least squares techniques, a normal node N could obtain its estimated N DV-Hop position as follows: where A T is the transpose of the matrix A, and A −1 represents its inverse. The anchors cannot be on the same line, otherwise the equation, A T A will be singular, so (A T A) −1 does not exist.

B. WDV-HOP LOCALIZATION ALGORITHM
In our previous paper [46], [47], we proposed an enhanced DV-Hop technique, namely WDV-Hop. In fact, alike DV-Hop, the WDV-Hop localization process is divided into the following three enhanced steps: i) anchor nodes flood their locations, ii) new formula of the average hop size is adopted, and iii) trilateration method is applied to estimate the nodes' position. More precisely, the first phase of our improved algorithm is similar to the basic DV-Hop. Every anchor node broadcasts a packet including the position of anchor A i and initializes the hop-count between two anchors by 0. In the second phase, we use a weighted mean technique [48] to compute the average hop size following a new formula. However, in order to calculate the average hop size in WDV-Hop, we applied the mean square error method [49]. Thus, the formula considered to obtain AvgHS i , is described by the following formula: where k is the number of anchor nodes, and AvgHS i is calculated by assuming that (∂e 1 /AvgHS i = 0). Here, dist i,j represents the distance from A i to A j and hc i,j represents the minimum hop-count values between A i and A j . It's worth noting that dist i,j represents the real distance between the anchor A i and A j , by assuming that the positions of anchor nodes are known, for example using the GPS module.
So, the average hop size is calculated using the following formula: In the third phase, we applied the multitrilateration positioning technique to estimate the location of sensor nodes. Indeed, during AvgHS new reception, the normal node N multiplies hc i,N (the number of hops to A i ) by AvgHS new , so that N obtains the approximate distance of each anchor . . , k} if we assume that there are totally k anchors. Then, the following equation can be derived, where (x, y) is the estimated position of N : By solving the above equation based on the least squares techniques, a normal node N could obtain its estimated N DV-Hop position as follows: A T is the transpose of the matrix A, and A −1 represents its inverse. The anchors cannot be on the same line, otherwise the equation, A T A will be singular, so (A T A) −1 does not exist.
Thus, N's coordinates are computed as follows:

C. HWDV-HOP LOCALIZATION ALGORITHM
In this second proposed Hyperbolic Weighted DV-Hop algorithm (denoted HWDV-Hop), the localization process is divided into the following three enhanced stages: i) anchor nodes flood their locations, ii) the new formula of average hop size is introduced, and iii) the 2D hyperbolic technique is applied, instead of the trilateration technique to compute the nodes' location. More precisely, the first stage of our algorithm is similar to the basic DV-Hop and WDV-Hop, respectively. Every anchor node broadcasts a packet including its locations and initializes the hop-count value between anchor nodes by 0. In the second stage, we use the weighted mean approach [33] to compute the average hop size AvgHS i following our new formula. Hence, the formula used to calculate the AvgHS i is illustrated as follows: where In the third stage, instead of using the multitrilateration positioning technique to estimate nodes' position, we have applied the 2D hyperbolic location technique [50]. It is VOLUME 9, 2021 assumed that (x i , y i ) are the coordinates of anchor node i and (x N , y N ) are the coordinates of normal node N . The estimated distance dist i,N is calculated as follows: If R i = x 2 i + y 2 i and S i = x 2 N + y 2 N , then, the equation Eq.(10) can be rewritten as follows: The matrix form of Eq. (19) is: where According to Eq. (20), using the least mean square estimation method, A can be obtained by the following formula: Thus, N's coordinates are computed as follows:

D. MOTIVATION BEHIND USING PSO
It is known that the localization error produced by the DV-Hop localization algorithm is caused by uncertainty resulting during the distance estimation in terms of the average hop size and the minimum hop count. Consequently, the generated error for estimated distance against real distance is relatively large, and therefore it affects the localization accuracy of sensor nodes in the network. In fact, localization in WSN is formulated as an NP-hard optimization problem.
In the literature, nature-inspired algorithms are considered to be the most suitable optimization algorithm for this problem as they are able to find out the best solution. On the other hand, nature-inspired algorithms are classified into many categories, including Evolutionary Algorithms, Physical Algorithms, Swarm Intelligence, Bio-inspired Algorithms and other nature-inspired algorithms. However, based on the literature studies, the swarm intelligence algorithms have proved their ability to elaborate adaptable solutions to localization problems in WSNs due to their flexibility, robustness, selforganization, simplicity, and decentralization. In fact, these qualities are observed in social behaviors of animal communities such as ants, fishes, birds and so on. The swarm intelligence algorithms in their turn include many algorithms: PSO, ACO, ABC, and so on. Based on recent comparisons in the literature, we find that the PSO is the best optimization algorithm for localization problems in WSNs due to many advantages: • PSO uses fewer parameters to adjust the particles' population.
• has a low space complexity as it uses small temporary storage.
• It has a fast convergence speed as only the most optimist particle can share its solution with other particles.
• It guarantees the diversity of application as it is adopted for many problems to be resolved.
• It provides an easy way to interpret and adapt the solution to the problem. In this work, our aim is to achieve reasonable accuracy with a faster convergence time based on the Particle Swarm Optimization algorithm. It is expected that PSO will help to optimize the estimated locations of unknown sensor nodes to achieve a higher localization accuracy in the area of interest. For this purpose, our proposed improvements of DV-Hop, including both WDV-Hop and HWDV-Hop, respectively, are extended to support an extra phase for PSO optimization in addition to three classical phases of the DV-Hop. Then, the localization process will consist of four main phases; i) the minimum hop is calculated per each sensor node, ii) average hop distance calculation is calculated by anchor nodes, iii) estimation of unknown node's locations, iiii) processing PSO algorithm of optimization of unknown node's locations.

E. PSO ALGORITHM
Particle Swarm Optimization (PSO) is a population based optimization algorithm introduced by Eberhart and Kennedy in 1995, which is motivated by the behavior of fish or bird flocking. Certainly, PSO is a branch of heuristic algorithms widely applied to optimize complex problems by continually trying to get the best solution with respect to certain measures of quality [25]. At each step, every particle changes its velocity towards the pbest and gbest locations during the searching operation.
The PSO is the most preferred algorithm to achieve better results than other techniques. After finding the two best values, the particles in PSO updates their velocity and positions according to the following equations as: where V id is the velocity of the particle, X id is the position of the particle C 1 and C 2 are the acceleration coefficients and also known as learning factors. σ 1 and σ 2 are two positive random numbers between 0 and 1. P id is an optimal solution position of an individual extreme; P gd is global minimum (group optimal solution position of group). We assume (x,y) is the coordinate of the unknown node i, then the distance d i can be obtained as described in the second step of each presented improvement of DV-HOP algorithm. In fact, an error can be produced due to the estimated value of distance. In this paper, we proposed four new localization algorithms based on particle swarm optimization to reduce the localization error as the main problem for localization in WSNs. In this section, the proposed objective function for PSO is illustrated as follows: According to objective function presented in equation Eq.(25), the fitness function is formulated as follows: Moreover, every particle makes an update based on Eq. (23), (24), (25), and (26). The fitness function applied to estimate the fitness of every particle is illustrated in equation Eq. (26). Furthermore, during this process, the best solution will be considered as the final estimated location of the unknown node. A detailed description of the overall localization process followed by our proposed algorithm is illustrated in Figure 3.
In the next subsection of this current paper, the PSO algorithm is applied to reduce the localization error produced by DV-Hop algorithm and other localization algorithms.

IV. PSO BASED IMPROVED DV-HOP ALGORITHM
In this section, we proposed four new localization algorithms for WSNs. Firstly, the WDV-Hop and HWDV-Hop have been described in section 3. Afterwards, the PSO optimization algorithm is applied on both WDV-Hop and HWDVHop in order to accurately estimate the location of unknown nodes in wireless sensor networks. Many scenarios have been conducted to verify and study the effectiveness of the introduced algorithms when compared to the basic DV-Hop, DV-HopPSO, and MDV-Hop localization algorithms for WSNs. All algorithms have been implemented in MATLAB and their overall performance is studied in static wireless sensor networks. The four new proposed localization algorithms are called as WDV-Hop, WDV-HopPSO, HWDV-Hop and HWDV-HopPSO, respectively. These algorithms are comprised of four stages which are described as follows i) anchor nodes flood their locations, ii) the calculation of the average hop size is modified, iii) the 2D hyperbolic technique is used, instead of the trilateration technique to compute the nodes' location, and iiii) the PSO is applied to accurately find the location of unknown nodes.
For the WDV-HopPSO localization algorithm, the first stage and third stage are the same as those of WDV-Hop which is an improved version of DV-Hop algorithm as discussed in the previous section 3. In the first stage, every anchor node broadcasts a packet containing the location information. In the second stage, the weighted mean technique [48] is used instead of the traditional formula to estimate the average hop size distance by every anchor node. In the third stage, the multitrilateration technique is used to determine the estimated location of unknown nodes in the for j = 1 to n do 7: Calculate the distance 8: and initialize hop-count hc i,j = 0; 10: if d i,j <= R then 11: hc i,j = 1; 12: else if i == j then 13: hc i,j = 1;  network. In stage four, the PSO is applied in order to correct the estimated location of unknown nodes.
Alike WDV-HopPSO, the HWDV-HopPSO has also been divided into the following four enhanced stages: i) anchor nodes flood their locations, ii) the average hop size distance calculation is modified, iii) the 2D hyperbolic method is applied, instead of the multitrilateration method to compute the nodes' location, and iiii) the PSO is applied to optimize the location of unknown nodes. More precisely, the first, second and third stages of the HWDV-HopPSO are similar to the HWDV-Hop. In fact, in the first stage, every anchor node floods its location to the other nodes. In the second stage, the weighted mean approach [33] is adopted to compute the average hop size AvgHS i following our new formula presented in section 3. In the third stage, the multitrilateration positioning technique is adopted instead of the 2D hyperbolic location technique [50] to calculate the position of the unknown node. In step 4, we applied PSO to correct the estimated positions. Moreover, as mentioned in this current work we applied PSO to find the correct location of unknown nodes. The flowchart of the proposed localization algorithms based on the DV-Hop and the Particle Swarm Optimization algorithm is shown in Figure 3, in addition, a detailed pseudo-code is described in Algorithm 1.

V. SIMULATION RESULTS AND DISCUSSIONS
In this section, we mainly focus on the performance evaluation of the basic DV-Hop and DV-Hop-based improvement algorithms. We have developed all proposed algorithms in the MATLAB simulator in order to evaluate and study their localization errors as well as localization accuracy. MATLAB is a simulator software and numeric computing platform used by many scientists to develop algorithms and analyze data, and create models. Accordingly, we have used MATLAB version 2019a to show and analyze the performance of introduced algorithms in static wireless sensor networks (SWSNs). Besides, the effectiveness of our proposed algorithms is compared to the original DV-Hop, improved DV-Hop based on PSO (denoted DV-HopPSO) [38] and improved DV-Hop (denoted MDV-Hop) [43] through simulations.
We have measured two key metrics of 40 experiments: the localization accuracy and localization error per node are evaluated, while varying parameters, such as the percentage of anchor nodes, total number of sensor nodes, and nodes communication range according to four kinds of distribution topology. Here, the localization accuracy is expressed as the average localization error of an algorithm, which is used to evaluate the superiority of an algorithm. It is calculated according to equation Eq. (27), shown at the bottom of the page, where (x i exact , y i exact ) is the estimated position of the sensor i by the respective localization algorithm, (x i estimated , y i estimated ) is the exact position of the sensor i, d(estimated i , exact i ) is the Euclidean distance between sensor i's exact location and its estimated location, N is the number of sensor nodes.
The localization error is expressed as the deviation between the exact location and the estimated location of the unknown node. It is illustrated by the formula in equation Eq. (28), as shown at the bottom of the page.
In this section, we performed extensive simulations to study the performance of these localization algorithms in static wireless sensor networks with the following parameters: i) the generated topology depends on the number of sensor nodes, percentage of anchor nodes and communication range, ii) nodes are randomly distributed in an area of 100m× 100m, iii) all distributed sensor nodes within the network have the same communication radius which is R. In Table 1, the parameters of the simulations are described.
In this section, we have also considered many scenarios to study the influence of several parameters, especially the communication range, number of anchor nodes, and number of unknown nodes, on the performance of the proposed localization algorithms. In these series of scenarios, we have computed the localization error with different communication range values, percentage of anchor nodes, and number of unknown nodes according to four complex network topologies, which are square random, O-shaped, H-shaped and X-shaped. The square random is one of the most commonly used topologies for WSNs where nodes are randomly dis- persed within the region. The O-shaped is irregularly network topology based on empty area on the interior side, H-shaped is another topology where nodes are randomly deployed with two empty areas, and X-shaped topology is also based on random deployment of nodes with an empty area on the four sides. Figure 4 illustrates the four used network topologies. In the next sections, the simulation results are given separately for each topology.

A. SQUARE RANDOM NETWORK TOPOLOGY
In this subsection, we analyze the impact of communication range, percentage of anchor nodes and total number of nodes on localization accuracy of all aforementioned algorithms. Here, the communication range R varies from 15m to 35m, the total number of sensor nodes varies 200 to 500 and the percentage of anchor nodes varies from 15% to 40%, respectively. Figure 5a shows that the increase in the communication range of sensor nodes has an effect on the localization accuracy. In fact, the localization errors of all algorithms decrease with the increase in the communication range because the network becomes more connected. Moreover, we can observe that both the basic DV-Hop and WDV-Hop have a higher localization error around 0.49R, while the HWDV-HopPSO has about 15% lower localization error, especially when the communication range is equal to 15m. In contrast, DV-HopPSO, WDV-HopPSO and HWDV-Hop outperform other algorithms in terms of localization error,  As depicted in Figure 5c, the localization error is computed by varying the total number of sensor nodes from 200 to 500, while the percentage of anchor nodes and communication range R are fixed at 20% and 30m, respectively. It is worth noting that when the density of the network is highly increased, the network becomes more connected due to a large number of total nodes deployed in the area of interest. Moreover, a better localization error is archived by the HWDV-HopPSO, which is around 0.21R. In comparison with DV-Hop, WDV-Hop and MDV-Hop, it is observed that the localization error is around 0.33R, 0.29R and 0.27R, respectively. Furthermore, the localization error in the case of WDV-HopPSO and HWDV-Hop is lower by around 9% and  around 4% on average as compared to DV-Hop and MDV-Hop, respectively. In addition, the localization error achieved by HWDV-HopPSO is lower by around 5%, 8% and around 12% on average in comparison with DV-HopPSO, MDV-Hop and DV-Hop, respectively. However, the HWDV-HopPSO outperforms all the other localization algorithms and it shows a better localization accuracy.
In Table 2, we introduce a comparison between the proposed algorithms and the other algorithms in terms of minimum, maximum and average localization error, respectively.

B. O-SHAPED RANDOM NETWORK TOPOLOGY
In this scenario, firstly, the localization accuracy is analyzed by varying the communication range from 15m to 35m, while both the total number of sensor nodes and percentage of anchor nodes are fixed at 200 and 20%, respectively. Figure 6a shows that when the communication range of sensor nodes is increased, a better performance in terms of localization error is achieved by HWDV-HopPSO. For instance, when the communication range is equal to 15m, the HWDV-HopPSO, WDV-HopPSO and DV-HopPSO have a localization error of around 0.42R, 0.49R and 0.51R,   In Figure 6b, the simulation results are expressed by varying the percentage of anchor nodes from 15% to 40%, while the total number of sensor nodes and communication range are fixed at 200 and 30m, respectively. We observed that the HWDV-HopPSO, HWDV-Hop and MDV-Hop algorithms In Table 3, in addition to simulation results in the above subsection, we also introduce a comparison between the proposed algorithms and the other algorithms in terms of minimum, maximum and average localization error, respectively.

C. H-SHAPED RANDOM NETWORK TOPOLOGY
In this scenario, firstly, the localization accuracy is analyzed by varying the communication range from 15m to 35m, while both the total number of sensor nodes and percentage of anchor nodes are fixed at 200 and 20%, respectively. Figure 7a shows that when the communication range of sensor nodes is increased, lower localization errors are achieved by the proposed HWDV-HopPSO, WDV-HopPSO and DV-HopPSO, which have localization errors of around 0.55R, 0.56R and 0.58R, respectively, whereas DV-Hop, In Table 4, we introduce an extra comparison between the proposed algorithms and the other algorithms in terms of minimum, maximum and average localization error, respectively.

D. X-SHAPED RANDOM NETWORK TOPOLOGY
In this scenario, we analyze the localization accuracy by varying the communication range from 15m to 35m, while both the total number of sensor nodes and percentage of anchor nodes are fixed at 200 and 20%, respectively. Figure 8a shows that both HWDV-HopPSO, WDV-Hop achieved lowest localization errors as compared to other localization algorithms. For example, when the communication range is equal to R = 15m, HWDV-HopPSO has around 0.65R, whereas both WDV-HopPSO and DV-HopPSO have a localization error of around 0.72R, respectively, and HWDV-Hop has a localization error of around 0.74R on average. In contrast, DV-Hop, WDV-Hop and MDV-Hop have localization errors of around 0.88R, 0.87R and 0.81R, respectively. However, the results reveal that the localization errors is decreased when increasing the communication range, where the proposed algorithms HWDV-HopPSO, WDV-HopPSO achieved better performance in comparison with other localization algorithms.
In Figure 8b, the simulation results are depicted by varying the percentage of anchor nodes from 15% to 40% while the number of unknown nodes and communication range are fixed at 200 and 30m, respectively. In this scenario, the HWDV-HopPSO, WDV-HopPSO, DV-HopPSO and HWDV-Hop achieve the lowest localization errors as compared to the other algorithms. The localization errors for HWDV-HopPSO, WDV-HopPSO, DV-HopPSO and HWDV-Hop are 0.37R, 0.39R, 0.40R and 0.41R, respectively as compared to DV-Hop, WDV-Hop and DV-HopPSO, which have 0.48R, 0.46R and 0.44R, respectively, especially when the percentage of anchor nodes is 15%. The obtained results in this scenario confirms that a lower localization error is achieved by both the proposed algorithms HWDV-HopPSO and HWDV-Hop in comparison with the other algorithms.
As depicted in Figure 8c, the localization error is analyzed by varying the total number of sensor nodes from 200 to 500, while the percentage of anchor nodes and communication range R are fixed at 20% and 30m, respectively. We remark that the localization errors achieved by HWDV-HopPSO, HWDV-Hop, DV-HopPSO and HWDV-HopPSO, which are 0.32R, 0.33R, 0.36R, and 0.37R, respectively, are lower than those of DV-Hop, WDV-Hop, and MDV-HopPSO, which have localization errors of 0.40R, 0.40R and 0.42R, espe-cially when the number of total nodes is equal to 500. Furthermore, the obtained results according to this scenario demonstrate that the localization error significantly decreases when the percentage of anchors increases. Also, we observed that the proposed HWDV-HopPSO and HWDV-Hop outperform DV-Hop, MDV-Hop and other localization algorithms.
In Table 5, we compare the proposed algorithms and the other algorithms in terms of minimum, maximum and average localization error, respectively. Figure 9 illustrates the localization error per sensor node for all introduced localization algorithms according to the square random network, O-shaped network, H-shaped and X-shaped network, respectively. Indeed, the localization error is computed while the total number of sensor nodes, percentage of anchors and communication range R are fixed at 200, 20% and 30m, respectively. It can be observed from the obtained results that the localization error of the proposed algorithm HWDV-HopPSO is lower as compared to the other algorithms regardless of the considered random network topology. Moreover, it is obvious that the proposed HWDV-HopPSO, WDV-HOP and HWDV-Hop algorithms achieve high localization accuracy as compared with DV-Hop and the other localization algorithms.

E. TIME COMPLEXITY ANALYSIS
Due to limitations on the cost and the size, sensor nodes have a limited capacity of computation and energy, which makes them sensitive to implementing complex algorithms. For these reasons, the time complexity is taken into consideration in this subsection. Indeed, the localization problem in WSNs is considered as an NP-hard optimization problem and can be modeled as follows: we assume a WSN consisting of n unknown sensor nodes and k anchor nodes. Besides, the maximum generation and the population size of PSO are MaxG and NP, respectively. Generally, the complexity of an algorithm is expressed to measure the worst-case time complexity or the longest amount of time that an algorithm can take to complete.
In this paper, the time complexity for each proposed algorithm is expressed. In fact, the time complexity in the first phase is O(k 2 ) because all algorithms need to calculate the matrix of minimum hop count. In the second phase, DV-Hop and DV-HopPSO use a classical technique to calculate the average hop size distance by every anchor node within the network, so the time complexity is O(k 2 ). Despite, the other proposed algorithms, WDV-Hop, WDV-HopPSO, HWDV-Hop, HWDV-HopPSO, MDV-Hop use different based weighted techniques, they have the same time complexity O(k 2 ). In the third phase, the time complexity is O(k*(n-k)) because DV-Hop and DV-HopPSO apply the least square technique to estimate the locations of unknown nodes. The other proposed algorithms, WDV-Hop, WDV-HopPSO, HWDV-Hop, HWDV-HopPSO, MDV-Hop, respectively, apply the 2D-Hyperbolic technique instead of the trilateration technique to estimate node's location and then their time complexity is O(k*(n-k)). In the fourth phase, the last phase of the optimization of unknown nodes' locations, the time complexity of DV-HopPSO, WDV-HopPSO, HWDV-HopPSO with PSO is O(MaxG*NP*(n-k)). Although an O(k*NP) extra time complexity is required to calculate the fitness function and O(MaxG*NP) to update the locations of particles, and then the time complexity of WDV-HopPSO and HWDV-HopPSO algorithms with PSO is O(MaxG*NP* (n-k)). Therefore, it can be observed that the time complexity of HWDV-HopPSO is slightly increased due to changes made in phase two and the use of PSO to optimize the node locations in wireless sensor networks.

VI. CONCLUSION
In this work, four new localization algorithms called HWDV-HopPSO, HWDV-Hop and WDV-Hop and WDV-HopPSO, respectively, have been proposed in order to enhance the localization accuracy. Accordingly, four different complex network topologies including uniform random, O-shaped, H-shaped and X-shaped networks are considered to evaluate and analyze the performance of the proposed algorithms. Indeed, additional phases have been added to the standard DV-Hop algorithm in order to minimize the localization error of unknown nodes in wireless sensor networks. Extensive simulations have been conducted while varying the total number of nodes, percentage of anchors and communication range according to four different random networks for static wireless sensor networks. The obtained results show that the HWDV-HopPSO achieved the lower localization error as compared with DV-Hop, DV-HopPSO, MDV-Hop and the other algorithms in all conducted network scenarios. In addition, HWDV-HopPSO and WDV-HopPSO are better in comparison with DV-Hop, WDV-Hop, MDV-Hop, DV-HopPSO, and HWDV-Hop in the case of the uniform random network, H-shaped and X-shaped network, respectively. Otherwise, HWDV-HopPSO and HWDV-Hop showed also good performance in the case of O-shaped network topology. In general, simulation results confirmed that the HWDV-HopPSO and HWDV-Hop outperformed the DV-Hop and the other algorithms in SWSNs according to uniform random, O-shaped, H-shaped and X-shaped networks in terms of localization error, respectively. In our ongoing work, other simulations will be conducted to evaluate these algorithms for mobile wireless sensor networks. Moreover, the proposed algorithms will be extended to estimate the position of unknown sensor nodes in 3D.