Skip to main content
. 2025 Jun 9;25(12):3620. doi: 10.3390/s25123620
Algorithm 1 VASF-PSO pseudocode.
  •  1:

    Input: Initialize swarm size, particle velocities (Vik), positions (Xik), search factor (wk), individual best (Pbesti), swarm best (Gbest), and iteration count.

  •  2:

    Output: Best fitness

  •  3:

    Initialize particles using Equation (10)

  •  4:

    Locate the coverage holes using Equations (11)–(13)

  •  5:

    for k = 1 to Max Iterations do

  •  6:

       for i = 1 to swarm size do

  •  7:

         Calculate the fitness using Equation (4).

  •  8:

         if fitness <Pbesti then

  •  9:

             Update Pbesti to the current fitness value.

  • 10:

         end if

  • 11:

         if fitness <Gbest then

  • 12:

             Update Gbest.

  • 13:

         end if

  • 14:

         Update the velocity of each particle using Equation (5).

  • 15:

         Update the position of each particle using Equation (6).

  • 16:

         Calculate acceleration coefficients using Equations (7) and (8)

  • 17:

         Update the search factor for VASF-PSO using Equation (9)

  • 18:

         Repeat steps 1 to 18 until the maximum number of iterations is reached.

  • 19:

       end for

  • 20:

    end for

  • 21:

    Return:Gbest, Optimized continuous WSNs deployment.