Firefly Optimization-Based Cooperative Localization Algorithm for Intelligent IoT

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.


Introduction
Due to advancements in wireless communication technology over the previous several decades, the Internet of ings (IoT) is now extensively employed in buildings and residences [1]. A typical Internet of ings system consists of low-power, low-cost devices that connect with one another through the Internet. e Internet of ings' 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. is enables machine-to-machine communication without the need for human intervention [2], potentially reducing manual labour costs. One of the most crucial di culties 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 o er position information to a wireless device, but it is expensive and energy-intensive. As a result, GPS may not be suitable for all IoT applications. e Internet of ings (IOT) industry is growing at an astonishing rate, with the application of location-based services gradually permeating people's lives. For example, in a smart factory, the Internet of ings collects key data of the equipment in the factory in real time through sensors, completes data storage, analysis, and other processing, timely and e ectively handles equipment failures, and ensures the normal operation of equipment.
e IoT management platform manages equipment in a uni ed manner, allocates and uses equipment reasonably, arranges production plans, and improves the overall operational eciency of smart factories. In smart agriculture [3,4], the Internet of ings 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][8][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][11][12] and firefly algorithm [13][14][15]. e firefly algorithm has the advantages of few parameters to be adjusted, is easy to implement, has simple structure, etc., and it is widely used. e 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 firefly-based 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. ey 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. e 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. erefore, we propose a firefly-based 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.

Traditional Firefly Localization Algorithm
It is assumed that in the positioning area, the coordinates of the anchor node are (u k , v k )k ∈ 1, 2, . . . , K { }; the coordinates of the unknown node are (x, y). According to the ranging information between the unknown node and all anchor nodes, the established positioning equations are where 2 and d k represent the actual distance and the measured distance from the k-th anchor node (u k , v k ) to the unknown node (x, y), respectively, and e k represents the ranging error. Randomly initializing the firefly position in the positioning area, the position of the n-th firefly can be expressed as X ⌢^n � (x n , y n ) T , the objective function defined according to formula (1) is (2) rough 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.

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. e use of ranging information is insufficient, resulting in very limited space for improving the positioning accuracy. In view of this, a firefly-based 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 (x k , y k ), k ∈ (1, . . . , Κ), and the position of the unknown node is expressed as (x i , y i ), i ∈ (1, . . . , Ι). e positioning equation established according to the ranging information between all the nodes and unknown node as 2 and d i,k represent the real distance and the measured distance from the anchor node to the unknown node, respectively; 2 and d i,j ′ represent the real distance and measured distance from the i-th unknown node to the j-th unknown node, respectively. e i,k and e i,j ′ represent the ranging error. e cooperative process based on firefly optimization is as follows: (1) i � 1 (2) Calculate the initial position of the i-th unknown node (x i , y i ) by using the traditional firefly localization algorithm. (3) Determine whether the initial position calculation of all unknown nodes is completed; if not, i � i + 1, go to step 2; otherwise, go to the next step. (4) Suppose there is N firefly, X (l) n � (x (l) n,x 1 , y (l) n,y 1 , . . . , x (l) n,x I , y (l) n,y I ) T indicates the position of the first firefly, and where the random numbers r 1 and r 2 both obey the zero mean normal distribution with variance σ 2 � 1, and l represents the number of searches. (5) e objective function defined according to formula Among them, Κ 2 � C 1 Ι C 1 Κ + C 2 Ι 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 r mn indicates the distance between fireflies, I 0 indicates the strongest brightness, and c indicates the absorption coefficient. e relative brightness can help you determine the direction of firefly movement.
Input: d k the measured distance from the k-th anchor node (u k , v k ) to the unknown node Output: (x, y) the estimated position of the unknown node (1) Randomly initialize the fireflies; (2) While maximum iteration is not reached do (3) Calculate the objective value of the firefly using formula (2) (4) Calculate the relative brightness of fireflies; (5) Calculate the attraction of fireflies; (6) Update the position (7) end ALGORITHM 1: Traditional firefly algorithm. Specific flow of the traditional firefly algorithm.
Discrete Dynamics in Nature and Society 3 (7) Calculate the attraction of fireflies with reference to the following formula: where β 0 represents the greatest attraction. (8) Update the position with reference to the following formula: where X l m is the position of the m-th 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.

Simulation Study
In simulation experiments, the main parameters of the traditional firefly positioning algorithm are the fireflies' number N � 20, the searches' number L 1 � 100, and the search step α � 0.25. e main parameters of the colocation based on firefly optimization are the fireflies' number N � 20, the searches' number L 2 � 100, and the search step α � 0.05. A rectangular positioning area is 12m × 12m in which all nodes are randomly distributed. e range inaccuracy is supposed to have a variance of σ 2 and a zeromean Gaussian distribution. e positioning error is defined as where (x i , y i ) represents the position of the i-th node. 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. is 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. 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. Figure 3, when the colocalization algorithm based on firefly optimization uses a randomly generated initial Table 1: Notation of variables.

Notation
Items e position of the k-th anchor node (x i , y i ) e position of the i-th unknown node e i,k , e i,j ′ e ranging error X l n e position of the n-th firefly r mn e distance between fireflies β e attraction of the firefly α e search step Input: d i,k the measured distance from the k-th anchor node to the i-th unknown node, d i,j ′ the measured distance from the i-th unknown node to the j-th unknown node Output: (x i , y i ), i ∈ (1, . . . , Ι) the estimated position of the i-th unknown node (1) i � 1; (2) while all the unknown nodes' positions have not been calculated do (3) calculate the initial position of the i-th unknown node using the firefly algorithm; (4) i � i + 1; (5) end (6) randomly initialize the fireflies; (7) while maximum iteration is not reached do (8) calculate the objective value of the firefly using formula (5) (9) calculate the relative brightness of fireflies using formula (6); (10) calculate the attraction of fireflies using formula (7) value, its localization error is larger than that of the traditional firefly algorithm. e 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.

Influence of Search
Step Size on Positioning Error. e 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.   where L 2 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 O(L * N 2 * I 2 ) in time complexity, but brings the benefits of significantly improved positioning accuracy.

Conclusion
is work has enhanced the localization performance of standard firefly technique by making full use of all range information to accomplish cooperative location. e algorithm creates an objective function with range information between unknown nodes, which it then solves using the firefly optimization process. e 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 ings, 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 ings. e upcoming 5G-based IoT has many complex application scenarios that require more efficient location services, so this research has far-reaching implications for the Internet of ings.  Data Availability e data used to support the findings of this study are included within the article.

Conflicts of Interest
e authors declare that they have no conflicts of interest.