Abstract
To achieve effective connection between each node of the Internet of Things (IoT), there is a great demand of precise positioning. The traditional firefly localization algorithm only considers part of the ranging information, and the positioning effect is not good. Therefore, an improved algorithm is proposed to take advantage of the ranging information between unknown nodes to achieve cooperative location. First, all ranging information is considered to construct a new objective function. The firefly optimization approach is then utilized to discover the best solution based on the new goal function. The starting location created by the random technique has a significant impact on the new algorithm’s localization performance, thus the traditional firefly localization method’s initial position is employed to increase cooperative localization performance. The simulation results demonstrate that the novel approach outperforms the classic firefly technique in terms of placement accuracy.
1. Introduction
Due to advancements in wireless communication technology over the previous several decades, the Internet of Things (IoT) is now extensively employed in buildings and residences [1]. A typical Internet of Things system consists of lowpower, lowcost devices that connect with one another through the Internet. The Internet of Things’ primary purpose is to guarantee that all devices, including sensors, smartphones, wearable sensors, tablets, and transportation systems, can connect with one another via a standard interface. This enables machinetomachine communication without the need for human intervention [2], potentially reducing manual labour costs. One of the most crucial difficulties in IoT is precise positioning. Consequently, wireless localization, or the extraction of an object’s geolocation information, has received a lot of attention. A Global Positioning System module may offer position information to a wireless device, but it is expensive and energyintensive. As a result, GPS may not be suitable for all IoT applications.
The Internet of Things (IOT) industry is growing at an astonishing rate, with the application of locationbased services gradually permeating people’s lives. For example, in a smart factory, the Internet of Things collects key data of the equipment in the factory in real time through sensors, completes data storage, analysis, and other processing, timely and effectively handles equipment failures, and ensures the normal operation of equipment. The IoT management platform manages equipment in a unified manner, allocates and uses equipment reasonably, arranges production plans, and improves the overall operational efficiency of smart factories. In smart agriculture [3, 4], the Internet of Things collects data such as temperature, then deals with these data, and combines precise positioning information to achieve smart operation of agricultural production. Precise positioning is the key to IoT locationbased service applications.
Node positioning requires ranging information. As shown in Figure 1, the dotted line represents ranging information from unknown nodes to anchor nodes, and the solid line represents ranging information between unknown nodes. According to ranging information provided by the ranging methods such as arrival time [5, 6] or received signal strength [7–9], a positioning equation system is established, and the equation system is solved to obtain the position of the node. Common solution methods include particle swarm algorithm [10–12] and firefly algorithm [13–15]. The firefly algorithm has the advantages of few parameters to be adjusted, is easy to implement, has simple structure, etc., and it is widely used. The goal function in the traditional firefly localization method only comprises ranging information from unknown nodes to anchor nodes and does not fully use the ranging information between unknown nodes, resulting in limited positioning accuracy increase. In view of this, we propose a fireflybased optimization method. To increase the position accuracy, the cooperative algorithm may make full use of all range information.
In addition to our proposed algorithm, there are other cooperative algorithms. Reference [16] searches for the optimal solution along the gradient descent direction; reference [17] proposes a statistical manifold (SM) method, which uses the Riemann metric tensor to correct the given gradient optimization direction to find the optimal solution. They all use the gradient information to find the appropriate solution through iterative calculation, but the establishment of the iterative coefficient matrix is very complicated. In the literature [18, 19], the colocalization problem needs to be transformed by a semidefinite programming (SDP) method. It can only be solved for convex optimization problems. However, this conversion process is more complicated. An upgraded cuckoo search (CS) localization algorithm [20] was presented that can exploit all of the distance information available. In relation to the SDP and SM methods, both our algorithm and the upgraded CS algorithm have relatively simpler operation and do not need to establish a convex optimization problem or construct an iterative coefficient matrix.
The reminder of the paper is organized as follows. Section 2 introduces the traditional firefly localization algorithm and shows how to use the firefly algorithm to obtain the estimated location of unknown nodes. Section 3 explains that the traditional firefly localization algorithm has limited room for improvement in accurate localization. Therefore, we propose a fireflybased cooperative algorithm and describe the colocalization algorithm in detail. In Section 4, we use MATLAB to conduct simulations and show the influence of ranging error, initial position, and search step size on the positioning error. Finally, Section 5 concludes the paper.
2. Traditional Firefly Localization Algorithm
It is assumed that in the positioning area, the coordinates of the anchor node are ; the coordinates of the unknown node are . According to the ranging information between the unknown node and all anchor nodes, the established positioning equations arewhere and represent the actual distance and the measured distance from the kth anchor node to the unknown node , respectively, and represents the ranging error. Randomly initializing the firefly position in the positioning area, the position of the nth firefly can be expressed as , the objective function defined according to formula (1) is
Through the objective function given by formula (2), the estimated position of the unknown node can be obtained by using the firefly algorithm. Algorithm 1 gives the specific flow of the traditional firefly algorithm.

3. Cooperative Localization Algorithms with Firefly Optimization
In the traditional algorithm, the objective function only considers the distance between the anchor node and the unknown node and does not consider others. The use of ranging information is insufficient, resulting in very limited space for improving the positioning accuracy. In view of this, a fireflybased cooperative algorithm is proposed. First, instead of selecting a random position as the initial position, the initial position is determined by the traditional firefly positioning method; then, all ranging information is used for precise positioning.
Suppose there is K anchor node and I unknown node randomly distributed in the positioning area, where the position of the anchor node is expressed as , and the position of the unknown node is expressed as . The positioning equation established according to the ranging information between all the nodes and unknown node aswhere and represent the real distance and the measured distance from the anchor node to the unknown node, respectively; and represent the real distance and measured distance from the ith unknown node to the jth unknown node, respectively. and represent the ranging error. The cooperative process based on firefly optimization is as follows:(1)(2)Calculate the initial position of the ith unknown node by using the traditional firefly localization algorithm.(3)Determine whether the initial position calculation of all unknown nodes is completed; if not, , go to step 2; otherwise, go to the next step.(4)Suppose there is N firefly, indicates the position of the first firefly, and where the random numbers and both obey the zero mean normal distribution with variance , and l represents the number of searches.(5)The objective function defined according to formula (3) is Among them, is the total number of measured distances between all nodes. Calculate the objective function value corresponding to each firefly according to formula (5).(6)Calculate the relative brightness of fireflies with reference to the following formula: where indicates the distance between fireflies, indicates the strongest brightness, and indicates the absorption coefficient. The relative brightness can help you determine the direction of firefly movement.(7)Calculate the attraction of fireflies with reference to the following formula: where represents the greatest attraction.(8)Update the position with reference to the following formula:where is the position of the mth firefly, is the search step, and the random number obeys a uniform distribution on the interval (−0.5, 0.5).
Determine whether the maximum number of searches has been reached. If the search is completed, the output result is the optimal position of the unknown node. Otherwise, jump to Step 5 and continue the search. Algorithm 2 gives the specific flow of the cooperative localization based on firefly optimization, and notation of variables is given in Table 1 for clarity.

4. Simulation Study
In simulation experiments, the main parameters of the traditional firefly positioning algorithm are the fireflies’ number , the searches’ number , and the search step . The main parameters of the colocation based on firefly optimization are the fireflies’ number , the searches’ number , and the search step . A rectangular positioning area is in which all nodes are randomly distributed. The range inaccuracy is supposed to have a variance of and a zeromean Gaussian distribution. The positioning error is defined aswhere represents the position of the ith node.
4.1. Influence of Ranging Error on Positioning Error
As shown in Figure 2, with the reduction of the ranging error, the localization mistake of the localization algorithm also decreases, but the localization error of the new algorithm is significantly lower than that of the traditional firefly localization algorithm. This is because the new algorithm considers not just the ranging information between the anchor node and the unknown node but also the ranging information among the unknown nodes, which increases placement accuracy. According to Table 2, the improvement percentage of positioning performance under different conditions is different, but the improvement percentage is more than 31%. Simultaneously, the improvement effect is better as the number of unknown nodes increases.
(a)
(b)
An overview of these methods’ performance comparison is provided by Table 3 in terms of ranging information usage, complexity, operation procedure, and positioning accuracy. All methods possess their drawbacks and advantages, which make them more appropriate for specific uses.
4.2. Influence of Initial Position on Positioning Error
As shown in Figure 3, when the colocalization algorithm based on firefly optimization uses a randomly generated initial value, its localization error is larger than that of the traditional firefly algorithm. The result shows that the initial value generated by the random method seriously affects the localization of the new algorithm performance, and the initial position provided by the traditional firefly algorithm significantly improves the positioning accuracy of the new algorithm.
(a)
(b)
4.3. Influence of Search Step Size on Positioning Error
The size of the search step is crucial for balancing the algorithm’s global and local search capabilities. A bigger step size is advantageous for increasing population variety, searching for areas with more ideal values, improving global search capability, and avoiding entering the premature convergence position. A smaller step size can improve the local search ability, which is conducive to refined search and improves the accuracy of the positioning result. As shown in Figure 4(b), the optimal value range of the search step size is 0.04–0.05.
(a)
(b)
4.4. Complexity Analysis
The time complexity used for traditional firefly positioning is approximately , where the number of anchor nodes is , the number of unknown nodes is , the maximum number of searches is , and the number of fireflies is . The time complexity of firefly colocation is , where is the maximum number of searches. In contrast to the placement method, the new technique searches for unknown nodes using range information, which leads to an increase in time complexity, but brings the benefits of significantly improved positioning accuracy.
5. Conclusion
This work has enhanced the localization performance of standard firefly technique by making full use of all range information to accomplish cooperative location. The algorithm creates an objective function with range information between unknown nodes, which it then solves using the firefly optimization process. The simulation results justify that our proposed approach may lessen range error’s impact. In the future, this research can also be applied to the Internet of Things, which rapidly expands a wide range of applications by connecting everything, moving towards a smart future world. It is very helpful for the precise positioning of various devices in the Internet of Things. The upcoming 5Gbased IoT has many complex application scenarios that require more efficient location services, so this research has farreaching implications for the Internet of Things.
Data Availability
The data used to support the findings of this study are included within the article.
Conflicts of Interest
The authors declare that they have no conflicts of interest.
Acknowledgments
This work was supported in part by the National Natural Science Foundation of China under Grant 62001272.