# A Double Rate Localization Algorithm with One Anchor for Multi-Hop Underwater Acoustic Networks
## 3 The DRL Algorithm
### The Optimal Selection Scheme of Reference Nodes for One Anchor UANs  
The proposed DRL algorithm only needs one anchor to accomplish the localization procedure with high accuracy. The only anchor selects two unknown nodes in UANs as references to help. However, different references' selection has different localization performance. Hence, in this section, we propose an Optimal Selection Scheme of reference nodes to reduce the influence of references' topology on localization accuracy. Assume that P sensor nodes are randomly distributed in a \(L1\times L_{2}\) region including one anchor \(\mathbf{N_{0}}(x_{N0},y_{N0})\) and P-1 unknown nodes. Two reference nodes \(\mathbf{N_{1}}(x_{N1},y_{N1})\) and \(\mathbf{N_{2}}(x_{N2},y_{N2})\) are selected by \(N_{0}\) from all unknown nodes and the rest of them are ordinary nodes \(\mathbf{X_{i}}(x_{i},y_{i})\), \(1\leq i\leq\mathrm{M}\), \(\mathrm{M}=\mathrm{P}-3\). The distance between \(i^{th}\) ordinary node and \(\mathbf{N_{0}}\), \(\mathbf{N_{1}}\), \(\mathbf{N_{2}}\) are expressed by \(d_{i0}\), \(d_{i1}\) and \(d_{i2}\) respectively. \[d_{ij}=\|\mathbf{X_{i}}-\mathbf{N_{j}}\|+n_{ij}\quad(i=1,2,\cdots,\mathrm{M;j} =0,1,2) \tag{5}\]  
\(n_{ij}\) is the additive measurement noise error. The least square (LS) estimation of Equation (5) is  
\[\underset{\mathbf{X_{i}}}{\arg\min}\ \ \sum_{i=1}^{M}\sum_{j=0}^{2}(d_{ij}-\| \mathbf{X_{i}}-\mathbf{N_{j}}\|)^{2}. \tag{6}\]  
The resulting estimation function (6) is a non-linear form. By expensing and subtracting the Equation (6), we get  
\[\left\{ \begin{array}{l}x_{N0}^{2}-x_{N2}^{2}-2(x_{N0}-x_{N2})x_{i}+y_{N0}^{2 }-y_{N2}^{2}-2(y_{N0}-y_{N2})y_{i}=d_{i0}^{2}-d_{i2}^{2}\\ x_{N1}^{2}-x_{N2}^{2}-2(x_{N1}-x_{N2})x_{i}+y_{N1}^{2}-y_{N2}^{2}-2(y_{N1}-y_{N 2})y_{i}=d_{i1}^{2}-d_{i2}^{2}\end{array} \right. \tag{7}\]  
Then we linearize (6) into Equation (7) and derive the solution as in Equation (8). \[\mathbf{X_{i}}=(\mathbf{A^{T}A})^{-1}\mathbf{A^{T}b_{i}},1\leq i\leq\mathrm{M} \tag{8}\]  
\[\mathbf{A}= \begin{bmatrix}2(x_{N0}-x_{N2})&2(y_{N0}-y_{N2})\\ 2(x_{N1}-x_{N2})&2(y_{N1}-y_{N2})\end{bmatrix} \]  
\[\mathbf{b_{i}}= \begin{bmatrix}x_{N0}^{2}-x_{N2}^{2}+y_{N0}^{2}-y_{N2}^{2}+d_{ i2}^{2}-d_{i0}^{2}\\ x_{N1}^{2}-x_{N2}^{2}+y_{N1}^{2}-y_{N2}^{2}+d_{i2}^{2}-d_{i1}^{2}\end{bmatrix} \]  
\[\mathbf{X_{i}}= \begin{bmatrix}x_{i}\\ y_{i}\end{bmatrix} \]  
According to the analysis above, we can also get the estimated location error of node \(i\)\(E_{i}\). \[ \begin{split} E_{i}&=(\mathbf{b_{i}}-\mathbf{A}\mathbf{X})^{ T}(\mathbf{b_{i}}-\mathbf{A}\mathbf{X})\\ &=(\mathbf{b_{i}}-\mathbf{A}(\mathbf{A^{T}A})^{-1}\mathbf{A^{T}b_{i}})^{T}( \mathbf{b_{i}}-\mathbf{A}(\mathbf{A^{T}A})^{-1}\mathbf{A^{T}b_{i}})\\ &=\mathbf{b_{i}}^{T}(\mathbf{I}-\mathbf{A}(\mathbf{A^{T}A})^{-1} \mathbf{A^{T}b_{i}})\end{split}  \tag{9}\]  
Hence, the estimated location error \(E\) for the whole network with \(M\) nodes is shown as Equation (9). \[E=\sum_{i=1}^{M}E_{i}=\sum_{i=1}^{M}\mathbf{b_{i}}^{T}(\mathbf{I}-\mathbf{A}( \mathbf{A^{T}A})^{-1}\mathbf{A^{T}b_{i}}) \tag{10}\]Then we can find the optimum reference nodes \((x_{N1},y_{N1})\),\((x_{N2},y_{N2})\) from \(E\) to get the minimum location error. Transform Equation (8) into an optimization problem. \[ \begin{array}{l}\underset{(x_{N1},y_{N1}),(x_{N2},y_{N2})}{\arg\min}\ \sum_{i=1}^{M}\mathbf{b_{i}}^{T}(\mathbf{I}-\mathbf{A}(\mathbf{A}^{T}\mathbf{A })^{-1}\mathbf{A}^{T}\mathbf{b_{i}})\\ s.t.\quad\left\{\begin{array}{ll}\mathbf{A}=\begin{bmatrix}2(x_{N0}-x_{N2})&2 (y_{N0}-y_{N2})\\ 2(x_{N1}-x_{N2})&2(y_{N1}-y_{N2})\end{bmatrix}\\ \mathbf{b_{i}}=\begin{bmatrix}x_{N0}^{2}-x_{N2}^{2}+y_{N0}^{2}-y_{N2}^{2}+d_{i2 }^{2}-d_{i0}^{2}\\ x_{N1}^{2}-x_{N2}^{2}+y_{N1}^{2}-y_{N2}^{2}+d_{i2}^{2}-d_{i1}^{2}\end{bmatrix} \\ 0\leq x_{N1}\leq L_{1},0\leq x_{N2}\leq L_{1}\\ 0\leq y_{N1}\leq L_{2},0\leq y_{N2}\leq L_{2}\end{array}\right.\end{array}  \tag{11}\]  
\(\mathbf{N_{0}}(x_{N0},y_{N0})\), \(\mathbf{N_{1}}(x_{N1},y_{N1})\) and \(\mathbf{N_{2}}(x_{N2},y_{N2})\) should not be in a line.