Traffic flow prediction method and system based on stnr model

By combining the STNR model with a fully connected layer, a long short-term processing module, a spatiotemporal convolution module, and a multilayer perceptron, the problem of time and space synchronization analysis in traffic flow prediction is solved, achieving higher prediction accuracy and real-time performance.

CN116434569BActive Publication Date: 2026-05-12ZHEJIANG UNIV BINJIANG RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG UNIV BINJIANG RES INST
Filing Date
2022-12-26
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing traffic flow prediction methods struggle to perform effective analysis simultaneously across both time and space dimensions, resulting in predictive delays and inconsistent accuracy.

Method used

A traffic flow prediction method based on the STNR model is adopted. By combining long-term and short-term data, a fully connected layer, a long-term and short-term processing module, a spatiotemporal convolution module, and a multilayer perceptron module, the temporal and spatial dependencies of traffic flow are captured. The prediction is then performed using a temporal convolutional network, a graph convolutional network, and a multilayer perceptron.

Benefits of technology

It improves the accuracy and real-time performance of traffic flow forecasting, and enhances the ability to predict traffic flow by combining analysis of time and spatial dimensions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116434569B_ABST
    Figure CN116434569B_ABST
Patent Text Reader

Abstract

The application discloses a traffic flow prediction method and system based on an STNR model, which comprises the following steps: sorting historical traffic flow data of a target road section in time sequence, dividing the historical traffic flow data into long-term data and short-term data, and obtaining a training set; constructing a traffic flow prediction model, taking the long-term data and the short-term data as inputs of the traffic flow prediction model, and training the traffic flow prediction model; the traffic flow prediction model comprises a full connection layer, a long short-term processing module, a space-time convolution module and a multilayer perceptron module; collecting traffic flow data of the target road section at a current time, inputting the traffic flow data into the trained traffic flow prediction model, and predicting traffic flow of a future period. The application effectively captures the spatial dependence and the time dependence of the traffic flow, and improves the prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent transportation technology, and in particular to a traffic flow prediction method and system based on the STNR model. Background Technology

[0002] With the continuous development of society, the number of motor vehicles in cities is increasing, and the resulting traffic congestion is becoming more and more serious. To address this issue, many countries are developing Intelligent Transportation Systems (ITS) to solve traffic congestion problems. ITS uses decision-making and guidance to solve these problems, and rapid and accurate traffic flow prediction is the key to ITS's decision-making and guidance.

[0003] Intelligent Transportation Systems (ITS) utilize roadside data collection units to gather information (such as traffic flow and vehicle speed). The data processing and analysis system analyzes this data, and the information dissemination system provides optimal routes to the public after statistical analysis, aiming to avoid traffic congestion and alleviate traffic pressure. Currently, the data analysis and processing portion relies on traffic flow prediction to achieve this goal; therefore, obtaining accurate prediction information has become a crucial step in developing intelligent transportation systems.

[0004] Zhao et al. proposed a traffic flow data prediction method based on LSTM (Hamilton W, Ying Z, Leskovec J. Inductive representation learning on large graphs[C]Advances in Neural Information Processing Systems.2017:1024-1034.), which uses LSTM to extract the temporal features of traffic flow data to obtain the temporal trend of traffic flow data. However, this method can only learn temporal characteristics and cannot extract the spatial features of traffic flow data. Furthermore, the incomplete data analysis leads to inaccurate traffic flow prediction.

[0005] Wu et al. proposed a hybrid deep learning framework incorporating CNN and LSTM modules (Wu, H. Tan, Short-term traffic flow forecasting with spatial-temporal correlation in a hybrid deep learning framework. 2016.), using CNN and LSTM modules respectively to extract different features from the data. The CNN module extracts spatial features of traffic flow data in adjacent areas. The LSTM module extracts temporal features of traffic flow data. Finally, the features extracted by the CNN and LSTM modules are combined to predict traffic flow data.

[0006] Zhou Ming from North China University of Technology proposed a Long Time Memory Network (RNC-LSTM) based on road network correlation (Zhou Ming. Research on Short-Term Traffic Flow Prediction Method Based on Road Network Spatiotemporal Information [D]. North China University of Technology, 2020.). By abstracting the road network structure, the correlation coefficient matrix is ​​calculated to obtain the spatiotemporal feature input of traffic data. Finally, the data is integrated to construct a prediction system for short-term traffic flow prediction.

[0007] However, due to the massive scale, strong spatiotemporal dependence, and significant social relevance of traffic flow information data, the time delay and accuracy of traffic flow prediction are difficult to guarantee. This is because current traffic flow prediction methods either use spatially adjacent road segments as independent variables and build prediction models using historical time-series data, or use changes in the time dimension as independent variables and employ the most popular intelligent learning algorithms for prediction simulation. They lack research and analysis that synchronizes both the temporal and spatial dimensions, thus making it difficult to achieve reliable, real-time, and accurate predictions of urban road traffic conditions. Summary of the Invention

[0008] This invention provides a traffic flow prediction method and system based on the STNR model, which improves the accuracy of traffic flow prediction.

[0009] The technical solution of the present invention is as follows:

[0010] A traffic flow prediction method based on the STNR model includes:

[0011] The historical traffic flow data of the target road segment is sorted in chronological order and divided into long-term data and short-term data to obtain the training set;

[0012] A traffic flow prediction model is constructed, using long-term and short-term data as inputs to train the model. The model includes a fully connected layer, a long-short-term processing module, a spatiotemporal convolution module, and a multilayer perceptron module. The fully connected layer extracts long-term and short-term temporal features from the long-term and short-term data, respectively. The long-short-term processing module fuses these features through an attention mechanism and outputs the result to the spatiotemporal convolution module. The spatiotemporal convolution module captures the temporal and spatial dependencies of the input and outputs the result to the multilayer perceptron module, which then obtains the prediction result.

[0013] The system collects traffic flow data for the target road segment at the current moment and inputs it into a trained traffic flow prediction model to predict traffic flow for future periods.

[0014] Preferably, the traffic flow data of the target road segment is extracted every 5 minutes as a traffic flow time series. It is then determined whether the traffic flow time series is a stationary time series. If it is a stationary time series, a training set is directly constructed. If it is not a stationary time series, it is differentially analyzed, and the differentially analyzed data is used to construct a training set.

[0015] If a time series is continuous, then it is a stationary time series.

[0016] Traffic flow data has a time attribute, namely daily periodicity and weekly periodicity.

[0017] Preferably, the short-term data is the traffic flow data predicted for the day, and the long-term data is historical observation data other than the short-term data.

[0018] Short-term data X S It can be represented as:

[0019]

[0020] Among them, T S This represents the S-th time period. T represents the recent period of time S The data is N, where N represents the length of the time series.

[0021] Long-term data X L It can be represented as:

[0022]

[0023] in, T is the nth period S Time-based data. A cycle is typically one day.

[0024] By extracting the long-term and short-term time features of long-term and short-term data respectively through fully connected layers, it can be represented as:

[0025] Z S =FC(X) S ) = ReLU(X S w s +b s )

[0026] Z L =FC(X) L ) = ReLU(X L w l +b l )

[0027] Where FC represents a fully connected layer; ReLU represents the ReLU function; w s ,w l ,b s and b l These are learnable parameters; and It is X S and X L The characteristic matrix of .

[0028] Preferably, the long-short processing module includes a temporal convolutional network unit and a long-short fusion unit; the temporal convolutional network unit captures the temporal features of long-term data, and the long-short fusion unit uses an attention mechanism to fuse long-term and short-term temporal features.

[0029] The temporal characteristics of long-term data captured by temporal convolutional network units can be represented as:

[0030] F L =θ*Z L +b1

[0031] in, and It is a learnable parameter; F L This represents the extracted long-term temporal features.

[0032] An attention mechanism is employed to fuse long-term and short-term temporal features, including:

[0033] Will and Convert to attention vector and

[0034]

[0035]

[0036] Where F is a nonlinear activation function; l1 and l2 are convolution operations;

[0037] Multiply the obtained attention vectors by the input separately, and then fuse the product results to obtain:

[0038]

[0039] Among them, ⊙ s It is a channel multiplication operator; ⊙ l It is a space multiplication operator; output It is the result of fusion.

[0040] More preferably, the temporal convolutional network is a dilated convolutional network.

[0041] Traffic conditions in road networks typically exhibit significant spatiotemporal correlations. This invention uses a spatiotemporal convolution module to effectively capture the spatial and temporal dependencies of traffic flow.

[0042] Preferably, the spatiotemporal convolution module includes a gated recurrent unit (GRU) and a graph convolutional unit (GCN); the gated recurrent unit takes fused temporal features as input and its output F G An attention-based adaptive adjacency matrix is ​​input into a graph convolutional unit, whose output G... (K) The prediction result is obtained after passing through a multilayer perceptron module.

[0043] Preferably, the multilayer perceptron module consists of two ReLU stacked layers with linear transformations.

[0044] Given G (K) ∈R N×T As input, the multilayer perceptron module operates as follows:

[0045] X′=W fc1 (ReLU(G (K) ))+b fc1

[0046]

[0047] Among them, W fc1 W fc2 ,b fc1 and b fc2 These are learnable parameters.

[0048] When training the traffic flow prediction model, the mean absolute error (MAE) is used as the training objective:

[0049]

[0050] Yt Indicates the prediction result. Represents the true value. θ represents the trained model, and θ represents all the learnable parameters in the model.

[0051] The present invention also discloses a traffic flow prediction system based on the STNR model, including the traffic flow prediction model constructed and trained as described above; collecting traffic flow data of the target road segment at the current time and inputting it into the traffic flow prediction system to obtain traffic flow prediction results for future time periods.

[0052] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0053] 1) This invention combines long-term and short-term data, and considers the long-term and short-term cycle dependencies of traffic data when designing long-term and short-term processing modules, which greatly improves the prediction accuracy at the time level.

[0054] 2) This invention combines the two dimensions of time and space, and proposes a spatiotemporal convolution module to effectively model these correlations, effectively capturing the spatial dependence of any road segment and the temporal dependence of any time interval. Attached Figure Description

[0055] Figure 1 The diagrams are schematic diagrams of the model structure, where (a) is the overall structure diagram of the STRN model, (b) is the structure diagram of the long short-term data processing module, and (c) is the structure diagram of the spatiotemporal convolution module.

[0056] Figure 2 This is a schematic diagram of the gated loop unit. Detailed Implementation

[0057] The basic content of the technical solution of this invention is as follows: Figure 1 As shown, the STRN (Short Temporal Recurrent Network) model mainly consists of four modules: a fully connected layer, a long short-term processing module, a spatiotemporal convolution module, and an MLP (Multi-Level Perceptron). First, historical observations are processed into long-term and short-term data as model inputs. Then, the two processed inputs are passed through a long short-term processing module to model the long- and short-term features of the data. Next, a spatiotemporal convolution module is used to model spatiotemporal dependencies. Finally, the output is fused by a multi-layer perceptron to obtain the prediction result.

[0058] This invention provides a preferred embodiment of a traffic flow prediction system based on the STNR model, comprising the following steps:

[0059] 1) Data preparation

[0060] This scheme uses an RFID dataset for model training. First, the data is preprocessed to remove missing and duplicate data. A road segment is selected and sorted chronologically, then divided into long-term and short-term data. Short-term data represents the data for the current day's prediction, while the rest is long-term data. The data includes traffic flow speed in kilometers per hour. Traffic flow data is extracted every 5 minutes to create a traffic flow time series. The time series is then assessed for stationarity (if continuous, it's considered stationary). If stationary, the dataset can be directly constructed; otherwise, it is differencing. The differencing data is then used to construct the dataset. When obtaining predicted traffic flow values, an inverse transformation is performed, and the data is divided into training, validation, and test sets in a 7:1:2 ratio. Finally, the data is normalized before being input into the model to facilitate training and achieve better results.

[0061] 2) Model building

[0062] 2.1 Fully Connected Layer (FC)

[0063] Traffic flow data has time attributes, namely daily and weekly periodic dependencies. To predict traffic flow at a certain moment today, the model needs to learn not only the most recent data but also data from the past few days. Therefore, we considered the long-term and short-term periodic dependencies of traffic data when designing the long-term and short-term processing modules. The specific execution flow of the long-term and short-term processing modules is described below.

[0064] The short-term input of the model is represented as:

[0065]

[0066] Where T S It is the number of times the model is used, and T represents the recent period of time S The data is N, where N represents the length of the time series.

[0067] The long-term input of the model is represented as:

[0068]

[0069] in T is the nth period S Time data. Let T p This represents the period number (usually one day). In our model, X S and X L This is the input. Then we extract the feature representations of the input vectors from the two inputs using fully connected layers respectively:

[0070] Z S =FC(X)S ) = ReLU(X S w s +b s )

[0071] Z L =FC(X) L ) = ReLU(X L w l +b l )

[0072] Where w s ,w l ,b s and b l These are learnable parameters. and It is X S and X L The characteristic matrix of .

[0073] 2.2 Long-term and Short-term Processing Modules

[0074] Traffic prediction tasks are challenging due to the complex temporal attributes of traffic datasets. We designed a long-term and short-term data processing module to simulate the long-term and short-term temporal attributes of traffic data. The long-term and short-term data processing module is as follows: Figure 1 As shown in (b) above. First, we process the more complex long-term data using a temporal convolutional network, and then fuse the results with the short-term data. Note that we fuse the long-term and short-term data using attention scores.

[0075] S1. Long-Term Temporal Convolutional Network (TCN)

[0076] Because long-term data is complex, we first employ TCN to learn the temporal properties of the data. TCN uses dilated convolutions to dynamically capture the temporal attributes of the data. Dilated convolutions can effectively alleviate the vanishing and exploding gradient problems in RNNs.

[0077] For a one-dimensional input sequence x (t) The receptive field of the convolution is f:{0,...,k-1}, and the dilated convolution operation is as follows:

[0078]

[0079] Where d is the dilation coefficient, k is the kernel size, and x s-9·i Let f(s) represent historical data, f(i) represent the receptive field, and f(i) represent the receptive field of the i-th layer. Dilated convolution can save computational resources when the network requires a large receptive field. Given long-term data... TCN operations are as follows:

[0080] F L =θ*ZL +b1

[0081] in and It is a parameter. F L This represents the extracted features.

[0082] S2. Integration of short-term and long-term strategies

[0083] STRN employs an attention module to fuse long-term and short-term temporal features. Given and We convert them into attention vectors and

[0084]

[0085] Where F is a nonlinear activation function. and It's a convolution operation. (Vector)

[0086]

[0087] Where λ1 and λ2 are convolution operations. Vector We multiply the resulting attention vectors by the input separately, and then fuse the product results:

[0088]

[0089] Among them ⊙ s It is the channel multiplication operator, ⊙ l It is the space multiplication operator. Output It is a result fusion.

[0090] 2.3 Spatiotemporal Convolution Module

[0091] Traffic conditions in road networks often exhibit significant spatiotemporal correlations; therefore, we propose a spatiotemporal convolutional module to effectively model these correlations. For example... Figure 1 As shown in (c), the spatiotemporal convolutional module consists of a gated recurrent unit (GRU) and a graph convolutional layer (GCN). To capture the spatial dependencies of any road segment and the temporal dependencies of any time interval, we designed a multi-layered model.

[0092] S1. Gated Cyclic Unit (GRU)

[0093] The temporal correlation of traffic networks is a key factor in traffic forecasting. The challenges of temporal correlation in traffic forecasting are similar to those in time series forecasting; therefore, time series data in traffic forecasting can be processed using models designed for processing time series data. Currently, the most widely used model for processing time series data is the Recurrent Neural Network (RNN). However, traditional recurrent neural networks have limitations in processing time series data.

[0094] GRU and LSTM are variants of RNN, but GRU has fewer parameters and is therefore more efficient when handling the same task. The structure of GRU is as follows: Figure 2 As shown. Each hidden layer in GRU can be accessed by resetting the gate r. t and update gate z t To control the flow of information. Reset gate r t Determine how much information needs to be forgotten from the previous hidden state. Update gate z. t Responsible for carrying the information from the previous hidden state into the current hidden state. Reset gate r t Used to control the flow from the previous hidden layer h t-1 To the current candidate hidden layer How much information to retain:

[0095] r t =σ(w rg g (t) +u rh h t-1 +b r )

[0096]

[0097] Where g (t) The input value is time t, b is the deviation, and w is the input value. rg w hg u rh u hh u hh b r b h All are learnable parameter matrices, σ is the sigmoid function, tanh is the hyperbolic tangent function, and ⊙ is the Hadamard product. Update gate z t Used to control the need to move from the previous hidden layer h t-1 How much information is forgotten in the middle:

[0098] z t =σ(w zg g (t) +u zh h t-1 +b z )

[0099] Current hidden layer ht By update gate z t The previous hidden layer h t-1 and the current candidate hidden layer Sure:

[0100]

[0101] S2. Graph Convolutional Network (GCN)

[0102] In road networks, traffic conditions between road segments typically exhibit complex spatial correlations. These correlations are influenced by various factors, and these influences are highly dynamic. We utilize Geographic Networks (GCNs) to capture these complex spatial correlations. For a given vertex v... i GCN can capture vertex v i Spatial correlation is modeled by the correlation between the network graph and its neighboring vertices. Given a network graph G = (V, E, A), let L = ID -1 / 2 AD -1 / 2 Here, is the graph Laplacian matrix, and D denotes the degree matrix. Mathematically, the GCN operation is defined as follows:

[0103]

[0104] Where X l Let L represent the features of the first layer, α0 represent the trainable coefficients, and L 0 Let represent the k-th power of the graph Laplacian matrix, and σ be the sigmoid activation function. Due to the influence of prior knowledge and data incompleteness, the predefined matrix may not reflect the true correlation between nodes. To address this issue, we further learn an adaptive adjacency matrix based on an attention mechanism:

[0105]

[0106]

[0107] Among them, E1E - ∈R N×A This represents two-node embedded learning. Let represent the adjacency matrix, δ be the ReLU activation function, and W represent the learnable parameters.

[0108] 2.4 Multilayer Perceptron (MLP)

[0109] We feed the output of the spatiotemporal convolutional module into the MLP layer to obtain the prediction results. The MLP layer consists of two stacked ReLU layers with linear transformations. The MLP layer synthesizes aggregated node features for node-level prediction.

[0110] Given G (K) ∈RN×T As input, the hidden layer operations of the MLP are as follows:

[0111] X′=W fc1 (ReLU(G (K) ))+b fc1

[0112]

[0113] Among them W fc1 W fc2 ,b fc1 and b fc2 These are learnable parameters. We choose to use the Mean Absolute Error (MAE) as the training objective for GraphWaveNet (a combination of the Long Short-Term Processing module and the Spatiotemporal Convolutional module), which is defined as:

[0114]

[0115] Y t Indicates the prediction result. θ represents the trained model, and θ represents all learnable parameters in the STRN.

[0116] 3) Model Training

[0117] Input the training set and validation set divided in step 1) into the model built in step 2) to train the model.

[0118] 4) Model Testing

[0119] Input the test set divided in 1) into the model trained in 3) to test the model's performance. The test metric is the mean squared error (MSE). The mean squared error is a measure of the difference between the estimator and the estimated quantity. The higher the prediction accuracy, the smaller the mean squared error, and vice versa.

[0120] The embodiments described above provide a detailed explanation of the technical solutions and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, additions, and equivalent substitutions made within the scope of the principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A traffic flow prediction method based on the STNR model, characterized in that, include: (1) Sort the historical traffic flow data of the target road segment in chronological order and divide it into long-term data and short-term data to obtain the training set; short-term data Represented as: ; in, It is the number of times the model is used. Indicates the recent period of time The data is N, where N represents the length of the time series; Long-term data Represented as: ; in, It is the first Each cycle Time data; (2) Construct a traffic flow prediction model, use long-term data and short-term data as inputs to train the traffic flow prediction model; the traffic flow prediction model includes a fully connected layer, a long-term and short-term processing module, a spatiotemporal convolution module and a multilayer perceptron module. The fully connected layers extract long-term and short-term time features from long-term and short-term data, respectively, as follows: ; ; Where FC represents a fully connected layer; ReLU represents the ReLU function; , , and These are learnable parameters; and yes and The feature matrix; The long-short processing module includes a temporal convolutional network unit and a long-short fusion unit; the temporal convolutional network unit captures the temporal characteristics of long-term data, represented as: ; in, and These are learnable parameters; This indicates the temporal characteristics of the extracted long-term data; Long-term and short-term fusion units employ an attention mechanism for fusion. and ,include: Will and Convert to attention vector and : ; ; in, It is a non-linear activation function; , , and It is a convolution operation; Multiply the obtained attention vectors by the input separately, and then fuse the product results to obtain: ; in, It is a channel multiplication operator; It is a space multiplication operator; output It is a fusion of temporal characteristics; The obtained fused temporal features are output to the spatiotemporal convolution module. The spatiotemporal convolution module includes a gated recurrent unit and a graph convolution unit; the gated recurrent unit takes fused temporal features as input and captures the temporal and spatial dependencies of the input as output. , The adaptive adjacency matrix based on the attention mechanism is input to the graph convolution unit output. , The prediction result is obtained after passing through a multilayer perceptron module; The multilayer perceptron module consists of two stacked ReLU layers with linear transformations; (3) Collect the traffic flow data of the target road segment at the current time and input it into the trained traffic flow prediction model to predict the traffic flow in the future period.

2. The traffic flow prediction method based on the STNR model according to claim 1, characterized in that, The temporal convolutional network is a dilated convolutional network.

3. The traffic flow prediction method based on the STNR model according to claim 1, characterized in that, When training the traffic flow prediction model, the mean absolute error (MAE) is used as the training objective: ; Indicates the prediction result. Represents the actual value. This represents the trained model. This represents all learnable parameters in the model.

4. A traffic flow prediction system based on the STNR model, characterized in that, The system includes a traffic flow prediction model constructed and trained as described in claim 1; the traffic flow data of the target road segment at the current time is collected and input into the traffic flow prediction system to obtain the traffic flow prediction results for future time periods.