# Modeling and Analysis of New Hybrid Clustering Technique for Vehicular Ad Hoc Network
## 3 Clustering Model
### Covering Rough Set Model
#### 3.1.2 Group Implementation  
The CRS algorithm was applied to the training data based on vehicle cases. The CRS algorithm was explained in Algorithm 1. Eventually, according to the rule decision, a rule is chosen for further processing. In this paper, we used a 10-fold cross that comprised 90% data for training and 10% data for testing. ```
Initialize  vid, vlocation, vspeed \(\leftarrow\) read from the dataset  v.direction \(\leftarrow\) [1,2]//1 for left, 2 for right \(L\leftarrow\) road length, c1 \(\leftarrow\) sector center  RSU1 \(\leftarrow\) (r\({}_{\text{rsu1},\text{yrsu1}}\)), RSU2 \(\leftarrow\) (r\({}_{\text{rsu2},\text{yrsu2}}\)) begin for i = 1 to n do \(d_{\text{cl}_{i}}^{\text{p. x. i}}=\sqrt{\left(\text{v}.x(i)-c(1 \text{x})\right)^{2}+\left(\text{v}.y(i)-c1(y)\right)^{2}}\) Distimate (i) \(\leftarrow\) (near, far] based on the value of L and Formula (5) Compare v.speed(i) with the range of speed Speed (i) \(\leftarrow\) [high, medium, low] based on Formula (4) Direction (i) \(\leftarrow\) [left, right] based on v.direction input Calculate the distance between the vehicle and {RSU1, RSU2} then assign the decision-making {CS, NS} endfor for i = 1 to n do  Apply the rule in Table 1 to create G = {G1, G2, G3,...,Gn} endfor for i = 1 to n do  Create the covering groups using Formula (6)//CG1, CG2, CG3,..., and CGn Select the Upper and Lower Approximation using Formula (1) and Formula (2) Calculate the Boundary Region using Formula (3) endfor  Export the CG and Boundary Region

Figure 5: Rough set covering distribution. ### K-Value Calculation Model

In this subsection, we try to select an optimal number of clusters (optimal K value). In the traditional K-Means clustering algorithm, the k-value selection is based on the minimum error rate only. The error rate can be calculated as the minimum value of cluster distance. In this work, we propose a different procedure to calculate the value of K.

Procedure steps

* **Calculate the initial value of K**. **Definition 3**. : _Let CG= {v1,v2,...,vn} be a set of group vehicles imported from CRS and VL=(v1.x,v1.y),(v2.x,v2.y),... (v.xn,v.yn)) be a set of Vehicle Locations. If and only if VL \(\in\) the vehicle group and not accessed in the group boundary, then:_

\(d_{Max}\) is the maximum distance within the group, and the representative group length can be defined as:

\[d_{Max.}=Mix\big{\{}d\big{(}V_{i},\ V_{j}\big{)}\big{\}} \tag{10}\]

Let CR be the node coverage region; then, K* is:

\[K^{*}=\frac{d_{Max.}}{CR} \tag{11}\]

where \(K\)* is the initial value of K.

* **Calculate the second value of K based on the similarity matrix. **

The second step in this procedure is to select a random K value, implement the K-Means clustering algorithm, and then calculate the similarity matrix and change the K value several times to obtain a minimum error rate. The second value of K is \(K^{**}\). **Definition 4**. : _Let {v1,v2,...,vn} be a set of cluster vehicles and VL = {(v1.x,v1.y), (v2.x,v2.y),... (v.xn,v.yn)} be the set of Vehicle Locations. If and only if \(\forall\) vehicles \(\in\) C, the similarity matrix represents the within-cluster distance (WD) matrix and is defined by:_

\[WD= \begin{bmatrix}0\\ d(2,1)&0\\ d(3,1)&d(3,2)&0\\ \vdots&\vdots&\vdots&0\\ d(n,1)&d(n,2)&d(n,3)&\ldots&0\end{bmatrix}  \tag{12}\]

The sum square of the error (SSE) is the total summation of all rows in the WD matrix. The SSE can be computed as:

\[SSE=\sum_{i=1}^{n}\sum_{j=1}^{n}d\big{(}v_{i},v_{j}\big{)}^{2} \tag{13}\]

where \(d\big{(}v_{i},v_{j}\big{)}=\sqrt{\big{(}x(i)-x(j)\big{)}^{2}+\big{(}y(i)-y(j) \big{)}^{2}}\). Figure 6 shows the \(K^{**}\) calculation flowcharts concerning the value of the SSE. The K** calculation model comprises the following steps:

1. Select k = 0, then increase the value of k.
2. Apply the K-Means clustering algorithm. 3. Calculate the cluster similarity based on (12) and (13). 4. Check the error rate value; if the value is at its minimum, then stop. 5. For each high error value, increase the value of k and repeat steps 2 to 4.