| (1) Initialize and , let , the real number , iteration counter , iteration counter , maximum |
| iteration number of PSO. |
| (2) Initialize the population size , the initial velocity of particles, the initial position of particles, , , , the threshold |
| and attrition rate . |
| (3) DO { |
| Repeat { |
| (a) Update partition matrix for all particles by (3). |
| (b) Calculate the cluster center for each particle by (4). |
| (c) Calculate the fitness value for each particle by (7). |
| (d) Calculate for each particle. |
| (e) Calculate for the swarm. |
| (f) Update the velocity and position of each particle by (5). |
| (g) |
| } |
| Until PSO termination condition is met |
| (i) Calculate the optimal threshold for each column of partition matrix by (12), |
| and relocate of th cluster according to |
| (ii) Calculate cardinality for each cluster on the basis of the number of data whose membership value equal to 1 by (14), |
| |
| (iii) Remove all clusters whose and is among lowest cardinality |
| (iv) Update cluster number C |
| (v) Calculate cluster validity index by (13) |
| (vi) Update iteration counter |
| } |
| While termination condition is not met |
| The termination condition of PSO in this method is (reach the maximum number of iterations) or the velocity |
| updates are close to zero over a number of iterations. |
| The algorithm can terminate under either of the following two conditions: |
| (1) The prototype parameters in stabilize within some threshold . |
| (2) The number of clusters has reached the minimum limit . |