# Clustering-Based Modified Ant Colony Optimizer for Internet of Vehicles (CACOIOV)
## 3 Proposed CACOIOV Architecture
### Protocol Description of CACIOV
As presented in Algorithm 2, DA-TRLD algorithm allocates a transmission range for vehicle communication in definite boundaries that are restricted by DSRC in highway scenarios. Our proposed dynamic transmission range algorithm is inspired by following research [11; 43]. The uniqueness of the DA-TRLD algorithm is that it considers all vehicles on the highway as a swarm and allocates transmission range for vehicles by calculating the local traffic density of each node. The equations that are used in the DA-TRLD algorithm are illustrated in Equations (1)-(5). The result of this algorithm is used during the process of solution construction (transition rule). As an advantage of DA-TRLD algorithm, we can observe better cluster management by selecting the appropriate vehicle as a CHs in the network. Besides, better network management leads to more traffic congestion facilitation, pollution reduction, and traffic safety. Therefore, drivers can take proper action/make a decision based on the obtained information from awareness of road and traffic conditions. Consequently, driver behavior and driver decision-making directly depends on accuracy of information load that is collected from the existing network. ```
1:Initialize Traffic service level of the road and Traffic constant from traffic flow; ([44; 45])
2:Initialize Transmission range based on DSRC standard in the interval of [200-1000 m] for highway;
3:Initialize Traffic Threshold = 10%;
4:functionDA-TRLD(\(L_{D}\),\(T_{TH}\))
5:for\(Ant_{i}=1\) to Swarm sizedo
6: Calculate Density estimation in vehicle's neighboring by Equation (1)
7: Calculate Local vehicle density by Equation (2)
8:if Local vehicle density == 0 then
9:\(\Delta T_{adj}=0\)
10: Calculate Transmission range for Free-flow traffic by Equation (3)
11:elseif Local vehicle density \(\leqslant\) Traffic Thresholdthen
12:\(\Delta T_{adj}=1\)
13: Calculate Transmission range for Normal traffic by Equation (4)
14:else
15:\(\Delta T_{adj}=2\)
16: Calculate Transmission range for Congested traffic by Equation (5)
17:endif
18:Return TR
19:EndFor
20:EndFunction
```  
**Algorithm 2** Proposed DA-TRLD algorithm  
The final step in search spaces is pheromone initialization for each ant/node on the graph. In the search space, low values of pheromones are assigned to the edges in the graph that are shown in Equation (6) [7]. This initialization and modeling of search space is illustrated in (line # 1-4) in Algorithm 1. \[T_{D}=\frac{V_{N}}{d_{front}}+d_{back}\cdot NL*100 \tag{1}\]\[L_{D}=[\frac{(1-T_{D})}{\lambda^{\prime}}+1]^{-1} \tag{2}\]  
\[TR=TR_{max} \tag{3}\]  
\[TR=TR_{max}*(1-L_{D}) \tag{4}\]  
\[TR=\sqrt{\frac{TR_{max}\cdot\ln TR_{max}}{L_{D}}}+\alpha\cdot TR_{max} \tag{5}\]  
\[\tau_{ij}(iter=1)=\frac{1}{|V_{total}|} \tag{6}\]  
_Cluster Head (CH) selection approaches._ This process includes some steps that are addressed in detail. _(a) Intelligent First-node selection:_  
A novel way of choosing a first node is inserted in the CACOIOV algorithm, based on a roulette wheel selection for preliminary state of searching space of the graph, rather than randomly selecting the first node which is used in a conventional ACO algorithm. In other words, the first CH in the ant solution is selected 100 percent randomly based on uniform probability \(\frac{1}{N}\); but we applied an effective solution for choosing the first node at the ant solution, which can have a significant impact on the quality of ant tour by considering pheromone and heuristic value. In this technique, we inserted an additional column to the pheromone matrix for the first nodes and, based on the worth of solution, the pheromone matrix will be updated and the chance of the first node being re-selected in the next tour as a CH will increase. _(b) Transition rule:_  
The probability of visiting a vertex by ants that has not been added in a current tour will be calculated with the use of Equation (7). Conducting a solution in the CACOIOV starts in the first _For_ loop from (line # 6-16) of Algorithm 1.