A traffic flow prediction method based on a space-time graph network
By constructing a spatiotemporal graph network model and integrating spatial and temporal attention mechanisms to optimize graph convolution and long short-term memory models, the problem of insufficient consideration of spatiotemporal correlation and differences in traffic flow prediction is solved, achieving higher accuracy and better interpretability in traffic flow prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2026-03-20
AI Technical Summary
Existing traffic flow prediction models fail to fully consider the spatiotemporal correlations and differences between traffic nodes, resulting in insufficient prediction accuracy and poor model interpretability.
A traffic flow prediction method based on spatiotemporal graph networks is constructed. By integrating spatial attention mechanism to optimize the graph convolution model and temporal attention mechanism to optimize the long short-term memory model, a spatiotemporal graph model is constructed to extract the spatiotemporal features of traffic flow for prediction.
It achieves accurate prediction of road network traffic, improves the interpretability and prediction accuracy of the model, and can better capture the spatiotemporal characteristics of traffic flow.
Smart Images

Figure CN115796007B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a traffic flow prediction method based on space-time graph network. BACKGROUND
[0002] With the vigorous development of economic society, the number of urban vehicles is increasing year by year, which greatly stimulates the demand for private car travel of citizens. The supply of urban road resources is difficult to meet the huge demand for travel, resulting in the occurrence of road traffic congestion. In order to alleviate the problem of traffic congestion, researchers propose to establish intelligent transportation system (ITS) to manage and control urban traffic. Traffic flow is an important parameter in urban traffic. Accurate prediction of traffic flow can provide urban traffic managers with information about the future status of urban road network, which is the basis for the establishment of intelligent transportation system. Traffic flow prediction is essentially to mine the internal correlation characteristics of historical data of road flow, and to predict future traffic flow based on this.
[0003] Traffic flow has correlation characteristics in time and space dimensions: the past road traffic flow distribution will have an impact on the future road state; the characteristics of adjacent nodes and the characteristics of connecting roads will have an impact on the transfer process of vehicles between nodes. These factors will all have an impact on the change process of road node traffic flow.
[0004] In the field of traffic flow prediction, scholars at home and abroad have carried out a lot of work. The mainstream prediction framework is divided into two categories: traditional mathematical statistics model and nonlinear theory prediction machine learning model. Among them, the mathematical statistics model mainly introduces Kalman filter, ARIMA regression model, gray theory model, chaos theory model and other models based on statistical learning framework with certain mathematical theory basis for prediction. The advantage of this method is that the constructed model has strong interpretability and is easy for people to understand, but its prediction performance depends on the accuracy of the model.
[0005] Machine learning model is the product of the vigorous development of contemporary artificial intelligence and computer science, which relies on various data-driven learning models such as artificial recurrent neural network, convolutional neural network, graph convolution network and attention mechanism to associate and capture input data and make prediction. The characteristic of this kind of model is that the model directly obtains information from data, and the interpretability is generally poor, but the model performance is generally good. At the same time, many scholars have also noticed that traffic flow has the characteristics of space-time correlation, and have begun to use different models to extract its space-time characteristics. However, although many methods have considered the space-time characteristics of road network traffic volume, the research often treats the associated road segments in a homogeneous way, ignoring the fact that the correlation between different nodes is strong or weak due to some geographical, physical and social factors. For example, when there is a direct path connection between multiple traffic nodes, past research often treats the correlation between them as the same when defining the adjacency matrix or traffic volume feature matrix, ignoring the fact that the traffic volume observed at the last time may not reach the target node within the corresponding time interval due to the large distance between nodes. SUMMARY
[0006] Therefore, the embodiment of the present application provides a traffic flow prediction method based on a space-time graph network, which can fully consider the internal correlation and node difference of the space-time characteristics of traffic flow, realize accurate prediction of road network traffic, and the model has better interpretability than existing models.
[0007] One aspect of the embodiment of the present application provides a traffic flow prediction method based on a space-time graph network, comprising:
[0008] Obtaining city traffic road network data and constructing a traffic flow feature matrix;
[0009] According to the feature matrix, the initial graph convolution model is optimized by fusing a space attention mechanism, and an optimized target graph convolution model is obtained; wherein the target graph convolution model is used to extract the spatial features in the input data;
[0010] According to the feature matrix, the initial long short-term memory model is optimized by fusing a time attention mechanism, and an optimized target long short-term memory model is obtained; wherein the target long short-term memory model is used to extract the time features in the input data;
[0011] The target graph convolution model and the target long short-term memory model are fused to construct a space-time graph model;
[0012] According to the space-time graph model, the traffic flow data to be predicted is predicted to obtain a traffic flow prediction result.
[0013] Optionally, the obtaining city traffic road network data and constructing a traffic flow feature matrix comprises:
[0014] According to the actual demand of the traffic road network to be predicted, the continuous time is divided into discrete time intervals, and the traffic road network information in each time interval is counted;
[0015] According to the network structure of the traffic road network, the road detectors are divided into topological nodes to obtain traffic road network nodes;
[0016] According to the topological relationship of the traffic road network nodes, the adjacency relationship between each node is analyzed, an adjacency matrix of the traffic network is generated, and the distance between adjacent nodes is counted;
[0017] According to the divided time intervals, the number of traffic flow vehicles of each traffic road network node in different time intervals is counted to generate a feature matrix of the traffic flow.
[0018] Optionally, the initial graph convolution model is optimized according to the feature matrix and a spatial attention mechanism to obtain an optimized target graph convolution model, including:
[0019] The initial graph convolution model is optimized in the spatial dimension by combining graph theory knowledge and deep learning knowledge;
[0020] Among them, at the level of the graph theory knowledge, the initial graph convolution model is optimized by a node distance improvement matrix and a step number improvement matrix from the traffic graph network itself;
[0021] At the level of the deep learning knowledge, the spatial attention mechanism is fused with the initial graph convolution model to optimize the initial graph convolution model.
[0022] Optionally, the calculation process of the node distance improvement matrix is:
[0023] For a source node and a target node on a graph, the source node is divided into a known node set, and the remaining nodes are divided into an unknown node set;
[0024] The minimum edge length between the nodes in the known node set and the nodes in the unknown node set is searched, and the nodes on one side of the path corresponding to the minimum edge length are added to the known node set, and the nodes at both ends of the minimum edge length are recorded;
[0025] The minimum edge length between the nodes in the known node set and the nodes in the unknown node set is repeatedly searched until the source node and the target node are contained at the same time;
[0026] The shortest path between the source node and the target node is output according to the traversal result;
[0027] The calculation formula of the node distance improvement matrix is:
[0028]
[0029] D i,j represent the distance between node v i and node v j , d(v i ,v j ) represents the shortest path length between node v i and node v j , d max represents the maximum value of the shortest path length between all nodes in the traffic road network;
[0030] The calculation process of the step number improvement matrix between nodes is as follows:
[0031] Solving the minimum transfer step number between all nodes in the traffic road network, the step number improvement matrix is established;
[0032] The calculation formula of the step number improvement matrix is as follows:
[0033]
[0034] Wherein, P i,j represents the step number between node v i and node v j ; p(v i ,v j ) represents the minimum step number when the vehicle transfers between node v i and node v j ; and p max represents the maximum value of the minimum step number between all nodes in the traffic road network.
[0035] Optionally, in the process of fusing the spatial attention mechanism with the initial graph convolution model, the calculation formula of the spatial attention matrix is as follows:
[0036]
[0037] Wherein, S1=W1·σ((X t W2)W3(X t W4) T +b)
[0038] Wherein, X t is the input traffic flow feature matrix; W1, W2, W3, W4 and b are parameter matrices learned through data-driven learning; σ represents the activation function used in the network; S′ 1i,j represents the spatial attention matrix; S1 represents the calculated spatial attention weight of the road network; i and j represent the numbers of road network nodes.
[0039] Optionally, the calculation formula of the optimized target graph convolution model is:
[0040] A' = A D P
[0041] H l = sigma (A' k * S'1H l-1 W l );
[0042] wherein A' represents the improved adjacency matrix; A represents the adjacency matrix of the road network node; represents the Hadamard product operation; D represents the road network distance improvement matrix; P represents the road network step improvement matrix; H represents the output of each layer; H l represents the output of the lth layer; W represents the weight of network training; sigma represents the activation function; A' k represents the k-order improved adjacency matrix.
[0043] Optionally, in the step of optimizing the initial long short-term memory model according to the feature matrix and fusing the time attention mechanism to obtain the optimized target long short-term memory model, the calculation formula of the time attention matrix is:
[0044] S2 = U1 * sigma ((X n U2) U3 (X n U4) T + b)
[0045]
[0046] wherein S2 represents the road network time attention matrix; U n , b represents the trainable parameter matrix; sigma represents the sigmiod activation function; X n represents the input feature matrix; S 2i,j represents the calculated time attention weight; S' 2i,j represents the normalized attention matrix; () T represents the matrix transposition.
[0047] Another aspect of the embodiment of the application further provides a traffic flow prediction device based on a space-time graph network, comprising:
[0048] A first module is configured to acquire city traffic road network data and construct a feature matrix of traffic flow;
[0049] A second module is configured to optimize an initial graph convolution model according to the feature matrix and fuse a space attention mechanism to obtain an optimized target graph convolution model; wherein the target graph convolution model is used to extract spatial features in input data.
[0050] The third module is configured to optimize an initial long short-term memory model by fusing a time attention mechanism according to the feature matrix, and obtain an optimized target long short-term memory model; wherein the target long short-term memory model is configured to extract time features in input data.
[0051] The fourth module is configured to fuse the target graph convolution model and the target long short-term memory model, and construct a spatio-temporal graph model.
[0052] The fifth module is configured to predict traffic flow data to be predicted according to the spatio-temporal graph model, and obtain a traffic flow prediction result.
[0053] Another aspect of the embodiment of the present application also provides an electronic device comprising a processor and a memory.
[0054] The memory is configured to store a program.
[0055] The processor executes the program to implement the method as described above.
[0056] The embodiment of the present application also discloses a computer program product or a computer program, which comprises computer instructions stored in a computer readable storage medium. A processor of a computer device can read the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to execute the method as described above.
[0057] The embodiment of the present application acquires urban traffic network data, constructs a feature matrix of traffic flow, optimizes an initial graph convolution model by fusing a space attention mechanism according to the feature matrix, and obtains an optimized target graph convolution model; wherein the target graph convolution model is configured to extract space features in input data; the initial long short-term memory model is optimized by fusing a time attention mechanism according to the feature matrix, and an optimized target long short-term memory model is obtained; wherein the target long short-term memory model is configured to extract time features in input data; the target graph convolution model and the target long short-term memory model are fused to construct a spatio-temporal graph model; and traffic flow data to be predicted is predicted according to the spatio-temporal graph model, and a traffic flow prediction result is obtained. The present application can fully consider the internal correlation and node difference of the spatio-temporal characteristics of traffic flow, accurately predict the traffic flow of a road network, and the model has better interpretability compared with existing models. BRIEF DESCRIPTION OF DRAWINGS
[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiment description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort on the basis of these drawings.
[0059] Figure 1 An improved GCN model architecture provided for the embodiments of the present application is shown in the following figure:
[0060] Figure 2 An improved LSTM model framework provided for the embodiments of the present application is shown in the following figure:
[0061] Figure 3 A fusion model STGM framework provided for the embodiments of the present application is shown in the following figure:
[0062] Figure 4 An overall step flowchart provided for the embodiments of the present application is shown in the following figure. DETAILED DESCRIPTION
[0063] In order to make the purposes, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0064] In view of the problems existing in the prior art, one aspect of the embodiments of the present application provides a traffic flow prediction method based on a space-time graph network, as shown in the following figure: Figure 4 The overall steps of the present application include:
[0065] Obtaining city traffic network data, constructing a feature matrix of traffic flow;
[0066] According to the feature matrix, the initial graph convolution model is optimized by fusing a space attention mechanism, and an optimized target graph convolution model is obtained; wherein the target graph convolution model is used to extract spatial features in the input data;
[0067] According to the feature matrix, the initial long short-term memory model is optimized by fusing a time attention mechanism, and an optimized target long short-term memory model is obtained; wherein the target long short-term memory model is used to extract time features in the input data;
[0068] Fusing the target graph convolution model and the target long short-term memory model, constructing a space-time graph model;
[0069] According to the space-time graph model, the traffic flow data to be predicted is predicted to obtain a traffic flow prediction result.
[0070] Optionally, the urban traffic road network data is acquired, and a feature matrix of traffic flow is constructed, including:
[0071] According to the actual demand of the traffic road network to be predicted, after dividing the continuous time into discrete time intervals, the traffic road network information in each time interval is counted;
[0072] According to the network structure of the traffic road network, the road detectors are divided into topological nodes to obtain traffic road network nodes;
[0073] According to the topological relationship of the traffic road network nodes, the adjacency relationship between each node is analyzed, an adjacency matrix of the traffic network is generated, and the distance between adjacent nodes is counted;
[0074] According to the divided time intervals, the number of traffic flow vehicles of each traffic road network node in different time intervals is counted to generate a feature matrix of traffic flow.
[0075] Optionally, the initial graph convolution model is optimized according to the feature matrix and a spatial attention mechanism to obtain an optimized target graph convolution model, including:
[0076] The initial graph convolution model is optimized in the spatial dimension by combining the graph theory knowledge and the deep learning knowledge;
[0077] Among them, at the level of the graph theory knowledge, the initial graph convolution model is optimized by a node distance improvement matrix and a step number improvement matrix from the traffic graph network itself;
[0078] At the level of the deep learning knowledge, the spatial attention mechanism is fused with the initial graph convolution model to optimize the initial graph convolution model.
[0079] Optionally, the calculation process of the node distance improvement matrix is:
[0080] For the source node and the target node on the graph, the source node is classified into a known node set, and the remaining nodes are classified into an unknown node set;
[0081] The minimum edge length between the nodes in the known node set and the nodes in the unknown node set is searched, and the nodes on one side of the path corresponding to the minimum edge length are added to the known node set, and the nodes at both ends of the minimum edge length are recorded;
[0082] The minimum edge length between the nodes in the known node set and the nodes in the unknown node set is repeatedly searched until the source node and the target node are contained at the same time;
[0083] According to the traversal result, the shortest path between the source node and the target node is outputted;
[0084] wherein the calculation formula of the inter-node distance improvement matrix is:
[0085]
[0086] D i,j represents the distance between node v i and node v j , d(v i ,v j ) represents the shortest path length between node v i and node v j , and d max represents the maximum value of the shortest path length between all nodes in the traffic road network;
[0087] The calculation process of the inter-node step number improvement matrix is:
[0088] The minimum transfer step number between all nodes in the traffic road network is solved to establish the step number improvement matrix.
[0089] wherein the calculation formula of the step number improvement matrix is:
[0090]
[0091] wherein P i,j represents the step number between node v i and node v j ; p(v i ,v j ) represents the minimum step number when a vehicle transfers between node v i and node v j ; and p max represents the maximum value of the minimum step number between all nodes in the traffic road network.
[0092] Optionally, in the process of fusing the spatial attention mechanism with the initial graph convolution model, the calculation formula of the spatial attention matrix is:
[0093]
[0094] wherein S1=W1·σ((X t W2)W3(X t W4) T +b)
[0095] wherein X t is an input traffic flow feature matrix; W1, W2, W3, W4, and b are parameter matrices learned through data-driven learning; σ represents an activation function used in the network; S′ 1i,jS1 represents the calculated spatial attention weight of the road network, and i and j represent the numbers of the nodes of the road network.
[0096] Optionally, the calculation formula of the optimized target graph convolution model is:
[0097] A' = A & D & P
[0098] H l = sigma (A' k & S'1H l-1 W l );
[0099] wherein A' represents the improved adjacency matrix, A represents the adjacency matrix of the nodes of the road network, & represents the Hadamard product operation, D represents the distance improvement matrix of the road network, P represents the step improvement matrix of the road network, H represents the output of each layer, H l represents the output of the lth layer, W represents the weight of network training, sigma represents the activation function, A' k represents the k-order improved adjacency matrix.
[0100] Optionally, in the step of optimizing the initial long short-term memory model according to the feature matrix by fusing the time attention mechanism to obtain the optimized target long short-term memory model, the calculation formula of the time attention matrix is:
[0101] S2 = U1 & sigma ((X n U2) U3(X n U4) T + b)
[0102]
[0103] wherein S2 represents the road network time attention matrix, U n , b represent the trainable parameter matrix, sigma represents the sigmiod activation function, X n represents the input feature matrix, S 2i,j represents the calculated time attention weight, S' 2i,j represents the normalized attention matrix, and () T represents the matrix transposition.
[0104] Another aspect of the embodiment of the application further provides a traffic flow prediction device based on a space-time graph network, comprising:
[0105] A first module is configured to acquire city traffic road network data and construct a feature matrix of traffic flow.
[0106] The second module is configured to optimize an initial graph convolution model by fusing a spatial attention mechanism according to the feature matrix, to obtain an optimized target graph convolution model; wherein the target graph convolution model is configured to extract spatial features in the input data.
[0107] The third module is configured to optimize an initial long short-term memory model by fusing a time attention mechanism according to the feature matrix, to obtain an optimized target long short-term memory model; wherein the target long short-term memory model is configured to extract time features in the input data.
[0108] The fourth module is configured to fuse the target graph convolution model and the target long short-term memory model, to construct a spatio-temporal graph model.
[0109] The fifth module is configured to predict the traffic flow data to be predicted according to the spatio-temporal graph model, to obtain a traffic flow prediction result.
[0110] Another aspect of the embodiment of the present application also provides an electronic device, comprising a processor and a memory.
[0111] The memory is configured to store a program.
[0112] The processor executes the program to realize the method as described above.
[0113] The embodiment of the present application also discloses a computer program product or a computer program, which comprises computer instructions stored in a computer readable storage medium. A processor of a computer device can read the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method as described above.
[0114] The specific working principle of the present application will be described in detail below in conjunction with the accompanying drawings of the specification:
[0115] In this embodiment, the model is applied to the PeMSD8 of the US highway data set, which is the highway data set of California, USA. The PeMSD8 is the aggregate data collected by the California Caltrans Performance Measurement System (PeMS) in the actual highway network. The traffic flow data in the network is counted at an interval of 30 seconds, and the counted features include traffic flow, average speed and occupancy. The data set also contains the location information of all collection nodes, which is conducive to the modeling of the spatial structure of the network.
[0116] The training process of the model will be introduced below taking the Figure 3 for example, including the following steps:
[0117] 1) For the target data set PeMSD8, obtain its basic road network information, including road network node traffic flow set data, traffic node adjacency relationship and distance information between nodes; and convert the node flow data into the target time interval. In this embodiment, the node flow data statistical interval is converted into 5 minutes.
[0118] 2) Define an improved GCN model, such as Figure 1 , including the following steps:
[0119] 2.1) Define the distance improvement matrix in the GCN model, and the calculation method is as follows:
[0120] First, the Dijkstra algorithm is used to greedily traverse the graph nodes to solve the shortest path, and the specific process is as follows:
[0121] 2.1.1) For the source node v o and the target node v t on the graph, v o is classified into the known node set V k , and the remaining nodes are classified into the unknown node set V u .
[0122] 2.1.2) Traverse to find the minimum edge length between the nodes in the known node set V k and the nodes in the unknown node set V u , and add the node on one side of the path V u to V k , and record the nodes at both ends of the edge.
[0123] 2.1.3) Repeat step 2.2) until V k contains v o and v t at the same time, and at this time, according to the traversal result, output the shortest path between v o and v t .
[0124] Based on this, the distance improvement matrix D∈R N×N is established, and the calculation method is as follows:
[0125]
[0126] Where d(v i ,v j ) represents the shortest path length between node v i and node v j , and d maxThe maximum value of the minimum transition steps between all nodes in the road network. The minimum transition steps between all nodes in the road network are divided by the maximum minimum transition steps in the road network to realize the normalization operation of the path length, and reasonably consider the relative size relationship of the shortest distance between all nodes.
[0127] 2.2) Define the step improvement matrix in the GCN, and the calculation method is as follows:
[0128] The minimum transition steps between all nodes in the road network are solved, and the process is similar to the shortest path between nodes. Based on this, the step improvement matrix P ∈ R N×N is established, and its calculation method is as follows:
[0129]
[0130] Where p(v i ,v j ) represents the minimum number of steps taken by the vehicle when transferring between node v i and node v j , and p max represents the maximum value of the minimum transition steps between all nodes in the road network.
[0131] 2.3) Define the space attention matrix, and the calculation method is as follows:
[0132] For a graph G containing N nodes, its space attention matrix S'1 ∈ R N×N The calculation method is as follows:
[0133] S1=W1·σ((X t W2)W3(X t W4) T +b)
[0134]
[0135] Where X t is the input traffic flow feature matrix, W1, W2, W3, W4 and b are parameter matrices learned through data-driven learning. σ represents the activation function used in the network. The physical meaning of the space attention mechanism is to iteratively calculate the target node flow and the data of other nodes in the road network, so as to find out the influence nodes with greater correlation with the target node flow, and give greater weight to these nodes to form the attention matrix. The introduction of the attention matrix enables the model to focus on these important influence nodes and mine the hidden spatial correlation between road network nodes.
[0136] 2.4) The calculation method of the improved GCN model is as follows:
[0137] A'=A⊙D⊙P
[0138] H l = σ(A' k ⊙ S'1H l-1 W l )
[0139] wherein A represents the adjacency matrix of the road network nodes, H represents the output of each layer, W represents the weight of network training, σ represents the activation function, A' represents the improved adjacency matrix, A' k represents the improved adjacency matrix of k order. From the operation expression of the graph convolution space domain, it can be seen that the GCN realizes the adaptive aggregation of the features of all nodes in the k order field of the road network, thereby generating the aggregated features of each node.
[0140] 3), define the improved LSTM model, such as Figure 2 , including the following steps:
[0141] 3.1), define the time attention matrix S'2∈R T×T , and its calculation method is as follows:
[0142] S2=U1·σ((X n U2)U3(X n U4) T +b)
[0143]
[0144] The parameter definition is similar to the spatial attention mechanism. The difference between the time attention mechanism and the spatial attention mechanism lies in the data dimension of their action. The time attention pays more attention to mining the sequence elements that play the greatest role in the input sequence, enhances the role of the sequence elements, and realizes better prediction performance.
[0145] 3.2), define the improved long short-term memory model (LSTM) to extract the time correlation characteristics of traffic flow data. The operation steps are:
[0146] i t ' = i t ⊙ S' 2i,j
[0147] f t = σ(W f [o t-1 , i t ] + b f )
[0148] n t = tanh(W n [o t-1 , i t ] + b n )
[0149] C t = sigma(W[o,i] + b) C [o t-1 ,i t ]+b C )
[0150] h t = C t x h t-1 +f t x n t
[0151] m t = sigma(W[o,i] + b) o [o t-1 ,i t ]+b o )
[0152] o t = m t x tanh(h t )
[0153] Wherein, sigma represents a sigmoid activation function operation;h t-1 , o t-1 It is the hidden state and output of the last time;I t , o t The current space-time input and output.
[0154] 4), define fusion model STGM, as Figure 3 , input sequence matrix X, first through the improved GCN module in the preliminary extraction of spatial correlation.Soon, the output of the GCN module will be input to the LSTM module, and the output of each node in the GCN module is used as a one-dimensional feature, and the LSTM module will extract the time correlation of the input sequence of each one-dimensional feature, and finally obtain the overall output Y of the space-time graph network model.
[0155] In order to iterate and optimize the model, the present application specifies the mean square error (Mean Square Error, MSE) as the loss function of the model.
[0156]
[0157] Wherein, y, is the actual value and the predicted value, and n is the number of predictions.
[0158] The entire process uses mean absolute error (Mean Absolute Error, MAE) and root mean square error (Root Mean Square Error, RMSE) as evaluation indicators.
[0159] The present application uses the first 80% of the experimental data to construct the training set and the validation set for model training and optimization, and the remaining 20% as the test set for model performance evaluation and horizontal comparison with the baseline model. The experimental results are shown in Table 1
[0160] Table 1
[0161]
[0162] Table 1 shows the comparison of STGM and other baseline models in MAE and RMSE, reflecting the actual gap between the predicted results and the true values of the model. Compared with the traditional mathematical statistical model VAR, the graph network model based on deep learning has higher prediction accuracy for time series, which shows that deep learning method has certain advantages in data-driven prediction model field, and the graph model combining spatial topological relationship modeling of road network has more outstanding performance, which also shows the necessity of traffic graph network analysis and modeling.
[0163] The comparison of the prediction results shows that the overall error of the spatio-temporal graph model under the MAE index is 16.83, and the overall error under the RMSE index is 25.94, which has higher prediction performance compared with other models.
[0164] In summary, the present application proposes a spatio-temporal graph model for traffic flow prediction. In order to reasonably consider the space-time characteristics of urban road network traffic flow, the present application improves the existing model from the perspective of traffic space-time characteristic modeling, and on this basis, proposes a new traffic flow prediction model.
[0165] Compared with the prior art, the present application has the following advantages: 1. The correction matrix is extracted from the spatial characteristics of the road network, and the corresponding elements of the adjacency matrix in the GCN are corrected, so that the model has the function of considering the heterogeneity in the road network. 2. The time attention mechanism is used to improve the LSTM, so that the model can better capture the time sequence characteristics in the traffic flow sequence. 3. On the basis of improving the model, two different models are fused, and a spatio-temporal graph model (Spatio-Temporal Graph Model, STGM) is proposed.
[0166] The model fuses the prediction advantages of GCN and LSTM, and adds an improved method to improve the prediction ability of the model. In order to test the prediction effect of the model, the present application carries out a series of comparative experiments on the PeMSD8 data set for analysis and verification, and the results show that the model has excellent prediction performance. Compared with the model proposed in the foregoing, the spatio-temporal graph network model proposed in the present application not only considers the traffic characteristics of the traffic network data, but also fuses the attention mechanism to mine the associated features hidden in the traffic flow data, and can realize higher prediction accuracy in the prediction task.
[0167] In some alternative embodiments, the functions / operations mentioned in the block diagrams can not occur in the order mentioned in the operation diagram. For example, depending on the functions / operations involved, two blocks shown in succession can actually be executed substantially simultaneously or the blocks can sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of the present application are provided by way of example, with the purpose of providing a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logical flows presented in the present application. Alternative embodiments are contemplated in which the order of various operations is changed and in which sub-operations described as part of larger operations are independently executed.
[0168] In addition, although the present application is described in the context of functional modules, it should be understood that, unless otherwise stated to the contrary, one or more of the functions and / or features described can be integrated in a single physical device and / or software module, or one or more functions and / or features can be implemented in separate physical devices or software modules. It can also be understood that a detailed discussion of the actual implementation of each module is unnecessary for an understanding of the present application. Rather, given the properties, functions and internal relationships of the various functional modules in the devices disclosed in the present application, the actual implementation of the module will be within the routine skill of an engineer, without undue experimentation. Therefore, those skilled in the art can implement the present application as set forth in the claims without undue experimentation using ordinary skill. It can also be understood that the disclosed specific concepts are merely illustrative and are not intended to limit the scope of the present application, which is determined by the full scope of the appended claims and their equivalents.
[0169] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the parts of the technical solutions that essentially contribute to the prior art or the parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0170] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a list of executable instructions for implementing logic functions, which can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus or device, such as a computer-based system, a system including a processor or other system that can fetch the instructions from the instruction execution system, apparatus or device and execute the instructions, or in conjunction with these instructions execution systems, apparatus or devices. For the purpose of this specification, the "computer-readable medium" can be any device that can contain, store, communicate, propagate or transport programs for use by or in connection with an instruction execution system, apparatus or device, or in conjunction with these instruction execution systems, apparatus or devices.
[0171] More specific examples (non-exhaustive list) of the computer-readable medium include the following: an electrical connection having one or more wires (electrical devices), a portable computer diskette (magnetic devices), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium can even be paper or other suitable medium on which the program can be printed, as the program can be electronically obtained, for example, by optical scanning of the paper or other medium, followed by editing, interpreting or otherwise processing, if necessary, in other suitable ways to be electronically obtained, and then stored in the computer memory.
[0172] It should be understood that aspects of the application can be implemented in hardware, software, firmware or a combination thereof. In the above embodiments, various steps or methods can be implemented in software or firmware which is stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, and in another embodiment, any of the following technologies, known in the art, can be used: a combination of discrete logic circuits having logic gates for implementing logic functions upon an application of data signals, application specific integrated circuits having logic gates, field programmable gate arrays (FPGA), or other components, in combination or as the case can be.
[0173] In the description of the present application, the terms "one embodiment", "some embodiments", "an example", "a specific example", or "some examples" are intended to mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. The illustrative appearances of the above terms in various places in the specification are not intended to exclude that the terms in other places mean the same or similar features, structures, materials, or characteristics. Furthermore, the particular features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0174] Although embodiments of the present application have been shown and described, it would be appreciated by those skilled in the art that changes can be made in these embodiments without departing from the principles and spirit of the application, the scope of which is defined in the claims and their equivalents.
[0175] The above is a specific description of the preferred embodiments of the present application, but the present application is not limited to the described embodiments, and those skilled in the art can make various equivalent modifications or replacements without departing from the spirit of the present application, and these equivalent modifications or replacements are all included in the scope defined by the claims of the present application.
Claims
1. A traffic flow prediction method based on spatiotemporal graph networks, characterized in that, include: Acquire urban traffic network data and construct a traffic flow feature matrix; Based on the feature matrix, the initial graph convolutional model is optimized by fusing a spatial attention mechanism to obtain the optimized target graph convolutional model; wherein, the target graph convolutional model is used to extract spatial features from the input data; Based on the feature matrix, the initial long short-term memory model was optimized by fusing a time attention mechanism to obtain the optimized target long short-term memory model; wherein, the target long short-term memory model is used to extract time features from the input data; By fusing the target graph convolutional model and the target long short-term memory model, a spatiotemporal graph model is constructed. Based on the spatiotemporal graph model, the traffic flow data to be predicted is used to obtain the traffic flow prediction result; The step of optimizing the initial graph convolutional model based on the feature matrix using a spatial attention mechanism to obtain the optimized target graph convolutional model includes: The initial graph convolution model is optimized by combining graph theory and deep learning knowledge in the spatial dimension. Specifically, at the level of graph theory knowledge, starting from the traffic graph network itself, an improved distance matrix between nodes and an improved step matrix are proposed to optimize the initial graph convolution model; At the level of deep learning knowledge, the spatial attention mechanism is fused with the initial graph convolution model to optimize the initial graph convolution model; The calculation process of the improved distance matrix between nodes is as follows: For the source node and the target node in the graph, the source node is assigned to the known node set, and the remaining nodes are assigned to the unknown node set. Traverse the set of known nodes to find the minimum side length between the nodes in the set of known nodes and the nodes in the set of unknown nodes, and add the nodes on one side of the path corresponding to the minimum side length to the set of known nodes, and record the nodes at both ends of the minimum side length; Repeatedly traverse the minimum edge length between nodes in the known node set and nodes in the unknown node set until both the source node and the target node are included; Output the shortest path between the source node and the target node based on the traversal results; The calculation process of the improved step matrix between nodes is as follows: Solve for the minimum number of transition steps between all nodes in the traffic network and establish an improved step matrix.
2. The traffic flow prediction method based on spatiotemporal graph networks according to claim 1, characterized in that, The process of acquiring urban traffic network data and constructing a traffic flow feature matrix includes: Based on the actual demand of the traffic network to be predicted, the continuous time is divided into discrete time intervals, and the traffic network information under each time interval is statistically analyzed. Based on the network structure of the traffic network, the road detectors are divided into topological nodes to obtain the traffic road network nodes; Based on the topological relationship of the traffic road network nodes, the adjacency relationship between each node is analyzed, the adjacency matrix of the traffic network is generated, and the distance between adjacent nodes is calculated. Based on the time intervals, the number of traffic flow vehicles at each traffic road network node in different time intervals is counted to generate a traffic flow feature matrix.
3. The traffic flow prediction method based on spatiotemporal graph networks according to claim 1, characterized in that, The formula for calculating the improved distance matrix between nodes is: Representative node and nodes The distance between them Representative node and nodes The shortest path length between them. This represents the maximum value of the shortest path length between all nodes in the transportation network; The formula for calculating the step improvement matrix is as follows: in, Representative node and nodes The number of steps between; Representing vehicles at nodes and nodes The minimum number of steps required to transition between them; and This represents the maximum value of the minimum number of steps between all nodes in a transportation network.
4. The traffic flow prediction method based on spatiotemporal graph networks according to claim 1, characterized in that, In the process of fusing the spatial attention mechanism with the initial graph convolution model, the formula for calculating the spatial attention matrix is as follows: in, in, It is the input traffic flow feature matrix; , , , as well as It is a parameter matrix obtained through data-driven learning; This represents the activation function used in the network; Represents the spatial attention matrix; The spatial attention weights calculated to represent the road network; , This represents the number of a road network node.
5. The traffic flow prediction method based on spatiotemporal graph networks according to claim 1, characterized in that, The calculation formula for the optimized target graph convolution model is as follows: ; in, This represents the improved adjacency matrix; The adjacency matrix representing the nodes of the road network; Represents the Hadamard product operation; Represents the road network distance improvement matrix; The matrix represents the improvement matrix for road network steps; H represents the output of each layer. Representing the The layer's output; W represents the weights used in network training; Represents the activation function; This represents the improved adjacency matrix of order k.
6. The traffic flow prediction method based on spatiotemporal graph networks according to claim 1, characterized in that, In the step of optimizing the initial long short-term memory model by fusing a time attention mechanism based on the feature matrix to obtain the optimized target long short-term memory model, the formula for calculating the time attention matrix is as follows: in, Represents the road network time attention matrix; b represents the trainable parameter matrix; Represents the sigmoid activation function; The feature matrix represents the input; This represents the calculated temporal attention weights; This represents the normalized attention matrix; This represents the transpose of a matrix.
7. An apparatus for implementing the traffic flow prediction method based on spatiotemporal graph networks as described in any one of claims 1-6, characterized in that, include: The first module is used to acquire urban traffic network data and construct a feature matrix of traffic flow. The second module is used to optimize the initial graph convolutional model by fusing a spatial attention mechanism based on the feature matrix, so as to obtain an optimized target graph convolutional model; wherein, the target graph convolutional model is used to extract spatial features from the input data; The third module is used to optimize the initial long short-term memory model by fusing a time attention mechanism based on the feature matrix, so as to obtain an optimized target long short-term memory model; wherein, the target long short-term memory model is used to extract time features from the input data; The fourth module is used to fuse the target graph convolutional model and the target long short-term memory model to construct a spatiotemporal graph model; The fifth module is used to predict the traffic flow data to be predicted based on the spatiotemporal graph model, and obtain the traffic flow prediction result.
8. An electronic device, characterized in that, Including the processor and memory; The memory is used to store programs; The processor executes the program to implement the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The storage medium stores a program that is executed by a processor to implement the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Highway freight volume prediction method and system based on deep learning network
CN112819213A
Space-time combined traffic flow prediction method and device
CN114529081A