Real-time traffic flow prediction method based on priori perception dynamic graph
Patent Information
- Application Number
- CN202610924351.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-25
- Publication Date
- 2026-09-15
AI Technical Summary
然而,受限于模型简化带来的表征能力降低,这些方法在复杂交通环境下对时空依赖和动态变化模式的刻画仍显不足
Smart Images

Figure CN122761601A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent transportation technology, and more specifically, relates to a real-time traffic flow prediction method based on prior perception dynamic maps. Background Technology
[0002] With the accelerating pace of urbanization and the continuous growth of motor vehicle ownership, urban road traffic networks face a series of problems, including increased traffic congestion, decreased traffic efficiency, and aggravated environmental pollution. Intelligent Transportation Systems (ITS) have become an important solution to alleviate urban traffic problems, and the key to ITS's rational guidance and decision-making lies in rapid and accurate traffic flow prediction technology.
[0003] The key to traffic flow prediction lies in accurately extracting the spatiotemporal features inherent in traffic data. Spatiotemporal Graph Neural Networks (STGNNs) have gradually become a widely adopted technical approach. STGNNs typically use graph convolution as the core to model spatial dependencies and further combine RNNs, Temporal Convolutional Networks (TCNs), and attention mechanisms to extract traffic temporal patterns. Many researchers have proposed various STGNN-based traffic flow prediction methods. However, most existing STGNN-based traffic flow prediction models are complex and require significant computational resources and relatively high inference times. For prediction tasks deployed on regional servers or edge devices, computational resources are often limited. Furthermore, in urban road networks, traffic flow is influenced by multiple factors such as commuting tides, signal timing, local congestion propagation, and sudden events, exhibiting significant dynamics, time-varying characteristics, and non-stationarity. Especially in real-time scenarios, traffic conditions may fluctuate significantly within a short period of time.
[0004] In recent years, some studies have attempted to achieve efficient traffic flow prediction with simpler structures. Compared to many complex prediction models, these methods typically offer higher computational efficiency and lower implementation complexity while maintaining good predictive performance. However, due to the reduced representational power resulting from model simplification, these methods still fall short in characterizing spatiotemporal dependencies and dynamic change patterns in complex traffic environments. Therefore, for dynamic and complex scenarios, it is still necessary to further explore prediction models that combine computational efficiency and predictive reliability. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide a real-time traffic flow prediction method based on prior perception dynamic graphs. By introducing temporal and spatial prior knowledge into the graph long short-term memory network, the prediction accuracy and efficiency of traffic flow prediction are improved.
[0006] To achieve the above-mentioned objectives, the real-time traffic flow prediction method based on prior-perceived dynamic maps of the present invention includes the following steps:
[0007] S1: Collect traffic flow data samples of the target area within a predetermined historical time period. , , This indicates the number of traffic flow data samples. This indicates the sampling time of the traffic flow data sample. This indicates the number of traffic data collection nodes. This represents the dimension of traffic flow data; then, several sets of continuous sampling times are extracted from it. A sample of traffic flow data, from the previous A series of traffic flow data samples constitute a historical traffic flow data sequence, which will be used to... A traffic flow data sample constitutes a predicted traffic flow data sequence, thereby constructing a traffic flow prediction training sample set;
[0008] S2: Extract prior time knowledge from traffic flow data samples over historical time periods, including... Time prior features , , Indicates the number of temporal prior features;
[0009] S3: For the target area A physical adjacency matrix is constructed based on the distances between traffic data collection nodes. A semantic adjacency matrix is constructed based on the similarity of traffic flow data between nodes. , physical adjacency matrix and semantic adjacency matrix As prior knowledge of space;
[0010] S4: Construct a traffic flow prediction model, including a time prior matching module, an adjacency matrix generation module, and a graph short-term memory network, where:
[0011] The time prior matching module is used to... Time prior features Current traffic flow data in the middle Time prior features And send it to the graph long short-term memory network;
[0012] The adjacency matrix generation module is used to generate adjacency matrices based on spatial prior knowledge and historical traffic flow data sequences. Generate the current time adjacency matrix And send it to the graph-length short-term memory network; the adjacency matrix generation module includes a fusion coefficient generation module and a spatial prior fusion module, wherein:
[0013] The fusion coefficient generation module is used to generate coefficients based on historical traffic flow data sequences. Obtain the fusion coefficient And send it to the spatial prior fusion module;
[0014] The spatial prior fusion module is used to determine the fusion coefficient. For physical adjacency matrix and semantic adjacency matrix Weighted fusion is performed to obtain the adjacency matrix. :
[0015] ;
[0016] Long Short-Term Memory (LSTM) networks are used to consider temporal prior features. and adjacency matrix Predicting the future Traffic flow data sequence at each time point The gating state update process is as follows:
[0017] ,
[0018] in, This represents the hidden state at the previous time step. Indicates the input gate. Represents the Gate of Oblivion Indicates the output gate. Indicates a candidate state. , , and These represent the weight matrices in the corresponding state update. This corresponds to the bias term in the state update. ;
[0019] S5: Use the traffic flow prediction training sample set obtained in step S1 to train the traffic flow prediction model and obtain the trained traffic flow prediction model.
[0020] S6: When traffic flow prediction is required, collect data on the current and previous times of the target area. Traffic flow data samples at each moment constitute a historical traffic flow data sequence, which is then input into a trained traffic flow prediction model to obtain future traffic flow data. A sequence of predicted traffic flow data at each time point.
[0021] This invention relates to a real-time traffic flow prediction method based on a priori-perceived dynamic graphs. It extracts temporal and spatial prior knowledge from traffic flow data samples over historical time periods, constructs and trains a traffic flow prediction model including a temporal prior matching module, an adjacency matrix generation module, and a graph long short-term memory network. The temporal prior matching module locates the temporal prior features of the current traffic flow data from the temporal prior features. It generates the adjacency matrix for the current moment based on spatial prior knowledge and the input historical traffic flow data sequence. The graph long short-term memory network predicts the future traffic flow data sequence based on the temporal prior features and the adjacency matrix. The trained traffic flow prediction model is then used for real-time traffic flow prediction.
[0022] The present invention has the following beneficial effects:
[0023] 1) Accurate prediction: This invention can combine pre-calculated spatiotemporal priors to dynamically adapt to temporal changes and spatial correlations, and simultaneously capture spatiotemporal correlations within a single calculation step;
[0024] 2) Spatiotemporal coupling: The Graph-LSTM network designed in this invention adopts a spatiotemporal coupling structure, which combines the spatial modeling capability of GNN with the temporal modeling capability of LSTM, so as to learn the spatiotemporal features of traffic flow data simultaneously during the single-step state update process.
[0025] 3) High computational efficiency: This invention places most of the computation in the offline computation stage, and calls the content calculated in the offline stage in the online prediction stage, and uses a lightweight model for prediction, thereby improving prediction efficiency. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating a specific implementation of the real-time traffic flow prediction method based on prior perception dynamic graphs of the present invention.
[0027] Figure 2 This is a schematic diagram illustrating the extraction of prior time knowledge in this embodiment;
[0028] Figure 3 This is a flowchart of the extraction of prior time knowledge in this embodiment;
[0029] Figure 4 This is a structural diagram of the traffic flow prediction model in this invention. Detailed Implementation
[0030] The specific embodiments of the present invention will now be described with reference to the accompanying drawings to enable those skilled in the art to better understand the invention. It should be particularly noted that in the following description, detailed descriptions of known functions and designs that might obscure the main content of the invention will be omitted here.
[0031] Example
[0032] Figure 1 This is a flowchart illustrating a specific implementation of the real-time traffic flow prediction method based on prior-perceived dynamic maps according to the present invention. Figure 1 As shown, the specific steps of the real-time traffic flow prediction method based on prior-perceived dynamic maps of the present invention include:
[0033] S101: Traffic flow data sample collection:
[0034] Collect traffic flow data samples of the target area within a predetermined historical time period. , , This indicates the number of traffic flow data samples. Indicates the sampling time (timestamp) of traffic flow data samples. This indicates the number of traffic data collection nodes. This represents the dimension of traffic flow data. Then, several consecutive sets of sampling times are extracted from it. A sample of traffic flow data, from the previous A series of traffic flow data samples constitute a historical traffic flow data sequence, which will be used to... A traffic flow data sample constitutes a predicted traffic flow data sequence, thereby constructing a traffic flow prediction training sample set.
[0035] S102: Prior knowledge for extraction time:
[0036] Extracting prior time knowledge from traffic flow data samples over historical time periods, including Time prior features , , This represents the number of prior features in time.
[0037] Figure 2 This is a schematic diagram illustrating the extraction of prior time knowledge in this embodiment. Figure 3 This is a flowchart for extracting prior time knowledge in this embodiment. For example... Figure 2 , Figure 3 As shown, the specific steps for extracting prior time knowledge in this embodiment include:
[0038] S301: Sampling time encoding:
[0039] For each traffic flow data sample Sampling time Encoding is performed to obtain time-coded features. .
[0040] To extract temporal attributes usable for temporal pattern recognition from historical data, this embodiment encodes historical traffic flow data using a sine-cosine function. For any sampling time... The corresponding historical time is converted into minute (1440) information within a day and week (7) information within a week to express the daily cycle characteristics respectively. and periodic characteristics The calculation formula is as follows:
[0041] ,
[0042] ,
[0043] in, and Representing time respectively Minute index within a day and week index within a week.
[0044] Then the daily cycle characteristics and periodic characteristics Concatenation yields time-coded features .
[0045] S302: Traffic Flow Data Standardization:
[0046] To preserve the traffic flow status of each node in the traffic network while avoiding bias in subsequent clustering results due to differences in measurement units, each traffic flow data sample... Standardization processing is performed to obtain standardized traffic flow data samples. In this embodiment, Z-score normalization is used, and the calculation formula is as follows:
[0047] ,
[0048] in, and These represent the mean and variance of the traffic flow data sample, respectively.
[0049] S303: Constructing Temporal Context Features:
[0050] Standardized traffic flow data samples With time coding features splicing to obtain temporal context features :
[0051] ,
[0052] in, This represents the temporal context feature dimension.
[0053] S304: Feature Vector Clustering
[0054] Because the evolution patterns of traffic flow differ significantly across different time periods, this invention addresses... Temporal context features Clustering is performed to obtain The central features of each cluster , , central feature vector It is stored as prior knowledge of time.
[0055] In this embodiment, the K-means clustering algorithm is used for clustering, thereby dividing the temporal context features with similar traffic flow conditions at different times into clusters. A typical temporal pattern. Before clustering, the temporal context features need to be expanded into a one-dimensional vector, and after clustering, the central feature vectors are reshaped into two-dimensional central features.
[0056] S103: Extracting prior knowledge from the space:
[0057] Traffic flow variations between different nodes are influenced by road connectivity structures. Graph structures built solely based on data similarity often lack physical topological constraints and are prone to introducing unreasonable edges. Therefore, this invention introduces a physical graph to characterize the spatial proximity relationships between nodes, thereby providing stable physical constraints. For the target area... A physical adjacency matrix is constructed based on the distances between traffic data collection nodes. A semantic adjacency matrix is constructed based on the similarity of traffic flow data between nodes. , physical adjacency matrix and semantic adjacency matrix It is stored as prior knowledge of space.
[0058] Regarding the physical adjacency matrix In this embodiment, the Gaussian kernel function and Nearest neighbor sparsification to construct the initial physical adjacency matrix Traffic data collection nodes and Initial physical adjacency values between The calculation formula is as follows:
[0059] ,
[0060] in, Represents a node With nodes The Euclidean distance between them Indicates the distance from the standard deviation. Represents a node of nearest neighbor set The value can be set as needed.
[0061] To prevent highly connected nodes from dominating information aggregation and to maintain numerical stability during graph convolution propagation, the initial physical adjacency matrix is... After performing symmetric normalization, the physical adjacency matrix is obtained. :
[0062] ,
[0063] in, Indicates based on the initial physical adjacency matrix The obtained degree matrix, Represents the identity matrix.
[0064] Spatial dependencies in transportation networks are also influenced by latent semantic associations (such as shared traffic patterns, similar functional areas, etc.). Relying solely on fixed distance structures is insufficient to reflect these implicit, higher-order spatial relationships. Therefore, this embodiment introduces a semantic graph to mine latent semantic correlations between nodes, thereby supplementing implicit dependencies that cannot be described by physical topology.
[0065] To characterize the semantic relationships between nodes, the Pearson correlation coefficient (PCC) is used as a similarity metric. PCC intuitively reflects the consistency of traffic changes between nodes, and nodes with different traffic volumes can be effectively compared. Traffic flow data sample Extract each traffic data collection node Traffic flow data sequence Then calculate the nodes With nodes Pearson correlation coefficient between traffic flow data series:
[0066] ,
[0067] in, and Representing nodes respectively With nodes In traffic flow data samples Traffic flow data in and This represents the average traffic flow data for the corresponding node across all traffic flow data samples.
[0068] Then construct the initial semantic adjacency matrix. Traffic data collection nodes and Initial adjacency values between The calculation formula is as follows:
[0069] ,
[0070] in, Represents nodes Pearson has the highest correlation A set of nodes The value can be set as needed.
[0071] Subsequently, the initial semantic adjacency matrix was also processed. After performing symmetric normalization, the semantic adjacency matrix is obtained. :
[0072] ,
[0073] in, Indicates the initial semantic adjacency matrix The resulting degree matrix.
[0074] S104: Constructing a traffic flow prediction model:
[0075] In real-time traffic flow prediction, models not only need to accurately capture complex spatiotemporal dependencies, but also need to have the ability to quickly adapt to dynamic environments and low inference overhead. To this end, this invention proposes a traffic flow prediction model (PADGL-Net), which aims to utilize pre-computed spatiotemporal prior knowledge to adaptively perceive temporal changes and spatial correlations, thereby achieving online real-time prediction. Figure 4 This is a structural diagram of the traffic flow prediction model in this invention. (See diagram below.) Figure 4 As shown, the traffic flow prediction model in this invention includes a time prior matching module, an adjacency matrix generation module, and a graph short-term memory network, wherein:
[0076] The time prior matching module is used to... Time prior features Current traffic flow data in the middle Time prior features And send it to the Graph Long Short-Term Memory network. The specific method for locating the temporal prior features in this embodiment is as follows:
[0077] Extraction time Time coding features and current traffic flow data Standardized traffic flow data, and then construct current traffic flow data. Temporal context features Filtering and timing The prior time features that are close to each other within the same day constitute a candidate set of prior time features, and then features that are relevant to the time context are selected from this set. The time prior features with the highest similarity are used as historical traffic flow data Time prior features .
[0078] The adjacency matrix generation module is used to generate adjacency matrices based on spatial prior knowledge and historical traffic flow data sequences. Generate the current time adjacency matrix And send it to the graph-long short-term memory network. The adjacency matrix generation module includes a fusion coefficient generation module and a spatial prior fusion module, wherein:
[0079] The fusion coefficient generation module is used to generate coefficients based on historical traffic flow data sequences. Obtain the fusion coefficient And send it to the spatial prior fusion module. In this embodiment, the fusion coefficient... The generating formula can be expressed as follows:
[0080] ,
[0081] in, Represents historical traffic flow data sequences The constructed tensor This represents the learnable weight matrix. Indicates the bias term. This represents the Sigmoid activation function, used to map weights to the (0,1) interval.
[0082] The spatial prior fusion module is used to determine the fusion coefficient. For physical adjacency matrix and semantic adjacency matrix Weighted fusion is performed to obtain the adjacency matrix. :
[0083] .
[0084] This adjacency matrix construction method can express the time-varying dynamic spatial characteristics of traffic flow without real-time reconstruction of the graph structure, effectively reducing the computational overhead of real-time prediction.
[0085] Graph-LSTM networks are used to apply time-prior features. and adjacency matrix Predicting the future Traffic flow data sequence at each time point .
[0086] This invention introduces two feature signals into the state update process of Graph-LSTM to achieve collaborative modeling of spatiotemporal dependencies and node-specific features:
[0087] (1) Graph aggregation item According to time adjacency matrix By aggregating neighboring nodes and capturing their spatial features, spatial context can be provided for gating updates.
[0088] (2) Time priors Used to dynamically adjust the gating structure according to the time pattern and provide historical traffic information.
[0089] Based on the role of each gating unit in memory updates, this invention employs a differentiated feature signal injection strategy in Graph-LSTM:
[0090] Input gate The graph aggregation term and time prior term are introduced to adjust the amount of new information written. The graph aggregation term ensures that nodes are aware of the neighborhood state before writing to memory, and the time prior term adjusts the writing intensity based on historical traffic information.
[0091] Forgotten Gate The model introduces graph aggregation terms and temporal priors to control the retention and forgetting of historical memories. Graph aggregation terms help the model consider the continuity of spatial correlation propagation in forgetting decisions, while temporal priors adjust the intensity of forgetting based on historical information to avoid excessive forgetting or retention.
[0092] Output gate The output gate is responsible for the readout strength of the memory cell, while external features are more suitable for participating in the regulation of the memory update process, so no feature signals are introduced.
[0093] Candidate state Candidate states primarily serve the function of content modeling. Introducing external information may interfere with the original representation, therefore no feature signals are introduced.
[0094] Therefore, the gated state update process of the Graph-LSTM network in this invention can be represented as follows:
[0095] ,
[0096] in, This represents the hidden state at the previous time step. , , and These represent the weight matrices in the corresponding state update. This corresponds to the bias term in the state update. .
[0097] Subsequently, memory unit With hidden state Updated to:
[0098] ,
[0099] in, This indicates element-wise multiplication.
[0100] Based on hidden state Traffic flow data sequence predicted Its prediction formula can be expressed as follows:
[0101] ,
[0102] in, and These are the learnable weights and biases in the two-layer linear mapping, respectively.
[0103] S105: Training the traffic flow prediction model:
[0104] The traffic flow prediction model is trained using the traffic flow prediction training sample set obtained in step S101, resulting in a trained traffic flow prediction model.
[0105] In this invention, a time prior at a certain moment Providing traffic flow prediction models with the corresponding flow information and temporal patterns at a given moment helps the model stabilize gating updates and maintain prediction accuracy when there are few samples in the early stages. However, if a strong prior injection is maintained in the later stages, the model may over-rely on priors rather than real observation data during memory and state updates. Therefore, this embodiment designs a progressive training strategy, which fully utilizes temporal priors to help the model converge in the early stages, and gradually weakens the influence of temporal priors in the later stages, allowing the model to rely more on the data-driven spatiotemporal feature learning results.
[0106] Specifically, because the time prior in the gating structure of this invention is achieved through... and The input and forget gates are injected separately, directly affecting the writing and updating of unit states. If this effect remains strong in later stages, it can lead to a decrease in the model's responsiveness to real-time dynamics. Therefore, regularization is applied to these two prior injection channels to suppress their influence in later training stages, resulting in the prior loss:
[0107] ,
[0108] Furthermore, in order to gradually weaken the dominant role of time priors during online learning while retaining their guiding effect, this embodiment employs a bounded annealing coefficient that decreases over time:
[0109]
[0110] in, This refers to the current time step in the online prediction process. Used to control the maximum strength of time prior. For a fixed annealing decay rate. With... Increase, From near It gradually approaches 0, thereby suppressing the strength of the later time prior.
[0111] Therefore, the calculation formula for the loss function of the traffic prediction flow model in this embodiment is as follows: as follows:
[0112] ,
[0113] in, The loss is represented by the mean absolute error of the predicted traffic flow data sequence in this embodiment.
[0114] S106: Real-time Traffic Flow Prediction
[0115] When traffic flow prediction is required, data is collected from the target area at the current time and previous times. Traffic flow data samples at each moment constitute a historical traffic flow data sequence, which is then input into a trained traffic flow prediction model to obtain future traffic flow data. A sequence of predicted traffic flow data at each time point.
[0116] To better illustrate the technical effects of the present invention, specific examples are used to experimentally verify the invention. In this embodiment, the PEMS-07 and PEMS-08 datasets are used to evaluate the performance of the present invention; each dataset contains traffic observation information with timestamps. Table 1 is an information table of the datasets in this embodiment.
[0117]
[0118] Table 1
[0119] In this embodiment, PADGL-Net is evaluated using an online learning approach. It predicts future traffic flow based on historical data from the past hour (12 steps). The model first makes predictions and calculates the error, then incrementally updates the model parameters using real observations. Therefore, the batch size and number of training rounds used in traditional offline training are not implemented.
[0120] In this embodiment, the data is divided into training, validation, and test sets in a 7:1:2 ratio. The first 70% of the data is used to build offline prior knowledge; the middle 10% serves as the validation set, used to select model hyperparameters and gating injection strategies; and the last 20% serves as the online test set. The learning rate for online updates is set to 0.001, the hidden dimension to 512, and the number of K-means clusters to [missing value]. The sparsity parameters for the physical graph and semantic graph are set to 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ... and Prior strength The annealing coefficient growth rate is set to This embodiment uses PyTorch 2.2.1 and Python 3.11.5 to implement the model proposed in this invention. All experiments were conducted on an Intel Core i7-13700KF CPU and an NVIDIA GeForce RTX 4070 GPU.
[0121] To comprehensively evaluate the performance of PADGL-Net, this invention is compared with the following four baseline models: a temporal baseline, a lightweight real-time baseline, and a complex spatiotemporal baseline. A brief description of each baseline model is as follows:
[0122] LSTM: LSTM is a classic RNN model that models temporal dependencies through a gating mechanism. State updates are achieved through fully connected transformations, and it does not explicitly model the spatial structure itself.
[0123] STMLP: STMLP is a real-time prediction model that uses knowledge distillation to extract knowledge from STGNN (STGCN is used as the teacher model) into a simple MLP model for real-time prediction.
[0124] STGCN: STGCN is a classic spatiotemporal prediction model that uses GCN to capture the spatial dependencies of a predefined physical graph and combines it with 1D temporal convolution to capture temporal dependencies.
[0125] DSTAGNN: DSTAGNN is a spatiotemporal prediction model based on semantic graphs. It describes spatial dependencies by constructing predefined semantic graphs and combines spatiotemporal attention mechanisms and spatiotemporal convolutional modules to jointly learn spatiotemporal correlations.
[0126] The baseline model was trained offline with 100 training epochs, a batch size of 32, a learning rate of 0.001, and a hidden dimension of 512. It also predicted future traffic flow based on historical data from the past hour (12 steps). The mean absolute error (MAE), mean absolute percentage error (MAPE), and root mean square error (RMSE) were then used as metrics to evaluate the prediction accuracy of the present invention and the baseline model. Table 2 compares the prediction accuracy of the present invention with that of each baseline model in this embodiment.
[0127]
[0128] Table 2
[0129] Table 2 shows a comparison of the prediction accuracy of the present invention and various baseline models under three prediction step sizes (Q) on four datasets. The best results are shown in bold, and the second-best results are shown underlined. Overall, PADGL-Net achieved optimal or near-optimal performance in almost all cases. Compared to the temporal baseline LSTM, which relies solely on a fully connected gating mechanism to capture temporal dependencies, the present invention explicitly introduces spatial neighborhood information into the gating through Graph-LSTM to synchronously capture spatiotemporal dependencies, thereby improving prediction performance. On the PEMS-07 dataset, MAE, RMSE, and MAPE are reduced by 39.99%, 35.32%, and 49.12% respectively when the prediction step size is 12; for the PEMS-08 dataset, the reductions are 51.63%, 47.14%, and 37.36% respectively. Compared to the spatiotemporal baselines STGCN and DSTAGNN, which simply use predefined static graphs, the present invention dynamically fuses physical and semantic graphs based on recent traffic conditions, taking into account both the inherent constraints of the road network and the dynamic characteristics of traffic flow, thus exhibiting stronger adaptability. On the PEMS-07 dataset, when the prediction step size is 12, MAE, RMSE, and MAPE are reduced by 24.48%, 22.16%, and 13.13% and 5.76%, 12.36%, and 0.10% respectively compared to STGCN and DSTAGNN. On the PEMS-08 dataset, compared to STGCN, they are reduced by 12.16%, 12.84%, and 9.81% respectively. Compared to DSTAGNN, RMSE is reduced by 4.28%, but MAE and MAPE are slightly increased by 1.30% and 2.85% respectively. Compared to the lightweight STMLP model obtained through knowledge distillation, this invention retains stronger spatiotemporal expressive power and utilizes spatiotemporal priors for online guidance, thus achieving lower errors in most cases. With a prediction step size of 12, the MAE and RMSE on the PEMS-07 dataset decreased by 5.98% and 14.83%, respectively, while the MAPE increased slightly by 3.82%. For the PEMS-08 dataset, the MAE and RMSE decreased by 2.19% and 1.46%, respectively, while the MAPE increased slightly by 1.85%. This is likely because the distillation model tends to output smoother predictions, resulting in lower relative errors.
[0130] Next, the computational efficiency of the three prediction step sizes of the present invention and the baseline model were compared on two datasets. Table 3 is a comparison table of the inference time of the present invention and each baseline model in this embodiment.
[0131]
[0132] Table 2
[0133] As shown in Table 3, this invention maintains low inference overhead on both datasets. With prediction step sizes of 3, 6, and 12, the inference times on the PEMS-07 dataset are 0.025s, 0.024s, and 0.026s, respectively, and on the PEMS-08 dataset are 0.024s, 0.024s, and 0.037s, respectively. Compared to LSTM, this invention introduces limited additional computational overhead on its structure, leading to an increase in inference time, but it remains within the same order of magnitude. This demonstrates that the Graph-LSTM design of this invention can maintain good real-time performance while improving prediction accuracy. In comparison, STGCN and DSTAGNN have significantly longer inference times. STGCN's inference times on the two datasets are 2.317s, 2.159s, 2.224s and 1.353s, 1.462s, 1.337s, respectively, while DSTAGNN's are 3.362s, 3.076s, 3.077s and 2.424s, 2.503s, 2.722s, respectively, all reaching the second level, reflecting the higher computational cost of multi-layered complex models. Furthermore, although STMLP is also a lightweight real-time model, its inference time is still significantly higher than PADGL-Net by an order of magnitude. The inference times for the two datasets are 0.265s, 0.266s, 0.266s and 0.291s, 0.292s, 0.291s, respectively, in the hundreds of milliseconds range.
[0134] In summary, this invention provides higher inference speed while ensuring prediction accuracy, verifying its real-time performance and effectiveness in traffic flow prediction tasks.
[0135] Although the illustrative specific embodiments of the present invention have been described above to enable those skilled in the art to understand the invention, it should be understood that the invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the invention as defined and determined by the appended claims, and all inventions utilizing the concept of the present invention are protected.
Claims
1. A real-time traffic flow prediction method based on prior-perceived dynamic maps, characterized in that, Includes the following steps: S1: Collect traffic flow data samples of the target area within a predetermined historical time period. , , This indicates the number of traffic flow data samples. This indicates the sampling time of the traffic flow data sample. This indicates the number of traffic data collection nodes. This represents the dimension of traffic flow data; then, several sets of continuous sampling times are extracted from it. A sample of traffic flow data, from the previous A series of traffic flow data samples constitute a historical traffic flow data sequence, which will be used to... A traffic flow data sample constitutes a predicted traffic flow data sequence, thereby constructing a traffic flow prediction training sample set; S2: Extract prior time knowledge from traffic flow data samples over historical time periods, including... Time prior features , , Indicates the number of temporal prior features; S3: For the target area A physical adjacency matrix is constructed based on the distances between traffic data collection nodes. A semantic adjacency matrix is constructed based on the similarity of traffic flow data between nodes. , physical adjacency matrix and semantic adjacency matrix As prior knowledge of space; S4: Construct a traffic flow prediction model, including a time prior matching module, an adjacency matrix generation module, and a graph short-term memory network, where: The time prior matching module is used to... Time prior features Current traffic flow data in the middle Time prior features And send it to the graph long short-term memory network; The adjacency matrix generation module is used to generate adjacency matrices based on spatial prior knowledge and historical traffic flow data sequences. Generate the current time adjacency matrix And send it to the graph-length short-term memory network; the adjacency matrix generation module includes a fusion coefficient generation module and a spatial prior fusion module, wherein: The fusion coefficient generation module is used to generate coefficients based on historical traffic flow data sequences. Obtain the fusion coefficient And send it to the spatial prior fusion module; The spatial prior fusion module is used to determine the fusion coefficient. For physical adjacency matrix and semantic adjacency matrix Weighted fusion is performed to obtain the adjacency matrix. : ; Long Short-Term Memory (LSTM) networks are used to consider prior temporal features. and adjacency matrix Predicting the future Traffic flow data sequence at each time point The gating state update process is as follows: , in, This represents the hidden state at the previous time step. Indicates the input gate. Represents the Gate of Oblivion Indicates the output gate. Indicates a candidate state. , , and These represent the weight matrices in the corresponding state update. This corresponds to the bias term in the state update. ; S5: Use the traffic flow prediction training sample set obtained in step S1 to train the traffic flow prediction model and obtain the trained traffic flow prediction model. S6: When traffic flow prediction is required, collect data on the current and previous times of the target area. Traffic flow data samples at each moment constitute a historical traffic flow data sequence, which is then input into a trained traffic flow prediction model to obtain future traffic flow data. A sequence of predicted traffic flow data at each time point.
2. The real-time traffic flow prediction method according to claim 1, characterized in that, The specific method for extracting time prior knowledge in step S2 is as follows: S2.1: For each traffic flow data sample Sampling time Encoding is performed to obtain time-coded features. ; S2.2: For each traffic flow data sample Standardization processing is performed to obtain standardized traffic flow data samples; S2.3: Standardize traffic flow data samples With time coding features splicing to obtain temporal context features : , in, Represents the temporal context feature dimension; S2.4: To Temporal context features Clustering is performed to obtain The central features of each cluster , ,Will Each central eigenvector As a priori feature of time, we can obtain prior knowledge of time.
3. The real-time traffic flow prediction method according to claim 2, characterized in that, The method for encoding the sampling time in step S2.1 is as follows: For any sampling time The daily cycle characteristics are obtained using the following formula. and periodic characteristics : , , in, and Representing time respectively Minute index within a day and week index within a week; Then the daily cycle characteristics and periodic characteristics splicing together yields time-coded features .
4. The real-time traffic flow prediction method according to claim 2, characterized in that, In step S2.4, the K-means clustering algorithm is used to cluster the temporal context features.
5. The real-time traffic flow prediction method according to claim 2, characterized in that, The time prior matching module locates the current traffic flow data. Time prior features The specific methods are as follows: Extraction time Time coding features and current traffic flow data Standardized traffic flow data, and then construct current traffic flow data. Temporal context features Filtering and timing The prior time features that are close to each other within the same day constitute a candidate set of prior time features, and then features that are relevant to the time context are selected from this set. The time prior features with the highest similarity are used as historical traffic flow data Time prior features .
6. The real-time traffic flow prediction method according to claim 1, characterized in that, The physical adjacency matrix in step S3 The construction method is as follows: Construct the initial physical adjacency matrix Traffic data collection nodes and Initial physical adjacency values between The calculation formula is as follows: , in, Represents a node With nodes The Euclidean distance between them Indicates the distance from the standard deviation. Represents a node of Nearest neighbor set; For the initial physical adjacency matrix After performing symmetric normalization, the physical adjacency matrix is obtained. : , in, This indicates that based on the initial physical adjacency matrix The obtained degree matrix, Represents the identity matrix.
7. The real-time traffic flow prediction method according to claim 1, characterized in that, The semantic adjacency matrix in step S3 The construction method is as follows: from Traffic flow data sample Extract each traffic data collection node Traffic flow data sequence Then calculate the nodes With nodes Pearson correlation coefficient between traffic flow data series: , in, and Representing nodes respectively With nodes In traffic flow data samples Traffic flow data in and This represents the mean traffic flow data for the corresponding node across all traffic flow data samples. Then construct the initial semantic adjacency matrix. Traffic data collection nodes and Initial adjacency values between The calculation formula is as follows: , in, Represents nodes Pearson has the highest correlation A set of nodes; For the initial semantic adjacency matrix After performing symmetric normalization, the semantic adjacency matrix is obtained. : , in, Indicates the initial semantic adjacency matrix The resulting degree matrix.