Skip to main content
. 2019 Sep 14;19(18):3973. doi: 10.3390/s19183973
Algorithm 6 Optimisation based on PSO algorithm
  • 1:

    Initialise population of particles with random values positions in the search space x∼U[tbeg,tend]

  • 2:

    Set each particle best known position to its initial position px

  • 3:

    Initialise each particle velocity to random values v∼U[d,d] where d = begend

  • 4:

    Initialise the best known position g to the x where f(x) is lowest

  • 5:

    while Termination condition not reached do

  • 6:

    for Each particle i do

  • 7:

      if i>1 then

  • 8:

       Choose two random numbers ϕp,ϕg

  • 9:

       Adapt velocity vω v + cp ϕp(px) + cg ϕg(gx)

  • 10:

       Bound v for all dimensions i (v, -d, d)

  • 11:

       Update the position of the particle xx + v

  • 12:

       Bound population xi for all dimensions i (x,tbeg,tend)

  • 13:

      end if

  • 14:

      if f(x)<f(p) then

  • 15:

       update the particle’s best known position px

  • 16:

      end if

  • 17:

      if f(x)<f(g) then

  • 18:

       update the particle’s best known position gx

  • 19:

      end if

  • 20:

    end for

  • 21:

    g holds the best found position in search space

  • 22:

    end while