# Clustering-Based Modified Ant Colony Optimizer for Internet of Vehicles (CACOIOV)
## 3 Proposed CACOIOV Architecture
### Protocol Description of CACIOV  
Frequent changes in topology and the increase in mobility need more stable conditions which are improved by reducing the quantity of IoV clusters. A minimum number of clusters indicates better communication in routing-based-clustering due to the shortest path in network. In this study, a unique algorithm, which is the modified ACO enabled with the DA-TRLD, is deployed for efficiency in the CH selection/election to create desirable solutions of clustering for IoV. In methods, which are swarm-based, each node is considered to be a single solution, and the swarm is a group of solutions. An ant, in a given instance, depicts all CH IDs of the entire route. The initial attempt in this work is to create optimum solutions in IoV clustering. Our proposed CACIOV algorithm by using intelligent first-node selection and dynamic evaporation strategy makes this aim possible. The initialization of the algorithm is made by finding the CHs regarding node speed, distance, direction, and local traffic density by using our novel presented DA-TRLD algorithm and then locating the neighboring nodes of the CHs. In this research, every vehicle is considered to have interfaces of 5G and 802.11p. The way the vehicular networks are organized is made up of clusters that are managed by the eNodeBs. The cluster sizes are of varying ranges at 802.11p (200-1000 m is the DSRC range for the VANET in highway) based on the vehicular local traffic density, to enable each node to reach the other clusters' nodes, particularly the CHs. The integrity of CACIOV framework has a methodological scheme involving the following steps that will be explained. The hybridization pseudo-code for CACIOV and DA-TRLD algorithms can be seen in Algorithm 1. * Search space modeling and Initialization
* CH selection approaches  
```
1:Creating vehicle traffic on highway by SUMO;
2:Initialize pheromone and heuristic value on every path Equations (6) and (8);
3:Creating mesh topology among nodes with DA-TRLD; (Algorithm 2)
4:Calculating and normalizing Euclidian distance on the mesh topology for corresponding edges;
5:whileIteration == Maximum Iteration OR when the solution for previous 20 iteration are same (e.g., Stall Iteration == 20) do
6:for\(Ant_{i}=1\) to Swarm size do
7: Calculate the fitness value for each \(Ant_{i}\)._tour
8:\(Ant_{i}\)._noOf clusters== empty and \(Ant_{i}Cluster\) fitness= infinity
9:noOfnodeSelected =0 ( all nodes available for clustering)
10:whileNodes available for clustering!= 0 or empty do
11:\(Ant_{i}\).\(Cluster\) fitness= \(CostFunction(Ant,noOfclusters)\) ;
12:if\(Ant_{i}\).\(Cluster\) fitness < BestSol.\(Cluster\) fitness then
13: BestSol = Anti ;
14:endif
15:endif
16:EndVinite
17:for\(Ant_{i}=1\) to Swarm size do
18:Evaporate. Equation (11)
19:Update Pheromone (Ant._cost). Equation (13)
20:Evaluating Best. Ant.cost;
21:EndFor
22:if\((Convergence_{\text{\emph{c}ureure}}(Iteration))==\)\(Convergence_{\text{\emph{c}ure}}(Iteration-1)\)then
23: Stall Iteration ++;
24:else
25: Stall Iteration = 0;
26:endif
27:Iteration ++;
28:EndWhile
29:TothanoOfcluster= BestSol.OfAnt.tour;
```  
**Algorithm 1** Proposed CACIOV algorithmSearch space modeling and initialization.The algorithm-based solution of the CACIOOV to a particular issue of concern begins with the search space design of a problem. Accordingly, the ants conduct the search to discover the candidate solutions with the graph form. The first step in searching spaces is route initialization which is randomly created by ants before the discovery of the optimal routes. For route initialization some parameters such as direction, distance, number of nodes, and velocity for each ant/vehicle should be initialized in advance. Secondly, WAVE protocol is employed as initialization for the transmission range per node. In this regard, routes are constructed in the form of mesh topology among ants/nodes by using DA-TRLD algorithm.