# A Matrix-Based Proactive Data Relay Algorithm for Large Distributed Sensor Networks
## 5 Model Maintenance Algorithm
### Updating the Data Distribution Matrix D
Else, the corresponding utility will be set to 0 since they indicate different information (line 6). ```
1:for all\(d_{h}\in dataG\cup dataR\)do
2:for all\(d_{j}\in L_{i}\);do
3:if\(relative(d_{h},d_{j})\)then
4:\(U_{d_{h},d_{i}}\gets utility(d_{h},d_{i},utilityTable)\);
5:else
6:\(U_{d_{h},d_{i}}\gets 0\);
```
**Algorithm 3**\(updateU(U,dataG,dataR,utilityTable)\). The example below shows the update process of the utility matrix. At time \(t\), the data set of \(v_{1}\) is \(L_{i}=\{d_{1},d_{2}\}\), and the sensor set in the knowledge of \(v_{1}\) is \(N_{i}=\{v_{2},v_{3}\}\). The details of \(d_{1},\ d_{2}\) are shown as follows:

\(d_{1}=<v_{A}\), \((T_{A},0.5)(T_{B},0.2)(CLUTTER,0.3)\), \((1.1,2.1)\), \(2013/05/08/16:00\), \(path=\{v_{4},v_{2}\}>\),

\(d_{2}=<v_{7}\), \((T_{A},0.4)(T_{B},0.5)(CLUTTER,0.1)\), \((3.2,7.1)\), \(2013/05/08/13:00\), \(path=\{v_{7},v_{3}\}>\). As the _location_ and _timestamp_ of these two data pieces are different, they are not relevant, and matrix \(u= \begin{pmatrix}d_{1}&d_{2}\\ d_{1}&0&0\end{pmatrix} \). At time \(t+1\), \(v_{1}\) receives \(d_{3}\) from \(v_{3}\), and \(d_{3}\) is shown in details as follows:

\(d_{3}=<v_{8}\), \((T_{A},0.6)(T_{B},0.3)(CLUTTER,0.1)\), \((1.3,2.0)\), \(2013/05/08/16:03\), \(path=\{v_{8},v_{5},v_{3}\}>\). According to its \(location:(1.3,2.0)\) and \(timestamp:2013/05/08/16:03\), which is close to \(d_{1}\) but not \(d_{2}\), \(v_{1}\) can confirm that \(d_{3}\) is related to \(d_{1}\) but not \(d_{2}\). It becomes obvious now that \(U_{d_{3},d_{2}}=\ U_{d_{2},d_{3}}=\ 0\). Right from here, \(v_{1}\) will look up the utility between \(d_{3}\) and \(d_{1}\) in its reward table according to their _identity_. * For target A, \(c_{d_{1}}(T_{A})=0.5\), \(c_{d_{3}}(T_{A})=0.6\). After checking \(utilitytable\), \(v_{2}\) can get \(value(T_{A})=\ 5.5\). Doing the same for target B, \(v_{2}\) can get \(value(T_{B})=3.5\)
* The utility is a function of these two values. One possible way: \(U_{d_{3},d_{1}}=value(T_{A})+\omega\cdot value(T_{B})=5.5+0.3\cdot 3.5=6.55\)

Finally, the matrix \(u= \begin{pmatrix}d_{1}&d_{2}&d_{3}\\ d_{1}&0&0&6.55\\ d_{2}&0&0&0\\ d_{3}&6.55&0&0\end{pmatrix} \) is obtained. ### Integrated Algorithm

With these updating algorithms, network connection, data distribution and utility matrix can be updated to help sensors get local observations to support rational communication decisions even in dynamically changing networks. The whole data relay process with local knowledge can be seen in Algorithm 4. ```
1:for all\(d_{h}\in dataG\cup dataR\)do
2:for all\(d_{j}\in L_{i}\)do
3:if\(relative(d_{h},d_{j})\)then
4:\(U_{d_{h},d_{i}}\gets utility(d_{h},d_{i},utilityTable)\);
5:else
6:\(U_{d_{h},d_{i}}\gets 0\);
```
**Algorithm 4**\(updateU(U,dataG,dataR,utilityTable)\). This algorithm consists of two parts. In the first part, sensors update these three matrices based on the approaches mentioned in last three subsections (line 1-7). In the second part, \(v_{i}\) will try to fuse with these new data and make communication decisions for those that have not been fused (line 8-21). Principally, \(v_{i}\) checks them one by one to see if any new information can be fused (line 8-11). If the quality of the new information exceeds the predefined threshold, data related to this information willbe fused and added into the outdated data set. \(v_{i}\) will then inform other sensors to stop propagation of these outdated data pieces (line 11-13). If no information can be fused, this data will be added into the pending queue(line 15). After the information fusion process completes, \(v_{i}\) makes decisions for data in pending queue based on our lightweight matrix computation (line 16) by balancing between the benefits and energy cost of broadcasting. If the benefit is higher than the energy cost (line 18), \(v_{i}\) will add itself onto the path of this data and broadcast it (line 19-20), and update the data set \(dataB\) with this data. Otherwise, this data will be ignored (line 21).