# An Indoor Collaborative Coefficient-Triangle APIT Localization Algorithm
## 3 Collaborative Coefficient-Triangle APIT Localization Algorithm  
Based on the limitation of APIT, a CCAL algorithm is proposed below, which involves an effective triangle criterion, an RSSI location and weighted triangle coordinate calculation method, and collaborative communication among nodes. Firstly, to reduce the probability of In-to-Out misjudgment and computational complexity, an effective triangle criterion is introduced to permute and combine \(N\) anchor nodes to form triangles. Then, the APIT algorithm is used to determine whether the unknown node is inside a triangle, and if inside, the triangle can be judged to be a valid triangle. Meanwhile, the unknown node is determined to be outside a triangle only if the number of neighboring anchor nodes outside that triangle exceeds a certain threshold. The definition of threshold is shown below:  
\[N=\lambda\times n \tag{1}\]  
where \(\lambda\) is the scale factor, \(n\) is the number of neighboring nodes involved in the judgment, and \(N\) is the threshold for the number of qualified neighboring nodes. An effective triangle criterion may improve valid triangles on a limited number of directions in APIT. Hence, In-to-Out misjudgment can be greatly reduced. To reduce the location error in APIT, a further RSSI-assisted location and weighted triangle coordinate calculation method is used. Using RSSI-assisted location, the distances between anchor nodes and unknown nodes of valid triangles are obtained. Then, the coordinates of the unknown nodes are estimated according to the maximum likelihood method. In addition, the idea of iterative collaborative positioning is introduced to solve the positioning problem of unknown nodes. Specifically, the node flag of the positioned unknown nodes can be set to 2. The positioned nodes can be converted to special anchor nodes, and can broadcast their own location  
Figure 2: In-to-Out Misjudgment of the APIT algorithm. information to surrounding nodes. This can effectively compensate for the low anchor node density and poor anchor node distribution. The collaborative positioning scheme is detailed in the following. Based on the above discussion, Figure 3 shows the flow chart of the CCAL algorithm, and detailed steps are given below:  
Step 1. Arrangement and definition of the nodes. The identification information of nodes is defined as follows: \(\mu\_f\lg=0\) represents the unlocated unknown nodes, \(\mu\_f\lg=1\) represents the known anchor nodes, and \(\mu\_f\lg=2\) represents the located unknown nodes. Step 2. For the unknown nodes, collect the power of transmitted signals from the adjacent anchor nodes. Step 3. Judge whether the number of anchor nodes is not less than 3. If yes, proceed to Step 4; if no, the positioning cannot continue; set the identification of node \(\mu\_f\lg=0\). Step 4. Judgment of valid triangles. Permute and combine \(N\) anchor nodes to form \(C_{N}^{3}\) triangles. The APIT algorithm is used to determine whether the unknown node is inside a triangle, and if inside, the triangle can be judged to be a valid triangle. Meanwhile, the unknown node is determined as being outside one triangle only if the number of neighboring anchor nodes outside this triangle exceeds the threshold \(N\) as in Equation (1). Step 5. RSSI-assisted location. Figure 3: Flow chart of Collaborative Coefficient-triangle APIT Localization (CCAL) algorithm. \[b=\left[ \begin{array}{c}x_{A_{i}}^{2}-x_{C_{i}}^{2}+y_{A_{i}}^{2}-y_{C_{i}}^{2} +d_{C_{i}}^{2}-d_{A_{i}}^{2}\\ x_{B_{i}}^{2}-x_{C_{i}}^{2}+y_{B_{i}}^{2}-y_{C_{i}}^{2}+d_{C_{i}}^{2}-d_{B_{i}} ^{2}\end{array} \right] \tag{7}\]  
\[X=\left[ \begin{array}{c}x_{D_{i}}\\ y_{D_{i}}\end{array} \right] \tag{8}\]  
Thus, the coordinates of the unknown location \(\left(x_{D_{i}},y_{D_{i}}\right)\) can be derived as follows:  
\[\left[ \begin{array}{c}x_{D_{i}}\\ y_{D_{i}}\end{array} \right]=\left(A^{T}\ A\right)^{-1}A^{T}b \tag{9}\]  
Step 7. Use the positioning method of the weighted triangle to estimate the coordinates of the unknown nodes.