Space-time synchronization traffic flow prediction method based on fusion type GraphSAGE

Compensated causal and spatial-temporal synchronous graph and multi-order spatial-temporal feature aggregation are constructed through the fusion GraphSAGE model, which captures the spatial-temporal dependencies and predicts multiple traffic nodes, and solves the poor prediction effect of existing models under the computing resource limitations and The problem of high resource consumption improves the efficiency and accuracy of traffic flow prediction.

CN119028152AInactive Publication Date: 2024-11-26NANTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411135786.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-11-26
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing traffic flow prediction model is difficult to capture the spatial and temporal dependencies and process multiple traffic nodes at the same time. Especially under the limitation of computing resources, the prediction effect of nodes lacking historical data is poor, and the model based on graph convolutional network is on large-scale traffic. High computing resources consumption in the network.

Method used

The spatial and temporal synchronous traffic flow prediction method based on the fusion GraphSAGE is adopted, and the compensatory causal spatiotemporal synchronous graph and multi-order spatiotemporal neighbor feature aggregation is used to achieve synchronous prediction of nodes with historical data and lack of historical data, and reduce the storage needs of computing equipment.

Benefits of technology

It significantly improves the efficiency and accuracy of traffic flow prediction, and can achieve efficient prediction of multiple traffic nodes under low computing resource requirements, solving the problems of space-time dependence and computing resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119028152A_ABST
    Figure CN119028152A_ABST
Patent Text Reader

Abstract

The invention discloses a fusion type GraphSAGE-based time-space synchronization traffic flow prediction method. The method comprises the steps of generating traffic flow data of a time sequence; constructing a compensation type space diagram according to the space adjacency diagram and the space correlation diagram, combining the compensation type space diagram with the causal time diagram, and designing a compensation type causal time-space synchronization diagram; a fusion type GraphSAGE time-space synchronization model is constructed, and the model is divided into two parts: one part is based on a GraphSAGE principle, and traffic features of multi-order time-space neighbors of each node are aggregated through an attention mechanism; and the other part adopts a mean value aggregation method to capture the traffic characteristics of the multi-order space-time neighbors, and the two parts are combined to realize fusion prediction of the two types of traffic nodes. By designing the compensation type causal time-space synchronization graph, time-space synchronization modeling of traffic flow is achieved, the prediction precision of the model is improved, in addition, time-space features of traffic nodes with historical data and traffic nodes without historical data are aggregated at the same time based on fusion type GraphSAGE, and the prediction precision of the model is improved. The limitation that only a single type of traffic nodes can be predicted in an existing method is overcome.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of traffic prediction and relates to a spatiotemporal synchronous traffic flow prediction method based on fused GraphSAGE. Background Art

[0002] With the acceleration of urbanization and the rapid growth of the number of motor vehicles, traffic problems have become increasingly prominent. Traffic congestion and frequent accidents have become a major problem in the daily lives of urban residents. Among the solutions to this series of traffic problems, the Intelligent Transportation System (ITS) stands out for its scientificity and efficiency. Among them, traffic flow prediction, as a key link of ITS, can reveal the dynamic changes of traffic flow through in-depth analysis and forward-looking prediction of historical traffic data. With the help of ITS intelligent scheduling, vehicles in the road network can be scientifically guided to ensure smooth and orderly traffic flow, which is of great practical significance for solving traffic problems. In addition, accurate traffic flow prediction can also help optimize traffic network planning, improve the efficiency of traffic resource allocation, reduce congestion and accidents, and is an indispensable function of the intelligent transportation system. Therefore, how to build a more efficient traffic flow prediction model and improve its prediction performance has become the focus of current research.

[0003] When constructing a traffic flow prediction model, the following points need to be fully considered: (1) The dynamic nature of traffic flow is not only reflected in its continuity in time, but also in its interactivity in space. The traffic flow at a certain moment is not only affected by the previous moment, but also correlated with the flow of other traffic nodes. This spatiotemporal dependency needs to be fully captured; (2) The complexity and diversity of urban traffic networks require that the prediction model be able to cover different types of traffic nodes. Due to cost and technical limitations, it is impossible to deploy sensors at all traffic nodes. Therefore, the model needs to have fusion prediction capabilities, which can not only provide accurate predictions for nodes with sensors, but also reasonably model nodes without sensors; (3) Considering the resource limitations in practical applications, the model should pursue prediction accuracy while minimizing the requirements for computing device performance. Many current deep learning models have high requirements for computing resources when processing large-scale traffic data. How to reduce resource consumption while ensuring prediction results is an issue that needs to be considered when designing the model. An ideal traffic flow prediction model should be able to simultaneously capture spatiotemporal dependencies, fusion predictions for multiple nodes, and reduce dependence on high-performance computing devices.

[0004] With the rapid development of deep learning technology, graph convolutional networks (GCNs) have attracted widespread attention in the field of traffic flow prediction due to their excellent feature learning capabilities. At the same time, recurrent neural networks (RNNs) and their variants such as long short-term memory networks (LSTMs) and gated recurrent units (GRUs) have also played an important role in capturing the temporal dependencies of traffic time series. However, past traffic flow prediction methods often independently handle temporal and spatial associations. Although a few studies have attempted to model spatiotemporal synchronization, they generally rely on graph convolutional networks to extract features. This direct learning method allows the model to only predict traffic nodes with historical data, and is helpless for nodes that lack historical data. In addition, the prediction model based on graph convolutional networks needs to load the entire traffic network graph during both the training and prediction stages, which makes it difficult to perform small batch training in scenarios with a large number of traffic nodes, and thus places extremely high demands on the memory of computing devices. Therefore, how to effectively solve these problems has become an important research direction in the field of traffic flow prediction. Summary of the invention

[0005] Purpose of the invention: In order to solve the above problems, the present invention innovatively proposes a spatiotemporal synchronous traffic flow prediction method based on the fused GraphSAGE. This method can cleverly capture the temporal dynamics and spatial correlation in traffic flow data at the same time, and realize the synchronous prediction of traffic node traffic with and without historical data. It is worth mentioning that the modeling process of the present invention does not need to rely on a complete graph structure. This design significantly reduces the demand for storage space of computing devices, thereby significantly improving the prediction efficiency and accuracy of the model in practical applications.

[0006] Technical solution: A spatiotemporal synchronous traffic flow prediction method based on fused GraphSAGE, comprising the following steps:

[0007] Step 1) Collect traffic data in the road network through data collection equipment, remotely transmit and store it to the traffic data server, and generate time series traffic flow data according to the data collection time;

[0008] Step 2) Generate a spatial adjacency graph and a spatial adjacency matrix according to the location of the data acquisition equipment in the road network, and standardize the time series traffic flow data according to the Z-score method, and then divide it into a training set, a validation set, and a test set;

[0009] Step 3) Based on the time series traffic flow data, a dynamic time warping algorithm is used to construct a spatial correlation graph and a spatial correlation adjacency matrix, and based on the spatial adjacency matrix and the spatial correlation matrix, a compensatory spatial graph is constructed, and combined with the causal time graph, a compensatory causal space-time synchronization graph is designed;

[0010] Step 4) Construct a fused GraphSAGE spatiotemporal synchronization model, which is divided into two parts: the first part focuses on predicting the future traffic flow of traffic nodes with historical data. It is based on the GraphSAGE principle and aggregates the traffic characteristics of each node's multi-order spatiotemporal neighbors through the attention mechanism; the second part is responsible for predicting the future traffic flow of traffic nodes without historical data. It adopts the mean aggregation method and also captures the traffic characteristics of multi-order spatiotemporal neighbors. The two parts are organically combined to achieve fused prediction of the two types of traffic nodes;

[0011] Step 5) Use the training set to train the fused GraphSAGE spatiotemporal synchronization model, use the validation set to verify the training effect, and use the test set to test the prediction accuracy of the model.

[0012] Furthermore, the specific steps of collecting traffic data in the road network through data collection equipment in step 1), and remotely transmitting and storing it in the traffic data server are as follows: deploying N data collection equipment in the road network; taking five minutes as a time step, each data collection equipment collects traffic flow data once in each time step, including C traffic flow features, including the traffic flow, average vehicle speed, lane occupancy rate, etc. passing through the time step; the time span of the collection process is T, that is, it includes T time steps; the time series traffic data set finally transmitted remotely and stored in the traffic data server is

[0013] Furthermore, in step 2), a spatial adjacency graph and a spatial adjacency matrix are generated according to the position of the data acquisition device in the road network, and the time series traffic flow data is standardized according to the Z-score method, and then divided into a training set, a validation set, and a test set. The specific steps include:

[0014] Step 2-1: Generate a traffic node graph G = (V, E, A) according to the location of the data acquisition equipment in the road network SD ), where V is the set of traffic nodes, representing N collection devices deployed in the road network; E is the edge in the traffic node graph, representing the relationship between each traffic node; A SD Represents the spatial adjacency matrix in the graph structure; the adjacency matrix is ​​generated according to the distance relationship between the data acquisition devices, and its structure is The value of each element in the adjacency matrix is ​​defined as:

[0015]

[0016] Step 2-2: Use the Z-score method to analyze the time series traffic data X H After standardization, the calculation method is as follows: Where mean(X H ) indicates X HThe mean, std(X H ) represents X H The standard deviation of

[0017] Step 2-3: Transform the standardized traffic data X Z Divide into training set, validation set and data set in proportion.

[0018] Furthermore, in step 3), according to the time series traffic flow data, a dynamic time warping algorithm is used to construct a spatial correlation graph and a spatial correlation adjacency matrix, and based on the spatial adjacency matrix and the spatial correlation matrix, a compensatory spatial graph is constructed, and combined with the causal time graph, a compensatory causal space-time synchronization graph is designed. The specific process is as follows:

[0019] Step 3-1: When representing the graph structure, the method that relies solely on the spatial adjacency matrix has significant limitations, which may lead to the loss of key information. For example, although two nodes are not directly adjacent in physical space, their traffic flow patterns may show highly consistent change trends, indicating that there is a close correlation between them. Therefore, the modeling method that relies solely on the spatial adjacency matrix is ​​difficult to effectively capture this temporal and spatial correlation. In order to more comprehensively understand and analyze the temporal and spatial dependencies between traffic nodes, a dynamic time warping algorithm is introduced to measure the similarity of traffic flows between nodes. Based on time series traffic flow data, a spatial similarity matrix can be constructed. It is used to describe the spatiotemporal correlation between traffic nodes; for two time series P = (p1, p2, ..., p m ) and Q=(q1,q2,…,q n ), any two elements p i and q j The distance between ij =|p i -q j |, and the minimum distance between the two can be expressed as:

[0020]

[0021] The iterative calculation of the above formula can finally get p i and q j The dynamic regularization distance between them, thus the spatial similarity matrix A SS The elements of can be defined as:

[0022]

[0023] Step 3-2: In order to more comprehensively characterize the spatial correlation between traffic nodes, the spatial adjacency matrix A is integrated SD and the spatial similarity matrix A SS , construct the compensated spatial adjacency matrix The calculation method is:

[0024]

[0025] Step 3-3: In addition to the mutual influence in the spatial dimension, the traffic flow between nodes also shows a close correlation in the time dimension; therefore, in order to accurately model the dependency in the time dimension, it is particularly important to design a time graph; for two adjacent time steps in the time dimension, the state of the current time step is often affected by the previous time step, but the reverse is not true; a causal time graph can be constructed to describe this unidirectional time correlation, and its adjacency matrix It can be calculated by the following formula:

[0026]

[0027] In order to simplify the complexity of the model, an assumption is made that the associations of all nodes at different time steps are consistent; based on this assumption, the causal temporal adjacency matrix can be shared among different nodes to describe the connection relationship between time steps;

[0028] Step 3-4: According to the compensated spatial adjacency matrix A SC and the temporal causal adjacency matrix A TC , construct a compensatory causal spatiotemporal synchronization graph It contains 2 time steps, which can simultaneously model the temporal and spatial correlation of traffic flow sequences; A WST The main diagonal of SC , A SC ], represents the spatial adjacency relationship between nodes in each time step, A WST A in the lower right corner SC Filled, indicating the causal time connection between two time steps, the upper right corner is 0, indicating that the reverse causal time relationship does not hold, A WST The structure is:

[0029]

[0030] Furthermore, in step 4), a fused GraphSAGE spatiotemporal synchronization model is constructed, which is divided into two parts: the first part focuses on predicting the future traffic flow of traffic nodes with historical data. It is based on the GraphSAGE principle and aggregates the traffic characteristics of multi-order spatiotemporal neighbors of each node through the attention mechanism; the second part is responsible for predicting the future traffic flow of traffic nodes without historical data. It adopts the mean aggregation method and also captures the traffic characteristics of multi-order spatiotemporal neighbors. The two parts are organically combined to realize the fusion prediction of the two types of traffic nodes. The specific steps are as follows:

[0031] Step 4-1: In order to improve the expressiveness of the data and the ability of the model to capture complex patterns, it is necessary to perform a series of transformations and enhancements on the data. A key step is to transform the input data through a fully connected layer. Perform dimensional transformation; this step actually maps the original data X to a higher-dimensional space to obtain its high-dimensional representation This high-dimensional representation can capture more subtle and complex features in the original data, thereby enhancing the expressiveness of the data. In order to further improve the performance of the model in processing spatiotemporal data, spatiotemporal embedding is added to these high-dimensional data, which embeds the information of time and space into the representation of the data, so that the model can better understand and capture the spatiotemporal dependencies in the data. This embedding enables the model to more accurately capture the intrinsic connections and dynamic changes between data with temporal continuity and spatial correlation when processing data. Its expression is:

[0032]

[0033] in For spatial embedding, Embedded for time;

[0034] Step 4-2: For traffic nodes with historical data, construct a corresponding number of compensatory causal spatiotemporal synchronization graphs A according to the length of the input traffic flow sequence WST ; Assume that the length of the input historical time series is X = (X1, X2, ..., X T ), the time segments used to construct the compensatory causal spatiotemporal synchronization graph are (X1,X2),(X2,X3),…,(X T-1 ,X T ), so each A WST The shape of the traffic flow sequence fragment is The number of spatiotemporal synchronization graphs is M = T-1;

[0035] Step 4-3: For traffic nodes without historical data, since it is impossible to calculate the spatial similarity matrix based on historical traffic flow, the adjacency matrix A of its spatiotemporal synchronization graph is constructed by the spatial adjacency matrix and the temporal causal matrix. OST :

[0036]

[0037] Similar to A WST , forming each A OST The shape of the traffic flow sequence fragment is The number of spatiotemporal synchronization graphs is also M = T-1;

[0038] Step 4-4: For traffic nodes with historical data, a sophisticated method is used to analyze the relationship between nodes and neighbors. Specifically, for each traffic node and its 1- to K-order spatial neighbors, an attention mechanism is introduced to dynamically calculate the weights between node pairs based on the historical data between nodes. These weights not only represent the physical or geographical proximity between nodes, but more importantly, they reflect the mutual influence and correlation between nodes in the traffic network. The attention weight matrix is ​​denoted as E = (E 1 ,E 2 ,…,E K );

[0039] Step 4-4-1: Define a fully connected layer as f(x) = LeakyReLU(xW+b), where W and b are trainable parameters;

[0040] Step 4-4-2: Calculate node v using the scaled dot product method i and its k-th neighbor The similarity coefficient between:

[0041]

[0042] Step 4-4-3: Normalize the similarity coefficient through the softmax function to get node v i and its neighbors The attention coefficient between:

[0043]

[0044] Step 4-4-4: To further improve the accuracy of the attention coefficient, the multi-head attention mechanism is used to calculate P attention coefficients and take the average to obtain the node v i and its neighbors The weight matrix E between k , whose elements are calculated as:

[0045]

[0046] Step 4-5: Based on the GraphSAGE principle, design an aggregation function to capture the characteristics of neighbor nodes:

[0047]

[0048] where x Ni Represents the node v i The aggregation result of the spatiotemporal neighbors of j For any space-time neighbor v j Features, v i The set of space-time neighbors of ;

[0049] For traffic nodes with historical data, the attention mechanism is used to implement the aggregation function:

[0050]

[0051] where w ij For node v i and v j The attention coefficient between By A WST Decide;

[0052] For traffic nodes without historical data, the mean function is used as the aggregation function:

[0053]

[0054] Where MEAN(·) represents the mean function, By A OST Decide;

[0055] Each spatiotemporal synchronization aggregation result is pruned to reduce its dimension from 2N to N:

[0056]

[0057] For M = T-1 spatiotemporal synchronization graphs constructed based on the input sequence of length T, the aggregation results of each graph are concatenated:

[0058]

[0059] Step 4-6: Define a module named "Spatiotemporal Synchronous GraphSAGE Layer", which covers all operations from step 3-2 to step 3-5; to build more complex models, three such layers are connected in series; to expand the aggregation range of spatiotemporal data, increasing time steps are used in different GraphSAGE layers to form the temporal causal adjacency matrix; specifically, the distances between adjacent time steps are set to 1, 2, and 4 respectively when constructing the temporal causal graph in these three GraphSAGE layers; further, in each layer (kth layer), the k-th order spatial adjacency matrix is ​​used to construct the spatiotemporal synchronization graph, which means that in the spatial dimension, the kth layer will aggregate the feature information of the k-th order spatial neighbors;

[0060] The node v i The results of the 1st to 3rd order spatiotemporal aggregation are concatenated with the characteristics of the node itself:

[0061]

[0062] Step 4-7: Generate predictions using a two-layer fully connected layer to get the output of the fused GraphSAGE spatiotemporal synchronization model:

[0063]

[0064] in

[0065] Further, in step 5), the fused GraphSAGE spatiotemporal synchronization model is trained with the training set, the training effect is verified with the validation set, and the prediction accuracy of the model is tested with the test set. The specific steps are as follows:

[0066] Step 5-1: Determine the hyperparameters of the fused GraphSAGE spatiotemporal synchronization model, including the dimension of the input fully connected layer, the dimension of the hidden layer, and the dimension of the fully connected layer in the output layer; set the hyperparameters in the training process, including batch size, variable learning rate, step size, etc., and initialize various weight parameters;

[0067] Step 5-2: Use the training set to train the model, select the mean absolute error function as the loss function, iteratively update the weights in the model through model forward propagation, error back propagation, and stochastic gradient descent method, and use the validation set to verify the training effect of the model during the training process;

[0068] Step 5-3: When the number of iterations or the loss function reaches the preset value, the training is terminated and the test set is input into the trained model to test the prediction accuracy of the model.

[0069] Beneficial effects: The present invention is aimed at the fact that past traffic flow prediction methods often handle time correlation and spatial correlation independently, and generally rely on graph convolutional networks, which can only predict traffic nodes with historical data, and are helpless for nodes that lack historical data. In addition, the prediction model based on graph convolutional networks needs to load the entire traffic network graph in both the training and prediction stages, which makes it difficult to perform small batch training in scenarios with a large number of traffic nodes, and thus puts extremely high demands on the memory of the computing device, so the performance of the model has a large shortcoming. To this end, the present invention innovatively proposes a spatiotemporal synchronous traffic flow prediction method based on fused GraphSAGE. This method can cleverly capture the temporal dynamics and spatial correlation in traffic flow data at the same time, and realize the synchronous prediction of traffic nodes with historical data and those lacking historical data. It is worth mentioning that the modeling process of the present invention does not need to rely on a complete graph structure. This design significantly reduces the demand for storage space on the computing device, thereby significantly improving the prediction efficiency and accuracy of the model in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1 It is a schematic diagram of the steps of the spatiotemporal synchronous traffic flow prediction method based on the fused GraphSAGE of the present invention;

[0071] Figure 2 This is a structural diagram of the spatiotemporal synchronization model based on the fused GraphSAGE of the present invention;

[0072] Figure 3 This is a fitting graph of the spatiotemporal synchronization model test set data based on the fused GraphSAGE of the present invention. DETAILED DESCRIPTION

[0073] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings.

[0074] like Figure 2 As shown, a spatiotemporal synchronous traffic flow prediction method based on fused GraphSAGE includes the following steps:

[0075] Step 1) Collect traffic data in the road network through data collection equipment, remotely transmit and store it to the traffic data server, and generate time series traffic flow data according to the data collection time;

[0076] The specific steps of collecting traffic data in the road network through data collection equipment in step 1), and remotely transmitting and storing it in the traffic data server are as follows: deploying N data collection equipment in the road network; taking five minutes as a time step, each data collection equipment collects traffic flow data once in each time step, including C traffic flow features, including the traffic flow, average vehicle speed, lane occupancy rate, etc. passing through the time step; the time span of the collection process is T, that is, it includes T time steps; the time series traffic data set finally transmitted remotely and stored in the traffic data server is

[0077] Step 2) Generate a spatial adjacency graph and a spatial adjacency matrix according to the location of the data acquisition equipment in the road network, and standardize the time series traffic flow data according to the Z-score method, and then divide it into a training set, a validation set, and a test set;

[0078] In the step 2), a spatial adjacency graph and a spatial adjacency matrix are generated according to the position of the data acquisition device in the road network, and the time series traffic flow data is standardized according to the Z-score method, and then divided into a training set, a validation set, and a test set. The specific steps include:

[0079] Step 2-1: Generate a traffic node graph G = (V, E, A) according to the location of the data acquisition equipment in the road network SD ), where V is the set of traffic nodes, representing N collection devices deployed in the road network; E is the edge in the traffic node graph, representing the relationship between each traffic node; A SD Represents the spatial adjacency matrix in the graph structure; the adjacency matrix is ​​generated according to the distance relationship between the data acquisition devices, and its structure is The value of each element in the adjacency matrix is ​​defined as:

[0080]

[0081] Step 2-2: Use the Z-score method to analyze the time series traffic data X H After standardization, the calculation method is as follows: Where mean(X H ) indicates X H The mean, std(X H ) represents X H The standard deviation of

[0082] Step 2-3: Transform the standardized traffic data X Z The dataset is divided into training set, validation set and data set in a ratio of 6:2:2.

[0083] Step 3) Based on the time series traffic flow data, a dynamic time warping algorithm is used to construct a spatial correlation graph and a spatial correlation adjacency matrix, and based on the spatial adjacency matrix and the spatial correlation matrix, a compensatory spatial graph is constructed, and combined with the causal time graph, a compensatory causal space-time synchronization graph is designed;

[0084] In the step 3), according to the time series traffic flow data, a dynamic time warping algorithm is used to construct a spatial correlation graph and a spatial correlation adjacency matrix, and based on the spatial adjacency matrix and the spatial correlation matrix, a compensatory spatial graph is constructed, and combined with the causal time graph, a compensatory causal space-time synchronization graph is designed. The specific process is as follows:

[0085] Step 3-1: When representing the graph structure, the method that relies solely on the spatial adjacency matrix has significant limitations, which may lead to the loss of key information. For example, although two nodes are not directly adjacent in physical space, their traffic flow patterns may show highly consistent change trends, indicating that there is a close correlation between them. Therefore, the modeling method that relies solely on the spatial adjacency matrix is ​​difficult to effectively capture this temporal and spatial correlation. In order to more comprehensively understand and analyze the temporal and spatial dependencies between traffic nodes, a dynamic time warping algorithm is introduced to measure the similarity of traffic flows between nodes. Based on time series traffic flow data, a spatial similarity matrix can be constructed. It is used to describe the spatiotemporal correlation between traffic nodes; for two time series P = (p1, p2, ..., p m ) and Q=(q1,q2,…,q n ), any two elements p i and q j The distance between ij =|p i -q j|, and the minimum distance between the two can be expressed as:

[0086]

[0087] The iterative calculation of the above formula can finally get p i and q j The dynamic regularization distance between them, thus the spatial similarity matrix A SS The elements of can be defined as:

[0088]

[0089] Step 3-2: In order to more comprehensively characterize the spatial correlation between traffic nodes, the spatial adjacency matrix A is integrated SD and the spatial similarity matrix A SS , construct the compensated spatial adjacency matrix The calculation method is:

[0090]

[0091] Step 3-3: In addition to the mutual influence in the spatial dimension, the traffic flow between nodes also shows a close correlation in the time dimension; therefore, in order to accurately model the dependency in the time dimension, it is particularly important to design a time graph; for two adjacent time steps in the time dimension, the state of the current time step is often affected by the previous time step, but the reverse is not true; a causal time graph can be constructed to describe this unidirectional time correlation, and its adjacency matrix It can be calculated by the following formula:

[0092]

[0093] In order to simplify the complexity of the model, an assumption is made that the associations of all nodes at different time steps are consistent; based on this assumption, the causal temporal adjacency matrix can be shared among different nodes to describe the connection relationship between time steps;

[0094] Step 3-4: According to the compensated spatial adjacency matrix A SC and the temporal causal adjacency matrix A TC , construct a compensatory causal spatiotemporal synchronization graph It contains 2 time steps, which can simultaneously model the temporal and spatial correlation of traffic flow sequences; A WST The main diagonal of SC , A SC ], represents the spatial adjacency relationship between nodes in each time step, A WST A in the lower right corner SC Filled, indicating the causal time connection between two time steps, the upper right corner is 0, indicating that the reverse causal time relationship does not hold, AWST The structure is:

[0095]

[0096] Step 4) Construct a fused GraphSAGE spatiotemporal synchronization model, which is divided into two parts: the first part focuses on predicting the future traffic flow of traffic nodes with historical data. It is based on the GraphSAGE principle and aggregates the traffic characteristics of each node's multi-order spatiotemporal neighbors through the attention mechanism; the second part is responsible for predicting the future traffic flow of traffic nodes without historical data. It adopts the mean aggregation method and also captures the traffic characteristics of multi-order spatiotemporal neighbors. The two parts are organically combined to achieve fused prediction of the two types of traffic nodes;

[0097] In the step 4), a fused GraphSAGE spatiotemporal synchronization model is constructed. The model is divided into two parts: the first part focuses on predicting the future traffic flow of traffic nodes with historical data. It is based on the GraphSAGE principle and aggregates the traffic characteristics of each node's multi-order spatiotemporal neighbors through the attention mechanism; the second part is responsible for predicting the future traffic flow of traffic nodes without historical data. It adopts the mean aggregation method and also captures the traffic characteristics of multi-order spatiotemporal neighbors. The two parts are organically combined to realize the fusion prediction of the two types of traffic nodes. The specific steps are as follows:

[0098] Step 4-1: In order to improve the expressiveness of the data and the ability of the model to capture complex patterns, it is necessary to perform a series of transformations and enhancements on the data. A key step is to transform the input data through a fully connected layer. Perform dimensional transformation; this step actually maps the original data X to a higher-dimensional space to obtain its high-dimensional representation This high-dimensional representation can capture more subtle and complex features in the original data, thereby enhancing the expressiveness of the data. In order to further improve the performance of the model in processing spatiotemporal data, spatiotemporal embedding is added to these high-dimensional data, which embeds the information of time and space into the representation of the data, so that the model can better understand and capture the spatiotemporal dependencies in the data. This embedding enables the model to more accurately capture the intrinsic connections and dynamic changes between data with temporal continuity and spatial correlation when processing data. Its expression is:

[0099]

[0100] in For spatial embedding, Embedded for time;

[0101] Step 4-2: For traffic nodes with historical data, construct a corresponding number of compensatory causal spatiotemporal synchronization graphs A according to the length of the input traffic flow sequence WST ; Assume that the length of the input historical time series is X = (X1, X2, ..., X T ), the time segments used to construct the compensatory causal space-time synchronization graph are (X1,X2),(X2,X3),...,(X T-1 ,X T ), so each A WST The shape of the traffic flow sequence fragment is The number of spatiotemporal synchronization graphs is M = T-1;

[0102] Step 4-3: For traffic nodes without historical data, since it is impossible to calculate the spatial similarity matrix based on historical traffic flow, the adjacency matrix A of its spatiotemporal synchronization graph is constructed by the spatial adjacency matrix and the temporal causal matrix. OST :

[0103]

[0104] Similar to A WST , forming each A OST The shape of the traffic flow sequence fragment is The number of spatiotemporal synchronization graphs is also M = T-1;

[0105] Step 4-4: For traffic nodes with historical data, a sophisticated method is used to analyze the relationship between nodes and neighbors. Specifically, for each traffic node and its 1- to K-order spatial neighbors, an attention mechanism is introduced to dynamically calculate the weights between node pairs based on the historical data between nodes. These weights not only represent the physical or geographical proximity between nodes, but more importantly, they reflect the mutual influence and correlation between nodes in the traffic network. The attention weight matrix is ​​denoted as E = (E 1 ,E 2 ,…,E K );

[0106] Step 4-4-1: Define a fully connected layer as f(x) = LeakyReLU(xW+b), where W and b are trainable parameters;

[0107] Step 4-4-2: Calculate node v using the scaled dot product method i and its k-th neighbor The similarity coefficient between:

[0108]

[0109] Step 4-4-3: Normalize the similarity coefficient through the softmax function to get node vi and its neighbors The attention coefficient between:

[0110]

[0111] Step 4-4-4: To further improve the accuracy of the attention coefficient, the multi-head attention mechanism is used to calculate P attention coefficients and take the average to obtain the node v i and its neighbors The weight matrix E between k , whose elements are calculated as:

[0112]

[0113] Step 4-5: Based on the GraphSAGE principle, design an aggregation function to capture the characteristics of neighbor nodes:

[0114]

[0115] where x Ni Represents the node v i The aggregation result of the spatiotemporal neighbors of j For any space-time neighbor v j Features, v i The set of space-time neighbors of ;

[0116] For traffic nodes with historical data, the attention mechanism is used to implement the aggregation function:

[0117]

[0118] where w ij For node v i and v j The attention coefficient between By A WST Decide;

[0119] For traffic nodes without historical data, the mean function is used as the aggregation function:

[0120]

[0121] Where MEAN(·) represents the mean function, By A OST Decide;

[0122] Each spatiotemporal synchronization aggregation result is pruned to reduce its dimension from 2N to N:

[0123]

[0124] For M = T-1 spatiotemporal synchronization graphs constructed based on the input sequence of length T, the aggregation results of each graph are concatenated:

[0125]

[0126] Step 4-6: Define a module named "Spatiotemporal Synchronous GraphSAGE Layer", which covers all operations from step 3-2 to step 3-5; to build more complex models, three such layers are connected in series; to expand the aggregation range of spatiotemporal data, increasing time steps are used in different GraphSAGE layers to form the temporal causal adjacency matrix; specifically, the distances between adjacent time steps are set to 1, 2, and 4 respectively when constructing the temporal causal graph in these three GraphSAGE layers; further, in each layer (kth layer), the k-th order spatial adjacency matrix is ​​used to construct the spatiotemporal synchronization graph, which means that in the spatial dimension, the kth layer will aggregate the feature information of the k-th order spatial neighbors;

[0127] The node v i The results of the 1st to 3rd order spatiotemporal aggregation are concatenated with the characteristics of the node itself:

[0128]

[0129] Step 4-7: Generate predictions using a two-layer fully connected layer to get the output of the fused GraphSAGE spatiotemporal synchronization model:

[0130]

[0131] in

[0132] Step 5) Use the training set to train the fused GraphSAGE spatiotemporal synchronization model, use the validation set to verify the training effect, and use the test set to test the prediction accuracy of the model.

[0133] In the step 5), the fused GraphSAGE spatiotemporal synchronization model is trained with the training set, the training effect is verified with the validation set, and the prediction accuracy of the model is tested with the test set. The specific steps are as follows:

[0134] Step 5-1: Determine the hyperparameters of the fused GraphSAGE spatiotemporal synchronization model, including the dimension of the input fully connected layer, the dimension of the hidden layer, and the dimension of the fully connected layer in the output layer; set the hyperparameters in the training process, including batch size, variable learning rate, step size, etc., and initialize various weight parameters;

[0135] Step 5-2: Use the training set to train the model, select the mean absolute error function as the loss function, iteratively update the weights in the model through model forward propagation, error back propagation, and stochastic gradient descent method, and use the validation set to verify the training effect of the model during the training process;

[0136] Step 5-3: When the number of iterations or the loss function reaches the preset value, the training is terminated and the test set is input into the trained model to test the prediction accuracy of the model.

[0137] like Figure 3 As shown in the figure, a spatiotemporal synchronous traffic flow prediction method based on fused GraphSAGE can achieve excellent prediction results on the test set, and has good accuracy for traffic flow predictions for the next 15 minutes and the next 60 minutes.

[0138] The present invention is aimed at the fact that the traffic flow prediction methods in the past often handle time association and space association independently, and generally rely on graph convolutional networks, which can only predict traffic nodes with historical data, and are helpless for nodes that lack historical data. In addition, the prediction model based on graph convolutional networks needs to load the entire traffic network graph in both the training and prediction stages, which makes it difficult to perform small batch training in scenarios with a large number of traffic nodes, and thus puts extremely high requirements on the memory of the computing device, so the performance of the model has a large shortcoming. To this end, the present invention innovatively proposes a spatiotemporal synchronous traffic flow prediction method based on fused GraphSAGE. This method can cleverly capture the temporal dynamics and spatial correlation in traffic flow data at the same time, and realize the synchronous prediction of traffic nodes with historical data and those lacking historical data. It is worth mentioning that the modeling process of the present invention does not need to rely on a complete graph structure. This design significantly reduces the demand for storage space of computing devices, thereby significantly improving the prediction efficiency and accuracy of the model in practical applications.

[0139] The above description is only a preferred implementation of the present invention in a traffic artery or highway data set. The protection scope of the present invention is not limited to the above implementation. Any equivalent modifications and changes made by ordinary technicians in this field based on the contents disclosed by the present invention should be included in the protection scope recorded in the claims.

Claims

1. A spatiotemporal synchronous traffic flow prediction method based on fused GraphSAGE, characterized by: The method comprises the following steps: Step 1) Collect traffic data in the road network through data collection equipment, remotely transmit and store it to the traffic data server, and generate time series traffic flow data according to the data collection time; Step 2) Generate a spatial adjacency graph and a spatial adjacency matrix according to the location of the data acquisition equipment in the road network, and standardize the time series traffic flow data according to the Z-score method, and then divide it into a training set, a validation set, and a test set; Step 3) Based on the time series traffic flow data, a dynamic time warping algorithm is used to construct a spatial correlation graph and a spatial correlation adjacency matrix, and based on the spatial adjacency matrix and the spatial correlation matrix, a compensatory spatial graph is constructed, and combined with the causal time graph, a compensatory causal space-time synchronization graph is designed; Step 4) Construct a fused GraphSAGE spatiotemporal synchronization model, which is divided into two parts: the first part focuses on predicting the future traffic flow of traffic nodes with historical data. It is based on the GraphSAGE principle and aggregates the traffic characteristics of each node's multi-order spatiotemporal neighbors through the attention mechanism; The second part is responsible for predicting the future traffic flow of traffic nodes without historical data. It adopts the mean aggregation method and also captures the traffic characteristics of multi-order spatiotemporal neighbors. The two parts are organically combined to achieve fusion prediction of two types of traffic nodes. Step 5) Use the training set to train the fused GraphSAGE spatiotemporal synchronization model, use the validation set to verify the training effect, and use the test set to test the prediction accuracy of the model.

2. The spatiotemporal synchronous traffic flow prediction method based on the fused GraphSAGE according to claim 1 is characterized by: The specific steps of collecting traffic data in the road network through data collection equipment in step 1), and remotely transmitting and storing it in the traffic data server are as follows: deploying N data collection equipment in the road network; taking five minutes as a time step, each data collection equipment collects traffic flow data once in each time step, including C traffic flow features, including the traffic flow, average vehicle speed, lane occupancy rate, etc. passing through the time step; the time span of the collection process is T, that is, it includes T time steps; the time series traffic data set finally transmitted remotely and stored in the traffic data server is 3. The spatiotemporal synchronous traffic flow prediction method based on the fused GraphSAGE according to claim 1 is characterized by: The specific process in step 2) includes: Step 1-1: Generate a traffic node graph G = (V, E, A) according to the location of the data acquisition equipment in the road network SD ), where V is the set of traffic nodes, representing N collection devices deployed in the road network; E is the edge in the traffic node graph, representing the relationship between each traffic node; A SD Represents the spatial adjacency matrix in the graph structure; the adjacency matrix is ​​generated according to the distance relationship between the data acquisition devices, and its structure is The value of each element in the adjacency matrix is ​​defined as: Step 1-2: Use the Z-score method to analyze the time series traffic data X H After standardization, the calculation method is as follows: Where mean(X H ) indicates X H The mean, std(X H ) represents X H The standard deviation of Step 1-3: Transform the standardized traffic data X Z Divide into training set, validation set and data set in proportion.

4. The spatiotemporal synchronous traffic flow prediction method based on the fused GraphSAGE according to claim 1 is characterized by: The detailed steps of step 3) are: Step 2-1: Construct a spatial similarity matrix based on time series traffic flow data It is used to describe the spatiotemporal correlation between traffic nodes; for two time series P = (p1, p2, ..., p m ) and Q=(q1,q2,…,q n ), any two elements p i and q j The distance between ij =|p i -q j |, and the minimum distance between the two is expressed as: The iterative calculation of the above formula finally obtains p i and q j The dynamic regularization distance between them, thus the spatial similarity matrix A SS The elements of are defined as: Step 2-2: Fusion spatial adjacency matrix A SD and the spatial similarity matrix A SS , construct the compensated spatial adjacency matrix The calculation method is: Step 2-3: Construct a causal time graph to describe this unidirectional temporal correlation, whose adjacency matrix Calculated by the following formula: The associations of all nodes at different time steps are consistent; based on this assumption, the causal temporal adjacency matrix can be shared among different nodes to describe the connection relationship between time steps; Step 2-4: According to the compensated spatial adjacency matrix A SC and the temporal causal adjacency matrix A TC , construct a compensatory causal spatiotemporal synchronization graph It contains 2 time steps, which can simultaneously model the temporal and spatial correlation of traffic flow sequences; A WST The main diagonal of SC , A SC ], represents the spatial adjacency relationship between nodes in each time step, A WST A in the lower right corner SC Filled, indicating the causal time connection between two time steps, the upper right corner is 0, indicating that the reverse causal time relationship does not hold, A WST The structure is:

5. The spatiotemporal synchronous traffic flow prediction method based on the fused GraphSAGE according to claim 1 is characterized by: The specific steps of step 4) to construct the spatiotemporal synchronous GraphSAGE model are as follows: Step 3-1: Input data through the fully connected layer Perform dimensional transformation; This step actually maps the original data X into a higher-dimensional space to obtain its high-dimensional representation Adding spatiotemporal embedding to high-dimensional data, the expression is: in For spatial embedding, Embedded for time; Step 3-2: For traffic nodes with historical data, construct a corresponding number of compensatory causal spatiotemporal synchronization graphs A according to the length of the input traffic flow sequence WST ; Assume that the length of the input historical time series is X = (X1, X2, ..., X T ), the time segments used to construct the compensatory causal spatiotemporal synchronization graph are (X1,X2),(X2,X3),…,(X T-1 ,X T ), so each A WST The shape of the traffic flow sequence fragment is The number of spatiotemporal synchronization graphs is M = T-1; Step 3-3: For traffic nodes without historical data, since it is impossible to calculate the spatial similarity matrix based on historical traffic flow, the adjacency matrix A of its spatiotemporal synchronization graph is constructed by the spatial adjacency matrix and the temporal causal matrix. OST : Similar to A WST , forming each A OST The shape of the traffic flow sequence fragment is The number of spatiotemporal synchronization graphs is also M = T-1; Step 3-4: For traffic nodes with historical data, an attention mechanism is introduced for each traffic node and its 1 to K order spatial neighbors to dynamically calculate the weights between node pairs based on the historical data between nodes; The attention weight matrix is ​​recorded as E = (E 1 ,E 2 ,…,E K ); Step 3-5: Based on the GraphSAGE principle, design an aggregation function to capture the characteristics of neighbor nodes: where x Ni Represents the node v i The aggregation result of the spatiotemporal neighbors of j For any space-time neighbor v j Features, v i The set of space-time neighbors of ; For traffic nodes with historical data, the attention mechanism is used to implement the aggregation function: where w ij For node v i and v j The attention coefficient between By A WST Decide; For traffic nodes without historical data, the mean function is used as the aggregation function: Where MEAN(·) represents the mean function, By A OST Decide; Each spatiotemporal synchronization aggregation result is pruned to reduce its dimension from 2N to N: For M = T-1 spatiotemporal synchronization graphs constructed based on the input sequence of length T, the aggregation results of each graph are concatenated: Step 3-6: Define a module named "Spatiotemporal Synchronous GraphSAGE Layer", which covers all operations from step 3-2 to step 3-5; connect three spatiotemporal synchronous GraphSAGE layers in series; use increasing time steps in different GraphSAGE layers to form the temporal causal adjacency matrix; when constructing the temporal causal graph, the distances between adjacent time steps of these three GraphSAGE layers are set to 1, 2, and 4 respectively; in each layer, use the k-th order spatial adjacency matrix to construct the spatiotemporal synchronous graph, which means that in the spatial dimension, the k-th layer will aggregate the feature information of the k-th order spatial neighbors; The node v i The results of the 1st to 3rd order spatiotemporal aggregation are concatenated with the characteristics of the node itself: Step 3-7: Generate predictions using a two-layer fully connected layer to get the output of the fused GraphSAGE spatiotemporal synchronization model: in 6. The spatiotemporal synchronous traffic flow prediction method based on the fused GraphSAGE according to claim 5 is characterized by: The detailed process of steps 3-4 is as follows: Step 4-1: Define a fully connected layer as f(x) = LeakyReLU(xW+b), where W and b are trainable parameters; Step 4-2: Calculate node v using scaled dot product method i and its k-th neighbor The similarity coefficient between: Step 4-3: Normalize the similarity coefficient through the softmax function to get node v i and its neighbors The attention coefficient between: Step 4-4: To further improve the accuracy of the attention coefficient, the multi-head attention mechanism is used to calculate P attention coefficients and take the average to obtain the node v i and its neighbors The weight matrix E between k , whose elements are calculated as:

7. The spatiotemporal synchronous traffic flow prediction method based on the fused GraphSAGE according to claim 1 is characterized by: The specific steps of step 5) are as follows: Step 5-1: Determine the hyperparameters of the fused GraphSAGE spatiotemporal synchronization model, including the dimension of the input fully connected layer, the dimension of the hidden layer, and the dimension of the fully connected layer in the output layer; set the hyperparameters during the training process, including batch size, variable learning rate, step size, and initialize various weight parameters; Step 5-2: Use the training set to train the model, select the mean absolute error function as the loss function, iteratively update the weights in the model through model forward propagation, error back propagation, and stochastic gradient descent method, and use the validation set to verify the training effect of the model during the training process; Step 5-3: When the number of iterations or the loss function reaches the preset value, the training is terminated and the test set is input into the trained model to test the prediction accuracy of the model.