## 2 A Behavior-Based Self-Deployment and -Repair Algorithm
### Algorithm Implementation  
Force parameters need to be heuristically set depending on the physical nature of nodes (robot and RF chipset). Although tests in large networks have been performed under simulation, we have built a small number of real robots to obtain these parameters (see Section 3.2). Table 1 shows the force equations and their respective parameters for both routing mechanisms in Section 2.2. As commented, in geographic routing, all nodes are affected by the same forces. In hierarchical routing, there are different clustering (\(f_{c}\)) and repulsion forces (\(f_{r2}\)) between nodes at Levels 0 (L0), 1 (L1) and 2 (sink node, SN). In order to set the parameters, the following considerations were taken into account. Our robots are built on a Hexbug Spider frame (5.1 inches \(\times\) 4.3 inches \(\times\) 4.3 inches), and they are attached with a Texas Instruments EZ430-RF2500, which has been configured to achieve a communication range of 25 m. They also include a SHARP IR range sensor for collision avoidance. Parameters are set so that we can cover approximately an area of 150 m \(\times\) 150 m with 100 robots. * Repulsion forces \(f_{r1}(r_{i,j})\) in our tests are fixed so that robots are not affected by objects farther than 1 m. Obstacles may include static objects and other robots and also the borderline of the area to be covered by the MWSN. * Repulsion forces \(f_{r2}(r_{i,j})\) are adjusted to keep at least 2 m between any two robots. * Clustering forces \(f_{c}(r_{i,j})\) are adjusted to start affecting robots when they are at least 1.5 m away. We set the parameters of each force heuristically, using a limited number of robots until their behavior consistently met our requirements, e.g., robots affected only by \(f_{r1}(r_{i,j})\) did not collide with each other, nor paid attention to obstacles further than 1 m. Obviously, if the size of the robots or the communication range changed, parameters would need to be recalculated using the new physical nodes. After the parameters of all forces were fixed in an isolated manner, all forces were combined into a single emergent motion vector, as proposed in the SPF framework. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Force** & **Geographic Routing** & \multicolumn{3}{c}{**Hierarchical Routing**} \\ \hline \(f_{r1}(r_{i,j})\) & \(-\frac{0.001}{(r_{i,j})^{3}}\) & & \(-\frac{0.001}{(r_{i,j})^{3}}\) & \\ \hline \multicolumn{5}{c}{**L1 vs. SN**} & **L1 vs. L1/L0** & **L0 vs. L1** & **L0 vs. L0** \\ \hline \(f_{r2}(r_{i,j})\) & \(-\frac{20}{(r_{i,j})^{3}}\) & \(-\frac{20}{(r_{i,j})^{3}}\) & \(-\frac{60}{(r_{i,j})^{3}}\) & \(-\frac{10}{(r_{i,j})^{3}}\) & \(-\frac{3}{(r_{i,j})^{3}}\) \\ \(f_{c}(rRepulsion forces are in charge of (i) collision avoidance (including deployment area boundaries) and (ii) spreading the network over the coverage area, so removing \(f_{r1}(r_{i,j})\) would result in collisions and escaped nodes, and removing \(f_{r2}(r_{i,j})\) would result in non-deployment. Figures 3 and 4 illustrate the effect of removing clustering forces for both routing strategies. In geographic routing, no clustering force is required for initial deployment as long as the number of nodes is enough to cover the full coverage area. However, when nodes start to die, some node clusters might get disconnected from the sink node. Nodes close to the sink node usually have a higher traffic load and fail first, whereas nodes on the boundaries may have a longer life [19]. However, if they are not compelled to move closer to the sink node after part of the network has failed, they might get disconnected from the rest of the MWSN. Figure 3a shows the same MWSN after 25% of its nodes have died in absence of a clustering force. If a clustering force is added, nodes tend to move closer to the sink node (Figure 3b). They still need to avoid dead nodes in the way, and coverage obviously decreases; but, all living nodes remain connected to the sink node. In a hierarchical network, clustering forces depend on node roles (Figure 2).