| Procedure ACO Based Routing and Clustering in WMSNs |
| 1. Initialization |
| Initialize the pheromone of lines between all sensor nodes, τij (i, j = 1,2,…, n) |
| Initialize the ant colony which contains k groups of ants. And each group consists of m ants. |
| Repeat |
| 2. Assign the number of sensor nodes to every ants |
| For each group i∈[1,…,k] and each ant j∈[1,…,m]: |
| Randomly select a sensor node as starting sensor nodes for current ant. |
| Randomly assign a number of sensor nodes,
, to jth ant in ith group. |
| Endfor
|
| 3. Route Selection |
| For each group i∈[1,…,k] and each ant j∈[1,…,m]: |
| If the number of sensor nodes in sub-tour list
is less than
|
| Then generate the probability of potential routes by Eq. (29) and select the next sensor node |
| Else current ant returns to its starting sensor node |
| EndIf
|
| Endfor
|
| 4. Pheromone Updating |
| For each group i∈[1,…,k]: |
| Calculate the total distance,
, accessed by current group of ants. |
| Endfor
|
| Find the optimal group of ants with the smallest
|
| Update the pheromone by Eq. (32) and Eq. (33)
|
|
Until stopping condition is satisfied (usually when the number of iterations reaches a predefined threshold, or when the best solution does not update for a certain number of iterations.) |
| 5. Output results |
| Output the routing and clustering results indicated by current best solution |