Method and system for predicting future traffic flow based on heterogeneous graph

Through a method based on heterogeneous graph, the spatial and temporal characteristics of the traffic network are extracted and the traffic flow prediction model is constructed, which solves the problem that the traffic flow prediction model in the existing technology cannot explore the spatial and temporal correlation, and achieves more efficient traffic flow prediction.

CN118247968BActive Publication Date: 2024-12-10QINGDAO UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410444491.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-15
Publication Date
2024-12-10
Estimated Expiration
2044-04-15

AI Technical Summary

Technical Problem

Existing traffic flow prediction models are difficult to effectively explore the spatial and temporal correlations of traffic networks, resulting in poor prediction performance.

Method used

Using a heterogeneous graph-based method, by obtaining traffic network information and historical traffic flow, extracting heterogeneous information matrix and node relationship sets, a traffic flow prediction model is constructed, including STREGCN block extraction spatial features and time block extraction time features, combined with the output layer Make predictions.

Benefits of technology

It improves the accuracy of traffic flow prediction, can better capture the spatiotemporal characteristics of the traffic network, reduces prediction errors, and performs better than the benchmark model in terms of short-term and long-term predictions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118247968B_ABST
    Figure CN118247968B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method and system for predicting future traffic flow based on a heterogeneous graph, which obtains traffic network information and historical traffic flow, extracts the adjacency matrix A and the node relationship set R of the traffic network information, and expands the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A′, and constructs a heterogeneous graph based on the heterogeneous information matrix A′ and the node relationship set; constructs a traffic flow prediction model, extracts spatial features through STREGCN blocks, extracts temporal features through time blocks, and predicts future traffic flow based on temporal features and spatial features through an output layer; and predicts traffic data to be predicted based on a trained traffic flow prediction model to obtain a prediction result. The method for predicting future traffic flow based on a heterogeneous graph solves the problem that the traffic flow prediction model in the prior art cannot well explore the spatial correlation and temporal correlation of the traffic network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, system, electronic device and storage medium for predicting future traffic flow based on a heterogeneous graph. Background Art

[0002] Existing traffic prediction models can be divided into two categories: traditional prediction models and prediction models based on machine learning methods; traffic flow usually exhibits nonlinear and non-steady-state characteristics, which are difficult to meet the assumptions of traditional models. Therefore, when these models are directly applied to traffic flow prediction tasks, they may perform poorly in practical applications. Although models based on machine learning methods can model more complex data, they rely heavily on feature engineering and it is difficult to mine and integrate the spatiotemporal characteristics of traffic flow.

[0003] As a deep learning method, graph convolution has received widespread attention recently. Graph convolution has the advantage of retaining high-dimensional information of traffic networks, so it has better performance in predicting traffic flow. Although graph convolution is very effective in extracting spatial correlation, it is difficult to capture the temporal correlation in traffic networks. Models based on graph convolution mainly use relatively simple relationships to capture the spatiotemporal correlation of data. However, real traffic networks may have multiple relationships and show different spatiotemporal correlations.

[0004] Therefore, there is an urgent need for a method that can better extract the spatial correlation and temporal correlation of traffic data networks. Summary of the invention

[0005] The purpose of the embodiments of the present invention is to provide a method, system, electronic device and storage medium for predicting future traffic flow based on heterogeneous graphs, so as to solve the problem that the traffic flow prediction model in the prior art cannot well explore the spatial correlation and temporal correlation of the traffic network.

[0006] To achieve the above object, an embodiment of the present invention provides a method for predicting future traffic flow based on a heterogeneous graph, and the method specifically includes:

[0007] Acquire traffic network information and historical traffic flow, extract the adjacency matrix A and node relationship set R of the traffic network information, expand the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A', and construct a heterogeneous graph based on the heterogeneous information matrix A' and the node relationship set;

[0008] Constructing a traffic flow prediction model, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, extracting spatial features through the STREGCN block, extracting temporal features through the time block, and predicting future traffic flow based on the temporal features and the spatial features through the output layer;

[0009] Constructing a training set based on the historical traffic flow, inputting the training set into the traffic flow prediction model for training, and obtaining a trained traffic flow prediction model;

[0010] The traffic data to be predicted is predicted based on the trained traffic flow prediction model to obtain a prediction result.

[0011] On the basis of the above technical solution, the present invention can also be improved as follows:

[0012] Furthermore, the extracting of the adjacency matrix A and the node relationship set R of the traffic network information, and expanding the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A', and constructing a heterogeneous graph based on the heterogeneous information matrix A' and the node relationship set includes:

[0013] Construct a point set V in a heterogeneous graph based on detectors on the road that meet preset conditions;

[0014] Construct edge set E in heterogeneous graph based on the relationship between detectors;

[0015] Construct the node relationship set R in the heterogeneous graph based on the distance relationship, road type relationship, and accessibility relationship between roads;

[0016] Based on different relationship types r∈R, the connectivity between different nodes in the heterogeneous graph is obtained;

[0017] The heterogeneous relationship information matrix A' is constructed based on the connectivity between different nodes in the heterogeneous graph.

[0018] Furthermore, the extracting of spatial features by the STREGCN block includes:

[0019] Using the information in the heterogeneous relationship information matrix A' to classify different edge types in the heterogeneous graph, a set of multiple groups of nodes is obtained, and the nodes in the same set have the same edge relationship;

[0020] Based on the target node, the adjacent nodes corresponding to the target node are sampled to obtain feature information of the adjacent nodes, the feature information is converged, and the feature information of each adjacent node is fused with the feature information of the target node to obtain the spatial feature.

[0021] Further, extracting the time feature through the time block includes:

[0022] The output of each subsequent layer is obtained based on the unknown input of the previous layer through one-dimensional causal convolution;

[0023] After convolution and activation operations are performed on the historical traffic flow through the gated linear unit, the final output result of the layer is controlled by activating the output gate to extract the temporal features;

[0024] The temporal correlation of historical traffic flows is captured and formed into temporal blocks through one-dimensional causal convolution and gated linear units.

[0025] Further, extracting the time feature through the time block includes:

[0026] The time characteristics are calculated by formula (1);

[0027]

[0028] Where, X (l) is the network input of the current layer, h (l) is the hidden layer information output of the current layer, f i (X) is the convolution operation, σ is the sigmoid nonlinear activation function, is the convolution operator.

[0029] Furthermore, the predicting of future traffic flow based on the temporal features and the spatial features through the output layer includes:

[0030] Predict future traffic flow through formula (2);

[0031]

[0032] Where, X (2) is the data processed by two STREGCN blocks, Γ is the temporal convolution kernel, * T is a temporal convolution operation, W and b are the learnable parameters and bias terms of the output layer, respectively.

[0033] Furthermore, the step of constructing a training set based on the historical traffic flow, inputting the training set into the traffic flow prediction model for training, and obtaining a trained traffic flow prediction model includes:

[0034] Dividing the historical traffic flow into a training set, a validation set, and a test set;

[0035] Training the traffic flow prediction model based on the training set;

[0036] Performing a performance evaluation on the trained traffic flow prediction model based on the validation set to obtain a traffic flow prediction model that meets performance requirements;

[0037] The prediction result of the traffic flow prediction model that meets the performance condition is evaluated based on the test set to obtain an evaluation index corresponding to the traffic flow prediction model.

[0038] A system for predicting future traffic flow based on a heterogeneous graph, comprising:

[0039] An acquisition module is used to acquire traffic network information and historical traffic flows, extract an adjacency matrix A and a node relationship set R of the traffic network information, and expand the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A', and construct a heterogeneous graph based on the heterogeneous information matrix A' and the node relationship set;

[0040] A construction module, used for constructing a traffic flow prediction model, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, extracting spatial features through the STREGCN blocks, extracting temporal features through the time block, and predicting future traffic flow based on the temporal features and the spatial features through the output layer;

[0041] A training module, used for constructing a training set based on the historical traffic flow, inputting the training set into the traffic flow prediction model for training, and obtaining a trained traffic flow prediction model;

[0042] The prediction module is used to predict the traffic data to be predicted based on the trained traffic flow prediction model to obtain a prediction result.

[0043] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the steps of the method are implemented when the processor executes the computer program.

[0044] A non-transitory computer-readable storage medium stores a computer program, which implements the steps of the method when executed by a processor.

[0045] The embodiments of the present invention have the following advantages:

[0046] The method for predicting future traffic flow based on heterogeneous graph in the present invention obtains traffic network information and historical traffic flow, extracts the adjacency matrix A and the node relationship set R of the traffic network information, and expands the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A', and constructs a heterogeneous graph based on the heterogeneous information matrix A' and the node relationship set; constructs a traffic flow prediction model, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, extracts spatial features through the STREGCN blocks, extracts temporal features through the time block, and predicts future traffic flow based on the temporal features and the spatial features through the output layer; constructs a training set based on the historical traffic flow, inputs the training set into the traffic flow prediction model for training, and obtains a trained traffic flow prediction model; predicts the traffic data to be predicted based on the trained traffic flow prediction model to obtain a prediction result; solves the problem that the traffic flow prediction model in the prior art cannot well explore the spatial correlation and temporal correlation of the traffic network. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the implementation methods of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the implementation methods or the description of the prior art. Obviously, the drawings in the following description are only exemplary, and for ordinary technicians in this field, other implementation drawings can be derived from the provided drawings without creative work.

[0048] The structures, proportions, sizes, etc. illustrated in this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with the technology. They are not used to limit the conditions under which the present invention can be implemented, and therefore have no substantial technical significance. Any structural modification, change in proportion or adjustment of size shall still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and purposes that can be achieved by the present invention.

[0049] Figure 1 A flow chart of a method for predicting future traffic flow based on a heterogeneous graph according to the present invention;

[0050] Figure 2 The present invention is a schematic diagram of a system for predicting future traffic flow based on a heterogeneous graph;

[0051] Figure 3 A schematic diagram showing the relationship between the heterogeneous graphs of the present invention;

[0052] Figure 4 is a flow chart of the causal convolution of the present invention;

[0053] Figure 5 It is a first schematic diagram of the error performance of the model of the present invention on PeMSD8;

[0054] Figure 6 is a second schematic diagram of the error performance of the model of the present invention on PeMSD8;

[0055] Figure 7 This is a schematic diagram of the physical structure of the electronic device provided by the present invention.

[0056] The accompanying drawings are denoted as follows:

[0057] Acquisition module 10, construction module 20, training module 30, prediction module 40, electronic device 50, processor 501, memory 502, bus 503. DETAILED DESCRIPTION

[0058] The following is a description of the implementation of the present invention by specific embodiments. People familiar with the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0059] Example

[0060] Figure 1 FIG. 1 is a flow chart of an embodiment of a method for predicting future traffic flow based on a heterogeneous graph according to the present invention. Figure 1 As shown, a method for predicting future traffic flow based on a heterogeneous graph provided by an embodiment of the present invention includes the following steps:

[0061] S101, obtaining traffic network information and historical traffic flow, extracting the adjacency matrix A and the node relationship set R of the traffic network information, and expanding the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A', and constructing a heterogeneous graph based on the heterogeneous information matrix A' and the node relationship set;

[0062] Specifically, specify the traffic flow X = {x t-m+1 ,x t-m+2 ,…,x t}∈R N×M×ci , where M is the input window size of the historical data sequence, N is the number of detectors in the road network, and c i is the number of features of the input data. The traffic network is represented by G, the adjacency matrix A represents the connectivity of nodes in the traffic network, and the heterogeneous information matrix is ​​A'. Specify the traffic flow prediction for the future time period in Indicates the future T i Traffic conditions of the road network at the moment.

[0063] The task of traffic flow prediction is to pass the given traffic flow X and traffic network information G to the traffic flow prediction function F to obtain the future time period T q The traffic flow Y of each node in the system is as follows: Y = F (X, G)

[0064] Most traffic prediction models construct traffic networks based on homogeneous graphs. Although this approach can capture the basic spatial characteristics of traffic networks, it may ignore some key features in traffic networks, such as the distinction between different road types such as one-way streets and roundabouts.

[0065] The limited expressiveness of homogeneous graphs stems from its reliance on the adjacency matrix, which stores only two values ​​0 and 1 to indicate the connectivity and non-connectivity of a node. The representation of road types is enhanced by expanding the values ​​in the adjacency matrix A to create a new set of heterogeneous information matrix A' containing 0,1,2…,n to represent the connectivity that nodes have according to different relationships.

[0066] For detectors in a heterogeneous graph, different colors represent different types of roads where the detectors are located. Red, green, and blue detectors represent arterial lanes, dedicated high-occupancy vehicle (HOV) lanes, and ramp lanes on highways, respectively. There may be multiple connections between nodes in a heterogeneous graph.

[0067] Figure 3 a- Figure 3 d represents the relationships based on the distance between nodes, road type relationship, road accessibility and weather similarity relationship respectively. These relationships can coexist in a heterogeneous graph, but for ease of representation, they are displayed separately. The multiple relationships in the heterogeneous graph enhance the model's representation of the transportation network, enabling the model to better explore the spatial correlation of the transportation network.

[0068] Construct a point set V in a heterogeneous graph based on detectors on the road that meet preset conditions;

[0069] Construct edge set E in heterogeneous graph based on the relationship between detectors;

[0070] Construct the node relationship set R in the heterogeneous graph based on the distance relationship, road type relationship, and accessibility relationship between roads;

[0071] Based on different relationship types r∈R, the connectivity between different nodes in the heterogeneous graph is obtained;

[0072] The heterogeneous relationship information matrix A' is constructed based on the connectivity between different nodes in the heterogeneous graph.

[0073] A preferred embodiment is:

[0074] The actual traffic conditions in cities are extremely complex. In order to extract the spatial information features of the traffic network, we represent the real urban traffic network as a graph structure, denoted as G = (V, E), and represent the detectors on the road that meet certain conditions as a point set V = {v1,v2,…,v N The existence of a certain relationship between detectors indicates that there is an edge between two nodes in the heterogeneous graph, E = {(v i ,v j ,r)|v i ,v j ∈V,r∈[1,n]} represents the edge set E, (v i ,v j ,r) represents the node v i and v j There is a relationship r between them. The node relationship set R is represented by R = {1,2,…,n} according to the distance relationship, road type relationship, accessibility relationship between roads, etc. According to different relationship types r∈R, the connectivity between different nodes is obtained and different edge types are represented. The traffic flow, speed, density and other features collected by the detector are represented in the form of node embedding. The connectivity represented by different relationships between nodes in the heterogeneous graph is represented by A', which is generated according to E.

[0075] The REGCN in the STREGCN block uses the information in the heterogeneous relationship information matrix A′ to classify different edge types in the heterogeneous graph. This will produce a set of multiple groups of nodes, and the nodes in the same group have the same edge relationship. The classification method is as follows: S = {S 1 ,S 2 ,…,S n} represents a set of points that are connected under a certain relationship. Based on the relationship R, select the points with relationship i in the edge set E to form a set, where the elements of A′ about point v are not zero, and the set of points with relationship i is recorded as S i ={v∈V|(v i ,v j ,i)∈E,a v ≠0and∈A′}. Then, the GCN method is applied to each group separately in turn, which can be expressed as follows:

[0076]

[0077] In the formula, * G represents the convolution on the heterogeneous graph, Θ represents the convolution kernel on the graph, l represents the number of propagation layers, i and j are both node identifiers, represents the embedding parameter of node i in layer l, σ represents the nonlinear activation function, represents the set of nodes that have r relationships with node i, C i,ris a problem-specific normalization constant that can be learned or chosen in advance. Represents the weight matrix when the relation r propagates to the first layer, Represents the weight parameter of node i when it propagates to the lth layer. The process is based on the target node sampling its neighboring nodes, obtaining their feature information, then converging the sampled feature information, and finally fusing the feature information of each neighboring node with its own feature.

[0078] S102, constructing a traffic flow prediction model, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, extracting spatial features through the STREGCN block, extracting temporal features through the time block, and predicting future traffic flow based on the temporal features and spatial features through the output layer;

[0079] Specifically, the extraction of spatial features through the STREGCN block includes:

[0080] Using the information in the heterogeneous relationship information matrix A' to classify different edge types in the heterogeneous graph, a set of multiple groups of nodes is obtained, and the nodes in the same set have the same edge relationship;

[0081] Based on the target node, the adjacent nodes corresponding to the target node are sampled to obtain feature information of the adjacent nodes, the feature information is converged, and the feature information of each adjacent node is fused with the feature information of the target node to obtain the spatial feature.

[0082] Traffic networks generate complex and sparse data, so efficient processing is crucial when processing time series data of traffic flow. To this end, one-dimensional causal convolution and gated linear unit (GLU) are used to mine the temporal correlation of traffic flow and form time blocks. This method is simple to operate, requires fewer parameters, and greatly improves the training speed of the model compared to other methods, thereby achieving efficient processing of traffic flow.

[0083] The extracting time features through the time block includes:

[0084] Causal convolution is a technique that uses past and present input values ​​to determine the current output value while excluding information about future input values. The computational process of causal convolution involves using the unknown input of the previous layer and its input from the previous position to obtain the output of subsequent layers. Figure 4 This technique is particularly useful for tasks that require consideration of causal relationships, such as those encountered in time series problems.

[0085] The function of GLU is to control the final output result of layer l by activating the output gate after convolution and activation operations on X. This structure can regulate the flow of information, distinguish and filter different input data features, and ensure that the model can better learn the characteristics of specific tasks.

[0086] The calculation formula of GLU is shown in the following formula;

[0087]

[0088] Where, X (l) represents the network input of the current layer, h (l) represents the hidden layer information output of this layer, f i (X) is the convolution operation, σ is the sigmoid nonlinear activation function;

[0089]

[0090] In the formula, functions u and g are sequences, and k and j represent subscripts in the sequence.

[0091] Combine the GLU data with the convolutional X (l) Add together to form the residual structure of the time block, as shown in the following formula:

[0092]

[0093] In the formula, Γ represents the convolution kernel, * T represents the convolution operation in the time block, and Υ is the ReLu activation function;

[0094] The temporal correlation of historical traffic flows is captured and formed into temporal blocks through one-dimensional causal convolution and gated linear units (GLU).

[0095]

[0096] In the formula, and They represent the temporal convolution kernels of the previous and next time blocks in the STREGCN Block of the lth layer. Correspondingly, Θ (l) Represents the graph convolution kernel, and BN represents the batch normalization operation performed on the data. After passing through two STREGCN blocks, another time block is used to further extract temporal features.

[0097] The data then passes through the output layer to calculate the predicted traffic flow value for a period of time in the future.

[0098]

[0099] Where, X (2)is the data processed by two STREGCN blocks, Γ is the temporal convolution kernel, * T is the temporal convolution operation, W and b are the learnable parameters and bias terms of the output layer, respectively.

[0100] S103, constructing a training set based on historical traffic flows, inputting the training set into a traffic flow prediction model for training, and obtaining a trained traffic flow prediction model;

[0101] Specifically, the historical traffic flow is divided into a training set, a validation set and a test set;

[0102] Training the traffic flow prediction model based on the training set;

[0103] Performing a performance evaluation on the trained traffic flow prediction model based on the validation set to obtain a traffic flow prediction model that meets performance requirements;

[0104] Evaluate the prediction results of the traffic flow prediction model that meets the performance conditions based on the test set to obtain an evaluation index corresponding to the traffic flow prediction model;

[0105] Based on the validation set, the performance of the trained traffic flow prediction model is evaluated to obtain a traffic flow prediction model that meets the performance conditions; based on the test set, the similarity calculation result of the traffic flow prediction model that meets the performance conditions is evaluated to obtain an evaluation index corresponding to the traffic flow prediction model. The performance of the traffic flow prediction model is evaluated to obtain a percentage score (i.e., the highest score is 100 points and the lowest score is 0 points), and based on the percentage score, a traffic flow prediction model with a score greater than a set value is determined, for example, a traffic flow prediction model with a score greater than 90 points is a traffic flow prediction model that meets the performance conditions;

[0106] The traffic flow prediction model that meets the performance conditions is evaluated by calculating the evaluation index to obtain the evaluation index of the traffic flow prediction model, and the evaluation value corresponding to each evaluation index is calculated to obtain the evaluation value used to represent the capability value of the traffic flow prediction model at the evaluation index.

[0107] The traffic flow study in this paper is based on a dataset obtained from the California Highway Performance Monitoring System (PeMS). The PeMS system consists of 39,000 detectors throughout California highways, and the dataset includes geographic information from the detectors, which is used to generate a traffic network. To validate the STREGCN model, the PeMSD8 dataset is used, which covers 8 roads, consists of 1979 detectors, and spans 62 days from July 1, 2016 to August 31, 2016. The dataset used in this paper involves traffic data collected in real time at 30-second intervals by the California Department of Transportation's performance testing system. To ensure that there is enough distance between detectors, a threshold of 3.5 miles is set, and detectors that do not meet this condition are removed. Therefore, a total of 170 detectors are retained for further analysis. There are 170 detectors in PeMSD8, and traffic data is summarized every 5 minutes, that is, each detector has 288 data points per day. This paper uses traffic flow as a measure of traffic flow, and the subsequent traffic flow analysis is also expressed in terms of traffic flow. The training set includes the data of the first 49 working days of these detectors, because there are differences in the data distribution between weekdays and weekends. The data of the subsequent 14 working days are used as the validation set. The missing values ​​in the data are processed by linear interpolation after cleaning, and zero-mean normalization transformation is performed to make the mean of the data 0.

[0108] Experimental setup:

[0109] Adam is used as the optimizer for the STREGCN model. When the data passes through the STREGCN block, the input channel is 3, represented by c i =3, the output channel is set to 16. The input time step M is 12, which means the utilization rate of the traffic in the past 60 minutes. The prediction time step T q is 6, indicating the prediction of traffic flow in the next 30 minutes. The time block has 16 input and output channels, and the causal convolution kernel size is 1×3. The training learning rate is set to 0.001, the decay parameter is set to 0.9, the batch size is set to 50, and the number of training rounds is also set to 50. This paper divides the entire dataset into two parts, one is a 60% training set and the other is a 40% test set. The implementation of the model is based on Python, and DGL and Pytorch are used to quickly build the model. The process is to first initialize the weight parameters using a normal distribution with a mean of 0 and a variance of 1, then use the temporal convolution module for forward propagation, and finally use the Adam gradient descent algorithm for back propagation to optimize the weight parameters. This paper uses the squared absolute error (MAE) and root mean square error (RMSE) to evaluate the model training results.

[0110] Compare models:

[0111] Gated Recurrent Unit (GRU): This is a description of a recurrent neural network (RNN) that is specialized for extracting long-term dependencies in time series data while keeping the number of parameters relatively small. This makes it well suited for building large networks with many layers.

[0112] Graph Convolutional Network (GCN): This model simultaneously learns the structural information of the graph structure and the attribute information of the nodes to obtain the final node feature representation, and takes into account the structural correlation between the nodes in the model.

[0113] Spatio-Temporal Dynamic Network (STDN): This model adopts a flow gating mechanism to capture the changing spatial similarities between regions and a periodic attention shifting mechanism to explain the temporal similarities that change over time.

[0114] Temporal Graph Convolutional Network (T-GCN): This model combines two powerful techniques: GCN for capturing complex spatial dependencies and GRU for learning the temporal dynamics of traffic data.

[0115] Spatio-Temporal Graph Convolutional Network (STGCN): This model can effectively capture the spatiotemporal dependencies of traffic flow. The traffic network is modeled using a generalized graph instead of considering the traffic flow as a single discrete part (such as a grid).

[0116] Spatial-Temporal Graph ODE Networks (STGODE): This model is a dynamic graph data modeling method. It combines spatial graph data with time series data and uses graph neural networks (GNN) and ordinary differential equations (ODE) to capture the spatiotemporal dependencies in graph data.

[0117] Multivariate Time Series Forecasting with Graph Neural Networks (MTGNN): This model represents multivariate time series data as a graph structure. The model consists of a graph learning layer, a graph convolution layer, and a time convolution module. The model is able to capture the interactions and dependencies between variables and take into account the time order.

[0118] Quantitative experimental analysis:

[0119] In this experiment, the traffic flow was initially screened and denoised, and data with ground truth was selected instead of zero data. The prediction results of the STREGCN model and seven baseline models were compared. Figure 5 As shown, it can be seen that GRU and GCN have poor prediction effects on highly discrete traffic flows. When the time step is 5 minutes and 30 minutes, the MAE values ​​of GRU are as high as 53.52 and 61.56, and the RMSE values ​​are as high as 83.23 and 95.63, respectively. In addition, the MAE values ​​of GCN are as high as 52.43 and 60.73, and the RMSE values ​​are as high as 81.56 and 93.12, respectively. GRU and GCN are able to extract temporal and spatial features from the data for predictive modeling. However, traffic flow itself has intricate spatiotemporal dependencies. Relying solely on temporal or spatial features is not enough to fully capture the interdependencies in the data. Therefore, these models tend to produce relatively high prediction errors.

[0120] Integrating spatiotemporal features in the STDN, T-GCN, and STGCN models reduces MAE and RMSE compared to the GRU and GCN models. On average, these models reduce MAE and RMSE by 21.12% and 24.34% within 5 minutes and by 29.31% and 31.10% within 30 minutes, respectively, compared to GRU and GCN. Figure 5 As shown in the figure, the STREGCN model outperforms the baseline models in both short-term and long-term predictions, with MAE and RMSE of 38.26 and 56.43, respectively, while the baseline models are 39.23 and 57.92, respectively. Compared with the base models GRU and GCN, STREGCN reduces MAE and RMSE by 27.77% and 31.51% in 5 minutes, and by 35.84% and 38.62% in 30 minutes, respectively. In addition, compared with complex models such as STDN, STGCN, and MTGNN, STREGCN reduces MAE and RMSE by 8.04% and 8.34% in 5 minutes, and by 8.35% and 9.53% in 30 minutes, respectively. On average, STREGCN reduces MAE by 11.62% and RMSE by 12.75% compared to all baseline models.

[0121] Qualitative experimental analysis:

[0122] In order to intuitively demonstrate the prediction effect of the model proposed in this paper, seven related models, GRU, GCN, STDN, T-GCN, STGCN, STGODE and MTGNN, were selected to compare with STREGCN in the experimental test phase. A road was randomly selected in the dataset, and a detector was selected from the road. Then the traffic flow of the road section was visualized to compare the difference between the predicted values ​​of each model and the actual values. In this experiment, the line graph shows the degree of fit between STREGCN and the baseline model and the actual data. The standard residual graph shows the residual distribution pattern of the model prediction value. Residuals above the 0 line indicate low prediction values, and vice versa. When the residuals of the model are more evenly distributed near the 0 line, the prediction effect of the model is better.

[0123] Performance comparison with the base model;

[0124] GRU and GCN models Figure 5 Both show significant deviations from the actual values. They often under-predict values, especially during periods of high volatility. The single-layer GRU model has difficulty capturing the complex spatiotemporal dependencies in traffic flow. It cannot effectively capture long-term dependencies. Similarly, the single-layer GCN model cannot capture the intricate relationships and long-term dependencies between nodes. Based on the residual distribution of the predicted values ​​of the two models, most of the predicted values ​​are lower than the true values, resulting in an uneven residual distribution. Compared with models that rely only on spatial information or only on temporal information for prediction, STREGCN can obtain better results by fusing the rich spatiotemporal information in heterogeneous graphs. This also proves the effectiveness of fusing spatiotemporal information for prediction.

[0125] Performance comparison with complex models:

[0126] Complex models such as STDN, T-GCN, and STGCN integrate spatial and temporal related features of traffic data. The prediction results are better than those of GCN and GRU, which shows that the fusion of spatial and temporal features improves the performance of the model. The prediction values ​​of the STDN model deviate from the true values ​​and the residuals are unevenly distributed. The CNN introduced in STDN fails to fully capture the spatial characteristics of the traffic network, resulting in poor model prediction results. GCN is adopted in T-GCN to capture the spatial characteristics of the traffic network. When the traffic volume is between 200 and 300, the residual of T-GCN is large, which is attributed to the challenge of capturing GRU. STGCN, STGODE, and MTGNN improve GCN to extract more accurate spatial features. The prediction results of STGCN are significantly improved compared with T-GCN, STDN, etc. However, the deviation from the true value is more obvious in the late peak period. STGCN utilizes GCN in the spatial domain and adopts one-dimensional convolution operation in the temporal domain. However, due to the possibility of losing local information in the convolution operation, its ability to capture high-dimensional space, time, and spatiotemporal correlation is limited, which may lead to relatively poor performance. STGODE can effectively capture data trends. However, relying solely on node neighborhoods without considering the impact of other important relationships between nodes on the data makes it inaccurate when predicting the stage of drastic changes in traffic flow. MTGNN uses dynamically constructed graph structures to continuously learn spatial correlations. However, learning dynamic graphs will bring conceptual deviations - data distribution and relationships will continue to change over time. The relationship between nodes in the data may change over time, resulting in unstable prediction results. The above models are all based on GCN to extract spatial features and integrate temporal features under homogeneous maps. The use of heterogeneous graphs can overcome the limitations of homogeneous graphs in expressing spatial features. STREGCN introduces heterogeneous graphs and enhances GCN by convolving heterogeneous graphs, thereby enhancing its ability to capture spatial features. In addition, STREGCN's custom spatiotemporal convolution greatly improves the prediction ability of long-term data and fluctuating data, especially the prediction accuracy of frequently changing data such as traffic flow peaks. Incorporating spatiotemporal correlations in heterogeneous maps can further improve prediction performance.

[0127] Ablation experiment analysis:

[0128] In the STREGCN block, a STREGCN block includes two temporal blocks and a REGCN. The REGCN in the STREGCN block extracts spatial features, and the temporal block (temporal block) extracts temporal features. In order to verify the effectiveness of these two methods, we conducted an ablation experiment on STREGCN.

[0129] STREGCN_N_S and STREGCN_N_T represent the new models formed after removing REGCN and temporal blocks, respectively. We compare the prediction results of STREGCN with the other two ablation experimental models. Figure 6 (a) and (b) show that at 5-min and 30-min time steps, the MAE values ​​of STREGCN are 47.3 and 53.44, and the RMSE values ​​are 78.12 and 83.65, respectively. In addition, the MAE values ​​of STREGCN_N_T are 41.77 and 42.36, and the RMSE values ​​are 59.54 and 62.84, respectively. Compared with STREGCN_N_S, the MAE and RMSE of STREGCN are reduced by 22.85% and 29.36% on average, respectively. Compared with STREGCN_N_T, its MAE and RMSE are reduced by 7.89% and 6.52% on average, respectively. Both methods in the model help improve the prediction performance, among which the enhancement effect of REGCN is more significant.

[0130] After different modules are ablated, STREGCN should have the best effect, while STREGCN_N_S and STREGCN_N_T have poor effects. When predicting time series data with large volatility, both have defects to varying degrees. For STREGCN_N_T, although the model can provide rich spatial correlation features through heterogeneity graphs, it cannot extract temporal features well. In general, the prediction performance of the STREGCN model is better than the other two models, indicating that the two modules of the model can extract the spatial and temporal features of traffic flow, thereby using spatiotemporal features to improve prediction accuracy.

[0131] S104, predicting the traffic data to be predicted based on the trained traffic flow prediction model to obtain a prediction result.

[0132] The method for predicting future traffic flow based on heterogeneous graph obtains traffic network information and historical traffic flow, extracts the adjacency matrix A and node relationship set R of the traffic network information, and expands the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A', and constructs a heterogeneous graph based on the heterogeneous information matrix A' and the node relationship set; constructs a traffic flow prediction model, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, extracts spatial features through the STREGCN block, extracts temporal features through the time block, and predicts future traffic flow based on the temporal features and the spatial features through the output layer; constructs a training set based on the historical traffic flow, inputs the training set into the traffic flow prediction model for training, and obtains a trained traffic flow prediction model; predicts the traffic data to be predicted based on the trained traffic flow prediction model to obtain a prediction result. The problem that the traffic flow prediction model in the prior art cannot well explore the spatial correlation and temporal correlation of the traffic network is solved.

[0133] The present invention proposes a method for predicting future traffic flow based on heterogeneous graphs, aiming to capture temporal and spatial features, and fuse these two features together to improve the information expression ability of traffic graphs, thereby improving the accuracy of traffic flow prediction; in terms of spatial features, the adjacency matrix is ​​no longer used to construct the traditional isomorphic graph, but the edge information in the graph is fully utilized. Real-time weather conditions and road maintenance are embedded in the edge information. The node information and edge information in the isomorphic graph are reconstructed into a heterogeneous graph, the correlation between various influencing factors is enhanced, and the spatial features of the traffic graph are better extracted.

[0134] Figure 2 FIG. 1 is a diagram showing an architecture of a system embodiment of the present invention for predicting future traffic flow based on heterogeneous graphs; Figure 2 As shown, an embodiment of the present invention provides a system for predicting future traffic flow based on a heterogeneous graph, comprising the following steps:

[0135] An acquisition module 10 is used to acquire traffic network information and historical traffic flows, extract an adjacency matrix A and a node relationship set R of the traffic network information, and expand the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A', and construct a heterogeneous graph based on the heterogeneous information matrix A' and the node relationship set;

[0136] A construction module 20 is used to construct a traffic flow prediction model, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, spatial features are extracted through the STREGCN blocks, time features are extracted through the time block, and future traffic flow is predicted based on the time features and the spatial features through the output layer;

[0137] A training module 30, for constructing a training set based on the historical traffic flow, inputting the training set into the traffic flow prediction model for training, and obtaining a trained traffic flow prediction model;

[0138] The prediction module 40 is used to predict the traffic data to be predicted based on the trained traffic flow prediction model to obtain a prediction result.

[0139] The system for predicting future traffic flow based on heterogeneous graph of the present invention obtains traffic network information and historical traffic flow through acquisition module 10, extracts adjacency matrix A and node relationship set R of the traffic network information, and expands the values ​​in adjacency matrix A to obtain a heterogeneous information matrix A', and constructs a heterogeneous graph based on the heterogeneous information matrix A' and the node relationship set; constructs a traffic flow prediction model through construction module 20, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, extracts spatial features through STREGCN blocks, extracts temporal features through the time block, and predicts future traffic flow based on the temporal features and the spatial features through the output layer; constructs a training set based on the historical traffic flow through training module 30, inputs the training set into the traffic flow prediction model for training, and obtains a trained traffic flow prediction model; predicts the traffic data to be predicted based on the trained traffic flow prediction model through prediction module 40 to obtain a prediction result. The method for predicting future traffic flow based on heterogeneous graph solves the problem that the traffic flow prediction model in the prior art cannot explore the spatial correlation and temporal correlation of the traffic network well.

[0140] Figure 7 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention, such as Figure 7 As shown, the electronic device 50 includes: a processor 501 (processor), a memory 502 (memory) and a bus 503;

[0141] The processor 501 and the memory 502 communicate with each other via the bus 503;

[0142] The processor 501 is used to call the program instructions in the memory 502 to execute the methods provided by the above-mentioned method embodiments, for example, including: obtaining traffic network information and historical traffic flow, extracting the adjacency matrix A and the node relationship set R of the traffic network information, and expanding the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A', and constructing a heterogeneous graph based on the heterogeneous information matrix A' and the node relationship set; constructing a traffic flow prediction model, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, extracting spatial features through the STREGCN block, extracting time features through the time block, and predicting future traffic flow based on the time features and the spatial features through the output layer; constructing a training set based on the historical traffic flow, inputting the training set into the traffic flow prediction model for training, and obtaining a trained traffic flow prediction model; predicting the traffic data to be predicted based on the trained traffic flow prediction model to obtain a prediction result.

[0143] The present embodiment provides a non-transitory computer-readable storage medium, which stores computer instructions. The computer instructions enable a computer to execute the methods provided by the above-mentioned method embodiments, for example, including: obtaining traffic network information and historical traffic flow, extracting the adjacency matrix A and the node relationship set R of the traffic network information, and expanding the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A', and constructing a heterogeneous graph based on the heterogeneous information matrix A' and the node relationship set; constructing a traffic flow prediction model, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, extracting spatial features through the STREGCN block, extracting temporal features through the time block, and predicting future traffic flow based on the temporal features and the spatial features through the output layer; constructing a training set based on the historical traffic flow, inputting the training set into the traffic flow prediction model for training, and obtaining a trained traffic flow prediction model; predicting the traffic data to be predicted based on the trained traffic flow prediction model to obtain a prediction result.

[0144] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk, etc., various storage media that can store program codes.

[0145] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.

[0146] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0147] Although the present invention has been described in detail above by general description and specific embodiments, it is obvious to those skilled in the art that some modifications or improvements can be made to the present invention. Therefore, these modifications or improvements made without departing from the spirit of the present invention all belong to the scope of protection claimed by the present invention.

Claims

1. A method for predicting future traffic flow based on heterogeneous graphs, characterized in that: The method specifically comprises: Acquire traffic network information and historical traffic flow, extract the adjacency matrix A and the node relationship set R of the traffic network information, and expand the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A′, and construct a heterogeneous graph based on the heterogeneous information matrix A′ and the node relationship set, including: Construct a point set V in a heterogeneous graph based on detectors on the road that meet preset conditions; Construct edge set E in heterogeneous graph based on the relationship between detectors; Construct the node relationship set R in the heterogeneous graph based on the distance relationship, road type relationship, and accessibility relationship between roads; Based on different relationship types r∈R, the connectivity between different nodes in the heterogeneous graph is obtained; Construct a heterogeneous relationship information matrix A′ based on the connectivity between different nodes in the heterogeneous graph; Constructing a traffic flow prediction model, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, extracting spatial features through the STREGCN block, extracting temporal features through the time block, and predicting future traffic flow based on the temporal features and the spatial features through the output layer; Predict future traffic flow through formula (2); Formula (2); Where, X (2) is the data processed by two STREGCN blocks, Γ is the temporal convolution kernel, * T is the temporal convolution operation, W and b are the learnable parameters and bias terms of the output layer respectively; Constructing a training set based on the historical traffic flow, inputting the training set into the traffic flow prediction model for training, and obtaining a trained traffic flow prediction model; The traffic data to be predicted is predicted based on the trained traffic flow prediction model to obtain a prediction result.

2. The method for predicting future traffic flow based on heterogeneous graph according to claim 1 is characterized in that: The spatial features are extracted by the STREGCN block, including: The information in the heterogeneous relationship information matrix A′ is used to classify different edge types in the heterogeneous graph to obtain sets of multiple groups of nodes, and the nodes in the same set have the same edge relationship; Based on the target node, the adjacent nodes corresponding to the target node are sampled to obtain feature information of the adjacent nodes, the feature information is converged, and the feature information of each adjacent node is fused with the feature information of the target node to obtain the spatial feature.

3. The method for predicting future traffic flow based on heterogeneous graph according to claim 1 is characterized in that: The extracting time features through the time block includes: The output of each subsequent layer is obtained based on the unknown input of the previous layer through one-dimensional causal convolution; After convolution and activation operations are performed on the historical traffic flow through the gated linear unit, the final output result of the layer is controlled by activating the output gate to extract the temporal features; The temporal correlation of historical traffic flows is captured and formed into temporal blocks through one-dimensional causal convolution and gated linear units.

4. The method for predicting future traffic flow based on heterogeneous graph according to claim 3 is characterized in that: The extracting of time features through the time block further includes: The time characteristics are calculated by formula (1); Where, X (l) is the network input of the current layer, h (l) is the hidden layer information output of the current layer, f i (X) is the convolution operation, σ is the sigmoid nonlinear activation function, is the convolution operator.

5. The method for predicting future traffic flow based on heterogeneous graph according to claim 1, characterized in that: The step of constructing a training set based on the historical traffic flow, inputting the training set into the traffic flow prediction model for training, and obtaining a trained traffic flow prediction model includes: Dividing the historical traffic flow into a training set, a validation set, and a test set; Training the traffic flow prediction model based on the training set; Performing a performance evaluation on the trained traffic flow prediction model based on the validation set to obtain a traffic flow prediction model that meets performance requirements; The prediction result of the traffic flow prediction model that meets the performance condition is evaluated based on the test set to obtain an evaluation index corresponding to the traffic flow prediction model.

6. A system for predicting future traffic flow based on heterogeneous graphs, characterized in that: include: An acquisition module is used to acquire traffic network information and historical traffic flow, extract an adjacency matrix A and a node relationship set R of the traffic network information, and expand the values ​​in the adjacency matrix A to obtain a heterogeneous information matrix A′, and construct a heterogeneous graph based on the heterogeneous information matrix A′ and the node relationship set; The acquisition module is also used for: Construct a point set V in a heterogeneous graph based on detectors on the road that meet preset conditions; Construct edge set E in heterogeneous graph based on the relationship between detectors; Construct the node relationship set R in the heterogeneous graph based on the distance relationship, road type relationship, and accessibility relationship between roads; Based on different relationship types r∈R, the connectivity between different nodes in the heterogeneous graph is obtained; Construct a heterogeneous relationship information matrix A′ based on the connectivity between different nodes in the heterogeneous graph; A construction module, used for constructing a traffic flow prediction model, wherein the traffic flow prediction model includes two STREGCN blocks, a time block and an output layer, extracting spatial features through the STREGCN blocks, extracting temporal features through the time block, and predicting future traffic flow based on the temporal features and the spatial features through the output layer; A training module, used for constructing a training set based on the historical traffic flow, inputting the training set into the traffic flow prediction model for training, and obtaining a trained traffic flow prediction model; A prediction module, used to predict the traffic data to be predicted based on the trained traffic flow prediction model to obtain a prediction result; Predict future traffic flow through formula (2); Where, X (2) is the data processed by two STREGCN blocks, Γ is the temporal convolution kernel, * T is a temporal convolution operation, W and b are the learnable parameters and bias terms of the output layer, respectively.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.