A Hybrid Algorithm of GA + Simplex Method in the WSN Localization

Localization provides the key support for wireless sensor networks (WSNs). In order to solve the large-error problem in the third phase and the poor position accuracy of the least square method in the weighted DV-Hop algorithm, a hybrid algorithm of GA + simplex method was proposed in this paper. The weighted DV-Hop position algorithm was applied to estimate the distance between the unknown node and the anchor node in the first and second phase. In the third phase, a hybrid genetic algorithm with the simplex method was proposed to optimize the coordinates of the unknown nodes. In the hybrid genetic algorithm, a fitness function which combined the cost function with the penalty function was built, and the simplex method was used to increase the local search ability of the algorithm. Experiments show that both of the localization accuracy and network coverage rate are improved significantly, and the hybrid algorithm of GA + simplex method is suitable for the WSN localization.


Introduction
In the past decades, the advances in microelectronics, computer, and wireless communication technologies stimulate the rapid development of low-power and multifunction sensors, which can integrate the information acquisition, data processing, wireless communication, and other functions in a tiny volume. The wireless sensor network (WSN) is a multiple-hops and self-organizing network system which consists of a large number of low-cost microsensor nodes deployed in monitoring area and communicating through wireless. WSN can be used to aware, collect, and process the information of perception objects in the network coverage area and then send the results to observers. The three components of a sensor network are sensor, cognitive object, and observer.
The application prospects of sensor networks are very broad and they can be widely used in military, environmental monitoring, health care, and so forth. With in-depth research and extensive application, sensor networks will gradually be applied to the various areas of human life.
In sensor networks, the location information is crucial. Monitoring messages without the location information are usually useless [1]. Therefore, the node location is one of the most basic functions in sensor networks, and it plays a key role in various applications. The node localization can be divided into two categories: range-based and range-free. The range-based localization (RBL) is obtained by calculating the actual distance between the unknown node and the anchor nodes. The range-free localization (RFL) is obtained by estimating the distance of the two nodes. RFL is less sensitive to the complex environment in signal transmission, but its hardware costs and energy consumption are low. Therefore, RFL is very suitable for WSN applications [2].
The traditional distance vector-hop (DV-Hop) algorithm was proposed by Dragos Niculescu, which uses GPS and distance vector routing. It is a range-free method [3], meaning that it does not measure the distance directly but rather utilizes the information of the distance vector and network connectivity to get the estimated distance. Therefore, DV-Hop has less demanding on the physical measuring unit, and it performs well in the isotropic networks [2].
The biological evolution law of selecting the superior and eliminating the inferior exists in natural systems. The evolution is a self-adaptive process that behaves robustly. Inspired by the evolution law, J. Holland proposed the genetic algorithm (GA), which is very suitable for solving global optimal solution in the combination and optimization problems [4]. It can obtain the optimal solution with a high probability and is easy to implement in mathematic models as well [5]. The paper is organized as follows. In the next section, the traditional DV-Hop positioning algorithm with its error analysis is introduced. The GA + simplex method for restricted problems is discussed in Section 3. In Section 4, an improved DV-Hop algorithm, the hybrid algorithm based on the GA + simplex method, is proposed. Experimental results and related analysis are presented in Section 5, and the conclusion is followed in the last section.

The DV-Hop Algorithm
2.1. The Principle. The procedure of the traditional DV-Hop algorithm is shown in Figure 1.
In general, there are three stages in the algorithm [6]. The first stage is to calculate the minimum counts of hop between unknown nodes and every anchor node. Neighboring nodes receive group messages in which anchor nodes broadcast their own position. The messages include the range of hop-counts with the initial value of zero. Receiving node will ignore group messages with the maximum of hop-counts which are broadcasted by the same anchor node until the minimum of hop-counts from every anchor node is recorded and then add 1 to the recorded hop-counts and send the value to a neighboring node. With this strategy, all nodes including unknown nodes and anchor nodes in WSN can record the minimum hop-counts to every anchor node.
The second stage is to calculate the estimated distance between unknown nodes and anchor nodes. For every anchor node, we use the hop-counts between two anchor nodes recorded in the first stage and the following formula to calculate the average hop-size: Here ( , ) and ( , ) are coordinates of the anchor nodes and , and ℎ is the hop-count between the two anchor nodes ( ̸ = ). Anchor nodes propagate the calculated average hop-size to the network; unknown nodes receive the first average hop-size which is recorded as the average hop distance and broadcast it to neighbor nodes. This method makes sure that most nodes recorded the latest average hopsize of anchor nodes. The distance from unknown nodes to every anchor node is calculated according to hop-counts and average hop-size.
The third stage is to calculate the unknown node's location with a three-sided measurement method, the maximum International Journal of Distributed Sensor Networks likelihood estimation method, or other multisided location methods. The detailed steps are described as follows.
The distances obtained by the first two stages between the unknown node ( , ) and the anchor node 1 ( 1 , 1 ), In (2), subtract the last one from each equation, and we have The above equations are simplified and reorganized as the following linear equations, = :

Simulation Analysis.
The simulation results of the traditional DV-Hop localization algorithm are shown in Table 1, in which the total number of nodes distributed randomly is 250, and the numbers of anchor nodes are 5, 10, 15, 20, 25, and 30. From the table, we can see that, with the increase of anchor nodes' ratio, the positioning error decreases and the accuracy improves. However, the decreasing rates of positioning errors are declining, and overall errors are still significant.
The position error formula is as follows: Here ( , ) is the true position of the th unknown node, and ( , ) is estimated coordinate. is WSN communication radius.

Error Analysis and Improved Ideas in the Second Phase.
The traditional DV-Hop location algorithm is suitable for the wireless sensor network in which anchor nodes are uniformly distributed, the network is isotropic, or most of the nodes are densely distributed. When nodes are distributed unevenly, there may be a large error when unknown nodes regard the average hop-size received first as the average hop-size to all anchor nodes. The authors in [7] use the average distance of every hop among all of the anchor nodes instead of the average hop-sizes in the traditional algorithm. In this paper, we improve the traditional algorithm through methods of assigning every received average hop-size a weight, namely, using the normalized thought to obtain the average hop-size.

Error Analysis and Improved Ideas in the Third Phase.
From the third stage of DV-Hop positioning algorithm, we can see that exists in every element of . Therefore, the coordinates obtained with the formula ∧ = ( ) −1 are affected by the accuracy of . To resolve this issue, we could transform the problem into the constrained optimization question [8].
Let us denote that the real distances from the anchor nodes 1 , 2 . . .
to are 1 , 2 . . . , and 1 , 2 . . . are the measuring errors of corresponding anchor nodes. We have International Journal of Distributed Sensor Networks . . .
And then we have the following: Hence, the problem can be reduced to minimize the function ( , ). Here When ( , ) reaches the minimum, the total error is also minimized. Therefore, the third stage of the DV-Hop can be transformed into solving constrained optimization problem. There are quite a few researches related on the nonlinear optimization problem, such as constrained particle swarm [8], artificial bee colony [9], genetic algorithm [10,11], simulated annealing algorithm [12,13], and differential evolution algorithm [14].

The Improvement of DV-Hop Localization Algorithm
3.1. The Improvement in the Second Stage. The process of the modified algorithm is as follows. Let us define Here is the mean square error of th anchor node, We assume that unknown nodes have received the information of anchor nodes: Therefore, we have So the average distance of every hop is The above algorithm is based on the weighted average distance of each hop, and the simulation results are shown in Table 2, in which the total number of nodes distributed randomly is 250, and the number of anchor nodes is 5, 10, 15, 20, 25, and 30. The results show positioning errors comparing the above modified algorithm with [7].
As can be seen from the table, with the proportion of anchor nodes increasing, the positioning errors decrease, and the modified algorithm performs better. Although the positioning accuracies of both algorithms are increasing, the errors are still relatively large.
With the least squares weighted DV-Hop algorithm, the third phase error is still very large for nonlinear constraint problems. A hybrid genetic algorithm of GA + simplex method is presented to optimize the weighted DV-Hop algorithm.

The GA + Simplex Method for Restricted Problems in
the Third Stage 3.2.1. The Principle. The basic procedure of GA is as follows. With constant iterations, the algorithm updates the assumption groups, and a fitness function is used to evaluate all individuals in each iteration, and then individuals with higher fitness values are picked with a higher probability. A new population is created through selection, crossover, and mutation genetic methods [14]. The defects of the genetic algorithm are time-consuming in computations and poor local search ability [15]. Therefore, the improved GA adopts the principle of saving the best individual in order to shorten the computation process.
The simplex method converts a variety of nonstandard forms into standard forms through series of transformations, and it is effective to solve the linear problem which contains many constraints of nonstandard forms. Therefore, it behaves strong apriority in local search ability.

Solving Restricted Problems.
To satisfy the constraint condition in (7) which contains many constraint conditions [16], the penalty function could be used to transform the restricted problems into the unconstrained optimization problem:

Min
( , ) International Journal of Distributed Sensor Networks 5 Here ( , ) ∈ , and is the searching space of the objective function ( , ); To construct the punishment function, let Then the punishment function is ( , ) = ∑ =1 |ℎ ( , )|. One has ( − ) 2 ≤ 2 ( , ) ≤ ( + ) 2 . If ( , ) ∈ feasible region, ℎ ( , ) = 0. If ( , ) ∉ feasible region, we have the following two cases: From the above two cases, we have ( , ) > 0. Therefore, the new objective function is To solve ( , ) with the hybrid genetic algorithm of GA + simplex method, we need to design an objective function and adopt the maximum coefficient method to obtain the minimum of ( , ): Here max is the maximum coefficient. From (18), we see that when ( , ) is the minimum, ( , ) reaches the maximum.
After the penalty term is added, all solutions in the 2dimensional space can be regarded as feasible ones, and it can obviously avoid taking the local optimal solution as the global optimal solution, but the corresponding amount of computation is increased [17]. We adopt the principle of saving the best individual, which can shorten the operation time. And the new algorithm can improve the poor performance from adding the penalty function.

The Improved DV-Hop Algorithm Based on the GA + Simplex Method.
We assume that there are total nodes in a WSN which contains anchor nodes, and we want to locate the ( − ) unknown nodes. During the positioning process, the unknown nodes obtained coordinates are converted into new "anchor nodes." The distance between any two nodes cannot be more than the radius of the WSN distance. Here we assume that there are not isolated points in the WSN [8].
The procedure of the proposed hybrid algorithm of GA + simplex method is as follows.
Step 1. Initialize the number of anchor nodes .
Step 2. From ( = − ) unknown nodes, find the unknown node with the largest number of neighboring anchor nodes.
Step 3. Randomly generate the initial population of groups.
Step 4. Put the fitness function ( , ) in the process of index calibration, and create a new fitness function ( , ) . Use the new fitness function to calculate the fitness of all the members of the group.
Step 5. Arrange all individuals according to the fitness level, and adopt the principle of saving the best individual. For the top five individuals with the highest fitness values, go to Step 7, and for the rest of − 5 individuals that are named group , continue to the next step.
Step 6. Generate a new group with the genetic algorithm.
(1) Selection (copy): here we use the roulette method.
(3) Mutations: select one or more genes, and then do the corresponding change according to the mutation probability .
Step 7. Combine the top five individuals with the highest fitness from Step 5 with the group with the individual number of − 5 from Step 6 and form a new group.
Step 8. Adopt the simplex method. Select individuals with a certain probability and perform the simplex method in the new group, and then replace the original individual with the new individual.
Step 9. If the number of iterations reaches the maximum, continue to Step 10. Otherwise, go back to Step 4.
Step 10. Obtain the position coordinates of anchor nodes according to the last step. Let ← + 1; when < , go back to Step 2; when = , all the unknown nodes in the WSN are positioned, and the algorithm ends.
In Step 4, the fitness function ( , ) is dealing with indexation, constructing a new fitness function which can promote the competition but do not violate the fundamental principle of fitness function. In Step 5, we implement the principle of saving the best individuals. That is, the best individuals do not go through genetic operator process and directly go to the next step. As a result, operation time is reduced for less iteration and meets the goal of effectively iterative optimization. In Step 8, the simplex method is used as the local search operator of GA, so that you can take advantage of the strong local searching ability.

The Simulation Scenario.
In the experiment, MATLAB was employed to perform the simulation of the weighted DV-Hop localization algorithm, the GA DV-Hop positioning algorithm [10], and the hybrid GA + simplex algorithm, respectively. In order to ensure the accuracy of simulation  results, before the start of each simulation, the network topology was constructed according to the parameters related to WSN connectivity and the density of anchor nodes. Anchor nodes are randomly generated and uniformly distributed in the region for better performance [1]. The experiment was repeated many times with the same parameters, and the average of results for each experiment was recorded. Only the isotropic WSN is discussed here.
Position performance is evaluated according to the average position error [16] and the network coverage rate.
The position error is defined in Section 2.2. The network coverage rate is the ratio of the unknown nodes that obtain the coordinates and the total unknown nodes in the network. It is one of the targets of location algorithm to achieve the precise positioning of unknown nodes as much as possible. In the case of meeting a certain positioning accuracy, the higher network coverage rate represents the better network performance.
The GA + simplex method needs to set the parameters, and we use the binary coding with the code length = 14, population size = 50, crossover probability = 0.9, mutation probability = 0.02, and the number of iterations = 100. We use the Nelder-Mead simplex method in which the parameters need to be reset, including the reflection factor = 1, the expansion factor = 0.5, and the shrinkage factor = 2. The simulation experiment would be discussed in the next section.

The Impact of Network Connectivity on the Positioning
Accuracy. We arranged a total of 250 nodes in the region, and the number of anchor nodes was 10. Figure 3 shows the simulation diagram of the weighted DV-Hop algorithm, the GA DV-Hop algorithm, and the hybrid DV-Hop algorithm  based on the GA + simplex method. From the figure, we can see that when the connectivity is less than 10, errors of three algorithms are reduced, and margins become large. The GA positioning algorithm performs better than the weighted DV-Hop positioning algorithm. The error of the hybrid of GA + simplex method is less than that of GA positioning algorithm. The simplex method can make up for some drawbacks of GA. When the connectivity is larger than 10, errors for all of the three algorithms are deteriorated. But the hybrid algorithm of GA + simplex method performs better than the other two. The reason is that when the network connectivity is large and over a certain value, hop-counts between nodes are inaccurate.

The Impact of the Number of Anchor Nodes on the
Positioning Accuracy. There are 250 nodes in the region, and the anchor node ratio varies from 0.02 to 0.12. Figure 4 shows the impact of anchor node ratio on the three algorithms in the isotropic network. From the figure, we see that, with the increase of anchor node ratio, performances of the three positioning algorithms are all improved. This is because, with the increase of the anchor node ratio, the number of available positioning nodes is increased, and the knowing ability of the network is also increased. The hybrid algorithm of GA + simplex method performs better than the other two. Figure 5 shows that, with the increase of the proportion of anchor nodes, the network coverage rates of the three positioning algorithms are increased. The positioning coverage of GA DV-Hop is larger than that of the weighted DV-Hop algorithm, and the hybrid algorithm of GA + simplex method performs significantly better than the GA DV-Hop. When anchor nodes proportion is small, the network coverage   rate increases by a big margin, and the coverage gaps of the three algorithms are large. As the proportion of anchor nodes increases to a certain degree, the network coverage rate increases more slowly and stably.

The Impact of Number of Nodes on the Positioning
Accuracy. Figure 6 shows the simulation results with the number of nodes being 50-250. The figure shows that, for a certain proportion of anchor nodes, when the number of nodes increases, the average positioning errors of the three algorithms are reduced, but the accuracy of the new  algorithm is better than the other two algorithms, especially when the number of nodes is relatively small.

Positioning Stability.
The confidence interval of the average positioning error reflects the stability of an algorithm. The general formula is defined as follows: Here is the number of samples. is the average positioning error of each algorithm in different node numbers.   Confidence intervals of the three algorithms in different node numbers are shown in Figure 7. From Figure 7, the GA + simplex method has the least positioning error and interval size. The GA + simplex method performs the best positioning performance with a minimum width of the confidence interval. So the new method is most stable in the three algorithms. Figure 8, it can be found that can influence the convergence of GA + simplex method. More concretely, when < 0.5, the speed of convergence becomes faster and the stability becomes better with the increase of . Conversely, when > 0.5, the speed slows down and stability becomes worse with the increase of . So, the value of is set at 0.5 in the GA + simplex method.

Time Complexity.
The GA + simplex method saves the best individuals when updating the population to reduce the total execution time. From Figure 9, the runtime increases along with population size but decreases after saving the best individuals. Therefore, the new algorithm can reduce the time complexity.

Conclusion
The genetic algorithm is suitable for correction of the weighted DV-Hop localization due to its own characteristics. This paper proposes a hybrid algorithm based on GA + simplex method to optimize the weighted DV-Hop localization in the third phase. Without large calculation, the algorithm preserves the advantage of the GA algorithm, while its simplex method makes up some inherent flaws of the GA. The experiment shows that the improved algorithm  has higher positioning accuracy and network coverage in isotropic WSN than other localization algorithms, and it is suitable for WSN positioning.