# Range-Free Localization Approaches Based on Intelligent Swarm Optimization for Internet of Things
## 2 Related Works and Background
### Weight-Based Enhancements to DV-Hop
#### 2.1.2 W-DV-Hop Localization Algorithm  
In our prior research papers [39; 40], we introduced a new scheme for the typical DV-Hop algorithm, which we denoted as W-DV-Hop. Similar to DV-Hop, W-DV-Hop usesthree main steps: (i) dissemination of information within the network; (ii) a new technique for computing the average hop distance; and (iii) estimating the locations of the unknown nodes using trilateration.  
More specifically, the first stage of the improved W-DV-Hop algorithm closely resembles the standard DV-Hop. A hello message containing the location of anchor node \(A_{i}\) is broadcast in the network, with the hop count from anchor to anchor initialized as 0. In the second stage, the average hop size between anchors \(A_{i}\) is determined through the use of a new weighted formula based on the mean [42]. In addition, in the improved W-DV-Hop algorithm the average hop size is determined using the mean square error approach [43]. The formula applied to compute \(AHSize_{i}\) is as follows:  
\[\xi_{1}=\frac{1}{k-1}\underset{j\
eq i}{\sum}(d_{i,j}-AHSize_{i}\times H_{i,j }^{2}), \tag{7}\]  
where \(k\) represents the ratio of anchors, \(AHSize_{i}\) is estimated under the assumption that \((\partial\xi_{1}/AHSize_{i}=0)\), \(d_{i;j}\) is the distance between anchor nodes \(A_{i}\) and \(A_{j}\) based on their exact positions, which can be obtained through the GPS module, and \(H_{i;j}\) is the minimum hop count between anchors \(A_{i}\) and \(A_{j}\).  
\[AHSize_{i}=\frac{\underset{j\
eq i}{\sum}H_{i,j}\times d_{i,j}}{\underset{j \
eq i}{\sum}H_{i,j}^{2}} \tag{8}\]  
To compute the updated \(AHSize_{new}\), the following formula is applied:  
\[AHSize_{new}=\frac{\underset{i=1}{\sum}W_{i}\times AHSize_{i}}{\underset{i= 1}{\sum}W_{i}}, \tag{9}\]  
where  
\[W_{i}=\frac{1}{\underset{j\
eq i}{\sum}\left|AHSize_{i}-AHSize_{j}\right|}. \tag{10}\]  
Here, \(W_{i}\) represents the weight assigned to every anchor \(A_{i}\) and \(k\) represents the percentage of anchors.  
In the third phase, the unknown nodes apply the multilateration technique to estimate their locations. Upon receiving \(AHSize_{new}\), a normal node U multiplies its hop count \(Hi;u\) (hops to \(A_{i}\)) by \(H_{i;j}\). This yields the estimated distance to \(A_{i}\), denoted as \(d_{i}\) (\(d_{i}=AHSize_{new}\times H_{i}\)), where \(i\in\{1,2,\ldots,k\}\) represents the anchor nodes. The following equation is then created using the estimated position \((x,y)\) of node \(U\).  
\[\begin{cases}(x-x_{1})^{2}+(y-y_{1})^{2}=d_{1}^{2}\\ (x-x_{2})^{2}+(y-y_{2})^{2}=d_{2}^{2}\\...\\ (x-x_{k})^{2}+(y-y_{k})^{2}=d_{k}^{2}\end{cases} \tag{11}\]  
Using the least square technique, the solution to the aforementioned equation enables an unknown node \(U\) to acquire its estimated position \(U_{WD-Hop}\) through the following formula:  
\[U_{WD-Hop}:\begin{bmatrix}x\\ y\end{bmatrix}=(A^{T}A)^{-1}A^{T}B, \tag{12}\]where  
\[A=-2\times\begin{bmatrix}x_{1}-x_{k}&y_{1}-y_{k}\\ x_{2}-x_{k}&y_{2}-y_{k}\\...&...\\ x_{k-1}-x_{k}&y_{k-1}-y_{k}\end{bmatrix} \tag{13}\] \[B=\begin{bmatrix}d_{1}^{2}-d_{k}^{2}-x_{1}^{2}+x_{k}^{2}-y_{1}^{2 }+y_{k}^{2}\\ d_{2}^{2}-d_{k}^{2}-x_{2}^{2}+x_{k}^{2}-y_{2}^{2}+y_{k}^{2}\\...\\ d_{k-1}^{2}-d_{k}^{2}-x_{k-1}^{2}+x_{k}^{2}-y_{k-1}^{2}+y_{k}^{2}\end{bmatrix}. \tag{14}\]  
It is important to note that the anchor nodes must not lie on a single line. If they do, the matrix \((A^{T}A)^{-1}\) becomes nonexistent due to the singularity of \(A^{T}A\).  
\[A=((G^{T}G)^{-1})G^{T}b \tag{15}\]  
The location of node \(U\) is then calculated as follows.  
\[\begin{cases}x_{u}=A(1)\\ y_{u}=A(2)\end{cases} \tag{16}\]