## 3 Proposed Solution
### Architecture Proposed
#### 3.1.2 Predicting the State of the Vehicular Network  
One of the responsibilities of Probe Car agents is to report to the cruise agents the delay experienced when traveling one of the streets that the cruise agent controls. The algorithm used to calculate the delay is based on the algorithm defined by [PERSON] (2018) and is modified to detect and report non-recurrent bottlenecks. The idea behind this is that a trip is an alternate sequence of periods in which the car is stationary and periods in which it is moving. A STOP event indicates when a vehicle has moved from a complete stop and can be described with the GPS position and the time the event occurred. A GO event indicates when a stopped vehicle moves (Figure 3).  
Figure 3: Flowchart showing the state machine used to detect the GO-STOP events ([PERSON] et al., 2019).  
Figure 2: Sequence diagram of a typical initial routing process.  
The Probe Car Agent is continuously recording the time that each GO-STOP event happens until it reaches an intersection. As soon as the PCA passes an intersection, it calculates the total delay it got when traveling on that street. The total delay is the sum of the time differences between a GO event and the previous STOP event as show in (1). The result, as well as the identifier of the street segment, are sent to the Cruise Agent of the intersection that the PCA has just crossed.  
\[Delay_{vehicle}=\sum_{j=2}\Bigl{(}TIME_{\_}GO_{j}-TIME_{\_}STOP_{j-1}\Bigr{)} \tag{1}\]  
Every 300 s, the Cruise Agent processes all the reports received and determines the average delay that exists in that segment of the street. The calculation of the average delay is based on (2).  
\[Delay_{\_}{arg}=\frac{\sum_{i=1}^{N}Delay_{\_}{vehicle_{i}}}{N} \tag{2}\]  
The CA sends an Update Message to the Network Agent. This message contains a time stamp, IDs of the streets it controls, as well as the average delay of each of the streets.  
The Network Agent is the responsible for making predictions using a deep five-layer architecture. As mentioned, from the perspective of Machine Learning, traffic prediction is a spatio-temporal sequence prediction [11]. If we assume that the traffic prediction problem in a vehicular network is a dynamic system on a spatial region represented by MxN adjacency matrix of M rows and N columns, and within each cell of this matrix, there exist P measurements, which vary with time. Based on the above, it can be observed that the problem of traffic prediction requires a prediction model that is capable of handling a sequence that contains spatial and temporal structures. When we see the results obtained by the ConvLSTM networks to predict the intensity of rain in a local region during a relatively short period, we decided to build a deep architecture with this type of network, since it has demonstrated to have excellent spatio-temporal sequence prediction capability, suitable for making predictions in complex dynamic systems. The process of training and defining the architecture is explained in detail in Section 4.  
The Network Agent uses the information received from the Cruise Agents to rectify the previous forecast and generate a new forecast using the ConvLSTM five-layer deep architecture mentioned above. This forecast will be valid for the next 300 s.  
If a non-recurrent congestion message is received during this time, the message will be stored for later use if a more recent update message does not arrive. Finally, the Network Agent sends the new forecast to both the Zone Agent and the Route Guidance Agent. The ZA analyzes the forecast to determine if there is a possibility of future congestion. While the RGA uses the forecast to generate new alternative routes.