## 2 Assessing Traffic Pattern Matrix  
This section focuses on the effective procedure to predict traffic pattern in vehicular communications for utilization in real-time applications, such as dynamic traffic management. RSUs can collect speed and flow data and the information gathered can be delivered to a control unit that automatically estimates volume of traffic [35]. The pattern of traffic can be characterized as a matrix on a temporal and spatial scale. The spatial scale incorporates the entire area of the street for which specific trip times can be anticipated. The temporal scale incorporates adequate time spans to characterize the impact of traffic on travel time. Traffic volume is specified as the number of vehicles that cross a section of road per unit time within a selected period. Volume of traffic can influence travel time together with speed of vehicles which is utilized as a marker for congestion. We assigned the weights at given times and locations to create the TP matrix based on congestion level to optimize travel times. The principal task here is to derive a historical days' database by using the assumption that traffic patterns are repetitive during a tight time period, for example, traffic time for 10 a.m. traffic can be viewed from 9 a.m. to 11 a.m. This search window can locate comparative traffic patterns rapidly. There are traffic examples of different days which are recorded in the database inside a time span of \(\pm\)x minutes for time estimation. Our scenario links to V2R communications and measures vehicles moving at speeds of 100 km/h (\(\sim\)27 m/s) crossing each of the RSU with a coverage range of 200 m (radius). This relates to the high contact duration of \(200\times 2/27\approx 15\) s.  
In our simulation, we assumed that the road section consists of \(k\) links and each link shows a section of road. Each section should be equipped with one RSU, the amount of days in historical database is denoted by \(i=1,2,3,\ \ldots n_{i},j=0,5,10,\ldots,n_{j}\) representing information in a five minutes resolution, and \(t\) which is the prediction time on prediction day \(p\). The start time of the traffic pattern on historical days denoted by \(t_{s}\). \(v(i,\ t-j,p)\) designates velocity on prediction day \(p\) at link \(k\) at time \(t-j\). Similarity, \(h=1,2,3,\ldots,n_{h}\) shows the number of days in historical database and \(t_{s}\) shows the beginning time of the traffic pattern on historical days then \(v(i,t_{s}-j,h)\) shows on historical day \(h\) at link \(k\) at time \(t_{s}-j\). Travel time on a road is mainly affected by the congestion present on the road. This congestion may occur due to bottlenecks. Weights are applied to account for the congestion produced due to the type of bottlenecks, whenever and wherever it occurs. We set the weights according to the rapid speed of each section. These weights have to be higher for the sections with lower rapid speeds which represented bottlenecks. The following practical formula is utilized in Equation (1):  
\[w(i,j)=\frac{1}{\left[v(i,t-j,p)\right]^{C}} \tag{1}\]  
where, \(C\) is a constant. The search is executed in \(\pm x\) minutes of estimation time \(t\) on historical days so \(t+x\geq t_{s}\geq t-x\). The basic purpose of the pattern matching process is to find the most similar historical pattern(s). Hence, the primary task is to generate some historical days' database. One way of searching these patterns is to discover the entire historical database for the most similar pattern, but this makes the search process computationally intensive. Hence, the sum of the squared difference between the prediction time traffic pattern and the historical traffic patterns is used as a criterion for finding similarities between the traffic patterns. The historical traffic pattern having minimum sum of squared difference, is regarded as the most similar pattern.