Skip to main content
. 2022 Feb 2;22(3):1129. doi: 10.3390/s22031129
Algorithm 3 PSO-based Optimal User Clustering
  • 1:

    Initialize group size G.

  • 2:

    Initialize the total number of iterations D.

  • 3:

    for g = 1:G do

  • 4:

        Initialize position θg for particle g.

  • 5:

        ebest,g=w(θg).

  • 6:

        pbest,g=θg.

  • 7:

    end for

  • 8:

    g¯ the position of the maximum in {ebest,g,g}.

  • 9:

    Gbest=pbest,g¯.

  • 10:

    t = 1.

  • 11:

    while  tD  do

  • 12:

       for g = 1:G do

  • 13:

          θg=0.5(pbest,g+Gbest)+δ(pbest,gGbest).

  • 14:

          eg=w(θg).

  • 15:

          if eg>ebest,g then

  • 16:

             pbest,g=θg.

  • 17:

             ebest,g=eg.

  • 18:

          end if

  • 19:

       end for

  • 20:

       g¯ the position of the maximum in {ebest,g,g}.

  • 21:

       Gbest=pbest,g¯.

  • 22:

       t = t + 1.

  • 23:

    end while

  • 24:

    θ=Gbest.

  • 25:

    Perform user clustereing with the obtained θ based on Algorithm 2.