Traffic flow prediction method and system based on multi-scale dynamic space diagram
Through multi-scale dynamic spatial graphs and adaptive convolution mechanism, the technical bottleneck of multi-scale and dynamic spatial dependence in traffic flow prediction is solved, and high-precision traffic flow prediction is achieved, which is suitable for smart traffic scheduling and congestion warning.
Patent Information
- Application Number
- CN202510773934.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2025-06-09
- Filing Date
- 2025-06-11
- Publication Date
- 2025-09-16
AI Technical Summary
Existing traffic flow prediction methods have difficulty accurately modeling the multi-scale and multi-level spatiotemporal dependencies in traffic systems. Especially in high-density urban road networks, the spatial dependencies between sensor nodes are highly dynamic, and existing models find it difficult to dynamically update the graph structure to adapt to such changes.
The multi-scale dynamic spatial graph structure and adaptive convolution mechanism are adopted. The multi-scale temporal features are extracted through the time coding module. The weighted directed graph is constructed by combining the Euclidean distance and Louvain algorithm. The traffic dynamic association graph and the spatial topological association graph are integrated. The GCN module and adaptive convolution module are used for efficient prediction.
It achieves high-precision prediction of traffic flow, can capture multi-scale and dynamic spatial dependency characteristics, improves the scalability and practical value of the model, and is suitable for smart traffic scheduling and congestion warning.
Smart Images

Figure CN120656318A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of traffic flow prediction, and in particular to a traffic flow prediction method and system based on a multi-scale dynamic spatial graph. Background Art
[0002] In the field of traffic flow prediction, accurately modeling the dynamic evolution of spatiotemporal dependencies in traffic systems remains a core challenge. Traditional methods focus on mining implicit spatial relationships between sensor nodes through techniques such as graph neural networks, ignoring explicit structural factors in actual road networks, such as node geographic distribution, road topology, lane capacity, and traffic signal influences. In practical applications, traffic flow not only propagates along topological paths but is also profoundly influenced by physical mechanisms such as congestion spread and traffic flow switching caused by spatial proximity. This is particularly evident in high-density urban road networks, where multi-scale and multi-level coupling characteristics are evident. Furthermore, due to the uneven spatial deployment of sensors, nodes within different distance ranges may form complex flow correlation patterns due to road connectivity and traffic functional zoning. Relying solely on implicit graph structures makes it difficult to accurately reproduce these dynamic dependencies dominated by spatial physical factors.
[0003] Existing graph neural networks, when modeling spatially dynamic systems such as traffic flow, generally rely on predefined static adjacency matrices to construct graph structures to characterize the spatial relationships between sensor nodes. However, this static graph modeling approach has significant limitations: First, static adjacency structures can only reflect spatial topological connections at a fixed scale and cannot simultaneously capture both local microscopic interactions and global macroscopic trends in traffic systems. Second, the spatial dependencies of actual traffic flow exhibit significant temporal dynamics. For example, the intensity of traffic coupling between regions varies significantly during peak hours, and traditional methods struggle to dynamically update the graph structure to accommodate these time-varying spatial dependencies. Furthermore, while some current studies have introduced adaptive embedding mechanisms to learn implicit relationships between sensor nodes, improving the model's responsiveness to spatial dynamics, these methods typically discard the original road topology and rely solely on index encoding for embedding learning. This method fails to fully leverage prior knowledge of the real road network, resulting in insufficient prediction performance in scenarios with high traffic network complexity and strong spatial heterogeneity. Therefore, a spatiotemporal modeling approach that integrates static topology with dynamic adaptive mechanisms is urgently needed. Summary of the Invention
[0004] The purpose of the present invention is to overcome the deficiencies in the prior art and provide a traffic flow prediction method and system based on multi-scale dynamic spatial graphs, which can achieve accurate modeling and efficient prediction of multi-granularity and multi-scale spatial dependency features.
[0005] To achieve the above object, the present invention is implemented by adopting the following technical solutions:
[0006] In one aspect, the present invention provides a traffic flow prediction method based on a multi-scale dynamic spatial graph, comprising:
[0007] Get traffic time data;
[0008] Inputting the traffic time data into a pre-built traffic flow prediction model and outputting a traffic flow prediction result; the traffic flow prediction model includes an input layer, a time encoding module, a multi-scale dynamic spatial graph module, a GCN module, an adaptive convolution module and an output layer connected in sequence;
[0009] The processing steps of the traffic flow prediction model include:
[0010] In the input layer, the traffic time data is input into the time coding module;
[0011] In the time coding module, the traffic time data is coded with periodic features to extract multi-scale time series features of the traffic time data;
[0012] In the multi-scale dynamic spatial graph module, a similarity matrix of the multi-scale time series features is calculated, and a traffic dynamic association graph is obtained based on the similarity matrix; a weighted directed graph is constructed based on the traffic time data and the acquired traffic spatial distance, and the weighted directed graph is divided into regions to obtain a spatial topological association graph; the traffic dynamic association graph and the spatial topological association graph are fused to obtain a fused association graph;
[0013] In the GCN module, the traffic flow values in the fusion correlation graph are aggregated and averaged to obtain a multi-scale dynamic graph;
[0014] In the adaptive convolution module, adaptive convolution is performed on the multi-scale dynamic graph to obtain convolution features;
[0015] In the output layer, feature mapping is performed on the convolutional features to obtain a traffic flow prediction result.
[0016] Optionally, performing periodic feature encoding on the traffic time data to extract multi-scale time series features of the traffic time data includes:
[0017] ;
[0018] ;
[0019] ;
[0020] ;
[0021] in, 、 、 Represents query, key, and value respectively; 、 、 Represent the query weight matrix, key weight matrix, and value weight matrix respectively; Represents travel time data; Represents the result of the dot product operation; Represents the dimension of the key; Represents matrix transpose; represents the attention weight; represents the softmax activation function; Represents multi-scale time series features.
[0022] Optionally, the Euclidean distance method is used to calculate the similarity matrix of the multi-scale time series features, including:
[0023] ;
[0024] ;
[0025] ;
[0026] in, represents the Euclidean distance between the i-th traffic node and the j-th traffic node; 、 They represent the traffic flow of the t-th time step of the i-th traffic node and the traffic flow of the t-th time step of the j-th traffic node in the flattened data respectively; represents the total time step; 、 、…、 、…、 They represent the similarity between the first traffic node and the first traffic node, the similarity between the first traffic node and the second traffic node, ..., the similarity between the i-th traffic node and the j-th traffic node, ..., the similarity between the n-th traffic node and the n-th traffic node respectively; Represents the similarity matrix.
[0027] Optionally, generating a traffic dynamic association graph based on the similarity matrix includes:
[0028] The Laplace matrix is constructed according to the similarity matrix, which is expressed as:
[0029] ;
[0030] The Laplace matrix is subjected to eigendecomposition to obtain decomposition features, and the first k smallest decomposition features are selected for clustering to obtain a traffic dynamic association graph, which is expressed as:
[0031] ;
[0032] in, represents the Laplace matrix; represents the identity matrix; represents the degree matrix; represents the similarity matrix; Represents a dynamic correlation graph of traffic; 、…、 They represent the first smallest decomposition feature, ..., the kth smallest decomposition feature among the first k smallest decomposition features respectively; Represents K-means clustering.
[0033] Optionally, a weighted directed graph is constructed based on the traffic time data and the obtained traffic spatial distance, and the weighted directed graph is divided into regions to obtain a spatial topological association graph, including:
[0034] A weighted directed graph is constructed by using the travel time data as vertices and the travel space distance as the weight of the directed edge.
[0035] The Louvain algorithm is used to perform region partitioning on the weighted directed graph to obtain a spatial topological association graph; wherein the quality of the region partitioning is represented by modularity, which is expressed as:
[0036] ;
[0037] in, represents modularity; represents the sum of the weights of directed edges; represents the weight of the edge from the i-th traffic node to the j-th traffic node; 、 They represent the degree of the i-th traffic node and the degree of the j-th traffic node respectively; 、 They represent the area to which the i-th traffic node belongs and the area to which the j-th traffic node belongs respectively; Represents the indicator function.
[0038] Optionally, the fusion association graph is represented as:
[0039] ;
[0040] in, Represents a fusion association graph; Represents a spatial topological association graph; Represents a dynamic correlation graph of traffic; Represents element-wise multiplication operation; Represents the softmax activation function.
[0041] Optionally, performing adaptive convolution on the multi-scale dynamic graph to obtain convolution features includes:
[0042] ;
[0043] ;
[0044] ;
[0045] ;
[0046] ;
[0047] in, Represents multi-layer perception features; Represents travel time data; Represent multi-scale dynamic graphs; Represents a multi-layer perception mechanism; 、 Represent the output of the hole convolution layer and the output of the standard convolution layer respectively; 、 Represent the weights of the hole convolution layer and the standard convolution layer respectively; Represents the dilated convolution operation; Represents a random number tensor; represents the standard convolution operation; represents the gating signal; Represents the sigmoid activation function; Represents convolutional features; Represents an element-wise multiplication operation.
[0048] Optionally, the traffic flow prediction result is expressed as:
[0049] ;
[0050] in, Indicates the prediction result of traffic flow; Represents convolutional features; represents the weight matrix; represents the bias term.
[0051] In a second aspect, the present invention provides a traffic flow prediction system based on a multi-scale dynamic spatial graph, comprising:
[0052] Data acquisition module, used to: obtain traffic time data;
[0053] A traffic flow prediction module is configured to input the traffic time data into a pre-built traffic flow prediction model and output a traffic flow prediction result; the traffic flow prediction model comprises an input layer, a time encoding module, a multi-scale dynamic spatial graph module, a GCN module, an adaptive convolution module, and an output layer connected in sequence;
[0054] The processing steps of the traffic flow prediction model include:
[0055] In the time coding module, the traffic time data is coded with periodic features to extract multi-scale time series features of the traffic time data;
[0056] In the multi-scale dynamic spatial graph module, a similarity matrix of the multi-scale time series features is calculated, and a traffic dynamic association graph is obtained based on the similarity matrix; a weighted directed graph is constructed based on the traffic time data and the acquired traffic spatial distance, and the weighted directed graph is divided into regions to obtain a spatial topological association graph; the traffic dynamic association graph and the spatial topological association graph are fused to obtain a fused association graph;
[0057] In the GCN module, the traffic flow values in the fusion correlation graph are aggregated and averaged to obtain a multi-scale dynamic graph;
[0058] In the adaptive convolution module, adaptive convolution is performed on the multi-scale dynamic graph to obtain convolution features;
[0059] In the output layer, feature mapping is performed on the convolutional features to obtain a traffic flow prediction result.
[0060] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the method described in the first aspect.
[0061] Compared with the prior art, the present invention has the following beneficial effects:
[0062] The present invention introduces a joint modeling method of multi-scale dynamic graph structure and adaptive convolution mechanism, which can effectively characterize the dynamic evolution law of traffic flow in the spatial dimension at different scales. First, the input traffic time data is encoded with periodic features through the attention mechanism to enhance the model's perception of time attributes such as daily traffic patterns (such as morning and evening rush hours); then, the clustering method is used at the global scale to extract cross-regional traffic change patterns and capture long-distance traffic dependencies; at the local scale, the region is divided according to the actual road network topology, and a fine-grained spatial graph is constructed to model local traffic dynamics; an adaptive convolution module is introduced to effectively integrate the multi-scale graph structure with real-time status data, and adaptively learn the complex spatiotemporal interaction characteristics between nodes, thereby achieving high-precision prediction of future traffic status, solving the technical bottleneck that traditional models have difficulty in handling multi-scale and dynamic spatial dependencies, and has good scalability and practical value. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 FIG2 is a flow chart of a traffic flow prediction method based on a multi-scale dynamic spatial graph in one embodiment of the present invention;
[0064] Figure 2 FIG2 is a schematic diagram of the structure of a multi-scale dynamic spatial graph module in one embodiment of the present invention;
[0065] Figure 3 FIG2 is a schematic diagram of the structure of an adaptive convolution module in one embodiment of the present invention;
[0066] Figure 4 FIG2 is a schematic diagram showing a comparison of MAE performance between the present invention and the prior art in one embodiment;
[0067] Figure 5 FIG2 is a schematic diagram showing a comparison of MAPE performances of the present invention and the prior art in one embodiment;
[0068] Figure 6 FIG2 is a schematic diagram showing a comparison of RMSE performance between the present invention and the prior art in one embodiment;
[0069] Figure 7 The figure shows a comparison diagram of R2 performance between the present invention and the prior art in one embodiment;
[0070] Figure 8 The figure shows a schematic diagram of visual comparison between actual results and predicted results in one embodiment of the present invention;
[0071] Figure 9 Shown is an abstracted traffic space graph of different sensor nodes in one embodiment of the present invention's visualization of the PEMS08 dataset;
[0072] Figure 10Shown is a spatial topology association diagram in one embodiment of the present invention;
[0073] Figure 11 Shown is a flow dynamic correlation diagram in one embodiment of the present invention. DETAILED DESCRIPTION
[0074] The technical solution of the present invention is described in detail below through the accompanying drawings and specific embodiments. It should be understood that the embodiments of the present invention and the specific features in the embodiments are detailed descriptions of the technical solution of the present invention, rather than limitations on the technical solution of the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.
[0075] The term "and / or" simply describes a relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. Additionally, the character " / " generally indicates an "or" relationship between the related objects.
[0076] Example 1
[0077] like Figure 1 As shown, this embodiment introduces a traffic flow prediction method based on a multi-scale dynamic spatial graph, which specifically includes the following steps:
[0078] Step 1: Obtain traffic time data, which includes time data at various time granularities such as hours, days, and weeks.
[0079] Step 2: Input the traffic time data into the pre-built traffic flow prediction model and output the traffic flow prediction results, specifically:
[0080] The traffic flow prediction model consists of an input layer, a time encoding module, a multi-scale dynamic spatial graph module, a GCN module, an adaptive convolution module, and an output layer connected in sequence. The processing steps are as follows:
[0081] In the input layer, the traffic time data is input to the time encoding module through the input layer.
[0082] In the time coding module, in order to effectively capture the strong temporal characteristics of traffic flow and fully explore the hidden laws and patterns at different time scales in the traffic system, a time coding module is constructed to use the attention mechanism to parallelly process data input covering multiple time granularities such as hours, days, and weeks, extract key features of traffic flow in terms of periodicity, trend, and sudden fluctuations, and through the synergy of multi-granularity time perception mechanism and attention mechanism, the extracted rich temporal features are converted into a form that can be understood by the model, providing comprehensive and discriminative time dimension and feature support. The core function of the time coding module is to weight the input features through different attention mechanisms, thereby extracting more representative temporal features. The input traffic time data is passed to multiple attention heads, each of which uses an independent weight matrix to calculate the query ,key Sum These weight matrices are generated through linear transformation, and the specific formula is:
[0083] ;
[0084] in, 、 、 Represent the query weight matrix, key weight matrix, and value weight matrix respectively; calculate the attention score of each attention head, which is obtained by the dot product operation, and the formula is:
[0085] ;
[0086] in, Represents the result of the dot product operation; Represents the dimension of the key, used for scaling to prevent gradient disappearance; represents the matrix transpose; subsequently, these scores are processed using the softmax activation function to generate normalized attention weights, as follows:
[0087] ;
[0088] in, represents the attention weight; Represents the softmax activation function; the weight reflects the importance of the input feature at different time steps; then, the attention weight is weighted and summed with the corresponding value to form a new feature representation, namely the multi-scale temporal feature , the formula is:
[0089] .
[0090] In the multi-scale dynamic spatial graph module, in order to extract dynamic traffic information, the similarity matrix between different traffic nodes is calculated using the Euclidean distance method. Euclidean distance is a widely used distance metric, suitable for evaluating the similarity of dynamic data such as traffic flow, multi-scale time series features. , where T represents the time step, N represents the number of nodes, and C represents different channels. For any two traffic nodes i and j, the Euclidean distance between them is defined as:
[0091] ;
[0092] in, represents the Euclidean distance between the i-th traffic node and the j-th traffic node; 、 They represent the traffic flow of the t-th time step of the i-th traffic node and the traffic flow of the t-th time step of the j-th traffic node in the flattened data respectively; represents the total time step;
[0093] In order to convert distance to similarity, a simple conversion function is used:
[0094] ;
[0095] In this way, smaller distances correspond to higher similarities, while larger distances correspond to lower similarities. Finally, we get the similarity matrix , N×N is the row×column of the similarity matrix, and the similarity matrix is expressed as:
[0096] ;
[0097] in, 、 、…、 、…、 They represent the similarity between the first traffic node and the first traffic node, the similarity between the first traffic node and the second traffic node, ..., the similarity between the i-th traffic node and the j-th traffic node, ..., the similarity between the n-th traffic node and the n-th traffic node respectively;
[0098] Construct Laplace matrix. Through Laplace transform, learn the dynamic characteristics and patterns in traffic flow sequence, and use similarity matrix The Laplace matrix L can be constructed. The Laplace matrix L is defined as:
[0099] ;
[0100] in, represents the identity matrix; Denotes the degree matrix, which is a diagonal matrix that represents the connection strength of each node. The constructed Laplacian matrix L is an n×n symmetric semi-positive matrix that is used to capture the structural information of the graph; the Laplacian matrix is decomposed into the following:
[0101] ;
[0102] in The column vectors of are the orthonormal eigenvectors of L, Is a diagonal matrix containing the decomposition characteristics , sort by eigenvalue from small to large, select the first k smallest decomposition features for clustering, and obtain the traffic dynamic association graph, traffic dynamic association graph Expressed as:
[0103] ;
[0104] in, 、…、 They represent the first smallest decomposition feature, ..., the kth smallest decomposition feature among the first k smallest decomposition features respectively; represents K-means clustering;
[0105] A weighted directed graph is constructed based on the traffic time data and the obtained traffic space distance. That is, the traffic time data is used as the vertex and the traffic space distance is used as the weight of the directed edge to construct a weighted directed graph;
[0106] In order to extract the topological features in spatial information, the Louvain algorithm is used to divide the weighted directed graph into regions and obtain the spatial topological association graph;
[0107] The Louvain algorithm is a classic community discovery algorithm based on modularity optimization. It can efficiently divide the network into multiple communities, making the nodes within the community closely connected, while the connections between communities are relatively sparse. Modularity (Q) is the core indicator of the Louvain algorithm, which is used to measure the quality of community division. Modularity represents the quality of regional division. Expressed as:
[0108] ;
[0109] in, represents the sum of the weights of directed edges; represents the weight of the edge from the i-th traffic node to the j-th traffic node; 、 They represent the degree of the i-th traffic node and the degree of the j-th traffic node respectively; 、 Respectively represent the area to which the i-th traffic node belongs and the area to which the j-th traffic node belongs. When the value is 1, otherwise it is 0. The modularity value is between -1 and 1. The larger the value, the better the regional division effect. represents the indicator function;
[0110] The traffic dynamic correlation graph and the spatial topology correlation graph are fused to obtain a fused correlation graph. Expressed as:
[0111] ;
[0112] in, Represents a spatial topological association graph; Represents a dynamic correlation graph of traffic; Represents an element-wise multiplication operation.
[0113] In the GCN module, the traffic flow values in the fusion correlation graph are aggregated and averaged to obtain a multi-scale dynamic graph. .
[0114] The multi-scale dynamic graph combines the Louvain algorithm with cluster analysis to obtain local topological structure information through regional division. At the same time, it models long-distance traffic associations based on traffic similarity clustering, achieving local and global multi-scale collaboration. It also dynamically evolves through real-time updates of traffic data, fully preserving the temporal evolution laws of network structure and traffic characteristics, forming a complete dynamic graph analysis framework.
[0115] In the adaptive convolution module, adaptive convolution is performed on the multi-scale dynamic graph to obtain the convolution features, namely:
[0116] The adaptive convolution module is used to capture key features at different time and spatial locations, and a multi-layer perceptron is used to fuse the residual structure traffic flow input and multi-scale dynamic graph. The formula is:
[0117] ;
[0118] in, Represents multi-layer perception features; Represents a multi-layer perception mechanism;
[0119] The expressive power of features is enhanced by dilated convolution and gating mechanism operations, thereby effectively capturing multiple dependencies. In the first convolution layer, the dilated convolution operation is used, and the formula is:
[0120] ;
[0121] in, Represents the output of the dilated convolutional layer; represents the weight of the dilated convolutional layer; Represents the dilated convolution operation; dilated convolution expands the receptive field by setting different dilation rates to capture a wider range of contextual information;
[0122] In the second convolutional layer, the standard convolution operation is used, the formula is:
[0123] ;
[0124] in, represents the output of a standard convolutional layer; represents the weights of a standard convolutional layer; represents the standard convolution operation; Represents a random number tensor, which is a uniform random number tensor in the range [-0.1, 0.1] and serves as a regularization term to increase the robustness of the model;
[0125] Next, a gating mechanism is used to combine the outputs of these two convolutions to calculate the gating signal , expressed as:
[0126] ;
[0127] in, Represents the sigmoid activation function, ensuring that the value of the gate signal is between 0 and 1;
[0128] Then, the gating signal is used to perform a weighted summation on the outputs of the two convolutions to form the final output convolution feature. , expressed as:
[0129] ;
[0130] in, .
[0131] Through the adaptive convolution module, the hole gated convolution module can effectively combine the features extracted by different convolution layers, and dynamically adjust the contribution of features through the gating mechanism, thereby improving the model's ability to understand complex time series data. The final output convolution feature It is passed to the subsequent output layer for further processing.
[0132] In the output layer, these features are mapped to the target output space through a fully connected linear transformation. The convolution features are mapped to obtain the traffic flow prediction results. , expressed as:
[0133] ;
[0134] in, represents the weight matrix; represents the bias term.
[0135] Traffic flow prediction results after linear transformation and activation function processing Will be returned as the model's predictions.
[0136] This embodiment solves the technical bottleneck of traditional models that are difficult to handle multi-scale and dynamic spatial dependencies. It has good scalability and practical value and can be widely used in scenarios such as smart traffic scheduling, congestion warning, and urban travel optimization.
[0137] Example 2
[0138] Based on Example 1, this example introduces an experimental example of a traffic flow prediction method based on a multi-scale spatial graph:
[0139] Figure 9 The figure shows a visualization of the abstracted traffic space diagram of the PEMS08 dataset at different sensor nodes. This example conducted traffic flow prediction experiments on the PEMS08 dataset for three different time spans: 15 minutes, 30 minutes, and 60 minutes. A systematic comparative analysis was conducted with various mainstream baseline models. The experimental results show that the prediction accuracy of all models decreases to some extent as the prediction time window increases, further demonstrating the challenges of modeling complex spatiotemporal dependencies in long-term prediction tasks.
[0140] Among them, Figure 4-7As shown, the traffic flow prediction model in this embodiment achieved optimal performance across all time scales. In particular, in the 15-minute prediction task, its MAE, RMSE, and MAPE achieved 12.74, 21.28, and 8.25% respectively, with an R² as high as 0.979, significantly outperforming other models. In comparison, the traditional linear model VAR performed the worst, with a MAE of 17.89, RMSE of 26.52, MAPE of 12.21%, and an R² of only 0.841 in the same prediction task, revealing its inability to capture complex nonlinear spatiotemporal features. In the more challenging 45-minute and 60-minute prediction tasks, the traffic flow prediction model in this embodiment maintained its leading position, with MAEs of 13.96 and 14.54, RMSEs of 24.18 and 25.21, and MAPEs of 9.24% and 9.73%, respectively, far exceeding other graph neural network models such as DCRNN and STGCN. Notably, Graph WaveNet's performance in long-term forecasting significantly degraded, with the 60-minute RMSE rising to 37.85. Traditional models such as VAR and FC-LSTM performed particularly poorly in this area, with VAR's MAE and RMSE reaching as high as 29.98 and 41.87, respectively, and its MAPE rising to 22.03%. Overall, graph neural network-based models, due to their superior ability to model spatiotemporal structures, have a clear advantage in short- and medium-term forecasting tasks. The traffic flow prediction model in this example, by incorporating a multi-scale dynamic graph structure, not only surpasses the comparison models in accuracy but also demonstrates excellent robustness and generalization in long-term forecasting scenarios, demonstrating its broad potential for application in complex real-world traffic environments.
[0141] like Figure 8 The figure shows a visual comparison of the actual results and the predicted results of the traffic flow prediction model in this embodiment. Figure 10 、 Figure 11 They are respectively the spatial topology association diagram and the traffic flow dynamic association diagram of the traffic flow prediction model in this embodiment, Figure 11This figure presents the results of a cluster analysis of the first batch of traffic network nodes in the PEMS08 dataset using a spectral clustering algorithm. Each dot represents a traffic sensor node, and the color represents the cluster category to which it belongs. The color gradient from purple to yellow corresponds to clusters numbered 0 to 40, resulting in a total of 41 cluster categories. The figure shows that the distribution of nodes in the index space exhibits distinct clustering characteristics, with the majority of nodes concentrated in clusters numbered 0 to 20. This suggests that these nodes have strong consistency in traffic flow patterns and may correspond to major arterial roads or areas with relatively regular traffic flow. In contrast, clusters numbered 30 and above contain fewer nodes, indicating that these nodes have relatively unique or heterogeneous traffic behavior characteristics and may be located on marginal roads or in areas with complex traffic flow variations. Furthermore, the figure also reveals significant local clustering of some nodes in the index, demonstrating that the spectral clustering method can effectively identify groups of nodes with geographical proximity or similar connectivity structures in the spatial dimension. This clustering structure not only helps to reveal the intrinsic partitioning patterns in the traffic network, but also provides strong support for subsequent multi-scale dynamic graph modeling, laying the foundation for more refined spatiotemporal feature learning and regional-level traffic flow prediction.
[0142] Example 3
[0143] Based on Example 1 or 2, this embodiment introduces a traffic flow prediction system based on a multi-scale spatial graph, including:
[0144] Data acquisition module, used to: obtain traffic time data;
[0145] A traffic flow prediction module is configured to input the traffic time data into a pre-built traffic flow prediction model and output a traffic flow prediction result; the traffic flow prediction model comprises an input layer, a time encoding module, a multi-scale dynamic spatial graph module, a GCN module, an adaptive convolution module, and an output layer connected in sequence;
[0146] The processing steps of the traffic flow prediction model include:
[0147] In the time coding module, the traffic time data is coded with periodic features to extract multi-scale time series features of the traffic time data;
[0148] In the multi-scale dynamic spatial graph module, a similarity matrix of the multi-scale time series features is calculated, and a traffic dynamic association graph is obtained based on the similarity matrix; a weighted directed graph is constructed based on the traffic time data and the acquired traffic spatial distance, and the weighted directed graph is divided into regions to obtain a spatial topological association graph; the traffic dynamic association graph and the spatial topological association graph are fused to obtain a fused association graph;
[0149] In the GCN module, the traffic flow values in the fusion correlation graph are aggregated and averaged to obtain a multi-scale dynamic graph;
[0150] In the adaptive convolution module, adaptive convolution is performed on the multi-scale dynamic graph to obtain convolution features;
[0151] In the output layer, feature mapping is performed on the convolutional features to obtain a traffic flow prediction result.
[0152] The specific functional implementation of each of the above modules can be found in the relevant contents of the method in Example 1 or 2 and will not be elaborated here.
[0153] Example 4
[0154] This embodiment introduces a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the method described in embodiment 1 or 2 are implemented.
[0155] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0156] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0157] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0158] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0159] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the purpose of the present invention and the claims, which are all protected by the present invention.
Claims
1. A traffic flow prediction method based on multi-scale dynamic spatial graph, characterized in that: include: Get traffic time data; Inputting the traffic time data into a pre-built traffic flow prediction model and outputting a traffic flow prediction result; the traffic flow prediction model includes an input layer, a time encoding module, a multi-scale dynamic spatial graph module, a GCN module, an adaptive convolution module and an output layer connected in sequence; The processing steps of the traffic flow prediction model include: In the input layer, the traffic time data is input into the time coding module; In the time coding module, the traffic time data is coded with periodic features to extract multi-scale time series features of the traffic time data; In the multi-scale dynamic spatial graph module, a similarity matrix of the multi-scale time series features is calculated, and a traffic dynamic association graph is obtained based on the similarity matrix; a weighted directed graph is constructed based on the traffic time data and the acquired traffic spatial distance, and the weighted directed graph is divided into regions to obtain a spatial topological association graph; the traffic dynamic association graph and the spatial topological association graph are fused to obtain a fused association graph; In the GCN module, the traffic flow values in the fusion correlation graph are aggregated and averaged to obtain a multi-scale dynamic graph; In the adaptive convolution module, adaptive convolution is performed on the multi-scale dynamic graph to obtain convolution features; In the output layer, feature mapping is performed on the convolutional features to obtain a traffic flow prediction result.
2. The traffic flow prediction method based on multi-scale dynamic spatial graph according to claim 1 is characterized in that: Performing periodic feature encoding on the traffic time data and extracting multi-scale time series features of the traffic time data includes: ; ; ; ; in, 、 、 Represents query, key, and value respectively; 、 、 Represent the query weight matrix, key weight matrix, and value weight matrix respectively; Represents travel time data; Represents the result of the dot product operation; Represents the dimension of the key; Represents matrix transpose; represents the attention weight; represents the softmax activation function; Represents multi-scale time series features.
3. The traffic flow prediction method based on multi-scale dynamic spatial graph according to claim 1 is characterized in that: Calculating the similarity matrix of the multi-scale time series features using the Euclidean distance method includes: ; ; ; in, represents the Euclidean distance between the i-th traffic node and the j-th traffic node; 、 They represent the traffic flow of the t-th time step of the i-th traffic node and the traffic flow of the t-th time step of the j-th traffic node in the flattened data respectively; represents the total time step; 、 、…、 、…、 They represent the similarity between the first traffic node and the first traffic node, the similarity between the first traffic node and the second traffic node, ..., the similarity between the i-th traffic node and the j-th traffic node, ..., the similarity between the n-th traffic node and the n-th traffic node respectively; Represents the similarity matrix.
4. The traffic flow prediction method based on multi-scale dynamic spatial graph according to claim 1 is characterized in that: According to the similarity matrix, a traffic dynamic association graph is generated, including: The Laplace matrix is constructed according to the similarity matrix, which is expressed as: ; The Laplace matrix is subjected to eigendecomposition to obtain decomposition features, and the first k smallest decomposition features are selected for clustering to obtain a traffic dynamic association graph, which is expressed as: ; in, represents the Laplace matrix; represents the identity matrix; represents the degree matrix; represents the similarity matrix; Represents a dynamic correlation graph of traffic; 、…、 They represent the first smallest decomposition feature, ..., the kth smallest decomposition feature among the first k smallest decomposition features respectively; Represents K-means clustering.
5. The traffic flow prediction method based on multi-scale dynamic spatial graph according to claim 1 is characterized in that: A weighted directed graph is constructed based on the traffic time data and the obtained traffic space distance, and the weighted directed graph is divided into regions to obtain a spatial topological association graph, including: A weighted directed graph is constructed by using the travel time data as vertices and the travel space distance as the weight of the directed edge. The Louvain algorithm is used to perform region partitioning on the weighted directed graph to obtain a spatial topological association graph; wherein the quality of the region partitioning is represented by modularity, which is expressed as: ; in, represents modularity; represents the sum of the weights of directed edges; represents the weight of the edge from the i-th traffic node to the j-th traffic node; 、 They represent the degree of the i-th traffic node and the degree of the j-th traffic node respectively; 、 They represent the area to which the i-th traffic node belongs and the area to which the j-th traffic node belongs respectively; Represents the indicator function.
6. The traffic flow prediction method based on multi-scale dynamic spatial graph according to claim 1 is characterized in that: The fusion association graph is represented as: ; in, Represents a fusion association graph; Represents a spatial topological association graph; Represents a dynamic correlation graph of traffic; Represents element-wise multiplication operation; Represents the softmax activation function.
7. The traffic flow prediction method based on multi-scale dynamic spatial graph according to claim 1 is characterized in that: Adaptively convolve the multi-scale dynamic graph to obtain convolution features, including: ; ; ; ; ; in, Represents multi-layer perception features; Represents travel time data; Represent multi-scale dynamic graphs; Represents a multi-layer perception mechanism; 、 Represent the output of the hole convolution layer and the output of the standard convolution layer respectively; 、 Represent the weights of the hole convolution layer and the standard convolution layer respectively; Represents the dilated convolution operation; Represents a random number tensor; represents the standard convolution operation; represents the gating signal; Represents the sigmoid activation function; Represents convolutional features; Represents an element-wise multiplication operation.
8. The traffic flow prediction method based on multi-scale dynamic spatial graph according to claim 1 is characterized in that: The traffic flow prediction result is expressed as: ; in, Indicates the prediction result of traffic flow; Represents convolutional features; represents the weight matrix; represents the bias term.
9. A traffic flow prediction system based on multi-scale dynamic spatial graph, characterized in that: include: Data acquisition module, used to: obtain traffic time data; A traffic flow prediction module is configured to input the traffic time data into a pre-built traffic flow prediction model and output a traffic flow prediction result; the traffic flow prediction model comprises an input layer, a time encoding module, a multi-scale dynamic spatial graph module, a GCN module, an adaptive convolution module, and an output layer connected in sequence; The processing steps of the traffic flow prediction model include: In the time coding module, the traffic time data is coded with periodic features to extract multi-scale time series features of the traffic time data; In the multi-scale dynamic spatial graph module, a similarity matrix of the multi-scale time series features is calculated, and a traffic dynamic association graph is obtained based on the similarity matrix; a weighted directed graph is constructed based on the traffic time data and the acquired traffic spatial distance, and the weighted directed graph is divided into regions to obtain a spatial topological association graph; the traffic dynamic association graph and the spatial topological association graph are fused to obtain a fused association graph; In the GCN module, the traffic flow values in the fusion correlation graph are aggregated and averaged to obtain a multi-scale dynamic graph; In the adaptive convolution module, adaptive convolution is performed on the multi-scale dynamic graph to obtain convolution features; In the output layer, feature mapping is performed on the convolutional features to obtain a traffic flow prediction result.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Traffic flow prediction method based on hierarchical space-time correlation
CN121838470A