Skip to main content
. 2017 Jan 22;17(1):209. doi: 10.3390/s17010209
Algorithm 1 The Competitive Swarm Optimizer Algorithm
  • 1:

    Initialize P(0),Maxgen; // P(t) is the swarm ingeneration t, Maxgen is the maximum number of iterations.

  • 2:

    for t=1 to Maxgen do

  • 3:

      calculate the fitness of all particles in P(t);

  • 4:

      L=P(t),P(t+1)=;//L denotes a set of particles that have not yet participated in a competition.

  • 5:

      while L do

  • 6:

        randomly choose two particles X1(t),X2(t)

  • 7:

        if f(X1(t))f(X2(t)) then// f(X1(t)) is the fitness function for X1(t)

  • 8:

         Xw(t)=X1(t),Xl(t)=X2(t); // Xw(t) is the winner particle in generation t, and Xl(t) is the loser particle in generation t

  • 9:

        else

  • 10:

         Xw(t)=X2(t),Xl(t)=X1(t);

  • 11:

        end if

  • 12:

        add Xw(t) into P(t+1);

  • 13:

        update Xl(t) using (1) and (2)

  • 14:

        add the updated Xl(t) into P(t+1);

  • 15:

        remove X1(t),X2(t) from L

  • 16:

      end while

  • 17:

    end for