A traffic flow prediction method, system and medium with physical guidance and congestion awareness
Patent Information
- Application Number
- CN202610957760.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-30
- Publication Date
- 2026-09-15
Smart Images

Figure CN122761602A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent transportation, and in particular to a traffic flow prediction method, system, and medium with physical guidance and congestion perception. Background Technology
[0002] With the development of Intelligent Transportation Systems (ITS), reliable traffic flow prediction has become a prerequisite for maximizing road operational efficiency. Traditional prediction methods have evolved from statistical models to data-driven methods based on deep learning. In recent years, spatiotemporal graphical neural networks (ST-GNNs) have gradually become the mainstream architecture in this field, demonstrating great potential in capturing complex, dynamic, long-range spatiotemporal dependencies.
[0003] Existing research includes: Research 1: Proposing a spatiotemporal prediction scheme for urban traffic flow based on graph convolutional neural networks. This scheme utilizes spatial graph convolution to extract topological spatial features between road network nodes and combines it with time series models to capture the dynamic evolution of traffic data. Finally, it performs global numerical fitting using standard loss functions (such as MSE or MAE). Research 2 (such as the feature enhancement model in invention patent CN114360254B): Proposing a prediction scheme that combines temporal convolutional neural networks and dual graph convolutional networks. This scheme uses multi-channel or parallel graph convolutional modules to enhance the feature extraction capability for complex spatiotemporal correlations of traffic flow, attempting to improve the model's prediction performance under fluctuating road conditions. Research 3: Proposing a deep learning prediction scheme that combines macroscopic traffic flow theory. In this scheme, physical equations (such as macroscopic basic graph formulas) are used as unscaled soft constraints or regularization terms and directly added to the main loss function for joint training with data-driven loss.
[0004] However, the aforementioned research approaches do not address the fundamental issues of prediction failure from the perspectives of differences in the dimensions of physical variables and the distribution of long-tailed congestion data. In practical traffic prediction applications, purely data-driven traffic prediction models (such as Studies 1 and 2) often focus only on numerical fitting while neglecting physical consistency, easily generating predictions that violate the basic kinematic laws of macroscopic traffic flow. The above-mentioned schemes suffer from "physical anomalies" (such as the paradox of high density and high flow). Furthermore, existing physical guidance schemes (such as Study 3), if directly adding physical constraints, are prone to gradient dominance and imbalance problems during training due to the significant differences in the scales of variables such as speed and density. In addition, all the above schemes use a global standard loss function and do not enhance dynamic perception and adaptive weighting for scarce "severe congestion" samples. If traditional global fitting metrics are used, the model is prone to "oversmoothing" bias, failing to accurately capture the nonlinear collapse process of traffic flow transitioning to congestion, resulting in a significant decrease in prediction accuracy in severe congestion scenarios. Summary of the Invention
[0005] The purpose of this invention is to provide a traffic flow prediction method, system, and medium with physical guidance and congestion perception that significantly improves the accuracy and reliability of traffic flow prediction.
[0006] The objective of this invention can be achieved through the following technical solutions: A traffic flow prediction method with physical guidance and congestion perception includes the following steps: The target traffic network is abstracted into a directed graph, and real-time traffic data of the target traffic network is obtained. A traffic flow prediction model is then used to process the data, and the traffic flow state prediction results are output. The training steps of the traffic flow prediction model include: Obtain historical traffic data for the target road network; Based on the historical traffic data and the directed graph, a multi-channel spatiotemporal backbone network model is used to perform spatiotemporal feature fusion to obtain spatiotemporal fusion features, which are then mapped to the predicted traffic flow state corresponding to the historical traffic data. Based on the predicted traffic flow state, a physical consistency loss is constructed in the physical space through a physical information regularization loop; Based on the historical traffic data corresponding to the predicted traffic flow state, a congestion perception weighted loss for the predicted time step is constructed through a congestion perception calibration loop. The traffic flow prediction model is obtained by jointly optimizing the physical consistency loss and congestion perception weighted loss and training the multi-channel spatiotemporal backbone network model.
[0007] Furthermore, the directed graph is represented as follows: , For a set of sensor nodes, For the set of connecting edges, This is an adjacency matrix generated based on the physical distance of the sensors.
[0008] Furthermore, both the real-time traffic data and the historical traffic data include traffic flow. Traffic density and traffic speed The normalized road occupancy rate is used for linear approximation calculation, replacing the traffic density. .
[0009] Furthermore, both the real-time traffic data and the historical traffic data are input in the form of graph signal matrices. Before being input into the traffic flow prediction model and the multi-channel spatiotemporal backbone network model, respectively, they are normalized using the Z-score normalization method to obtain the normalized graph signal matrix and the normalized historical graph signal matrix.
[0010] Furthermore, the multi-channel spatiotemporal backbone network model includes multiple stacked spatiotemporal blocks. Each spatiotemporal block includes a spatial attention mechanism module, a temporal attention mechanism module, a spatial graph convolutional network module, and a temporal convolutional network module connected in sequence. The processing steps in the first spatiotemporal block include: For the spatial attention mechanism module: Using the historical traffic data as input features, a linear transformation is performed on the input features to obtain the spatial query matrix. Space bond matrix and spatial value matrix , respectively represented as: , In the formula, For input features, , , For spatial attention, learnable weight matrix; Based on the spatial query matrix Space bond matrix Calculate the association weights between different nodes in the directed graph. , is represented as: , In the formula, The dimension of the key vector; For the aforementioned association weights Normalization yields the spatial attention matrix representing the dependence strength between any two nodes. ,in for Normalization operation; For the spatial attention matrix and spatial value matrix Weighting yields spatial attention-weighted temporal features. , is represented as: , For the time attention mechanism module: The spatial attention-weighted temporal features are linearly mapped along the time dimension to generate a temporal query matrix. Space bond matrix and spatial value matrix , respectively represented as: , In the formula, , , These are the learnable weights of temporal attention; Calculate the correlation score between each historical time step and the prediction target. , is represented as: , In the formula, The time-series vector dimension; The correlation score After normalization, we obtain the time attention weight matrix representing the prediction contribution of each historical step. ; For the time attention weight matrix and spatial value matrix Weighting yields spatiotemporal dual attention weighted features. , is represented as: , For spatial graph convolutional network modules: Output a normalized Laplace matrix based on the adjacency matrix of the directed graph. ; Pick Chebyshev polynomial Scaling the Laplacian matrix: , In the formula, This is the scaled Laplace matrix. for Maximum eigenvalue; get Polynomial approximation graph convolution kernel: , In the formula, For approximate graph convolution kernel, These are the polynomial learnable coefficients; For the spatiotemporal dual attention weighted features at each time step Perform ChebNet graph convolution, aggregating itself and... The spatial propagation patterns of the neighboring nodes are extracted from the topological information of the first-order neighboring nodes to obtain the spatiotemporal characteristics of the local topology of the fused road network, which are represented as follows: , In the formula, To integrate the spatiotemporal characteristics of local road network topology, It is a non-linear activation function. Transform the weights for the convolution channels; For the temporal convolutional network module: Based on the spatiotemporal characteristics of the local topology of the fused road network A temporal convolutional network is used to perform convolution operations in the time dimension to obtain the convolution output, which is represented as: , In the formula, For convolution output, For one-dimensional convolution, The void coefficient is... For convolution kernel; Introducing residual connections to fuse the spatiotemporal characteristics of the local topology of the fused road network Furthermore, the temporal receptive field is expanded, and the first spatiotemporal block outputs spatiotemporal fusion features, which serve as the input features for the next spatiotemporal block. The spatiotemporal fusion features are expressed as follows: , In the formula, It is a spatiotemporal fusion feature.
[0011] Furthermore, the step of constructing the physical consistency loss includes: Let the predicted traffic flow state be ,in, To predict traffic, To predict density, For predicting speed; The predicted traffic flow state is Inverse normalization is performed to perform spatial reconstruction, resulting in inverse normalized predicted traffic flow states. ,in This is an inverse Z-score normalization operation; Obtain the predicted flow Calculate the standard deviation of the corresponding actual traffic flow. ; Traffic flow state prediction based on the inverse normalization Calculate the physical residual of each node at each prediction time step. ,in, For nodes In the predicted time step Predicted traffic, For nodes In the predicted time step The predicted density, For nodes In the predicted time step Prediction speed; Using the standard deviation The physical residuals are scaled and normalized to construct a physical consistency loss. , is represented as: , In the formula, This represents the total number of sensor nodes. The predicted future time step.
[0012] Furthermore, the step of constructing the congestion-aware weighted loss for the prediction time step includes: Extracting the steady flow peaks and congestion flow peaks exhibiting a bimodal distribution from the historical traffic speed data, and using the local minimum points between the steady flow peaks and congestion flow peaks as the preset congestion thresholds for the target traffic network. ; Obtain the nodes in the target traffic network In the predicted time step Real traffic speed ; The actual traffic speed With the preset congestion threshold The comparisons are performed, and a two-level congestion weight mask is constructed based on the comparison results. , is represented as: , In the formula, To increase the penalty weight for congestion, For nodes In the predicted time step Corresponding real-world traffic speed; Congestion weight mask based on all nodes and the prediction time step Construct a congestion weight matrix , is represented as: , In the formula, The number of nodes in the target transportation network. Indicates the prediction time step; Using the congestion weight matrix The error between the predicted traffic flow state and the corresponding actual traffic flow state is dynamically weighted to construct a congestion perception weighted loss. , is represented as: , In the formula, Congestion weight matrix The element at the corresponding position, i.e., the node In the predicted time step The corresponding congestion weight, It is an L1 norm. For nodes In the predicted time step Predicted traffic flow conditions For nodes In the predicted time step The corresponding actual traffic flow status.
[0013] Furthermore, by jointly optimizing the physical consistency loss and the congestion-aware weighted loss, the total loss is constructed, expressed as: , In the formula, For the total loss, For congestion perception weighted loss, For physical consistency loss, For hyperparameter weights.
[0014] The present invention also provides a traffic flow prediction system with physical guidance and congestion perception, including a memory, a processor, and a program stored in the memory. When the processor executes the program, it implements a traffic flow prediction method with physical guidance and congestion perception as described above.
[0015] The present invention also provides a storage medium storing a program thereon, which, when executed, implements a traffic flow prediction method with physical guidance and congestion perception as described above.
[0016] Compared with the prior art, the present invention has the following beneficial effects: (1) This invention optimizes the physical consistency loss and congestion perception weighted loss together so that the model can simultaneously satisfy the physical laws of traffic flow and accurately capture congestion characteristics, which significantly improves the accuracy and reliability of traffic flow prediction.
[0017] (2) In this invention, spatial and temporal attention differential weighting within the spatiotemporal block preserves congestion mutation features and suppresses excessive smoothing of convolutional graphs. Then, relying on congestion perception calibration loops combined with congestion weighted loss, the training gradient of long-tail congestion samples is amplified. In addition, physical consistency loss is used for hierarchical iterative joint optimization to systematically solve the problems of prediction degradation and feature homogeneous smoothing distortion in long-tail congestion scenarios.
[0018] (3) This invention utilizes a dual attention mechanism to independently mine dynamic spatial dependencies and dynamic temporal dependencies, and then uses ChebNet to solidify the road network topology and TCN to uniformly extract temporal evolution, thereby achieving multi-dimensional information layered extraction on dynamic dependencies and static topology in both long and short time series, solving the pain point of traditional models where spatiotemporal features are coupled and mixed and cannot be optimized separately. At the same time, the dual attention mechanism adaptively adjusts the weights, and even in non-ideal road network scenarios such as local data anomalies and tidal lane switching, it can still stably extract effective features based on topological and temporal patterns, and will not cause prediction collapse due to local data failure.
[0019] (4) This invention is based on the basic traffic flow conservation relationship. By constructing physical residuals, the physical consistency loss is penalized, forcing the model to automatically adjust its predictions during optimization to meet physical constraints. This addresses the problem of "physical anomalies" that are easily generated in existing technologies, and these physical constraints provide prior domain knowledge. This is equivalent to adding a "physical anchor point" to the model, enabling it to maintain reasonable output even when data is lacking due to new road sections, new time periods, or sudden events.
[0020] (5) This invention automatically assigns higher loss weights to congestion grids and congestion time series through congestion weight mask, and greatly amplifies the gradient update intensity of congestion prediction error during backpropagation, forcing the model to focus on learning the laws of congestion formation, overflow and dissipation, and significantly reducing the prediction errors of congestion density, congestion duration and congestion propagation path.
[0021] (6) The present invention controls the physical consistency loss to manage the basic physical deviation of the global traffic flow, and the congestion perception weighted loss focuses on the temporal / spatial deviation of the congested area. It dually constrains the density, speed and flow matching relationship under congestion, which greatly improves the interpretability of the prediction results.
[0022] (7) The PI physical regularization loop of the present invention relies on physical consistency loss to iteratively correct global physical distortion, and the CW congestion calibration loop relies on congestion weighted loss to iteratively correct congestion bias. After the two loops converge alternately, the parameters are updated globally, which greatly reduces the pressure of overall model iterative correction and improves the real-time prediction stability in the inference stage. Attached Figure Description
[0023] Figure 1 This is a schematic diagram of the method flow of the present invention; Figure 2 This is a structural block diagram of the multi-channel spatiotemporal backbone network model of the present invention; Figure 3 This is a schematic diagram of the feature extraction logic for the spatiotemporal block in this invention. Detailed Implementation
[0024] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. These embodiments are based on the technical solution of the present invention and provide detailed implementation methods and specific operating procedures. However, the scope of protection of the present invention is not limited to the following embodiments.
[0025] This embodiment provides a traffic flow prediction method with physical guidance and congestion perception. This method extracts the spatiotemporal features of traffic flow data and introduces macroscopic physical law constraints and a dynamic congestion error penalty mechanism in parallel, thereby achieving high-precision traffic prediction. It addresses two core shortcomings of existing pure data-driven traffic prediction models: First, it solves the problem of models lacking physical consistency and easily generating "physical anomalies" (i.e., prediction results that violate macroscopic traffic flow kinematics). Second, it addresses the problem of severe performance degradation and "over-smoothing" in complex congestion scenarios with long-tailed distributions.
[0026] First, the core parameters and symbols involved in the embodiments of this invention are uniformly explained as shown in Table 1 below: Table 1. Explanation of core parameters in embodiments of the present invention. This method trains a multi-channel spatiotemporal backbone network model to obtain a traffic flow prediction model, and then uses this model to predict traffic flow in real-world scenarios. Combined with... Figure 1 As shown, the training steps for this multi-channel spatiotemporal backbone network model include: S1. Data Acquisition and Preprocessing 1. Road Network Modeling: Obtain historical traffic data for each node in the target traffic network within the past time window. In this embodiment, the target traffic network is abstractly represented as a directed graph. ,in Represents the set of sensor nodes (total number of nodes is ). ), Represents the set of connecting edges. This represents the adjacency matrix generated based on the physical distance from the sensors.
[0027] 2. Feature Construction: Historical traffic data is input in the form of a graph signal matrix, specifically including traffic flow ( (Unit: veh / h), traffic density ( ) and traffic speed ( (Unit: mph). Since traffic density is difficult to measure directly in actual road monitoring, under homogeneous traffic conditions, this embodiment uses a normalized road occupancy rate for linear approximation calculation to replace the actual traffic density. .
[0028] 3. Normalization: In order to eliminate the differences in data units between different traffic variables and accelerate model convergence, the acquired historical traffic data is normalized using Z-score.
[0029] S2. Multi-channel spatiotemporal feature extraction and state prediction 1. Backbone network input: The normalized historical map signal matrix is input into the multi-channel spatiotemporal backbone network model to extract the spatial features and temporal correlation of the traffic network.
[0030] 2. Spatiotemporal feature extraction: such as Figure 2 As shown, the multi-channel spatiotemporal backbone network model in this embodiment (based on ASTGCN (a spatiotemporal graph convolutional network architecture based on attention mechanism) is composed of multiple stacked spatiotemporal blocks (ST-Blocks). The number of stacked spatiotemporal blocks ranges from 1 to 10 layers, and is set to 2 layers in this embodiment. Each spatiotemporal block contains, in sequence, a spatial attention mechanism module, a temporal attention mechanism module, a spatial graph convolutional network module, and a temporal convolutional network (TCN) module. Specifically, the processing steps of the first spatiotemporal block are as follows: (1) The spatial attention mechanism module receives the input graph signal matrix, calculates the association weights between different nodes, and generates a spatial attention matrix. Then, the spatial attention matrix is used to weight the input features, giving greater feature weights to nodes with significant traffic state changes or strong topological associations, thereby dynamically representing the spatial dependencies in the traffic network. Specifically: Using historical traffic data as input features, a linear transformation is performed on the input features to obtain the spatial query matrix. Space bond matrix and spatial value matrix , respectively represented as: , In the formula, For input features, , , For spatial attention, learnable weight matrix; Based on spatial query matrix Space bond matrix Calculate the association weights between different nodes in a directed graph. , is represented as: , In the formula, The dimension of the key vector; Association weights Normalization yields the spatial attention matrix representing the dependence strength between any two nodes. ,in for Normalization operation; Spatial attention matrix and spatial value matrix Weighting yields spatial attention-weighted temporal features. , is represented as: .
[0031] This module dynamically calculates node association weights using an attention matrix, automatically increasing feature weights for road segments with strong congestion propagation and traffic flow disturbance linkages. It accurately captures the dynamic traffic flow coupling relationships between ramps, intersections, and bottleneck segments, improving the accuracy of spatial association modeling for complex road networks. Furthermore, it can reduce the feature weights of nodes with weak correlations and independent traffic states, filter out noise from irrelevant road segments, reduce the interference of invalid spatial information on subsequent predictions, and enhance the model's ability to identify road network congestion propagation paths and traffic flow diffusion patterns.
[0032] (2) The temporal attention mechanism module receives the feature sequence after spatial attention weighting, calculates the correlation between each historical time step and the future predicted state, and generates a temporal attention matrix. Then, based on the temporal attention matrix, the weights of historical time-series features are reallocated, so that time steps with a greater impact on future traffic states receive a higher feature proportion, thereby enhancing the model's ability to model long-term temporal dependencies. Specifically: A temporal query matrix is generated by linearly mapping the spatial attention-weighted temporal features along the time dimension. Space bond matrix and spatial value matrix , respectively represented as: , In the formula, , , These are the learnable weights of temporal attention; Calculate the correlation score between each historical time step and the prediction target. , is represented as: , In the formula, The time-series vector dimension; Relevance score After normalization, we obtain the time attention weight matrix representing the prediction contribution of each historical step. ; Attention weight matrix and spatial value matrix Weighting yields spatiotemporal dual attention weighted features. , is represented as: .
[0033] Since historical data from the morning rush hour and time series prior to sudden incidents have a greater impact on future predictions, while off-peak irrelevant time series have low value, this module automatically allocates time series weights through time attention, amplifying the features of highly relevant historical time steps. This strengthens long-term time series dependencies such as morning and evening rush hours and weekday cycles, while also preserving short-term abrupt changes such as accidents and temporary traffic controls, thus addressing the shortcomings of ordinary TCN / GRU in treating all time steps equally. Furthermore, by focusing on key time series segments with weights, it weakens the gradient loss caused by redundant historical information, which helps improve long-term prediction performance.
[0034] (3) The Spatial Graph Convolutional Network (GCN) module, based on the road network topology described by the adjacency matrix, uses Chebyshev polynomial (ChebNet, Chebyshev Graph Convolutional Network) approximate graph convolution operators to perform multi-order feature aggregation on the target node and its neighboring nodes. Through convolution calculations, it extracts the local spatial topology features of the traffic network and the spatial propagation patterns between nodes. Specifically: Output a normalized Laplacian matrix based on the adjacency matrix of the directed graph. ; Pick Chebyshev polynomial Scaling the Laplacian matrix: , In the formula, This is the scaled Laplace matrix. for Maximum eigenvalue; get Polynomial approximation graph convolution kernel: , In the formula, For approximate graph convolution kernel, These are the polynomial learnable coefficients; For the spatiotemporal dual attention weighted features at each time step Perform ChebNet graph convolution, aggregating itself and... The spatial propagation patterns of the neighboring nodes are extracted from the topological information of the first-order neighboring nodes to obtain the spatiotemporal characteristics of the local topology of the fused road network, which are represented as follows: , In the formula, To integrate the spatiotemporal characteristics of local road network topology, It is a non-linear activation function. Transform the weights for the convolution channels.
[0035] This module utilizes Chebyshev polynomials to aggregate multi-order neighborhood features, simultaneously extracting topological features of first-order adjacent road segments and second-order upstream and downstream linked road segments without stacking multiple layers of graph convolutions. This fully depicts the spatial evolution of congestion spreading from bottlenecks to upstream and downstream levels. Furthermore, it models the inherent connectivity of roads based on the road network Laplacian matrix, avoiding the generation of meaningless node associations by the attention mechanism that is completely detached from the actual road network topology. This achieves a two-way constraint of "dynamic attention weight + fixed road network topology," balancing flexibility and traffic physics rationality.
[0036] (4) The Temporal Convolutional Network (TCN) module performs temporal convolution operations on the feature sequences output by the spatial graph convolutional network to extract the dynamic patterns of traffic state changes over time. Simultaneously, residual connections are used to expand the temporal receptive field, enabling the model to learn both short-term fluctuation features and long-term trends, thus obtaining the final spatiotemporal fusion feature representation. Specifically: For the temporal convolutional network module: Spatiotemporal characteristics based on local topology of fused road network A temporal convolutional network is used to perform convolution operations in the time dimension to obtain the convolution output, which is represented as: , In the formula, For convolution output, For one-dimensional convolution, The void coefficient is... For convolution kernel; Introducing residual connectivity to fuse the spatiotemporal characteristics of the local topology of the fused road network Furthermore, the temporal receptive field is expanded. The first spatiotemporal block outputs spatiotemporal fusion features, which serve as the input features for the next spatiotemporal block. The spatiotemporal fusion features are represented as follows: , In the formula, As a spatiotemporal fusion feature, this feature fully preserves the underlying laws of spatial propagation and temporal cycles of traffic flow, providing high-quality basic features for subsequent physical information regularization cycles and congestion perception calibration cycles, reducing the pressure of subsequent iterative corrections, and accelerating the convergence of the overall model.
[0037] The residual connection of this module directly transmits the original spatial topology features, avoids gradient decay in deep networks, supports the stacking of multiple spatiotemporal blocks to build deep models, and further improves the feature extraction capability of complex road networks.
[0038] 3. State Output: After multi-layer spatiotemporal block feature extraction, the final prediction layer outputs the 3D predicted traffic state of each node within the future time window. Past time window (input step size) ) and future time window (prediction step size) The value range of ) is preferably from 1 to 24 steps, and in this embodiment, it is set to 12. This embodiment of the invention also outputs the predicted flow rate. Predicted density and prediction speed .
[0039] S3, Physical Information (PI, Physics-Informed) Regularized Loop like Figure 3 As shown in the right-hand branch, a physical information regularization loop is constructed, and the principle of the macroscopic traffic flow basic graph is introduced for constraint: 1. Spatial Reconstruction: To strictly constrain the predicted solution space of deep learning within a range consistent with real fluid dynamics, the predicted flow rate output by the multi-channel spatiotemporal backbone network model is... Predicted density and prediction speed Denorm is performed to restore the traffic flow to its true physical dimension space, resulting in the denormated predicted traffic flow state. .
[0040] 2. Calculation of Physical Consistency Loss: Based on the fluid dynamics relationship (flow rate equals the product of density and velocity), the physical residuals between the three predictor variables are calculated. To avoid excessively large loss values and gradient-dominated problems caused by directly calculating residuals in physical space, this embodiment uses the standard deviation of real traffic flow data from the training set. The residuals are scaled and normalized to generate a dimensionless physical consistency loss. The specific formula is as follows: , In the formula, This represents the total number of sensor nodes. For the predicted future time step, For nodes In the predicted time step Predicted traffic, For nodes In the predicted time step The predicted density, For nodes In the predicted time step Prediction speed, This is the inverse Z-score normalization operation.
[0041] This loss term forces the model's predicted solution space to be constrained within boundaries that conform to the laws of real physics.
[0042] S4, Congestion-Weighted Calibration Cycle (CW) This embodiment constructs a congestion-aware calibration loop and enhances the model's learning ability on long-tail congestion samples through a dynamic weighting mechanism. Specifically, it includes the following steps: 1. Adaptive Threshold Determination: To address the scarcity of congestion samples in traffic flow data, historical traffic speed data of the target road network is statistically analyzed. The peaks of steady flow and congested flow exhibiting a bimodal distribution are extracted, and the local minimum points between these two distribution peaks are automatically determined as the preset congestion threshold τ for the road network. This threshold typically fluctuates between 20 mph and 50 mph; in the highway scenario of this embodiment, it is set to 40 mph.
[0043] 2. Weight Mask Construction: Obtain the actual traffic speed at the corresponding node and prediction time step. ,in, Represents a node In the predicted time step The corresponding real traffic speed, that is, the real speed in the label data during the training phase.
[0044] Based on actual speed Compared with the preset congestion threshold Based on the comparison results, a two-level congestion weight mask is constructed. : , When the actual speed is lower than the threshold, it is judged as an unpredictable long-tail severe congestion event and assigned a congestion amplification penalty weight greater than 1. This represents the congestion amplification penalty weight, with a value greater than 1, used to increase the loss contribution of severely congested samples during model training; when the actual speed is higher than the congestion threshold, a normal base weight of 1 is assigned. This is based on the congestion weight mask corresponding to all nodes and the prediction time step. Construct a congestion weight matrix: , in, This indicates the number of nodes in the transportation network. Indicates the prediction time step, matrix The Middle Line 1 Column elements represent nodes In the predicted time step The corresponding congestion weight.
[0045] 3. Congestion-perceived weighted loss calculation: using the aforementioned congestion weight matrix The error between the model's predicted state and the actual state is dynamically weighted to construct a congestion-aware weighted loss. : , in, Represents a node In the predicted time step The predicted state vector; Represents a node In the predicted time step The corresponding true state vector; Represents the congestion weight matrix The element at the corresponding position in the middle; This represents the L1 norm. By multiplying this weight mask by the error term between the model's predicted state and the actual state, a congestion-aware weighted loss is generated, forcing the network optimizer to shift its attention towards the congestion collapse phase.
[0046] Through the aforementioned dynamic weighting mechanism, greater loss weights are assigned to prediction errors under severe congestion conditions, thereby guiding the model optimizer to pay more attention to long-tail congestion samples and improving the prediction accuracy and robustness of the model under complex traffic conditions.
[0047] S5, Joint Optimization and Model Update 1. Total Loss Calculation: Jointly optimize the physical consistency loss obtained in step S3 and the congestion perception weighted loss obtained in step S4 to calculate the total loss function. : , In the formula This represents the hyperparameter weight, which ranges from 0.01 to 0.5, and is set to 0.1 in this embodiment.
[0048] 2. Gradient Update and Early Stopping: Based on the total loss function, the parameters of the multi-channel spatiotemporal backbone network model are updated using the Adam gradient descent optimizer. The initial learning rate ranges from 1e-5 to 1e-2, and in this embodiment, it is set to 1e-3. An early stopping mechanism is incorporated during iterative training. Training stops when the prediction performance on the validation set no longer improves within 5 to 50 consecutive iterations (15 in this embodiment) to prevent overfitting. When the stopping condition is met, training ends and the optimized traffic flow prediction model is output.
[0049] This embodiment uses root mean square error (RMSE) and mean absolute error (MAE) as performance evaluation metrics. To highlight the advantages of this embodiment under complex congestion conditions, the experiment not only evaluated the prediction error of the global sample, but also specifically evaluated the error of the severely congested sample where the actual speed was below the threshold (less than 40 mph). The performance comparison results of the method of this embodiment (CAP-STGCN) with existing mainstream baseline models are shown in Table 2: Table 2 Comparison of prediction errors between the method of the present invention and the baseline model under overall and congested conditions. As shown in Table 2, although some existing advanced models (such as MegaCRN) perform well in terms of global average error, their errors increase sharply on long-tailed congestion samples (e.g., the congestion RMSE is as high as 54.92 on PeMS04). In contrast, the embodiment of this invention (CAP-STGCN), by introducing a congestion-aware calibration mechanism, achieves the lowest RMSE (53.69) in the congestion scenario of PeMS04, and achieves the best prediction performance in both global and congestion scenarios on the PeMS08 dataset. This fully demonstrates the significant advantages of the embodiment of this invention in overcoming the "oversmoothing" bias of purely data-driven models and improving the prediction accuracy of extreme road conditions.
[0050] Furthermore, to verify the independent contributions and synergistic effects of the physical guidance module and the congestion sensing module in this embodiment, ablation experiments were conducted on the PeMS04 dataset. The base model (M1), the model containing only physical guidance constraints (M2), the model containing only congestion sensing weights (M3), and the complete model of this embodiment (M4) were compared. The RMSE results for different prediction time steps (15 minutes, 30 minutes, and 60 minutes) are shown in Table 3. Table 3 Comparison of ablation experimental performance (RMSE) of core modules in embodiments of the present invention As shown in Table 3, the ablation experiment results indicate that introducing only physical guidance (M2) effectively alleviates the error accumulation of the model under a long prediction window (60 minutes); introducing only congestion perception (M3) significantly improves short- and medium-term prediction performance. The complete CAP-STGCN model (M4) in this embodiment combines both, achieving the best overall and most stable prediction performance. This demonstrates that the congestion perception module actively guides the optimizer to capture complex nonlinear traffic collapse characteristics, while the physical guidance module provides robust boundary constraints to ensure the kinematic feasibility of the predicted solution. Their collaborative work ensures that this embodiment maintains high statistical accuracy while strictly guaranteeing physical consistency.
[0051] Through the above training and verification, a traffic flow prediction model was finally obtained from the multi-channel spatiotemporal backbone network model. This traffic flow prediction model is used for real-time traffic flow prediction in real-world scenarios. Specifically, it acquires real-time traffic data of the target traffic network, performs Z-score normalization, inputs the data into the traffic flow prediction model for prediction, and outputs real-time traffic flow state prediction results, including real-time predicted flow rate, predicted density, and predicted speed.
[0052] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0053] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of the present invention can be implemented using various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0054] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0055] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0056] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0057] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0058] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A traffic flow prediction method with physical guidance and congestion awareness, characterized in that, Includes the following steps: The target traffic network is abstracted into a directed graph, and real-time traffic data of the target traffic network is obtained. A traffic flow prediction model is then used to process the data, and the traffic flow state prediction results are output. The training steps of the traffic flow prediction model include: Obtain historical traffic data for the target road network; Based on the historical traffic data and the directed graph, a multi-channel spatiotemporal backbone network model is used to perform spatiotemporal feature fusion to obtain spatiotemporal fusion features, which are then mapped to the predicted traffic flow state corresponding to the historical traffic data. Based on the predicted traffic flow state, a physical consistency loss is constructed in the physical space through a physical information regularization loop; Based on the historical traffic data corresponding to the predicted traffic flow state, a congestion perception weighted loss for the predicted time step is constructed through a congestion perception calibration loop. The traffic flow prediction model is obtained by jointly optimizing the physical consistency loss and congestion perception weighted loss and training the multi-channel spatiotemporal backbone network model.
2. The traffic flow prediction method with physical guidance and congestion perception according to claim 1, characterized in that, The directed graph is represented as , is a set of sensor nodes, is a set of connecting edges, is an adjacency matrix generated based on the physical distance of sensors.
3. The traffic flow prediction method with physical guidance and congestion perception according to claim 1, characterized in that, Both the real-time traffic data and the historical traffic data include traffic flow. Traffic density and traffic speed The normalized road occupancy rate is used for linear approximation calculation, replacing the traffic density. .
4. The traffic flow prediction method with physical guidance and congestion perception according to claim 1, characterized in that, The real-time traffic data and historical traffic data are both input in the form of graph signal matrices. Before being input into the traffic flow prediction model and the multi-channel spatiotemporal backbone network model, respectively, they are normalized using the Z-score normalization method to obtain the normalized graph signal matrix and the normalized historical graph signal matrix.
5. The traffic flow prediction method with physical guidance and congestion perception according to claim 1, characterized in that, The multi-channel spatiotemporal backbone network model includes multiple stacked spatiotemporal blocks. Each spatiotemporal block includes a spatial attention mechanism module, a temporal attention mechanism module, a spatial graph convolutional network module, and a temporal convolutional network module connected in sequence. The processing steps in the first spatiotemporal block include: For the spatial attention mechanism module: Using the historical traffic data as input features, a linear transformation is performed on the input features to obtain the spatial query matrix. Space bond matrix and spatial value matrix , respectively represented as: , In the formula, For input features, , , For spatial attention, learnable weight matrix; Based on the spatial query matrix Space bond matrix Calculate the association weights between different nodes in the directed graph. , is represented as: , In the formula, The dimension of the key vector; For the aforementioned association weights Normalization yields the spatial attention matrix representing the dependence strength between any two nodes. ,in for Normalization operation; For the spatial attention matrix and spatial value matrix Weighting yields spatial attention-weighted temporal features. , is represented as: , For the time attention mechanism module: The spatial attention-weighted temporal features are linearly mapped along the time dimension to generate a temporal query matrix. Space bond matrix and spatial value matrix , respectively represented as: , In the formula, , , These are the learnable weights of temporal attention; Calculate the correlation score between each historical time step and the prediction target. , is represented as: , In the formula, The time-series vector dimension; The correlation score After normalization, we obtain the time attention weight matrix representing the prediction contribution of each historical step. ; For the time attention weight matrix and spatial value matrix Weighting yields spatiotemporal dual attention weighted features. , is represented as: , For spatial graph convolutional network modules: Output a normalized Laplace matrix based on the adjacency matrix of the directed graph. ; Pick Chebyshev polynomial Scaling the Laplacian matrix: , In the formula, This is the scaled Laplace matrix. for Maximum eigenvalue; get Polynomial approximation graph convolution kernel: , In the formula, For approximate graph convolution kernel, These are the polynomial learnable coefficients; For the spatiotemporal dual attention weighted features at each time step Perform ChebNet graph convolution, aggregating itself and... The spatial propagation patterns of the neighboring nodes are extracted from the topological information of the first-order neighboring nodes to obtain the spatiotemporal characteristics of the local topology of the fused road network, which are represented as follows: , In the formula, To integrate the spatiotemporal characteristics of local road network topology, It is a non-linear activation function. Transform the weights for the convolution channels; For the temporal convolutional network module: Based on the spatiotemporal characteristics of the local topology of the fused road network A temporal convolutional network is used to perform convolution operations in the time dimension to obtain the convolution output, which is represented as: , In the formula, For convolution output, For one-dimensional convolution, The void coefficient is... For convolution kernel; Introducing residual connections to fuse the spatiotemporal characteristics of the local topology of the fused road network Furthermore, the temporal receptive field is expanded, and the first spatiotemporal block outputs spatiotemporal fusion features, which serve as the input features for the next spatiotemporal block. The spatiotemporal fusion features are expressed as follows: , In the formula, It is a spatiotemporal fusion feature.
6. The traffic flow prediction method with physical guidance and congestion perception according to claim 1, characterized in that, The steps for constructing the physical consistency loss include: Let the predicted traffic flow state be ,in, To predict traffic, To predict density, For predicting speed; The predicted traffic flow state is Inverse normalization is performed to perform spatial reconstruction, resulting in inverse normalized predicted traffic flow states. ,in This is an inverse Z-score normalization operation; Obtain the predicted flow Calculate the standard deviation of the corresponding actual traffic flow. ; Traffic flow state prediction based on the inverse normalization Calculate the physical residual of each node at each prediction time step. ,in, For nodes In the predicted time step Predicted traffic, For nodes In the predicted time step The predicted density, For nodes In the predicted time step Prediction speed; Using the standard deviation The physical residuals are scaled and normalized to construct a physical consistency loss. , is represented as: , In the formula, This represents the total number of sensor nodes. The predicted future time step.
7. The traffic flow prediction method with physical guidance and congestion perception according to claim 1, characterized in that, The steps for constructing the congestion-aware weighted loss for the predicted time step include: Extracting the steady flow peaks and congestion flow peaks exhibiting a bimodal distribution from the historical traffic speed data, and using the local minimum points between the steady flow peaks and congestion flow peaks as the preset congestion thresholds for the target traffic network. ; Obtain the nodes in the target traffic network In the predicted time step Real traffic speed ; The actual traffic speed With the preset congestion threshold The comparisons are performed, and a two-level congestion weight mask is constructed based on the comparison results. , is represented as: , In the formula, To increase the penalty weight for congestion, For nodes In the predicted time step Corresponding real-world traffic speed; Congestion weight mask based on all nodes and the prediction time step Construct a congestion weight matrix , is represented as: , In the formula, The number of nodes in the target transportation network. Indicates the prediction time step; Using the congestion weight matrix The error between the predicted traffic flow state and the corresponding actual traffic flow state is dynamically weighted to construct a congestion perception weighted loss. , is represented as: , In the formula, Congestion weight matrix The element at the corresponding position, i.e., the node In the predicted time step The corresponding congestion weight, It is an L1 norm. For nodes In the predicted time step Predicted traffic flow conditions For nodes In the predicted time step The corresponding actual traffic flow status.
8. The traffic flow prediction method with physical guidance and congestion perception according to claim 1, characterized in that, By jointly optimizing the physical consistency loss and the congestion-aware weighted loss, the total loss is constructed, expressed as: , In the formula, For the total loss, For congestion perception weighted loss, For physical consistency loss, For hyperparameter weights.
9. A traffic flow prediction system with physical guidance and congestion perception, comprising a memory, a processor, and a program stored in the memory, characterized in that, When the processor executes the program, it implements a traffic flow prediction method with physical guidance and congestion perception as described in any one of claims 1-8.
10. A storage medium having a program stored thereon, characterized in that, When the program is executed, it implements a traffic flow prediction method with physical guidance and congestion perception as described in any one of claims 1-8.
Citation Information
Patent Citations
A spatiotemporal traffic flow prediction method and related equipment
CN114360254B