Highway traffic flow prediction method based on STGCN-Transform hybrid model
By using the STGCN-Transformer hybrid model, which combines multiple matrices and algorithms, the problem of insufficient spatiotemporal dependence in highway traffic flow prediction is solved, achieving higher accuracy and more stable traffic flow prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-05
- Publication Date
- 2026-03-13
AI Technical Summary
Existing traffic flow prediction methods have limitations in dealing with the complex spatiotemporal dependencies of highways. They are unable to effectively capture the long-range nonlinear temporal characteristics and global spatial correlations of traffic flow, resulting in insufficient prediction accuracy and stability.
The STGCN-Transformer hybrid model is adopted. By constructing Euclidean distance adjacency matrix, connectivity adjacency matrix and temporal similarity adjacency matrix, and combining learnable temporal information embedding and node2vec algorithm, it integrates temporal Transformer module, spatial graph convolution module and dynamic graph convolution module to predict traffic flow.
It improves the accuracy of traffic flow prediction and the ability to characterize spatial correlations, enhances the ability to capture long-range nonlinear temporal dependencies and global spatial structures of traffic flow, and improves the model's adaptability to dynamic traffic conditions and prediction stability.
Smart Images

Figure CN121661828A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent transportation technology, and in particular relates to a method for predicting highway traffic flow based on the STGCN-Transformer hybrid model. Background Technology
[0002] As a core component of modern transportation networks, highways significantly impact regional traffic flow capacity through their operational efficiency and safety. With the continuous growth of traffic volume and the increasing complexity of road network structures, highway traffic conditions exhibit significant dynamic, nonlinear, and spatiotemporally correlated characteristics. To enhance road network management and early warning capabilities, various traffic flow prediction methods have emerged, primarily including statistical models based on time series analysis (such as ARIMA and state-space models) and prediction methods based on machine learning (such as support vector machines and traditional neural networks). These methods, by analyzing the temporal patterns of historical traffic flow data, can achieve short-term traffic flow prediction to a certain extent and provide data support for traffic management, particularly effective in scenarios with stable data and clear patterns of change.
[0003] However, existing methods still have significant limitations in addressing the complex spatiotemporal dependencies of highways. On the one hand, traditional time series models struggle to effectively capture the long-range nonlinear temporal characteristics of traffic flow and exhibit poor adaptability to sudden traffic events. On the other hand, conventional machine learning methods often ignore the spatial correlation effects brought about by the road network topology and fail to fully integrate multi-source adjacency information (such as geographical distance, connectivity, and dynamic flow similarity), resulting in limited accuracy in characterizing cross-segment traffic propagation mechanisms. Furthermore, existing methods based on single graph neural networks or time series models typically cannot simultaneously consider local spatial dependencies and global dynamic evolution patterns, limiting their generalization ability and prediction stability in large-scale road networks. Therefore, there is an urgent need for a traffic flow prediction method that can deeply integrate spatiotemporal features and adapt to the dynamic evolution patterns of highways to improve prediction accuracy and practicality. Summary of the Invention
[0004] To address the aforementioned technical problems, this invention proposes a highway traffic flow prediction method based on the STGCN-Transformer hybrid model, thereby resolving the issues present in the existing technologies.
[0005] To achieve the above objectives, this invention provides a highway traffic flow prediction method based on the STGCN-Transformer hybrid model, comprising: S1. Obtain license plate recognition data of each gantry node through the highway gantry system, count the traffic flow at the minute level, extract the latitude and longitude of the gantry nodes, and construct a road network topology map; S2. Calculate the Euclidean distance adjacency matrix based on the latitude and longitude of the gantry node, calculate the connectivity adjacency matrix based on the road network topology map, and calculate the temporal similarity adjacency matrix based on recent historical data. S3. The temporal location features of historical training traffic sequences are represented by a learnable temporal information embedding algorithm, and the global road network structure information is represented by the node2vec algorithm. S4. Input the temporal location features of the historical training traffic sequence and the global road network structure information into the temporal Transformer module and the spatial graph convolution module, respectively, to train the STGCN-Transformer hybrid model. S5. Based on the learnable time information embedding algorithm, the temporal location features of recent historical traffic sequences are characterized, and based on the node2vec algorithm, the local road network structure information is characterized. S6. Input the temporal location features of the recent historical traffic flow sequence and the local road network structure information into the trained STGCN-Transformer hybrid model, and output the traffic flow prediction results of each gantry node through the dynamic graph convolution module; wherein, the dynamic graph convolution module is used to generate a fused graph structure based on the node representation of the static adjacency matrix and the current input features, and perform graph convolutional encoding and prediction restoration based on the fused graph structure.
[0006] Preferably, the construction of the road network topology map specifically includes: The license plate recognition data is time-aggregated at preset time intervals to form a node-level traffic sequence; Map the station number of the gantry node to latitude and longitude in the target coordinate system; Using the gantry nodes as nodes in the graph, calculate the geographical distance between any two gantry nodes based on the latitude and longitude. When the geographical distance is less than a preset distance threshold or there is a direct road connection between two gantry nodes, an edge connection is established between the corresponding gantry nodes to form the road network topology map.
[0007] Preferably, the calculation of the Euclidean distance adjacency matrix specifically includes: The geographic straight-line distance between any two gantry nodes is calculated using the spherical distance formula. A threshold method is used to filter the geographic straight-line distance. When the geographic straight-line distance is less than or equal to the preset distance threshold, the corresponding element in the Euclidean distance adjacency matrix is assigned a first value; otherwise, it is assigned a second value.
[0008] Preferably, the calculation of the connectivity adjacency matrix specifically includes: If there is a direct road connection between two gantry nodes, the corresponding element in the connectivity adjacency matrix will be assigned the first value. If there is no direct road connection, then assign the second value.
[0009] Preferably, the calculation of the temporal similarity adjacency matrix specifically includes: Extract the flow sequence of each gantry node within the most recent preset time step; The similarity between the flow sequences of any two gantry nodes is calculated using the dynamic time warping method.
[0010] Preferably, the method of characterizing the temporal location features of historical training traffic sequences based on the learnable temporal information embedding algorithm specifically includes: A first trainable vector table is created for each day of the week, and a second trainable vector table is created for multiple time intervals within a day. The timestamps are embedded based on the first trainable vector table and the second trainable vector table to output daily timestamp vectors and time interval timestamp vectors. The daily timestamp vector and the time interval timestamp vector are concatenated by feature dimensions to obtain the embedded time information. The time information is embedded and divided into historical training time features and recent historical time features through a fully connected layer.
[0011] Preferably, the representation of global road network structure information based on the node2vec algorithm specifically includes: The gantry nodes and their connectivity relationships are modeled as a graph structure; A sequence of nodes is generated on the graph structure by a biased second-order random walk; The skip-gram model is used to maximize the conditional probability between a node and its neighboring nodes in order to learn the vectorized representation of the gantry node and output the node embedding matrix.
[0012] Preferably, the temporal Transformer module processes historical traffic data and historical external temporal features through a multi-head self-attention mechanism with causal masking, residual connections, layer normalization, and feedforward neural networks to extract dynamic temporal features.
[0013] Preferably, the spatial graph convolution module processes the input features through a Chebyshev graph convolution layer to extract spatial features; the Chebyshev graph convolution layer constructs a Chebyshev polynomial based on the normalized Laplacian matrix of the graph, and multiplies and sums the graph signals of each order with the corresponding learnable weight matrix to achieve feature fusion.
[0014] Preferably, the dynamic graph convolution module performs the following operations: The static adjacency matrix is fused with the node representation of the last time step in the current input features through the graph construction module, a dynamic similarity graph is calculated, and the fused graph structure is generated. The fused graph structure and feature tensor are input into a graph convolutional encoder to obtain a high-order graph structure embedding representation. The high-order graph structure is embedded and represented as input to the decoder for prediction and reconstruction, and the traffic flow prediction result for the future time step is output.
[0015] Compared with the prior art, the present invention has the following advantages and technical effects: This invention provides a highway traffic flow prediction method based on the STGCN-Transformer hybrid model. By collaboratively constructing Euclidean distance adjacency matrix, connectivity adjacency matrix, and temporal similarity adjacency matrix in step S2, the model can comprehensively and meticulously characterize the complex spatial relationships between road network nodes from multiple dimensions such as geographical proximity, physical connectivity, and dynamic flow pattern correlation. This more accurately reflects the propagation and interaction mechanism of traffic flow in the road network, improving the accuracy of traffic flow prediction and the ability to characterize spatial correlations.
[0016] This invention employs a learnable temporal information embedding algorithm to represent temporal location features in step S3, and combines it with the node2vec algorithm to represent global road network structure information. In step S4, the two types of features are input into the temporal Transformer module and the spatial graph convolution module for joint training. This enables the model to learn deep temporal patterns and global spatial dependencies in traffic data in parallel and collaboratively, enhancing its ability to capture long-range nonlinear temporal dependencies and global spatial structures of traffic flow. This overcomes the limitations of traditional methods in long-range prediction and global structure modeling.
[0017] The present invention uses a dynamic graph convolution module in step S6 to perform prediction output. This module can generate a dynamically updated fusion graph structure based on the fusion of the static adjacency matrix and the node representation in the current input features. This allows the model to adaptively adjust its internal spatial relationship model according to the real-time traffic conditions, improving the model's adaptability and prediction stability to dynamic traffic conditions and emergencies. Thus, it can still maintain high prediction accuracy and robustness when facing traffic flow changes or emergencies. Attached Figure Description
[0018] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings: Figure 1This is a flowchart of a highway traffic flow prediction method based on the STGCN-Transformer hybrid model according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the internal framework of the STGCN-Transformer hybrid model according to an embodiment of the present invention; Figure 3 This is a schematic diagram of traffic flow prediction results for future time steps in an embodiment of the present invention; wherein the PeMS04 dataset is the result of predicting the next 3 time steps, the PeMS07 dataset is the result of predicting the next 6 time steps, and the Tianjin dataset is the result of predicting the next 12 time steps. Detailed Implementation
[0019] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0020] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0021] Example 1 like Figure 1 As shown, this embodiment provides a highway traffic flow prediction method based on the STGCN-Transformer hybrid model. First, license plate recognition data is preprocessed, and minute-level traffic flow for each gantry node is statistically analyzed, and the latitude and longitude of the corresponding gantry nodes are extracted. A connectivity adjacency matrix and an Euclidean distance adjacency matrix are constructed based on the road network topology and the latitude and longitude of the gantry nodes, respectively. Then, the one-hot algorithm is used to characterize the temporal location features of the traffic flow sequence, and the node2vec algorithm is used to characterize the road network structure information. Next, the Transformer module is used to extract the temporal features of historical training data, and STGCN is used to extract spatial correlation features. These spatiotemporal features are then fused to complete model training. Finally, based on recent historical data, the trained hybrid model is input, and the minute-level traffic flow prediction results for each gantry node are output. The method specifically includes: S1. Obtain license plate recognition data of each gantry node through the highway gantry system, count the traffic flow at the minute level, extract the latitude and longitude of the gantry nodes, and construct a road network topology map; Furthermore, the construction of the road network topology map specifically includes: The license plate recognition data is time-aggregated at preset time intervals to form a node-level traffic sequence; Map the station number of the gantry node to latitude and longitude in the target coordinate system; Using the gantry nodes as nodes in the graph, calculate the geographical distance between any two gantry nodes based on the latitude and longitude. When the geographical distance is less than a preset distance threshold or there is a direct road connection between two gantry nodes, an edge connection is established between the corresponding gantry nodes to form the road network topology map.
[0022] Specifically, in this embodiment, license plate recognition data collected by the highway gantry system is aggregated over time in 5-minute intervals to form a node-level traffic sequence. The highway gantry station numbers are converted into latitude and longitude coordinates in the CGCS2000 coordinate system through map mapping. Using the gantries along the highway as nodes in the graph, the geographical distance between any two nodes is calculated based on the latitude and longitude coordinates. When the distance is less than a preset threshold or there is a direct road connection, an edge connection is established between the corresponding nodes, thereby forming a spatial topology graph in which nodes represent gantries and edges represent road connections.
[0023] S2. Calculate the Euclidean distance adjacency matrix based on the latitude and longitude of the gantry node, calculate the connectivity adjacency matrix based on the road network topology map, and calculate the temporal similarity adjacency matrix based on recent historical data. Furthermore, the calculation of the Euclidean distance adjacency matrix specifically includes: The geographic straight-line distance between any two gantry nodes is calculated using the spherical distance formula. A threshold method is used to filter the geographic straight-line distance. When the geographic straight-line distance is less than or equal to the preset distance threshold, the corresponding element in the Euclidean distance adjacency matrix is assigned a first value; otherwise, it is assigned a second value.
[0024] Furthermore, the calculation of the connectivity adjacency matrix specifically includes: If there is a direct road connection between two gantry nodes, the corresponding element in the connectivity adjacency matrix will be assigned the first value. If there is no direct road connection, then assign the second value.
[0025] Furthermore, the calculation of the temporal similarity adjacency matrix specifically includes: Extract the flow sequence of each gantry node within the most recent preset time step; The similarity between the flow sequences of any two gantry nodes is calculated using the dynamic time warping method.
[0026] Specifically, the Euclidean distance adjacency matrix is calculated based on the latitude and longitude of the gantry nodes. First, the geographic straight-line distance between any two nodes is calculated using the Haversine formula, thus obtaining the spatial distance metric between nodes. The calculation formula is as follows: (1) In the formula, This represents the actual straight-line distance on the ground between the two nodes. For nodes latitude, For nodes longitude, For nodes latitude, For nodes The longitude is then used. A threshold method is employed to filter the distances. When the spherical distance between two nodes is less than or equal to a preset threshold, they are considered adjacent, and the corresponding adjacency matrix element is assigned a value of 1; otherwise, they are considered not directly adjacent, and the corresponding element is assigned a value of 0. The calculation formula is: (2) In the formula, For the preset threshold, For nodes With nodes The degree of spatial distance correlation.
[0027] The connectivity adjacency matrix is calculated based on the road network topology graph. First, highway gantry nodes are abstracted as vertices in the graph. If two gantry nodes have a direct road connection, they are considered adjacent in the graph, and the corresponding element in the adjacency matrix is assigned a value of 1; if there is no direct connection between the two nodes, the corresponding element is assigned a value of 0. The calculation formula is: (3) In the formula, For pairs of gantry nodes that have direct connections, For nodes With nodes The degree of connectivity and association.
[0028] The temporal similarity adjacency matrix is calculated based on recent historical data. First, the gantry node is extracted from its most recent... The traffic sequence within a time step is calculated; then, the Dynamic Time Warping (DTW) method is used to calculate the similarity between the traffic sequences of any two nodes. Assume the time sequences of the two nodes are... and Given the distance matrix The elements therein are The minimum distance for DTW accumulation is: (4) in, The initial conditions are .
[0029] S3. The temporal location features of historical training traffic sequences are represented by a learnable temporal information embedding algorithm, and the global road network structure information is represented by the node2vec algorithm. Furthermore, the method for characterizing the temporal location features of historical training traffic sequences based on the learnable temporal information embedding algorithm specifically includes: A first trainable vector table is created for each day of the week, and a second trainable vector table is created for multiple time intervals within a day. The timestamps are embedded based on the first trainable vector table and the second trainable vector table to output daily timestamp vectors and time interval timestamp vectors. The daily timestamp vector and the time interval timestamp vector are concatenated by feature dimensions to obtain the embedded time information. The time information is embedded and divided into historical training time features and recent historical time features through a fully connected layer.
[0030] Furthermore, the representation of global road network structure information based on the node2vec algorithm specifically includes: The gantry nodes and their connectivity relationships are modeled as a graph structure; A sequence of nodes is generated on the graph structure by a biased second-order random walk; The skip-gram model is used to maximize the conditional probability between a node and its neighboring nodes in order to learn the vectorized representation of the gantry node and output the node embedding matrix.
[0031] Specifically, the learnable temporal information embedding algorithm (one-hot encoding) consists of an encoding layer and a fully connected layer. The encoding layer employs learnable temporal information embedding, which, compared to using fixed temporal information encoding, provides a more flexible temporal vector for subsequent spatiotemporal networks. A size of [missing information] is established for the 7 days of the week. A trainable vector table is created for 288 five-minute time intervals throughout the day, with a size of [missing information]. The trainable vector table. After embedding with time information, the daily timestamps for the week are output as follows: The daily 5-minute time interval timestamp output is Then, after concatenation along the feature dimensions, the final embedded time information is output. Then, the fully connected layer will Divided into characteristics of historical training time. and as a characteristic of recent historical time ,in .
[0032] The method for representing global road network structure information based on the node2vec algorithm is as follows: model highway gantry nodes and their connectivity relationships as a graph structure. ,in Represents a set of nodes. Let represent the set of edges. Then, node2vec generates a sequence of nodes on the graph through a biased second-order random walk and learns the vectorized representation of nodes by maximizing the conditional probability between a node and its neighboring nodes using a skip-gram model. Its optimization objective is: (5) in, Mapping of nodes to low-dimensional embedding space. This represents the nodes obtained through random walk sampling. The neighborhood of the target. To balance the search preferences of breadth-first search (BFS) and depth-first search (DFS), node2vec defines the transition probabilities of a second-order random walk: (6) Wherein, the current node is The previous node is Candidate nodes are , Represents a node and Shortest path distance, parameters and The probabilities of rollback and cross-community exploration are controlled separately. Finally, the node embedding matrix output by node2vec is... Each node corresponds to one Dimensional vector.
[0033] S4. Input the temporal location features of the historical training traffic sequence and the global road network structure information into the temporal Transformer module and the spatial graph convolution module, respectively, to train the STGCN-Transformer hybrid model. Furthermore, the temporal Transformer module processes historical traffic data and historical external temporal features through a multi-head self-attention mechanism with causal masking, residual connections, layer normalization, and feedforward neural networks to extract dynamic temporal features.
[0034] Furthermore, the spatial graph convolution module processes the input features through a Chebyshev graph convolution layer to extract spatial features; the Chebyshev graph convolution layer constructs a Chebyshev polynomial based on the normalized Laplacian matrix of the graph, and multiplies and sums the graph signals of each order with the corresponding learnable weight matrix to achieve feature fusion.
[0035] Specifically, the internal framework of the STGCN-Transformer hybrid model, such as Figure 2 As shown.
[0036] The temporal Transformer module consists of n stacked standard Transformer layers. Each layer includes a multi-head self-attention mechanism with causal masking, residual connections, layer normalization, and a feedforward neural network. Historical traffic data is used. and historical external time characteristics As input, but using the target's external temporal features in the second spatiotemporal Transformer fusion block. Alternative historical external time features Improve predictions. First, use a fully connected layer to process historical traffic data. Features and external time features To merge Then, the dimensions are compressed to match the input requirements of the Transformer, i.e. The features are processed separately after linear mapping to obtain: (1) (2) (3) .
[0037] (7) In the formula , , They are , and The learnable weight matrix, and , , These are the corresponding embedded temporal features for each time interval. This is used to achieve the three high-dimensional temporal fusion features ( , and After that, dynamic time dependency Calculated by the temporal attention layer, as given in the equation.
[0038] (8) in This indicates the relationship between each time interval and all other time intervals. In this embodiment, it is assumed that... In addition, it has The feedforward network with activation function generates dynamic temporal features with residual connections through formulas (9)-(11). .
[0039] (9) (10) (11) In the formula , It is a learnable parameter matrix. , It is the bias vector.
[0040] SGCB consists of Chebyshev graph convolutional layers, linear mapping layers, activation layers, and an output layer. First, the input features are processed... Perform feature rearrangement and convert it into This is to facilitate subsequent processing of local graph relationships of nodes in the time dimension. Then, based on the graph's normalized Laplacian matrix... To construct the Chebyshev polynomial, we will refer to a third-order polynomial: (12) in, A matrix representing the relationships between nodes and their neighbors. These are the original node features. This represents the features obtained after propagation between a node and its first-order neighborhood. This represents the high-order graph features that integrate second-order neighborhood information. Then, the graph signal of each order is multiplied by the corresponding learnable weight matrix. And perform summation to achieve feature fusion: (13) In the formula, For the first The weight matrix corresponding to the first-order convolution. This is the bias term. Finally, the output is restored to... .
[0041] This module is used to fuse spatiotemporal features extracted from the temporal Transformer module and the spatial graph convolution module. It includes a linear mapping layer, an attention computation layer, and a fusion output layer. First, the temporal features... and spatial features Mapping to a unified attention space yields a representation of spatiotemporal features: (14) In the formula It is a learnable linear projection matrix. This represents the attention space dimension. Subsequently, an attention mechanism is executed on the time series of each node, calculating the correlation between different time steps and performing weighted aggregation of spatial features: (15) To maintain feature stability and preserve the original temporal representation, the final fusion result is defined in the form of residual connections: (16) in, The final output feature after spatiotemporal feature fusion. This involves fusing spatiotemporal features extracted from the temporal Transformer module and the spatial graph convolution module. This represents the dynamic time characteristics with residual connections.
[0042] S5. Based on the learnable time information embedding algorithm, the temporal location features of recent historical traffic sequences are characterized, and based on the node2vec algorithm, the local road network structure information is characterized. Specifically, the one-hot algorithm and node2vec algorithm constructed based on S3 respectively characterize the temporal location features and local road network structure information of recent historical traffic sequences.
[0043] S6. Input the temporal location features of the recent historical traffic flow sequence and the local road network structure information into the trained STGCN-Transformer hybrid model, and output the traffic flow prediction results of each gantry node through the dynamic graph convolution module; wherein, the dynamic graph convolution module is used to generate a fused graph structure based on the node representation of the static adjacency matrix and the current input features, and perform graph convolutional encoding and prediction restoration based on the fused graph structure.
[0044] Furthermore, the dynamic graph convolution module performs the following operations: The static adjacency matrix is fused with the node representation of the last time step in the current input features through the graph construction module, a dynamic similarity graph is calculated, and the fused graph structure is generated. The fused graph structure and feature tensor are input into a graph convolutional encoder to obtain a high-order graph structure embedding representation. The high-order graph structure is embedded and represented as input to the decoder for prediction and reconstruction, and the traffic flow prediction result for the future time step is output.
[0045] Specifically, a schematic diagram illustrating the traffic flow forecast results for future time steps, such as... Figure 3As shown, the PeMS04 dataset predicts the results for the next 3 time steps, the PeMS07 dataset predicts the results for the next 6 time steps, and the Tianjin dataset predicts the results for the next 12 time steps. The temporal location features and local road network structure information of the recent historical traffic sequences generated by S3 are used as input. The temporal Transformer module and spatial graph convolution module constructed by S4 are used as the backbone model, and a dynamic graph convolution module that can adaptively update with time windows is set at its output as the fully connected layer. The dynamic graph convolution module consists of three parts: a graph construction module, a graph convolution encoder, and a decoder. The graph construction module fuses the static adjacency matrix with the node representation of the last time step in the current input features to calculate a dynamic similarity graph. And generate a fusion graph structure based on this. : (17) in These are learnable parameters used to control the fusion ratio between the static graph and the data-driven graph. The graph structure can be further visualized to analyze the spatial relationships learned by the model.
[0046] Subsequently, the merged graph structure With feature tensor Together, they are input into the DGCN encoder module. The encoder consists of a stack of multiple graph convolutional layers, DGCNLayer. Each layer first uses... The features are subjected to graph convolution propagation, followed by linear transformation and ReLU activation function, and finally regularization is applied to obtain a high-order graph structure embedding representation.
[0047] encoder output The data is fed into the decoder for prediction and reconstruction. The decoder consists of two layers. The convolutional process first performs a non-linear mapping along the channel dimension, and finally outputs the predicted value. , representing the prediction result for each node at a future time step.
[0048] The beneficial effects of this embodiment: This embodiment designs a process for predicting traffic flow at each gantry on highways based on license plate recognition data collected by the gantry system. By extracting historical traffic flow and gantry latitude and longitude, the Euclidean distance adjacency matrix, connectivity adjacency matrix, and temporal similarity adjacency matrix are calculated. Then, the STGCN-Transformer hybrid model is trained to achieve highway traffic flow prediction.
[0049] This invention enables high-precision prediction of highway traffic flow, significantly improving the ability to identify and predict traffic conditions. By introducing a joint modeling approach combining spatiotemporal graph convolution and Transformer structures, it can simultaneously capture the spatial correlation and temporal dependency features of traffic flow, thereby more accurately reflecting the dynamic evolution of highway traffic flow across different times and road segments. Compared with traditional methods based on time series or single graph convolution models, this invention significantly improves both prediction accuracy and generalization performance, providing a scientific basis for highway congestion early warning and proactive management, and enhancing road traffic efficiency and the level of intelligent management.
[0050] The above are merely preferred embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A highway traffic flow prediction method based on the STGCN-Transformer hybrid model, characterized in that, Includes the following steps: S1. Obtain license plate recognition data of each gantry node through the highway gantry system, count the traffic flow at the minute level, extract the latitude and longitude of the gantry nodes, and construct a road network topology map; S2. Calculate the Euclidean distance adjacency matrix based on the latitude and longitude of the gantry node, calculate the connectivity adjacency matrix based on the road network topology map, and calculate the temporal similarity adjacency matrix based on recent historical data. S3. The temporal location features of historical training traffic sequences are represented by a learnable temporal information embedding algorithm, and the global road network structure information is represented by the node2vec algorithm. S4. Input the temporal location features of the historical training traffic sequence and the global road network structure information into the temporal Transformer module and the spatial graph convolution module, respectively, to train the STGCN-Transformer hybrid model. S5. Based on the learnable time information embedding algorithm, the temporal location features of recent historical traffic sequences are characterized, and based on the node2vec algorithm, the local road network structure information is characterized. S6. Input the temporal location features of the recent historical traffic flow sequence and the local road network structure information into the trained STGCN-Transformer hybrid model, and output the traffic flow prediction results of each gantry node through the dynamic graph convolution module; wherein, the dynamic graph convolution module is used to generate a fused graph structure based on the node representation of the static adjacency matrix and the current input features, and perform graph convolutional encoding and prediction restoration based on the fused graph structure.
2. The highway traffic flow prediction method according to claim 1, characterized in that, The construction of the road network topology map specifically includes: The license plate recognition data is time-aggregated at preset time intervals to form a node-level traffic sequence; Map the station number of the gantry node to latitude and longitude in the target coordinate system; Using the gantry nodes as nodes in the graph, calculate the geographical distance between any two gantry nodes based on the latitude and longitude. When the geographical distance is less than a preset distance threshold or there is a direct road connection between two gantry nodes, an edge connection is established between the corresponding gantry nodes to form the road network topology map.
3. The highway traffic flow prediction method according to claim 2, characterized in that, The calculation of the Euclidean distance adjacency matrix specifically includes: The geographic straight-line distance between any two gantry nodes is calculated using the spherical distance formula. A threshold method is used to filter the geographic straight-line distance. When the geographic straight-line distance is less than or equal to the preset distance threshold, the corresponding element in the Euclidean distance adjacency matrix is assigned a first value; otherwise, it is assigned a second value.
4. The highway traffic flow prediction method according to claim 3, characterized in that, The calculation of the connectivity adjacency matrix specifically includes: If there is a direct road connection between two gantry nodes, the corresponding element in the connectivity adjacency matrix will be assigned the first value. If there is no direct road connection, then assign the second value.
5. The highway traffic flow prediction method according to claim 4, characterized in that, The calculation of the temporal similarity adjacency matrix specifically includes: Extract the flow sequence of each gantry node within the most recent preset time step; The similarity between the flow sequences of any two gantry nodes is calculated using the dynamic time warping method.
6. The highway traffic flow prediction method according to claim 1, characterized in that, The learningable temporal information embedding algorithm characterizes the temporal location features of historical training traffic sequences, specifically including: A first trainable vector table is created for each day of the week, and a second trainable vector table is created for multiple time intervals within a day. The timestamps are embedded based on the first trainable vector table and the second trainable vector table to output daily timestamp vectors and time interval timestamp vectors. The daily timestamp vector and the time interval timestamp vector are concatenated by feature dimensions to obtain the embedded time information. The time information is embedded and divided into historical training time features and recent historical time features through a fully connected layer.
7. The highway traffic flow prediction method according to claim 6, characterized in that, The representation of global road network structure information based on the node2vec algorithm specifically includes: The gantry nodes and their connectivity relationships are modeled as a graph structure; A sequence of nodes is generated on the graph structure by a biased second-order random walk; The skip-gram model is used to maximize the conditional probability between a node and its neighboring nodes in order to learn the vectorized representation of the gantry node and output the node embedding matrix.
8. The highway traffic flow prediction method according to claim 1, characterized in that, The temporal Transformer module uses a multi-head self-attention mechanism with causal masking, residual connections, layer normalization, and feedforward neural networks to process historical traffic data and historical external temporal features in order to extract dynamic temporal features.
9. The highway traffic flow prediction method according to claim 8, characterized in that, The spatial graph convolution module processes the input features through a Chebyshev graph convolution layer to extract spatial features. The Chebyshev graph convolution layer constructs a Chebyshev polynomial based on the normalized Laplacian matrix of the graph, and multiplies and sums the graph signals of each order with the corresponding learnable weight matrix to achieve feature fusion.
10. The highway traffic flow prediction method according to claim 1, characterized in that, The dynamic graph convolution module performs the following operations: The static adjacency matrix is fused with the node representation of the last time step in the current input features through the graph construction module, a dynamic similarity graph is calculated, and the fused graph structure is generated. The fused graph structure and feature tensor are input into a graph convolutional encoder to obtain a high-order graph structure embedding representation. The high-order graph structure is embedded and represented as input to the decoder for prediction and reconstruction, and the traffic flow prediction result for the future time step is output.
Citation Information
Patent Citations
Traffic flow prediction method based on Transform space-time diagram convolutional network
CN114330671A
Traffic flow prediction method based on adaptive graph fusion convolutional network
CN116071923A
Traffic flow prediction model construction method and prediction method based on adaptive dynamic graph
CN116187555A
Multi-information fusion space-time diagram convolution traffic flow prediction method
CN116258258A
Transform-based traffic flow prediction method and device capable of sensing local-global time-space relationship
CN119990191A