Skip to main content
. 2022 Nov 14;22(22):8789. doi: 10.3390/s22228789
Algorithm 1MV(n,ρ,s) moving sensors on [0,1]

Require: The initial locations of n mobile sensors, placed uniformly and independently at random on the unit interval [0,1].

Ensure: The final positions of the sensors such that:
  • (i)
    The distance between consecutive sensors is greater than or equal to s and less than or equal to ρ.
  • (ii)
    The leftmost sensor is at a distance less than or equal to ρ2 from the origin.
Initialization:   Sort the initial locations of n sensors with respect to the origin of the interval, the location of sensors after sorting X(1)X(2)X(n);
  •  1:
    Let X0=0;
  •  2:
    fori=1ndo
  •  3:
       if X(i)X(i1)<s then
  •  4:
         move left to right the sensor X(i) to the new position mins+X(i1),1;
  •  5:
       else if X(i)X(i1)>ρ then
  •  6:
         move right to left the sensor X(i) to the new position ρ+X(i1);
  •  7:
       else
  •  8:
         do nothing;
  •  9:
       end if
  • 10:
    end for
  • 11:
    ifX(1)>12ρthen
  • 12:
       z:=X(1)12ρ;
  • 13:
       for i=1n do
  • 14:
         move right to left the sensor X(i) to the new position X(i)z;
  • 15:
       end for
  • 16:
    end if