An Intelligent Multimode Clustering Mechanism Using Driving Pattern Recognition in Cognitive Internet of Vehicles

Connected autonomous vehicles can leverage communication and artificial intelligence technologies to effectively overcome the perceived limitations of individuals and enhance driving safety and stability. However, due to the high dynamics of the vehicular network and frequent interruptions and handovers, it is still challenging to provide stable communication connections between vehicles, which is likely to cause disasters. To address this issue, in this paper, we propose an intelligent clustering mechanism based on driving patterns in heterogeneous Cognitive Internet of Vehicles (CIoVs). In the proposed approach, we analyze the driving mode containing multiple feature parameters to accurately capture the driving characteristics. To ensure the accuracy of pattern recognition, a genetic algorithm-based neural network pattern recognition algorithm is proposed to support the reliable clustering of connected autonomous vehicles. The cognitive engines recognize the driving modes to group vehicles with a similar driving mode into a relatively stable cluster. In addition, we formulate the stability and survival time of clusters and analyze the communication performance of the clustering mechanism. Simulation results show that the proposed mechanism improves the reliable communication throughput and average cluster lifetime by approximately 14.4% and 11.5% respectively compared to the state-of-the-art approaches.


Introduction
The Intelligent Transportation System (ITS) benefits from communication and intelligence technologies to enhance traffic management capabilities and improve vehicle driving efficiency. Autonomous driving (AD) as an important component of ITS has received widespread attention due to its ability to avoid traffic jams, reduce the probability of traffic accidents, and free human hands, which will produce significant economic and social benefits. At present, the Connected Autonomous Vehicles (CAVs) employ vehicular communication technology to exchange environmental and perception information to obtain non-line-of-sight (NLOS) traffic information to strengthen its own perception capabilities [1]. In addition, the analysis of a large amount of sensory data in network space and physical space can effectively assist CAVs in AD decision making [2][3][4][5]. However, the traditional Internet of Vehicles (IoV) merely provides communication services and lacks efficient cognition of physical space and network space, thus preventing intelligent vehicle mobility management and collaboration to better support AD services [6,7].
Recently, the Cognitive Internet of Vehicle (CIoVs) has emerged as an innovative paradigm for bringing intelligence and cognitive capabilities to IoV, which can provide smarter, reliable, and proactive services in AD scenarios [8]. CIoVs emphasizes the use of cognitive methods to facilitate intelligent collaboration in physical and network space to ensure traffic safety and quality of communication services. The cognitive engine (CE) can assist decision making and guide the movement of CAVs. In addition, the powerful We design a heterogeneous CIoVs network architecture and propose an intelligent clustering mechanism using AD pattern recognition, which brings CAVs with the same or a similar driving mode together to form a stable cluster to enhance the connectivity of the communication service. • We establish an AD mode model considering multiple driving parameter factors to perform AD pattern recognition. Then, the stability and survival time metrics of clusters are formulated and analyze the communication performance of the proposed clustering mechanism. • To ensure the effectiveness of clustering, we propose a genetic algorithm (GA)-based neural network (GANN) AD pattern recognition algorithm to perform accurate AD mode recognition for reliable clustering. • The simulation results are discussed and analyzed to evaluate the effectiveness of the proposed clustering mechanism compared with existing schemes in terms of AD pattern recognition accuracy, communication throughput, and average cluster lifetime.
The rest of the paper is organized as follows. Related works are introduced in Section 2. Section 3 presents the network architecture, clustering mechanism, and driving behavior modeling. Section 4 describes the GANN algorithm for AD pattern recognition in detail. Section 5 analyzes the performance indicators of the proposed clustering mechanism. Simulation results and discussions are carried out in Section 6. Finally, we summarize this paper in Section 7.

Related Work
As important components of smart city and ITS, IoV and AD have attracted extensive interest from both industry and academia. In this section, we discuss related work from the perspective of the vehicular network architecture, the network clustering and switching mechanism in IoV, and vehicle clustering and the driving behavior modeling approach that are closely related to this paper. The comparative study of our work with existing work is listed in Table 1. [26] Vehicular networks Analyzing the cluster-based heterogeneous vehicular networks Developing a heterogeneous vehicular networks framework [27] Cognitive radio Increasing network scalability in a distributed cognitive radio network Proposing a novel reinforcement learning based trust model to adjust cluster size [28] Network selection Improving quality of service of vehicles Developing a network recommendation system through big data analysis [29] Vehicular networks Making load balancing among heterogeneous base stations Proposing an online reinforcement learning approach for network load balancing Vehicle clustering and driving behavior [30] Autonomous vehicle Clustering a wide range of driving encounter scenarios Proposing a generic unsupervised learing framework [31] IoV Dealing with large scale network-based trajectory data Designing a dynamic network representation learning based clustering method [32] Transportation management Proposing an intelligent clustering mechanism based on driving patterns

IoV Network Architecture
Lin et al. [19] proposed a software-defined networking (SDN) enabled vehicular network architecture which divided the networks into three layers to improve network management capacity. In [20], the authors proposed a cognitive radio (CR)-based architecture for in-vehicle networks to employ CR technology to alleviate spectrum resource shortages in the presence of highly dynamic typologies and time-varying spectrum utilization. They used reinforcement learning methods to design optimal data transmission scheduling schemes and make full use of V2V and V2I communication resources. To deal with the problem of a lack of communication between vehicles, the authors in [21] proposed a heterogeneous V2V communication architecture and investigated a relaying method for the coexistence of DSRC and LTE-V2V technologies. In [22], the authors investigated the performance of the heterogeneous IoV architecture with multiple communication modes, which included V2V-only and hybrid situations. In [23], the authors surveyed a heterogeneous vehicular network architecture, which utilized multiple wireless communication technologies. Through analyzing and comparing the performance indicators required by safety services and non-safety services, they pointed out that a heterogeneous vehicular network combined with a cellular network and DSRC would be a potential solution to meet the communication requirements of ITS. These articles have put forward some communication optimization schemes from the aspect of vehicular network architecture and data transmission, which include multiple communication technologies and modes. However, the dynamic changes in network topology and communication interruptions and handovers caused by the random mobility of vehicles still challenge the reliability and scalability of IoV.

Network Clustering and Switching in IoV
Qi et al. [24] proposed a traffic differentiated clustering routing mechanism for vehicular data collection to reduce cellular bandwidth cost in a heterogeneous network, which was compose of DSRC and cellular vehicle-to-everything. To achieve high reliability, low latency, and wide-area coverage communication, the authors in [25] proposed an adaptive clustering method, which utilized DSRC and the cellular network to provide intra-cluster V2V communication and V2I communication outside the cluster, respectively. In [26], the authors proposed a section-based cluster mechanism, which clustered vehicles based on road sections and selected the vehicle closest to the cluster center as the CH, ignoring the driving stability of vehicles. In [27], the authors proposed a dynamic cluster adjustment mechanism to improve the scalability of the vehicular network, where CH discovered malicious cluster member (CM) nodes and adjusted cluster size according to the available spectrum to maximize resource utilization. The authors in [28] proposed a recommendation and switching mechanism in heterogeneous IoV to alleviate the load on the cellular network and improve network performance. In [29], the authors proposed an online reinforcement learning approach, which enabled switching between different heterogeneous vehicular networks by observing the patterns of data traffic in the spatialtemporal dimension. These studies investigated the communication switching problem caused by the dynamic network topology of the IoV from the perspective of clustering of heterogeneous networks. However, they neglected the impact of driving behavior and patterns of vehicles in heterogeneous vehicular networks on the communication performance, which is crucial for the stability of vehicle clusters and the reliability of communication.

Vehicle Clustering and Driving Behavior Modeling
Wang et al. [30] proposed a classification method for driving encounter scenarios using connected vehicle trajectories. A generic unsupervised learning framework including a feature representation layer and a clustering layer was designed to cluster driving encounter scenes based on multi-vehicle GPS trajectories. In [31], the authors employed machine learning methods to cluster the vehicle trajectories from a network perspective, which constructed IoV based on k-nearest neighbor. In [32], the authors adopted density-based spatial clustering of application with a noise algorithm to analyze travel patterns in a city and evaluate the similarity between trajectories. In [33], the authors proposed a clustering approach based on history and current driving information for ITS, which utilized the social relationship to perform a clustering algorithm. In addition, a vehicle route selection algorithm based on game evolution was proposed to control the traffic flow. In [34], the authors employed an internal reward function-based driving model to simulate human decision-making mechanisms and proposed a structural hypothesis on human driving behavior focused on discrete potential driving intentions. Tan et al. [35] proposed a new approach to unify the modeling of driving behavior in different scenarios, which combined behavioral theories and field theory. Liu et al. [36] investigated a driving behavior scoring model based on entropy weighting and hierarchical analysis, which analyzed driving behavior data by establishing a driving behavior identification algorithm. Shahverdy et al. [37] proposed a convolutional neural network based method to recognize five types of driving styles according to vehicle signals instead of monitoring driver visual features. These articles focused on vehicle clustering in physical space and behavioral analysis in a single traffic scenario; however, they lacked joint optimization and analysis of communication performance in a connected autonomous driving scenario.
Although much work has been done on IoV, traditional IoV ignores the driving characteristics and intelligence of CAVs, which leads to poor vehicle communication connectivity that cannot serve AD well. In network-assisted AD scenarios, CIoVs can better support AD scenarios by introducing the CE for cognition and collaboration in physical and cyberspace. Specifically, the cognition and clustering of the driving pattern can effectively improve the stability of the cluster, reduce frequent network switching and interruptions, and provide stable and reliable communication. In addition, effective collaboration between CAVs can greatly enhance the safety and efficiency of AD. However, it is very complex and challenging to solve the above problems.
In this paper, we propose an AD pattern recognition algorithm and design an intelligent clustering mechanism based on different AD patterns to provide stable and reliable AD communication services.

Network Architecture and Clustering Mechanism
In this section, we describe the proposed architecture and the intelligent clustering mechanism based on AD pattern recognition in detail. First, we present the proposed system architecture of the heterogeneous CIoV, the components that are included, and their functions in detail. We then describe the process of modelling AD patterns and build a training model which serves as the basis for pattern recognition. Finally, we detail the pattern recognition based clustering and CH selection mechanism.

CIoVs Architecture for AD
The proposed reliability-enhanced hierarchical CIoVs architecture is shown in Figure 1. The architecture mainly contained multiple CAVs with different AD modes, a 5G base station gNB, CE, and a cloud server (CS). Within the fog cell, the gNB collects Floating Car Data (FCD) within its coverage area. The CE processes the collected FCD to perform AD pattern recognition and clustering. Then, the CAVs are divided into different clusters according to AD modes. Among them, CAVs with the same or similar AD mode can form a cluster to maintain a relatively stable state. When the driving characteristics of CAVs are different from the proposed AD modes or a new driving mode appears, it can be switched to the same mode as the cluster member vehicles. Specifically, the constituents and functions are as follows. (1) CAVs: CAVs are classified into CHs, CMs, and standalone (SA) vehicles, where SA vehicles refer to vehicles that are not clustered. Specifically, DSRC is an effective V2V communication technology, which is used to support the communication between vehicles in the cluster to provide realtime safety services. The SA CAVs communicate directly with the base station. (2) gNB: The gNB is a centralized communication infrastructure that is responsible for communication with CHs and SA vehicles. For example, outside the cluster, the CH connects with the gNB through 5G-V2I technology, which can use the existing communication infrastructure to access the CS to obtain wider communication coverage and internet services. The CAVs set V within a fog cell is expressed as where N is the total number of vehicles. In the fog cell, CAVs generate a large amount of FCD and networking data. Processing these data to obtain valuable information can better promote ITS and network-assisted AD. These CAVs are divided into multiple clusters C = {C 1 , C 2 , . . . , C L } according to the excavated driving mode information. The vehicles in the fog cell have three different AD modes, and the set of driving modes can be expressed as V_ID = {M 1 , M 2 , M 3 }, where M 1 represents conservative driving mode, M 2 represents moderate driving mode, and M 3 represents aggressive driving mode. Therefore, the category attribute of the vehicle can be expressed as V i_v ∈ V_ID. The modeling of the AD mode will be introduced in the next subsection.
The gNB collects FCD and passes it to CE and the CE uses machine learning (ML) algorithms for data analysis to obtain the AD mode attributes of CAVs. The ML algorithm was used in this paper, which has strong data fitting and function mapping capabilities, and feature classification can be performed efficiently and reasonably [38]. Then, the CAVs with the same or similar driving patterns are gathered together to form a cluster through control instructions. Finally, each cluster selects the most reliable vehicle as the CH to connect with the gNB according to the stability of the AD mode, location, and communication status. This clustering mechanism can reduce the burden on the base station network and provide reliable communication [39]. Clustering is performed based on the result of AD pattern recognition, and we model the AD mode in the next subsection.

AD Mode Modeling
The AD modes of CAVs should be human-like and need to be adapted to the prevailing situation in order to achieve a comfortable and safe experience [40,41]. Based on the characteristics of driving in real urban traffic conditions, we classified the driving modes into three modes: aggressive, moderate, and conservative.These contain the main driving characteristics and can meet the needs of most driving scenarios. The CAVs with aggressive mode will have a relatively high-speed distribution compared to the CAVs with the other two modes and will overtake the CAVs of the other two modes. Conservative mode is the opposite of aggressive mode, i.e., lower average speed, very steady state of motion, and a tendency to follow. Finally, the moderate mode is between them.
Considering the driving behavior of the vehicle changes dynamically over time, we used VISSIM simulation software to collect the driving data of vehicles in different driving modes over time, which is presented in Section 6.1. Finally, through statistical analysis and preprocessing of these data, we obtained multidimensional data information closely related to the driving modes, i.e., feature vectors. The reflection in speed obeys truncated Gaussian distribution, the speed and overtaking frequency are mainly affected by the independent variables of acceleration and acceleration time. Therefore, based on the above analysis, several eigenvalues most relevant to the AD mode were selected as training data, including normalized velocity, acceleration time, overtaking frequency, etc. Through statistical analysis of the driving data of vehicles v i in different modes, the preprocessed statistical feature value was used as the training feature tensor. The preprocessed statistical feature values were employed as training feature vectors. The feature matrix can be expressed as where v i ∈ V and the meaning of each letter parameter can be expressed as follows: A v i represents the mean of the velocity distribution of the CAV v i , B v i represents the variance of the velocity distribution, C v i represents the acceleration mean, D v i represents the acceleration variance, E v i represents the acceleration time, F v i represents the overtaking frequency. T represents the vector of the output label. The GANN algorithm for AD pattern recognition is proposed in the next section, which utilizes these feature tensors as the training sets to identify the similarity of AD modes for intelligent clustering of CAVs and the clustering mechanism is introduced in the following subsection.

Clustering Mechanism
The model divided the AD mode into three categories, and the driving mode category label of each CAVs and its probability value in the category were obtained through the proposed AD pattern recognition algorithm. In the same category, the larger the probability value, the more stable the driving mode. It can be expressed as Among them, V_ID represents the vehicle driving mode category and P(v i_v ) represents the output category vector of the proposed driving pattern recognition algorithm GANN, i_v = 1, 2, . . . , N. It is a classification probability value, which satisfies The vector V i_v = (V_ID, max P(v i_v )) represents the driving mode category attribute of CAV i_v, where max P(v i_v ) is the probability value of vehicle i_v under the category V_ID, which reflects the stability of the driving mode. Therefore, the driving mode category indicator of the vehicle can be expressed as where S v i_v represents the quantitative value of the category attribute of the vehicle driving mode. The larger the value of S v i_v , the higher the stability of the vehicle in the category.
.Then, according to the recognized vehicle mode, the vehicles with the same category are grouped in the same cluster. At the same time, in the same category, the larger the value of S v i_v , the higher the priority for being selected as the CH. Based on the proposed clustering mechanism, in the next subsection we will introduce the cluster header selection method.

Cluster Header Selection
CAVs with the same AD mode will not have frequent overtaking and switching behaviors because the CAVs in the cluster have similar speed distributions and have already met their own driving needs. In addition, to improve cluster stability and flexibility, the CAV can be switched to different AD modes based on traffic and road conditions. Appropriate CH can improve the reliability of communication inside and outside the cluster and avoid frequent switching due to CH changes. When clustering is performed, CAVs with the same V_ID value are grouped together to form a cluster based on position. The leader priority can be defined based on stability, channel quality, and distance from the centroid and it can be expressed as where ρ(t) represents the channel quality index, D norm is the normalized distance of each vehicle from the cluster center, and c 1 and c 2 are the weights of each variable, c 1 + c 2 = 1. When the value of max P(v i_v ) is larger, the driving state of the vehicle in this mode is more stable. It can be seen that when the vehicle with the largest L v i_v (t) is selected as the CH, the subsequent ones will be used as candidate CH.

GANN for AD Pattern Recognition
In this section, we establish an AD pattern recognition model optimized by GA that takes full advantage of NN and GA.

NN Model for AD Pattern Recognition
According to the driving model established above, the NN architecture for AD pattern recognition was established as follows: (a) Number of layers in the NN: The NN consists of an input layer, an output layer, and multiple hidden layers. Theoretical studies have shown that a three-layer network with one hidden layer, which has sufficient neurons can achieve arbitrary nonlinear mapping [42]. We adopted a three-layer structure for pattern recognition. . Specially, T 1 stands for aggressive mode, which means that the vehicle accelerates frequently and travels at a high speed. T 3 stands for conservative mode, which means that the vehicle tends to actively brake to maintain a longer following distance and travels at a lower speed. T 2 stands for moderate mode and refers to the transition zone between the above two modes, which usually maintains a steady speed with little fluctuation. The NN target output column vector T 1 , T 2 , T 3 are [1, 0, 0], [0, 1, 0], [0, 0, 1], respectively. Therefore, the number of neurons in the output layer is three.
The driving pattern recognition model is a fully connected feedforward NN as shown in Figure 2. It works according to the principle that the number of neurons in the hidden layer is larger than that of the input layer and proportional. Considering the tradeoff between benefit and efficiency, the parameters and variables of the proposed GANN for AD pattern recognition are shown in Table 2.

Cost Function
According to the proposed network structure, the NN weights and thresholds to be optimized can be expressed as a matrix as follows where, W is the total parameter to be optimized; w 1 is the weight between the input layer neurons and the hidden layer neurons; θ 1 is the threshold of the hidden layer neurons; w 2 is the weight between the hidden layer and the output layer neurons; and θ 2 is threshold of the output layer neurons. The error of the actual output value and the target value of the network is taken as the objective function. The error between the expected value and the output value can be continuously reduced by using the gradient descent method. The error cost function of NN can be expressed as where m represents the number of training samples, Y k is the target value of the training sample, and Z k is the actual output value of the NN. In the process of network forward propagation, the weights and thresholds were first initialized. Using vectorization opera-tion to calculate the output of each layer, the output of the hidden layer neurons and the output of the output layer neurons are, respectively, expressed as where j = 1, . . . , n 2 and f ( ) and g( ) are the transfer functions of the hidden layer and the output layer, respectively. After two layers of forwarding transmission, the actual output value of the network can be obtained, and the network error can be obtained by substituting the above formula. The NN error function can be expressed as This shows that the NN error is a function of the parameters with respect to the W. Therefore, the pattern recognition error can be reduced by continuously adjusting the W of the NN.

Parameter Update
Using the backpropagation algorithm, the W updates along the direction of the gradient descent of the error function until the error accuracy requirement is met or the maximum number of iterations is reached. The update process of weights and thresholds can be expressed as follows where Υ is the learning rate, i.e., the adjustment step size of the weights and thresholds. The partial derivative of the model error function can be calculated using the chain derivation rule. However, the initial W has a large impact on the performance of the NN model, which will result in unstable classification results. In order to obtain the global optimal solution, the initial W needs to be optimized.

GANN Algorithm for AD Pattern Recognition
The optimization process includes the NN training phase and GA optimization phase. In this subsection, we use the GA algorithm to optimize the initial W. First, the W to be optimized was encoded as the chromosome of individuals, and the NN error norm was used to construct the fitness function. Then, we calculated the fitness value of individuals in the population, and used the operations of selection, crossover, and mutation to generate the next-generation and find the optimal chromosome. The specific steps of the GANN algorithm are as follows: (1) Population initialization: The population contains M individuals, each of which represents all the parameters to be optimized. Each individual can be coded as where Ind represents an individual in the population and M is the number of individuals included in the population during initialization. That is, all weights and thresholds are encoded as a chromosome of an individual, which is a row vector. Then a population of size M can be expressed as where X represents the initial population of the GA. Len represents the chromosome length of each individual. During the initial coding of the individuals, each parameter is coded in a standard binary code. That is, all the parameters to be optimized for each individual are encoded as a 10 − bit binary number, so the length of the chromosome of each individual can be represented as L en = 10 × (252 + 42 + 126 + 3) = 4230. (2) Fitness function determination: The fitness function is established based on the objective function. According to the principle of the survival of the fittest by GA, the smaller the error of the objective function, the greater the fitness value. Based on the above analysis, the fitness function can be expressed as where X represents an individual in the population and E represents the test sample error produced by the individual. (3) Selection operation: The GA will preferentially select individuals with higher fitness values for inheritance, and the superior genes of the previous generation will be preserved. The probability that a parent individual is selected is The probability of selection is constructed according to the individual fitness value, i.e., individuals with high fitness values are more likely to pass on the genes to the next generation. (4) Crossover operatio: Using a single point crossover method, each parental individual produces a progeny individual through chromosome crossover. Assuming that the parent individuals are C u (gen) and C v (gen), respectively, the progeny individuals generated after the crossover are C u (gen + 1) = C u (gen, q) q < r c C v (gen, q) q ≥ r c .
That is, the parent forms new offspring by exchanging chromosomes, where r c ∈ [1, L en ] is the crossover coding lengths of chromosomes. (5) Mutation operation: In order to maintain the global search characteristics of GA and avoid the convergence to the local optimum quickly, the individuals must maintain a certain probability of variation. Mutation produces the number of variant genes with a certain probability, and randomly selects the gene for mutation. If the selected gene is coded as 1, it becomes 0; otherwise, it becomes 1. Variations maintain population diversity to prevent immature convergence. (6) Termination condition: We set G as the maximum number of genetic generations of the GA. The optimization algorithm terminates when the GA reaches the maximum genetic generation or minimum target error. Then, the individual that has the smallest error in the genetic evolution process is the optimal solution. The output of the final training result is the optimal solution.

GANN for AD Pattern Recognition Algorithm
Algorithm 1 presents the process of GANN for pattern recognition, which overcomes the defect that NN easily falls into the local optimal during the learning process.

Algorithm 1 GANN for AD pattern recognition
Input: Initial population X, Training samples F, Initialization parameters. Output: Optimal network parameters Ind, minimum error E. 1 Training of NN; 8: Calculate Fit(X);

11:
X(gen + 1) = X ← X ; 12: Convert X(gen + 1) → decimal; 13: gen = gen + 1; 14: Update trace ← best error E, optimal X; 15: end while The main idea was to use the test error obtained through NN training as the optimization objective function of GA. We will introduce the NN training part in the next section. The NN model is a multi-classification problem. The Softmax function has good multi-classification properties, it is a probability selection mechanism. At the output layer of NN, we used Softmax as the transfer function. It can be expressed as The sum of the probabilities of the output of the three categories is 1, and the class with the highest probability can be output as the mode category to which the CAV belongs. A larger output value indicates a higher accuracy of the classification, where the NN training process for AD to obtain the error of each iteration is the objective function of GA optimization. The training of NN is to minimize network output errors in each training process by updating the weights and thresholds.

Performance Analysis
In this section, we introduce the stability and lifetime of the cluster and analyze the communication performance of the proposed clustering mechanism.

Cluster Stability and Lifetime Analysis
Considering the CAVs in motion is a time-varying process, each period T is divided into several equal time slots τ. Each time slot is used to collect the beacon information of the vehicle, which can be obtained from the electronic control unit (ECU). Therefore, the vehicle position information V i_v (t) = [x i_v , y i_v ] and other driving parameters can be used for cluster stability calculation and driving mode classification. For example, the vehicle speed and the distance between vehicles can be effectively calculated based on the location information of the vehicle at a certain moment.
The relative distance between CH j_v and CM i_v can be obtained through the Euclidean formula using position information. It can be characterized as The average relative distance between CM i_v and CH j_v in a cluster can be expressed as . Therefore, the sequence of the average distance variable between CM i_v and CH j_v changing with time is {D v (1), D v (2), · · · , D v (t)}, which can be obtained using the Euclidean distance. We can obtain ∆D by performing the difference operation on the average relative distance D v (t), then the stability index of the cluster can be derived by calculating the variance of the difference variable ∆D V (t). The stability index of the cluster can be expressed as When the CM of the cluster changes, the average distance between CH and CM will change, even the CAV will escape from the current cluster which may cause handover. At the same time, to maintain effective communication within the cluster, the maximum distance between CM and CH should be less than the coverage of the DSRC, i.e., max D(V CH , V CM ) < range(DSRC). If S ta remains a very small value, the time duration τ can represent the lifetime of the cluster. The lifetime of cluster can be expressed as The CE performs AD mode recognition based on the collected FCD of CAVs. Based on the location information, the CAVs with the same or similar AD mode are formed into a cluster and generate an info table of the cluster. When the number of CMs changes greatly, it will cause the average relative distance to change greatly, and the lifetime of the cluster may decrease. Therefore, the smaller the S ta , the more stable the cluster.

Communication Performance
The proposed architecture contains multiple clusters, the CH set can be expressed as CH = {CH 1 , CH 2 , · · · , CH L }, and the CM set of each cluster can be expressed as CM = {CM 1 , CM 2 , · · · , CM K }. In the analysis of reliable traffic, it is necessary to consider two communication models, within the cluster and outside the cluster. The sum of the reliable traffic of the CAVs is the reliable throughput of the fog cells. Therefore, the V2V reliable traffic between the CM and CH in the cluster can be expressed as where η 0 is the spectrum efficiency, W 0 is the CM bandwidth, and R(t) represents the reliable transmission index. We assume that the channel quality index ρ(t) is constant within a time period T, it can be detected by the vehicle sensing unit. Through the above CH selection mechanism, the CH can stably and reliably collect vehicle data and upload it to the base station. The V2I reliable traffic between the CH and the infrastructure can be expressed as where η l is the spectrum efficiency and W ch is the bandwidth allocated to CH for V2I communication.
Thus, the reliable throughput of the proposed architecture can be expressed as substituting Equations (9)-(11) into the Equation (12) can obtain It can be seen that in order to increase reliable throughput, the stability of the cluster needs to be improved. The improvement of cluster stability can effectively avoid the migration of CAVs between different clusters, thus, the handover and interruption can be avoided and improve cluster lifetime. Based on the proposed AD mode clustering and CH selection mechanism, CAVs can be automatically clustered, which can effectively enhance the cluster stability and reduce handover.

Simulation Results and Discussions
In this section, simulations and discussions are carried out. We mainly discuss the accuracy of the AD pattern recognition and the reliability of cluster communication to evaluate our proposed architecture and clustering mechanism. The CAVs were equipped with communication equipment and had large numbers of onboard sensors as data sources, such as acceleration, speed, brakes, LiDAR, and other sensors [43].

Training and Test Dataset
In order to verify the rationality of the proposed three AD modes, the traffic simulation software VISSIM was used to collect the sample data. Three experimental vehicle models were built in VISSIM, corresponding to the three driving modes in Section 3.2. By setting the operating parameters of the experimental vehicle, including the desired speed distribution, maximum acceleration function, and desired acceleration function, we established the distribution of three vehicle categories corresponding to the three driving modes. Finally, the data obtained were analyzed to obtain the driving characteristics of the vehicles in the different modes. The settings of the simulation parameters in VISSIM are shown in Table 3. A snapshot of the simulation running environment is shown in Figure 3.  Through statistical analysis of the dynamic driving data collected during the VISSIM simulation period, the distribution of these data was obtained. These data belonged to a truncated Gaussian distribution. The mean and variance were obtained by preprocessing. For simulation convenience, corresponding feature vector matrices were simulated in MATLAB according to distribution features. A portion of the normalized training samples utilized for GANN learning optimization are listed in Table 4. In reality, FCD can be transmitted to the CE via CIoVs and processed in CE, or preprocessed locally.

Performance Analysis of AD Pattern Recognition
The proposed algorithm was trained and validated using the dataset collected by the above method and was compared with the NN without genetic optimization, the deep neural network (DNN) with four layers, and the support vector machine (SVM). The settings of the simulation parameters of the GANN optimization algorithm model are shown in Table 5, which contains the GA part and the NN part. The number of generations and populations must be integers and the values of parameter regarding the probability were decimals between 0 and 1.  [44] 10 MHz 5G V2I Channel bandwidth [45] 20 MHz Total bandwidth 300 MHz Figure 4 shows the evolution of the GANN test errors, which was an important indicator of the generalization ability and accuracy of the proposed GANN pattern recognition algorithm. The test error of the test sample was an important indicator of the generalization ability of the GANN. It can be seen from the figure that the error decreased with the increase in genetic generation. The smaller the test error, the stronger the generalization ability of the network for new samples. The error decreased from above 0.35 to below 0.02 and the minimum test error was 0.014. The minimum value of 0.014 was obtained at 47 generations. The number of experiments took into account the balance between cost and effectiveness to verify the reasonableness of the maximum number of genetic generations. It can be seen from Figure 5 that after 50 iterations for each experiment, a low minimum error was achieved. High recognition accuracy was already achieved under this error condition. Therefore, the maximum number of iterations was chosen to be 50 for the tradeoff between efficiency and accuracy. Figure 6 shows the variation curves of the AD pattern recognition errors of GANN and NN. Since the initialization weights and thresholds of each NN were random, the errors converged to different local optimal solutions, and the pattern recognition error fluctuated each time. The GANN for the AD pattern recognition algorithm, which optimized the training error of the NN and continuously reduced the recognition error with genetic iteration, obtained more accurate recognition.   Figure 7 shows the comparison of GANN with other ML algorithms for conservative driving pattern recognition. The closer the output value of the pattern recognition algorithm to 1, the higher the recognition accuracy. The output value of the GANN for the AD pattern recognition algorithm was almost equal to 1 and remained stable, while the output values of other algorithms fluctuated significantly. This is because GANN can effectively optimize the initial weights and threshold vectors to obtain the global optimal solution, thus reducing the recognition error. Therefore, the GANN algorithm had higher recognition accuracy and stability than the other algorithms. Similarly, to verify the generality of the model, the output comparison simulations for the other two drive models in real life are shown in Figures 8 and 9. The NN and DNN models had a large and dramatic fluctuation between the predicted and actual values. The SVM performed very erratically, due to the jitter of the vehicle driving pattern. However, the predicted values of the GANN model were very close to the actual values, and the fluctuations of the output values were very small. The proposed GANN for AD pattern recognition algorithm had better recognition stability and generalization and was able to perform pattern recognition with high accuracy, which led to more stable clustering.
The test error and training error of different algorithms are shown in Table 6. The proposed GANN for AD pattern recognition algorithm had the smallest error, which could effectively avoid the wrong decisions caused by misjudgments and maintain the stability of the AD clustering system.

The Effectiveness of the Proposed Clustering Mechanism
Effective driving pattern recognition and classification to form clusters were the basic components of our proposed architecture, which are very important for reliable communication. To verify the effectiveness of the proposed clustering mechanism based on the AD mode (ADMode-cluster), we adopted six schemes for comparison as follows: 1.
The non-cluster scheme: The scheme was not clustered, and each vehicle on the road only communicated with the new base station through the allocated 5G-V2I technology [25]; 2.
The section-cluster scheme: The scheme divided the road into sections of equal length, and vehicles on the same road section formed a cluster [26]. Then the V2V communication within-cluster and V2I between CH and gNB were performed, respectively; 3.
The ADMode-cluster scheme: The CE used the proposed pattern recognition algorithm to gather vehicles with the same driving pattern into a cluster. On the basis of the proposed clustering mechanism, a heterogeneous hierarchical network architecture was used to carry out multimode communication to complete AD services; 4.
The Mixmode-cluster scheme: At the same time, the vehicles in the cluster had different driving modes, i.e., the CAVs in the cluster had three driving modes; 5.
The ADMix-cluster scheme: CAVs with different driving modes on the same road at the same time were divided into different subclusters based on the driving modes, i.e., the driving modes in each cluster were the same; 6.
The Kmeans-cluster scheme: It performed an iterative unsupervised clustering algorithm based on the position of the CAVs, thus clustering the vehicles into different clusters [46].
The communication simulation was performed considering a two-parallel three-lane (2 × 3 lanes) urban road. The total bandwidth was 300 MHz, of which 200 MHz was utilized for 5G V2I communication, and the remaining 100 Mhz was exploited for DSRC V2V communication. The spectral efficiency of the DSRC was defined as 10 bps/Hz, the spectral efficiency of the 5G V2I was 15 bps/Hz, and the communication range of the DSRC was 200 m. The other simulation parameters are shown in Table 5. Figure 10 shows the comparison of the average reliable traffic for the six schemes under different vehicle density conditions. The proposed scheme based on the ADModecluster was better than the other five schemes. This is due to the fact that the proposed scheme selects CAVs with the best channel quality and stability as CH. In addition, clusters with the same or similar AD mode are able to maintain stable driving, avoid frequent handover, and interruptions of vehicle communication. Since the ADMix-cluster scheme was divided into different subclusters on the same road, it had better performance in terms of stability. However, too many clusters can cause coverage space overlap and reduce channel utilization. Therefore, the performance was slightly lower than that of the ADMode-cluster scheme. The Kmeans-cluster scheme achieved good results because it performed effective clustering based on location. The non-cluster scheme had the lowest reliable traffic due to the very unstable network topology and only 5G V2I communication mode. The Mixmode-cluster scheme decreased its reliable traffic due to the frequent migration and switching of CAVs with different driving modes within the cluster. As the vehicle density increased, the performance of the Section-cluster was higher than that of the non-cluster scheme but lower than that of the Kmeans-cluster scheme. This is mainly due to the fact that although the section-cluster scheme can use DSRC bandwidth by clustering, this fixed section division scheme cannot perform effective clustering to solve the problem of random movement. Figure 11 shows the reliable throughputs of the six schemes with different vehicle densities. The throughput of the proposed ADMode-cluster scheme was significantly higher than the other schemes. This is due to the consistent driving mode of the CAVs in the cluster, thus avoiding the frequent replacement of CAVs. Similarly, the ADMixcluster scheme also achieved high reliable throughput. The section-cluster scheme is a fixed clustering method that divided CAVs into different clusters based on fixed road sections. In this way, the CAVs in the cluster were likely to move out and replace frequently, which would lead to frequent handovers. This phenomenon becomes more pronounced when the vehicle density increases, which will lead to a decrease in reliable throughput. As vehicle density increases, the reliable throughput tends to increase and then decrease. This is mainly because the increase of cluster members results in better spectrum gain but above a certain level will cause an increase in collision probability and overload, thus affecting performance. The non-cluster scheme had the smallest reliable throughput, and the variation with vehicle density was also small since no clustering communication was performed.   Figure 12 shows the average lifetime of different schemes. The ADMode-cluster scheme and ADMix-cluster scheme had the highest average lifetime of clusters. The reason is that the clusters can be maintained for a long time as the CAVs move in the same driving mode and the driving stability is higher than the hybrid model. This means that CAVs can maintain connections within a cluster for a long time while avoiding frequent handovers. The Kmeans-cluster scheme also showed a good cluster lifetime, since clusters can be kept relatively stable by continuous iterative clustering. Figure 12 shows that the average lifetime of clusters for all schemes tended to increase as the CAVs density increased. In addition, the Mixmode-cluster scheme and Section-cluster scheme were greatly affected by vehicle density. This is because when the vehicle density is higher, there will be more members in the cluster. Therefore, the CAVs are less likely to switch their AD mode, because it becomes difficult to change lanes.

Conclusions and Future Work
In this paper, we proposed an intelligent clustering mechanism in heterogeneous CIoVs which orchestrated the CAVs into different clusters based on AD mode to enhance the reliability of vehicular communication. In the proposed heterogeneous clustered CIoVs architecture, multiple communication technologies were exploited to improve connectivity and coverage area. We established an AD mode model and proposed a GANN-based AD pattern recognition algorithm to improve the accuracy of the clustering mechanism. Simulation results showed that our approach outperformed the state-of-the-art methods in terms of pattern recognition accuracy, reliable throughput, and cluster lifetime. In future work, we will investigate the blockchain-enabled CIoVs to establish a secure and trustworthy intelligence sharing and incentive platform to facilitate the collaboration of CAVs.

Data Availability Statement:
The data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest:
The authors declare no conflict of interest.