Algorithm 1. Pseudocode for the moving distance reduction scheme. |
/* Pi0(xi0,yi0) and Pi1(xi1,yi1) are the initial position and the candidate target position of the ith mobile sensor si, i = 1, …, m. */ 1. For i = 1 to m do 2. moved[i] = true 3. For i = 1 to m do 4. P = Pi1, Pi1 = Pi0 5. If (Rarea(S) reduces) Pi1 = P; moved[i] = false; 6. end; 7. For i = 1 to m do 8. For j = 1 to m do 9. d1 = , d2 = , d3 = , d4 = . 10. If (i ≠ j) and (moved[i]) and (moved[j]) and (d1 + d2 > d3 + d4) 11. Pi1↔Pj1 12. end 13. For j: = 1 to m do 14. For i: = 1 to m do 15. d2 = , d3 = 16. if (moved[j]) and (not moved[i]) 17. if (d2 > d3) P = Pj1,Pi1 = Pj1,Pj1 = Pj0 18. if (Rarea(S) reduces ) Pj1 = P; Pi1 = Pi0 19. end |