# An Effective Hybrid Routing Algorithm in WSN:
## 4 ACOHCM Routing Algorithm
### Implementation of ACOHCM Algorithm  
The implementation procedure of the ACOHCM algorithm includes three main steps, namely initialization, network topology generation and routing finding. The pseudo code is given in Algorithm 1.  
```
function \(1\).Initialization (Set initial energy value, energy threshold, lower energy threshold, communication radius of the node, lower pheromone limit, upper pheromone limit, mutation probability of the ant) \(2\).Network topology generation  According to the nodes' location information, the hop count-classification network topology is generated \(3\).Route finding fornode\(i=1\) to \(Number\_of\_Nodes\)do foriter\(=1\) to \(Number\_of\_Iteration\)do for\(ant=1\) to \(Number\_of\_Ants\)do \(3.1\) Get the set of the alternative next hop nodes according to the dynamic energy threshold strategy. \(3.2\) Determine the best next hop node based on the improved probabilistic node state transition Formula (6) and the mutation strategy. \(3.3\)Update \(Location\_of\_ant\). \(\}\) While (the ant has not reached the sink node) \(3.4\) Calculate the total energy consumption of data transmitting along the path by which the ant goes. endfor \(3.5\)Choose the path with minimal total energy consumption among the paths that \(m\) ants find out. \(3.6\)Ants feedback backwards. Update the pheromone values according to Formula (7). endfor \(3.7\)Output the optimal path from the node i to the sink (whose total energy consumption is minimal, the number of hops is least, and the energy consumption is balanced on the path) endfor \(3.8\)Output the routing information of every node in the network. endfunction
```  
**Algorithm 1** ACOHCM algorithm.  
The choices of the parameters \(\alpha,\beta,\rho\) in Formulas (6) and (7) have important effects on the ant routing process [29]. Generally speaking, the greater \(\alpha\) is, the bigger the probability that an ant will traverse the path that has been passed through in the past, which will lead the ant colony algorithm to fall into the local optimal solution earlier. The smaller \(\alpha\) is, the smaller the effect of the pheromone with the higher the randomness of the path selection, which will increase the searching time, slowing the convergence speed of the algorithm. The greater \(\beta\) is, the bigger the probability that an ant chooses the node with high residual energy and shorter distance. However, if \(\beta\) is too large, it will suppress the effect of the pheromone; The smaller \(\beta\) is, the higher the randomness of the next hop node selection. Pheromone evaporation factor \(\rho\) is another crucial parameter. The greater \(\rho\) is, the stronger the role of the positive feedback is, which will increase the likelihood of the traversed path being re-selected, while decrease the randomness of searching. On the contrary, the smaller \(\rho\) is, the bigger the randomness of the search becomes, and the stronger the global search capability of the algorithm becomes.  
When the wireless sensor network is started, the ACOMHC algorithm is run to generate the routing information for each node, and all nodes perform data forwarding according to the routing information.