Traffic flow prediction method based on dynamic multi-graph space-time synchronization network
Through the dynamic multi-graph spatiotemporal synchronization network method, combined with external data, a multi-layer spatiotemporal synchronization layer is constructed, which solves the unilateral capture problem of time and space dependence in the existing traffic flow prediction method, improves the prediction accuracy, and reflects the influence of external factors. .
Patent Information
- Application Number
- CN202411135781.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-11-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing traffic flow prediction methods are difficult to capture the time dependence and spatial dependence of traffic flow data at the same time, and ignore the influence of external factors, resulting in insufficient prediction accuracy.
Using a method based on a dynamic multi-graph spatiotemporal synchronization network, a multi-layer dynamic spatiotemporal synchronization layer is constructed to synchronize the space-time dependence of traffic data by constructing dynamic spatiotemporal synchronization diagrams and modules, combining external data, and integrating time and spatial characteristics.
It effectively improves the accuracy of traffic flow prediction, takes into account the impact of external factors on traffic flow, and extracts space-time correlations from multiple aspects, improving the prediction ability of the model.
Smart Images

Figure CN119007442A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of traffic prediction and relates to a traffic flow prediction method based on a dynamic multi-graph spatiotemporal synchronization network. Background Art
[0002] With the continuous development of social economy, motor vehicles have become the main means of transportation for people to travel, and their ownership has increased rapidly year by year. However, due to objective conditions, the construction speed of the traffic network cannot keep up with the growth rate of the number of motor vehicles, which has led to an increasing load on the traffic network, resulting in a series of traffic problems such as traffic congestion, affecting people's travel efficiency and travel experience. Intelligent transportation system (ITS) has been proven to be one of the most effective scientific methods to solve various traffic problems. Scientifically dispatching vehicles in the road network through intelligent transportation systems and inducing smooth traffic flow have important practical significance for solving traffic problems. Accurate traffic flow prediction is an important function of intelligent transportation systems. It can not only help people plan vehicle routes more reasonably and improve travel experience, but also provide reference for transportation departments to formulate management plans and reasonably allocate traffic resources. Therefore, it is particularly important to design a more effective traffic flow prediction model and improve the accuracy of traffic flow prediction.
[0003] Traffic flow data has the following three characteristics: (1) time correlation and space correlation, that is, time dependence and space dependence. The traffic flow of a traffic node at each moment is affected by the traffic flow of its own node at the historical moment. At the same moment, the traffic flow of each traffic node is also affected by the traffic flow of other traffic nodes. Time dependence and space dependence exist at the same time and vary with time and space; (2) It is easily affected by external factors. External factors such as weather, temperature, wind speed, etc. will affect traffic flow. For example, there is a significant difference between traffic flow on rainy days and traffic flow on sunny days; (3) spatiotemporal complexity. In space, there are more complex relationships between different traffic nodes, including adjacency relationships, distance relationships, etc.; in time, there is more than one correlation between traffic flow sequences, such as similarity of change trends, consistency of time patterns, etc. If the above characteristics of traffic flow data are considered simultaneously during modeling, the prediction accuracy of the model will be better.
[0004] With the widespread application of deep learning technology and graphs, many studies have constructed graph structures from traffic flow data, and then used graph convolutional networks (GCN) to model the spatial dependency of traffic flow on the one hand; on the other hand, recurrent neural networks (RNN) and their variants, long short-term memory networks (LSTM) and gated recurrent units (GRU) were introduced to model the temporal dependency of traffic flow. However, most of the previous methods capture temporal dependency and spatial dependency separately. A few methods can extract temporal and spatial features at the same time, but do not consider the impact of external factors on traffic flow. In addition, the single and static spatiotemporal graph structure also limits the model's ability to learn spatiotemporal correlations. Summary of the invention
[0005] Purpose of the invention: In view of the above problems, the present invention introduces a traffic flow prediction method based on a dynamic multi-graph spatiotemporal synchronization network. The method takes into account the impact of external factors on traffic flow, and constructs the characteristics of traffic flow in multiple directions and angles in time and space, while capturing the time dependency and spatial dependency of traffic flow data, which can effectively improve the prediction accuracy of the model.
[0006] Technical solution: A traffic flow prediction method based on a dynamic multi-graph spatiotemporal synchronization network, comprising the following steps:
[0007] Step 1) Traffic data in the road network is collected by traffic collection equipment, remotely transmitted and stored in a traffic data server, time series traffic data is generated according to the data collection time, and the data is standardized according to the Z-score method, and then divided into a training set, a validation set, and a test set;
[0008] Step 2) Collect external data such as weather and temperature through meteorological equipment, transmit remotely and store them in the traffic data server; design feature enhancement module FAM to integrate traffic data with external data;
[0009] Step 3) define multi-graphs in time and space, and construct two dynamic spatiotemporal synchronization graphs based on them;
[0010] Step 4) construct a dynamic multi-graph spatiotemporal synchronization network DMSTSN, which superimposes four layers of dynamic multi-graph spatiotemporal synchronization layers DMSTSL, and deploys two parallel dynamic multi-graph spatiotemporal synchronization modules DMSTSM in each layer to synchronously model the spatiotemporal dependency of traffic data;
[0011] Step 5) Use the training set to train the dynamic multi-graph spatiotemporal synchronization network, use the validation set to verify the training effect, and use the test set to test the prediction accuracy of the model.
[0012] Furthermore, in step 1), traffic data in the road network is collected by traffic collection equipment, remotely transmitted and stored in a traffic data server, time series traffic data is generated according to the data collection time, and the 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:
[0013] Step 1-1: Deploy N traffic collection devices in the road network; take five minutes as a time step, and each traffic collection device collects traffic data once in each time step, including C traffic characteristics, including traffic flow, average vehicle speed, lane occupancy, etc. in 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
[0014] 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
[0015] Step 1-3: Standardize the traffic data X' h Divide into training set, validation set and data set in proportion.
[0016] Furthermore, in step 2), external data such as weather and temperature are collected by meteorological equipment, and remotely transmitted and stored in a traffic data server; a feature enhancement module FAM is designed to integrate traffic data with external data. The specific steps include:
[0017] Step 2-1: Deploy N meteorological devices in the road network; collect four external data of the device location on a daily basis, including the highest temperature, lowest temperature, weather, and wind speed of each day; remotely transmit and store them to the traffic data server, and expand them in the time dimension so that the time series length of the external data is consistent with the time series length of the traffic data, recorded as
[0018] Step 2-2: Design the feature enhancement module FAM to fuse traffic data with external data through splicing operations and spatiotemporal attention mechanisms. The specific process is as follows:
[0019] Step 2-2-1: Define the fully connected layer as: f(x) = ReLU(xW+b), where W and b are learnable parameters; each traffic collection device represents a traffic node, then represents the spatial attention matrix between N different nodes in T time steps. The attention coefficient in this matrix is obtained in two steps. First, the scaled dot product method is used to calculate the node v i and node v j The correlation coefficient between:
[0020]
[0021] Then the correlation coefficient Perform softmax normalization to obtain the spatial attention coefficient
[0022]
[0023] Step 2-2-2: Traffic data and external data are time series of length T, then represents the time attention matrix of all traffic nodes between T different time steps. The attention coefficient in this matrix is also obtained in two steps. First, the scaled dot product method is used to calculate the node v i At time step t j The correlation coefficient between and t is:
[0024]
[0025] Then the correlation coefficient Perform softmax normalization to obtain the time attention coefficient
[0026]
[0027] Step 2-2-3: Transmit traffic data to X' h First concatenate with external data E, and then use the spatial attention matrix and temporal attention matrix to fuse: X = f x ((U·(S·(X h '||E)) T ) T ).
[0028] Furthermore, in step 3), multiple graphs in time and space are defined, and two dynamic spatiotemporal synchronization graphs are constructed based on them. The specific process is as follows:
[0029] Step 3-1: Define two graph structures in the spatial dimension: adjacency graph and distance map The adjacency graph represents the adjacency relationship of nodes in space, and its adjacency matrix is defined as:
[0030]
[0031] The distance graph represents the distance relationship between nodes in space, and its adjacency matrix is defined as:
[0032]
[0033] where d i,j Represents node v i and node v j The Euclidean distance between
[0034] Step 3-2: Define two graph structures in the time dimension: change trend graph and time pattern diagram A T Characterizes the consistency of traffic flow change trends between different nodes. The elements of its adjacency matrix are calculated according to the DTW algorithm:
[0035]
[0036] in For node v i and node v j The DTW distance of the traffic flow sequence; P It represents the similarity of the time pattern of traffic flow between different nodes, and its adjacency matrix elements are calculated using the Pearson correlation coefficient:
[0037]
[0038] Among them Ti={ti,1,ti,2,···ti,h,···ti, H ,} represents node v i Traffic flow data within a time range of length H;
[0039] Step 3-3: Construct two types of dynamic spatiotemporal synchronization diagrams based on the above four spatial diagrams and time diagrams: Trend spatiotemporal synchronization diagram and mode spatiotemporal synchronization diagram First, design a predefined trend time-space synchronization diagram and mode spatiotemporal synchronization diagram The former is composed of a spatial adjacency graph and a temporal trend graph, while the latter is composed of a spatial distance graph and a temporal pattern graph. Each predefined spatiotemporal synchronization graph contains two l time step to integrate the temporal and spatial relationship of node traffic flow; the main diagonal of the trend spatiotemporal synchronization diagram is [A T , A T ], and the secondary diagonal is [A Ne , 0]; the main diagonal of the trend time-space synchronization diagram is [A P , A P ], and the secondary diagonal is [A D , 0]; then the two predefined spatiotemporal synchronization graphs are multiplied by the parameter matrix of the same shape to obtain two dynamic spatiotemporal synchronization graphs:
[0040] Further, in step 4), the specific steps of constructing a dynamic multi-graph spatiotemporal synchronization network DMSTSN are as follows:
[0041] Step 4-1: For the two dynamic spatiotemporal synchronization diagrams, two dynamic spatiotemporal synchronization modules DMSTSM are designed to simultaneously model the spatiotemporal correlation of traffic flow data: trend spatiotemporal synchronization module and pattern spatiotemporal synchronization module; the two dynamic spatiotemporal synchronization modules are deployed in parallel and do not share parameters with each other to extract spatiotemporal features from multiple angles. The specific process is as follows:
[0042] Step 4-1-1: In each trend spatiotemporal synchronization module, stack M layers of gated GCN to synchronize and aggregate the spatiotemporal features of the input time series. The output of the previous layer of gated GCN is used as the input of the next layer of gated GCN. The formula of each gated GCN is: in is the input of the mth gated GCN, is the output of the mth gated GCN; tanh(·) represents the tanh activation function, σ(·) represents the sigmoid activation function;
[0043] Step 4-1-2: In each mode spatiotemporal synchronization module, stack M layers of gated GCN to synchronize and aggregate the spatiotemporal features of the input time series. The output of the previous layer of gated GCN is used as the input of the next layer of gated GCN. The formula of each gated GCN is: in is the input of the mth gated GCN, is the output of the mth gated GCN; tanh(·) represents the tanh activation function, σ(·) represents the sigmoid activation function;
[0044] Step 4-1-3: In each dynamic spatiotemporal synchronization module, skip knowledge connections are used between the M layers of gated GCNs, and the outputs of all gated GCNs are max-pooled:
[0045] Then, the clipping operation is performed to reduce the 2N dimension to N dimension, and the outputs of the trend spatiotemporal synchronization module and the pattern spatiotemporal synchronization module are:
[0046] Step 4-2: Determine the number of two dynamic spatiotemporal synchronization modules according to the length of the traffic flow sequence input in each dynamic spatiotemporal synchronization layer DMSTSL and the distance between two time steps in the spatiotemporal synchronization graph; set the expansion rate of the first layer to 2 l , any node v in time step t iNot only connected to its temporal neighbor nodes, but also to nodes with a distance of 2 l Time step t-2 l The spatial neighbor nodes in are connected; let the length of the input historical time series of the lth layer be Then in the first layer, select the distance 2 l Time step pair Two dynamic spatiotemporal synchronization modules are constructed for each time step, so the number of each dynamic spatiotemporal synchronization module is T-2 l ;
[0047] Step 4-3: Splice the output of each dynamic spatiotemporal synchronization module.
[0048] Fusion through gating mechanism: The calculation formula of z is: Finally, it is convolved with the result of time dimension expansion O T Add together to get the output of the dynamic spatiotemporal synchronization layer:
[0049] Step 4-4: Stack four layers of dynamic spatiotemporal synchronization layers, and concatenate the outputs of all dynamic spatiotemporal synchronization layers, and pass through a double-layer fully connected layer to obtain the output of the dynamic spatiotemporal synchronization network.
[0050]
[0051] Furthermore, in step 5), the dynamic multi-graph spatiotemporal synchronization network is trained with a training set, the training effect is verified with a validation set, and the prediction accuracy of the model is tested with a test set. The specific steps are as follows:
[0052] Step 5-1: Determine the hyperparameters of the dynamic multi-graph spatiotemporal synchronization network, including the sparsity rate of the change trend graph and the time pattern graph, the number and input and output dimensions of the gated GCN in each dynamic spatiotemporal synchronization module, and the input and output dimensions of each fully connected layer; set the hyperparameters in the training process, including batch size, variable learning rate, step size, etc., and initialize various weight parameters;
[0053] Step 5-2: Use the training set to train the model, select the smooth L1 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;
[0054] Step 5-3: When the number of iterations reaches the preset value or the early stopping mechanism is triggered, the training is terminated and the test set is input into the trained model to test the prediction accuracy of the model.
[0055] Beneficial effects: The present invention is aimed at the previous traffic flow prediction methods, most of which extract time correlation and space correlation separately, without considering the impact of external factors on traffic flow. In addition, the single and static space-time graph structure also limits the model's ability to learn space-time correlation, so the prediction accuracy of the model still has a lot of room for improvement. To this end, the present invention introduces a traffic flow prediction method based on a dynamic multi-graph space-time synchronization network. This method can simultaneously capture the time dependency and space dependency of traffic flow data, reflecting the impact of external factors on traffic flow, and at the same time constructs different dynamic space-time synchronization graphs to synchronously extract the space-time correlation of traffic flow data from multiple aspects and angles, thereby effectively improving the prediction accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 A schematic diagram of the steps of a traffic flow prediction method based on a dynamic multi-graph spatiotemporal synchronization network of the present invention;
[0057] Figure 2 This is a structural diagram of a dynamic multi-graph spatiotemporal synchronization network model according to the present invention;
[0058] Figure 3 This is a structural diagram of the dynamic multi-image spatiotemporal synchronization module in the present invention;
[0059] Figure 4 This is a data fitting diagram of the test set based on the dynamic multi-graph spatiotemporal synchronization network model of the present invention. DETAILED DESCRIPTION
[0060] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings.
[0061] like Figure 3 As shown, a traffic flow prediction method based on a dynamic multi-graph spatiotemporal synchronization network includes the following steps:
[0062] Step 1) Traffic data in the road network is collected by traffic collection equipment, remotely transmitted and stored in a traffic data server, time series traffic data is generated according to the data collection time, and the data is standardized according to the Z-score method, and then divided into a training set, a validation set, and a test set;
[0063] In the step 1), traffic data in the road network is collected by traffic collection equipment, remotely transmitted and stored in a traffic data server, time series traffic data is generated according to the data collection time, and the 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:
[0064] Step 1-1: Deploy N traffic collection devices in the road network; take five minutes as a time step, and each traffic collection device collects traffic data once in each time step, including C traffic characteristics, including traffic flow, average vehicle speed, lane occupancy, etc. in 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
[0065] 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
[0066] Step 1-3: Standardize the traffic data X' h The dataset is divided into training set, validation set and data set in a ratio of 6:2:2.
[0067] Step 2) Collect external data such as weather and temperature through meteorological equipment, transmit remotely and store them in the traffic data server; design feature enhancement module FAM to integrate traffic data with external data;
[0068] In step 2), external data such as weather and temperature are collected by meteorological equipment, and remotely transmitted and stored in a traffic data server; a feature enhancement module FAM is designed to integrate traffic data with external data. The specific steps include:
[0069] Step 2-1: Deploy N meteorological devices in the road network; collect four external data of the device location on a daily basis, including the highest temperature, lowest temperature, weather, and wind speed of each day; remotely transmit and store them to the traffic data server, and expand them in the time dimension so that the time series length of the external data is consistent with the time series length of the traffic data, recorded as
[0070] Step 2-2: Design the feature enhancement module FAM to fuse traffic data with external data through splicing operations and spatiotemporal attention mechanisms. The specific process is as follows:
[0071] Step 2-2-1: Define the fully connected layer as: f(x) = ReLU(xW+b), where W and b are learnable parameters; each traffic collection device represents a traffic node, then represents the spatial attention matrix between N different nodes in T time steps. The attention coefficient in this matrix is obtained in two steps. First, the scaled dot product method is used to calculate the node v i and node v j The correlation coefficient between:
[0072]
[0073] Then the correlation coefficient Perform softmax normalization to obtain the spatial attention coefficient
[0074]
[0075] Step 2-2-2: Traffic data and external data are time series of length T, then represents the time attention matrix of all traffic nodes between T different time steps. The attention coefficient in this matrix is also obtained in two steps. First, the scaled dot product method is used to calculate the node v i At time step t j The correlation coefficient between and t is:
[0076]
[0077] Then the correlation coefficient Perform softmax normalization to obtain the time attention coefficient
[0078]
[0079] Step 2-2-3: Transmit traffic data to X' h First concatenate with external data E, and then use the spatial attention matrix and temporal attention matrix to fuse: X = f x ((U·(S·(X h '||E)) T ) T ).
[0080] Step 3) define multi-graphs in time and space, and construct two dynamic spatiotemporal synchronization graphs based on them;
[0081] In step 3), multiple graphs in time and space are defined, and two dynamic spatiotemporal synchronization graphs are constructed based on them. The specific process is as follows:
[0082] Step 3-1: Define two graph structures in the spatial dimension: adjacency graph and distance map The adjacency graph represents the adjacency relationship of nodes in space, and its adjacency matrix is defined as:
[0083]
[0084] The distance graph represents the distance relationship between nodes in space, and its adjacency matrix is defined as:
[0085]
[0086] where d i,j Represents node v i and node v j The Euclidean distance between
[0087] Step 3-2: Define two graph structures in the time dimension: change trend graph and time pattern diagram A T Characterizes the consistency of traffic flow change trends between different nodes. The elements of its adjacency matrix are calculated according to the DTW algorithm:
[0088]
[0089] in For node v i and node v j The DTW distance of the traffic flow sequence; P It represents the similarity of the time pattern of traffic flow between different nodes, and its adjacency matrix elements are calculated using the Pearson correlation coefficient:
[0090]
[0091] Among them Ti={ti,1,ti,2,···ti,h,···ti, H ,} represents node v i Traffic flow data within a time range of length H;
[0092] Step 3-3: Construct two types of dynamic spatiotemporal synchronization diagrams based on the above four spatial diagrams and time diagrams: Trend spatiotemporal synchronization diagram and mode spatiotemporal synchronization diagram First, design a predefined trend time-space synchronization diagram and mode spatiotemporal synchronization diagram The former is composed of a spatial adjacency graph and a temporal trend graph, while the latter is composed of a spatial distance graph and a temporal pattern graph. Each predefined spatiotemporal synchronization graph contains two l time step to integrate the temporal and spatial relationship of node traffic flow; the main diagonal of the trend spatiotemporal synchronization diagram is [A T , A T ], and the secondary diagonal is [A Ne , 0]; the main diagonal of the trend time-space synchronization diagram is [A P , A P ], and the secondary diagonal is [AD , 0]; then the two predefined spatiotemporal synchronization graphs are multiplied by the parameter matrix of the same shape to obtain two dynamic spatiotemporal synchronization graphs:
[0093] Step 4) construct a dynamic multi-graph spatiotemporal synchronization network DMSTSN, which superimposes four layers of dynamic multi-graph spatiotemporal synchronization layers DMSTSL, and deploys two parallel dynamic multi-graph spatiotemporal synchronization modules DMSTSM in each layer to synchronously model the spatiotemporal dependency of traffic data;
[0094] In the step 4), a dynamic multi-graph spatiotemporal synchronization network DMSTSN is constructed. The network is stacked with four layers of dynamic multi-graph spatiotemporal synchronization layers DMSTSL. Two parallel dynamic multi-graph spatiotemporal synchronization modules DMSTSM are deployed in each layer to synchronously model the spatiotemporal dependency of traffic data. The specific steps are as follows:
[0095] Step 4-1: For the two dynamic spatiotemporal synchronization diagrams, two dynamic spatiotemporal synchronization modules DMSTSM are designed to simultaneously model the spatiotemporal correlation of traffic flow data: trend spatiotemporal synchronization module and pattern spatiotemporal synchronization module; the two dynamic spatiotemporal synchronization modules are deployed in parallel and do not share parameters with each other to extract spatiotemporal features from multiple angles. The specific process is as follows:
[0096] Step 4-1-1: In each trend spatiotemporal synchronization module, stack M layers of gated GCN to synchronize and aggregate the spatiotemporal features of the input time series. The output of the previous layer of gated GCN is used as the input of the next layer of gated GCN. The formula of each gated GCN is: in is the input of the mth gated GCN, is the output of the mth gated GCN; tanh(·) represents the tanh activation function, σ(·) represents the sigmoid activation function;
[0097] Step 4-1-2: In each mode spatiotemporal synchronization module, stack M layers of gated GCN to synchronize and aggregate the spatiotemporal features of the input time series. The output of the previous layer of gated GCN is used as the input of the next layer of gated GCN. The formula of each gated GCN is: in is the input of the mth gated GCN, is the output of the mth gated GCN; tanh(·) represents the tanh activation function, σ(·) represents the sigmoid activation function;
[0098] Step 4-1-3: In each dynamic spatiotemporal synchronization module, skip knowledge connections are used between the M layers of gated GCNs, and the outputs of all gated GCNs are max-pooled:
[0099] Then, the clipping operation is performed to reduce the 2N dimension to N dimension, and the outputs of the trend spatiotemporal synchronization module and the pattern spatiotemporal synchronization module are:
[0100] Step 4-2: Determine the number of two dynamic spatiotemporal synchronization modules according to the length of the traffic flow sequence input in each dynamic spatiotemporal synchronization layer DMSTSL and the distance between two time steps in the spatiotemporal synchronization graph; set the expansion rate of the first layer to 2 l , any node v in time step t i Not only connected to its temporal neighbor nodes, but also to nodes with a distance of 2 l Time step t-2 l The spatial neighbor nodes in are connected; let the length of the input historical time series of the lth layer be Then in the first layer, select the distance 2 l Time step pair Two dynamic spatiotemporal synchronization modules are constructed for each time step, so the number of each dynamic spatiotemporal synchronization module is T-2 l ;
[0101] Step 4-3: Splice the output of each dynamic spatiotemporal synchronization module. Then merge through the gating mechanism: The calculation formula of z is: Finally, it is convolved with the result of time dimension expansion O T Add together to get the output of the dynamic spatiotemporal synchronization layer:
[0102] Step 4-4: Stack four layers of dynamic spatiotemporal synchronization layers, and concatenate the outputs of all dynamic spatiotemporal synchronization layers, and pass through a double-layer fully connected layer to obtain the output of the dynamic spatiotemporal synchronization network.
[0103]
[0104] Step 5) Use the training set to train the dynamic multi-graph spatiotemporal synchronization network, use the validation set to verify the training effect, and use the test set to test the prediction accuracy of the model.
[0105] In step 5), the dynamic multi-graph spatiotemporal synchronization network is trained with a training set, the training effect is verified with a validation set, and the prediction accuracy of the model is tested with a test set. The specific steps are as follows:
[0106] Step 5-1: Determine the hyperparameters of the dynamic multi-graph spatiotemporal synchronization network, including the sparsity rate of the change trend graph and the time pattern graph, the number and input and output dimensions of the gated GCN in each dynamic spatiotemporal synchronization module, and the input and output dimensions of each fully connected layer; set the hyperparameters in the training process, including batch size, variable learning rate, step size, etc., and initialize various weight parameters;
[0107] Step 5-2: Use the training set to train the model, select the smooth L1 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;
[0108] Step 5-3: When the number of iterations reaches the preset value or the early stopping mechanism is triggered, the training is terminated and the test set is input into the trained model to test the prediction accuracy of the model.
[0109] As Figure 4 As shown in the figure, a traffic flow prediction method based on a dynamic multi-graph spatiotemporal synchronization network 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.
[0110] The present invention is aimed at the fact that most of the previous traffic flow prediction methods extract time correlation and space correlation separately, without considering the impact of external factors on traffic flow. In addition, the single and static spatiotemporal graph structure also limits the model's ability to learn spatiotemporal correlation, so the prediction accuracy of the model still has a lot of room for improvement. To this end, the present invention introduces a traffic flow prediction method based on a dynamic multi-graph spatiotemporal synchronization network. This method can simultaneously capture the time dependency and spatial dependency of traffic flow data, reflecting the impact of external factors on traffic flow, and at the same time constructs different dynamic spatiotemporal synchronization graphs to synchronously extract the spatiotemporal correlation of traffic flow data from multiple aspects and angles, thereby effectively improving the prediction accuracy of the model.
[0111] 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 traffic flow prediction method based on a dynamic multi-graph spatiotemporal synchronization network, characterized by: The method comprises the following steps: Step 1) Traffic data in the road network is collected by traffic collection equipment, remotely transmitted and stored in a traffic data server, time series traffic data is generated according to the data collection time, and the data is standardized according to the Z-score method, and then divided into a training set, a validation set, and a test set; Step 2) Collect external data such as weather and temperature through meteorological equipment, remotely transmit and store them in the traffic data server; Design the feature enhancement module FAM to fuse traffic data with external data; Step 3) define multi-graphs in time and space, and construct two dynamic spatiotemporal synchronization graphs based on them; Step 4) construct a dynamic multi-graph spatiotemporal synchronization network DMSTSN, which superimposes four layers of dynamic multi-graph spatiotemporal synchronization layers DMSTSL, and deploys two parallel dynamic multi-graph spatiotemporal synchronization modules DMSTSM in each layer to synchronously model the spatiotemporal dependency of traffic data; Step 5) Use the training set to train the dynamic multi-graph spatiotemporal synchronization network, use the validation set to verify the training effect, and use the test set to test the prediction accuracy of the model.
2. The traffic flow prediction method based on dynamic multi-graph spatiotemporal synchronization network according to claim 1 is characterized by: The specific steps of step 1) are: Step 1-1: Deploy N traffic collection devices in the road network; take five minutes as a time step, and each traffic collection device collects traffic data once in each time step, including C traffic characteristics, including traffic flow, average vehicle speed, lane occupancy, etc. in 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 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: Standardize the traffic data X' h Divide into training set, validation set and data set in proportion.
3. The traffic flow prediction method based on dynamic multi-graph spatiotemporal synchronization network according to claim 1 is characterized by: The specific process in step 2) includes: Step 2-1: Deploy N meteorological devices in the road network; collect four external data of the device location on a daily basis, including the highest temperature, lowest temperature, weather, and wind speed of each day; remotely transmit and store them to the traffic data server, and expand them in the time dimension so that the time series length of the external data is consistent with the time series length of the traffic data, recorded as Step 2-2: Design the feature enhancement module FAM to fuse traffic data with external data through splicing operations and spatiotemporal attention mechanism.
4. The traffic flow prediction method based on dynamic multi-graph spatiotemporal synchronization network according to claim 3 is characterized by: The detailed process of step 2-2 is as follows: Step 3-1: Define the fully connected layer as: f(x) = ReLU(xW+b), where W and b are learnable parameters; each traffic collection device represents a traffic node, then represents the spatial attention matrix between N different nodes in T time steps. The attention coefficient in this matrix is obtained in two steps. First, the scaled dot product method is used to calculate the node v i and node v j The correlation coefficient between: Then the correlation coefficient Perform softmax normalization to obtain the spatial attention coefficient Step 3-2: Traffic data and external data are time series of length T, then represents the time attention matrix of all traffic nodes between T different time steps. The attention coefficient in this matrix is also obtained in two steps. First, the scaled dot product method is used to calculate the node v i At time step t j The correlation coefficient between and t is: Then the correlation coefficient Perform softmax normalization to obtain the time attention coefficient Step 3-3: Transmit traffic data to X' h First concatenate with external data E, and then use the spatial attention matrix and temporal attention matrix to fuse: X = f x ((U·(S·(X h '||E)) T ) T ).
5. The traffic flow prediction method based on dynamic multi-graph spatiotemporal synchronization network according to claim 1 is characterized by: The detailed steps of step 3) are: Step 4-1: Define two graph structures in the spatial dimension: adjacency graph and distance map The adjacency graph represents the adjacency relationship of nodes in space, and its adjacency matrix is defined as: The distance graph represents the distance relationship between nodes in space, and its adjacency matrix is defined as: where d i,j Represents node v i and node v j The Euclidean distance between Step 4-2: Define two graph structures in the time dimension: change trend graph and time pattern diagram A T Characterizes the consistency of traffic flow change trends between different nodes. The elements of its adjacency matrix are calculated according to the DTW algorithm: in For node v i and node v j The DTW distance of the traffic flow sequence; P It represents the similarity of the time pattern of traffic flow between different nodes, and its adjacency matrix elements are calculated using the Pearson correlation coefficient: Among them Ti={ti,1,ti,2,···ti,h,···ti, H ,} represents node v i Traffic flow data within a time range of length H; Step 4-3: Construct two types of dynamic spatiotemporal synchronization diagrams based on the above four spatial diagrams and time diagrams: Trend spatiotemporal synchronization diagram and mode spatiotemporal synchronization diagram First, design a predefined trend time-space synchronization diagram and mode spatiotemporal synchronization diagram The former is composed of a spatial adjacency graph and a temporal trend graph, while the latter is composed of a spatial distance graph and a temporal pattern graph. Each predefined spatiotemporal synchronization graph contains two l time step to integrate the temporal and spatial relationship of node traffic flow; the main diagonal of the trend spatiotemporal synchronization diagram is [A T , A T ], and the secondary diagonal is [A Ne , 0]; the main diagonal of the trend time-space synchronization diagram is [A P , A P ], and the secondary diagonal is [A D , 0]; then the two predefined spatiotemporal synchronization graphs are multiplied by the parameter matrix of the same shape to obtain two dynamic spatiotemporal synchronization graphs:
6. The traffic flow prediction method based on dynamic multi-graph spatiotemporal synchronization network according to claim 1 is characterized by: The specific steps of step 4) to construct a dynamic multi-graph spatiotemporal synchronization network DMSTSN are as follows: Step 5-1: For the two dynamic spatiotemporal synchronization diagrams, two dynamic spatiotemporal synchronization modules DMSTSM are designed to simultaneously model the spatiotemporal correlation of traffic flow data: trend spatiotemporal synchronization module and pattern spatiotemporal synchronization module; the two dynamic spatiotemporal synchronization modules are deployed in parallel and do not share parameters with each other to extract spatiotemporal features from multiple angles; Step 5-2: Determine the number of two dynamic spatiotemporal synchronization modules according to the length of the traffic flow sequence input in each dynamic spatiotemporal synchronization layer DMSTSL and the distance between two time steps in the spatiotemporal synchronization graph; set the expansion rate of the first layer to 2 l , any node v in time step t i Not only connected to its temporal neighbor nodes, but also to nodes with a distance of 2 l Time step t-2 l The spatial neighbor nodes in are connected; let the length of the input historical time series of the lth layer be Then in the first layer, select the distance 2 l Time step pair Two dynamic spatiotemporal synchronization modules are constructed for each time step, so the number of each dynamic spatiotemporal synchronization module is T-2 l ; Step 5-3: Splice the outputs of each dynamic spatiotemporal synchronization module. Then merge through the gating mechanism: The calculation formula of z is: Finally, it is convolved with the result of time dimension expansion O T Add together to get the output of the dynamic spatiotemporal synchronization layer: Step 5-4: Stack four layers of dynamic spatiotemporal synchronization layers, concatenate the outputs of all dynamic spatiotemporal synchronization layers, and pass through a double-layer fully connected layer to obtain the output of the dynamic spatiotemporal synchronization network Y = ReLU (((X 1 ,X 2 ,···,X L )Θ1+b1)Θ2+b2).
7. The traffic flow prediction method based on dynamic multi-graph spatiotemporal synchronization network according to claim 6 is characterized by: The detailed process of step 5-1 is as follows: Step 6-1: In each trend spatiotemporal synchronization module, stack M layers of gated GCN to synchronize and aggregate the spatiotemporal features of the input time series. The output of the previous layer of gated GCN is used as the input of the next layer of gated GCN. The formula of each gated GCN is: in is the input of the mth gated GCN, is the output of the mth gated GCN; tanh(·) represents the tanh activation function, σ(·) represents the sigmoid activation function; Step 6-2: In each mode spatiotemporal synchronization module, stack M layers of gated GCN to synchronize and aggregate the spatiotemporal features of the input time series. The output of the previous layer of gated GCN is used as the input of the next layer of gated GCN. The formula of each gated GCN is: in is the input of the mth gated GCN, is the output of the mth gated GCN; tanh(·) represents the tanh activation function, σ(·) represents the sigmoid activation function; Step 6-3: In each dynamic spatiotemporal synchronization module, skip knowledge connections are used between the M layers of gated GCNs, and the outputs of all gated GCNs are max-pooled: Then, the clipping operation is performed to reduce the 2N dimension to N dimension, and the outputs of the trend spatiotemporal synchronization module and the pattern spatiotemporal synchronization module are:
8. The traffic flow prediction method based on dynamic multi-graph spatiotemporal synchronization network according to claim 1 is characterized by: The specific steps of step 5) are as follows: Step 7-1: Determine the hyperparameters of the dynamic multi-graph spatiotemporal synchronization network, including the sparsity rate of the change trend graph and the time pattern graph, the number and input and output dimensions of the gated GCN in each dynamic spatiotemporal synchronization module, and the input and output dimensions of each fully connected layer; Set hyperparameters during training, including batch size, variable learning rate, step size, and initialize various weight parameters; Step 7-2: Use the training set to train the model, select the smooth L1 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 7-3: When the number of iterations reaches the preset value or the early stopping mechanism is triggered, the training is terminated and the test set is input into the trained model to test the prediction accuracy of the model.
Citation Information
Cited By
Multi-modal traffic flow prediction method based on dynamic space-time hypergraph and large language model
CN119942803A
