Skip to main content
. 2019 Mar 8;19(5):1192. doi: 10.3390/s19051192
Algorithm 4: Cluster head selection optimization algorithm based on IAPSO
Input: Sensor nodes group: s=s1,s2,,sn
   Predefined swarm size: num
   Number of dimensions of particles: D2=k
   Largest number of iterations: maxnumber
Output: Cluster head group: CH=CH1,CH2,,CHk
1: Initialize particle P2i,i,j,1inum,1jD2=k, X2i,j0=x2i,j0,y2i,j0
2: for i=1 to num do
3:       (1) Calculate Fitness2P2i, Using Equation (15)
4:       (2) P2besti=P2i
5: end for
6: G2best=P2besti|Fitness2P2besti=minFitness2P2besti,i,1inum
7: for t=1 to maxnumber do
8:       for i=1 to num do
9:             (1) Update velocity and position of P2i using Equations (18) and (19)
10:           (2) Calculate Fitness2P2i, update P2besti and G2besti
11:           (3) Output the optimal cluster heads group G2besti
12:      end for
13: end for