## 3 The System Implementation  
To forecast traffic, the Long Short-Term Memory (LSTM) neural network is an appropriate choice because the inputs are time series (the traffic values in each node in the graph that represents the transport road network and considers the spatial-temporal characteristics of the inputs). The LSTM network [19, 21] is a recurrent neural network that processes input data by looping over time steps and updating its state and contains information stored over all the previous time moments and consists of several cells as in the Figure 3.  
At a given moment of time \(t\), the input cell is \(X_{t}\). The cell state at time \(t\) is \(C_{t}\), and the output is \(H_{t}\). The initial value of \(C_{t-1}\) and \(H_{t-1}\) at \(t=0\) is zero. Assuming that \(X_{t}\) and \(H_{t}\) are \((M,1)\) vectors, \(B_{f}\), \(B_{i}\), \(B_{c}\), \(B_{o}\) are scalars, the weights \(w_{f}\), \(w_{i}\), \(w_{c}\), \(w_{o}\) are \((1,M)\) vectors, and the weight \(w\) is a scalar with \(M\) being the number of features (inputs in the neural network) and one output of the neural network, then the LSTM computations are the following relations:  
\[F_{t}=\text{sigmoid}\big{(}\sum_{i=0}^{M-1}\left[w_{f}(i)\cdot H_{t-1}(i)+w_{ f}(i)\cdot X_{t}(i)\right]+B_{f}\big{)}\]  
\[I_{t}=\text{sigmoid}\big{(}\sum_{i=0}^{M-1}\left[w_{i}(i)\cdot H_{t-1}(i)+w_{ i}(i)\cdot X_{t}(i)\right]+B_{i}\big{)}\]  
\[C_{t}=F_{t}\cdot C_{t-1}+I_{t}\text{tanh}\big{(}\sum_{i=0}^{M-1}\left[w_{c}(i) \cdot H_{t-1}(i)+w_{c}(i)\cdot X_{t}(i)\right]+B_{c}\big{)}\]  
\[O_{t}=\text{sigmoid}\big{(}\sum_{i=0}^{M-1}\left[w_{o}(i)\cdot H_{t-1}(i)+w_{ o}(i)\cdot X_{t}(i)\right]+B_{o}\big{)}\]  
\[H_{t}=O_{t}\cdot\text{tanh}(C_{t})\]  
At each time step, the neural network learns to predict the value of the next time step (the inputs are shifted by one time step) [22]. The sequence output is determined by a neural network regression layer. There are two methods of forecasting: open-loop and closed-loop forecasting. Open-loop forecasting predicts the next time step in a sequence using only the input data (true input from traffic sensors). The output sequence is predicted using several past input sequences. Closed-loop forecasting predicts using the previous predictions as input and does not require the true inputs' values to make the prediction. To make a prediction for current time, this method uses the predicted value (past the neural network output) as input. The open-loop forecasting method has the disadvantage of a greater network load because each vehicle on the road more often reads the traffic sensors,  
Figure 3: LSTM neural network cell. but the traffic forecasting is more accurate. On the other hand, closed-loop forecasting requires fewer readings of traffic sensors (and reduces the network load), but the forecasting is less accurate and depends on neural network accuracy and graph filtering. The proposed method takes into consideration two factors: the communication network load (how often the inputs in the neural network are updated) and the neural network performance (in terms of forecast accuracy). The two proposed scenarios follow the methods used in the real world: time-triggered systems or event-triggered systems. While time-triggered systems (scenario 1) are suitable for more predictable traffic, the event-triggered system is used for bursting-like traffic. The two scenarios are somewhat complementary (they are applied in different situations). However, the time-triggered system is simpler to implement and covers the event-triggered system. The communication network load is greater in the time-triggered system (scenario 1) than in the event-triggered system (scenario 2), but the neural network performance is better if it reads real inputs more often (like in scenario 1) instead of using the predicted outputs (as in scenario 2).