# Firefly Optimization-Based Cooperative Localization Algorithm for Intelligent IoT

Authors: Cheng peng Liu; Bin Xia; Liye Zhang
Journal: Discrete Dynamics in Nature and Society
 (2022)

---

## 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.


---

## Body

## 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 low-power, low-cost 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 machine-to-machine 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 geo-location 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 energy-intensive. 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 location-based 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 location-based service applications.Node positioning requires ranging information. As shown in Figure1, 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 firefly-based optimization method. To increase the position accuracy, the cooperative algorithm may make full use of all range information.Figure 1
The positioning panorama for IoT network.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. Section2 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 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.


## 2. Traditional Firefly Localization Algorithm

It is assumed that in the positioning area, the coordinates of the anchor node areuk,vkk∈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(1)d1=x−u12+y−v12+e1,⋮dk=x−uk2+y−vk2+ek⋮dK=x−uK2+y−vK2+eK,,where x−uk2+y−vk2 and dk represent the actual distance and the measured distance from the k-th anchor node uk,vk to the unknown node x,y, respectively, and ek 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=xn,ynT, the objective function defined according to formula (1) is(2)fΧ^n=1Κ∑k=1Κxn−uk2+yn−vk2−dk2.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.Algorithm 1:Traditional firefly algorithm. Specific flow of the traditional firefly algorithm.
Input:dk the measured distance from the k-th anchor nodeuk,vk to the unknown nodeOutput: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


## 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 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 asxk,yk,k∈1,…,Κ, and the position of the unknown node is expressed as xi,yi,i∈1,…,Ι. The positioning equation established according to the ranging information between all the nodes and unknown node as(3)d1,1=x1−u12+y1−v12+e1,1⋮di,k=xi−uk2+yi−vk2+ei,k⋮dΙ,Κ=xΙ−uΚ2+yΙ−vΚ2+eΙ,Κd1,2′=x1−x22+y1−y22+e1,2′⋮di,j′=xi−xj2+yi−yj2+eΙ−1,Ι,′i<j⋮dΙ−1,Ι′=xΙ−1−xΙ2+yΙ−1−yΙ2+eΙ−1,Ι,′where xi−uk2+yi−vk2 and di,k represent the real distance and the measured distance from the anchor node to the unknown node, respectively; xi−xj2+yi−yj2 and di,j′ represent the real distance and measured distance from the i-th unknown node to the j-th unknown node, respectively. ei,k and ei,j′ represent the ranging error. The cooperative process based on firefly optimization is as follows:(1)
i=1(2)
Calculate the initial position of the i-th unknown nodex^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,Xnl=xn,x1l,yn,y1l,…,xn,xIl,yn,yIlT indicates the position of the first firefly, and(4)xn,xil=x^i+r1yn,yil=y^i+r2,i=1,2,…,Ι,where the random numbersr1 and r2 both obey the zero mean normal distribution with variance σ2=1, and l represents the number of searches.(5)
The objective function defined according to formula (3) is(5)fXnl=1Κ2∑i=1Ι∑k=1Κxn,xil−uk2+yn,yil−vk2−di,k2+1Κ2∑i=1Ι−1∑j=1j>iΙxn,xil−xn,xjl2+yn,yil−yn,yjl2−di,j′2.Among them,Κ2=CΙ1CΚ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:(6)I=I0e−γrmn2,wherermn indicates the distance between fireflies, I0 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:(7)β=β0e−γrmn2,whereβ0 represents the greatest attraction.(8)
Update the position with reference to the following formula:(8)Xnl+1=Xnl+βXml−Xnl+α×ε,where Xml 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 Table1 for clarity.Algorithm 2:Cooperative localization algorithm based on firefly optimization. Specific flow of the cooperative localization algorithm.
Input:di,k the measured distance from the k-th anchor node to the i-th unknown node,di,j′ the measured distance from the i-th unknown node to the j-th unknown nodeOutput:x^i,yi,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);(11)
update the position;(12)
endTable 1
Notation of variables.
NotationItemsdi,k, di,j′The ranging distanceuk,vkThe position of thek-th anchor nodexi,yiThe position of thei-th unknown nodeei,k, ei,j′The ranging errorXnlThe position of then-th fireflyrmnThe distance between firefliesβThe attraction of the fireflyαThe search step


## 4. Simulation Study

In simulation experiments, the main parameters of the traditional firefly positioning algorithm are the fireflies’ numberN=20, the searches’ number L1=100, and the search step α=0.25. The main parameters of the colocation based on firefly optimization are the fireflies’ number N=20, the searches’ number L2=100, and the search step α=0.05. A rectangular positioning area is 12m×12m in which all nodes are randomly distributed. The range inaccuracy is supposed to have a variance of σ2 and a zero-mean Gaussian distribution. The positioning error is defined as(9)∑i=1Ix^i−xi2+y^i−yi2I,where x^i,y^i represents the position of the i-th node.


### 4.1. Influence of Ranging Error on Positioning Error

As shown in Figure2, 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.Figure 2
The variation of the positioning error with the variance of the ranging error. (a) I = 8,K = 4; (b) I = 16, K = 4.
(a)(b)Table 2
Improvement percentage of the positioning performance.
Ranging errorPositioning error/m, I = 8Improvement percentagePositioning error/m, I = 16Improvement percentageTraditional fireflyProposed methodTraditional fireflyProposed method0.40.90670.618331.80.85700.50341.30.81.20800.786834.91.16350.630345.81.21.42590.943833.81.38630.72647.61.61.55141.0232341.61330.87124621.73851.179932.11.74260.927246.8An overview of these methods’ performance comparison is provided by Table3 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.Table 3
Performance comparison of positioning methods.
MethodRanging information usageComplexityOperation procedurePositioning accuracyPSO, fireflyPartLowLowLowProposed method, upgraded CSALLHighMiddleHighSDP, SMALLHighHighHigh


### 4.2. Influence of Initial Position on Positioning Error

As shown in Figure3, 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.Figure 3
The effect of initial value on positioning accuracy. (a) I = 8,K = 4; (b) I = 16, K = 4.
(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 Figure4(b), the optimal value range of the search step size is 0.04–0.05.Figure 4
Influence of different search step size on positioning error. (a) I = 8,K = 4; (b) I = 16, K = 4.
(a)(b)


### 4.4. Complexity Analysis

The time complexity used for traditional firefly positioning is approximatelyOL1∗N2∗K∗I, where the number of anchor nodes is K, the number of unknown nodes is I, the maximum number of searches is L1, and the number of fireflies is N. The time complexity of firefly colocation is OL1∗N2∗K∗I+OL2∗N2∗I2, where L2 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 OL∗N2∗I2 in time complexity, but brings the benefits of significantly improved positioning accuracy.


## 4.1. Influence of Ranging Error on Positioning Error

As shown in Figure2, 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.Figure 2
The variation of the positioning error with the variance of the ranging error. (a) I = 8,K = 4; (b) I = 16, K = 4.
(a)(b)Table 2
Improvement percentage of the positioning performance.
Ranging errorPositioning error/m, I = 8Improvement percentagePositioning error/m, I = 16Improvement percentageTraditional fireflyProposed methodTraditional fireflyProposed method0.40.90670.618331.80.85700.50341.30.81.20800.786834.91.16350.630345.81.21.42590.943833.81.38630.72647.61.61.55141.0232341.61330.87124621.73851.179932.11.74260.927246.8An overview of these methods’ performance comparison is provided by Table3 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.Table 3
Performance comparison of positioning methods.
MethodRanging information usageComplexityOperation procedurePositioning accuracyPSO, fireflyPartLowLowLowProposed method, upgraded CSALLHighMiddleHighSDP, SMALLHighHighHigh


## 4.2. Influence of Initial Position on Positioning Error

As shown in Figure3, 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.Figure 3
The effect of initial value on positioning accuracy. (a) I = 8,K = 4; (b) I = 16, K = 4.
(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 Figure4(b), the optimal value range of the search step size is 0.04–0.05.Figure 4
Influence of different search step size on positioning error. (a) I = 8,K = 4; (b) I = 16, K = 4.
(a)(b)


## 4.4. Complexity Analysis

The time complexity used for traditional firefly positioning is approximatelyOL1∗N2∗K∗I, where the number of anchor nodes is K, the number of unknown nodes is I, the maximum number of searches is L1, and the number of fireflies is N. The time complexity of firefly colocation is OL1∗N2∗K∗I+OL2∗N2∗I2, where L2 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 OL∗N2∗I2 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 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 Things.



---

*Source: 3398071-2022-06-06.xml*