Skip to main content
. 2017 Jan 9;17(1):117. doi: 10.3390/s17010117
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 = |Pi0Pi1¯|, d2 = |Pj0Pj1¯|, d3 = |Pi0Pj1¯|, d4 = |Pj0Pi1¯|.
10.    If (ij) and (moved[i]) and (moved[j]) and (d1 + d2 > d3 + d4)
11.     Pi1Pj1
12. end
13. For j: = 1 to m do
14.  For i: = 1 to m do
15.   d2 = |Pj0Pj1¯|, d3 = |Pi0Pj1¯|
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