Skip to main content
. 2021 Dec 9;12(12):1532. doi: 10.3390/mi12121532
Algorithm 2. Particle swarm algorithm.
1: Start
2: Randomly initialize particle swarm
3: While (number of iterations or the stopping iteration on is not met)
4: Evaluate fitness of the particle swarm
5: for n = 1 to number of particles
6: Find individual optimal solution pti
7: Find group optimal solution ptg
8: for d = 1 to number of dimensions of particle
9: update the velocity of particles via vt+1i=wtvti+c1r1(ptixti)+c2r2(ptgxti)
10: update the position of particles via xt+1i=xti+vt+1i
11: end for
12: end for
13: update the inertia weight via wt=(wmaxwmin)(tmaxt)tmax+wmin
14: end While
15: Output the best solution found