Traffic flow prediction method and system based on space-time delay and heterogeneity modeling
By modeling spatiotemporal delay and heterogeneity, using the STDCM and DPOM modules to capture spatiotemporal delay, and combining the Transformer framework to optimize features, the shortcomings of existing models in spatiotemporal dynamic changes and delay modeling are solved, and high-precision traffic flow prediction is achieved.
Patent Information
- Application Number
- CN202511529753.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-24
- Publication Date
- 2026-01-30
AI Technical Summary
Existing traffic flow prediction models are insufficient in capturing the spatiotemporal dynamics and delays between different spatial nodes, making it difficult to fully understand and accurately predict the complex dynamics of urban transportation systems.
A spatiotemporal delay and heterogeneity modeling approach is adopted. The STDCM module captures the spatiotemporal delay, the DPOM module generates dynamic weights and bias parameters, and the Transformer framework is used for feature fusion to achieve dynamic optimization of high-dimensional data features.
It significantly improves the accuracy of traffic flow prediction, can more realistically reflect the laws of traffic flow propagation, adapts to the unique traffic patterns in different areas and time periods of the city, and enhances the generalization ability of the model and the reliability of the prediction results.
Smart Images

Figure CN121438587A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent transportation technology and relates to a traffic flow prediction method and system based on spatiotemporal delay and heterogeneity modeling. Background Technology
[0002] With the rapid development of the Intelligent Transportation Systems (ITS) field, the importance of real-world traffic flow forecasting is becoming increasingly prominent. Traffic flow forecasting has a profound and positive impact on practical applications such as efficient urban travel planning and effective traffic accident prevention. Accurately predicting traffic conditions, such as traffic flow, speed, and lane occupancy, can reveal the overall dynamics of the underlying transportation network, aiding in early warning for emergency management and diagnosis of faulty equipment. The core objective of this field is to predict future traffic flow trends through in-depth analysis of historical traffic data and the underlying spatial structure of the transportation network, providing crucial support for traffic management decisions.
[0003] With the rapid development of artificial intelligence technology, numerous methods have emerged in the field of traffic flow prediction, which can be mainly categorized into two main types: The first category is based on traditional machine learning models. These methods include linear regression models, support vector machines, decision trees, and the K-nearest neighbors algorithm. Their advantage lies in their relatively simple models and low computational cost. However, when faced with the inherent complex spatiotemporal correlations and significant spatial heterogeneity of traffic data, traditional machine learning models struggle to effectively fit a large number of heterogeneous features, and are unable to fully capture the complex nonlinear relationships of traffic flow in time and space. Therefore, their prediction accuracy has a bottleneck and cannot meet the practical needs of high-precision prediction.
[0004] The second category is methods based on deep learning models. In recent years, deep learning models such as Long Short-Term Memory (LSTM) networks, convolutional neural networks (CNNs), and graph convolutional networks (GCNNs) have been widely introduced into the field of traffic prediction. Thanks to their powerful feature learning capabilities, deep learning models can better fit heterogeneous features and capture complex spatiotemporal relationships, thus more effectively learning nonlinear patterns in traffic data. Overall, deep learning methods typically outperform traditional machine learning methods.
[0005] Nevertheless, existing methods still face two key challenges. First, current models are insufficient in capturing the spatiotemporal dynamics between different spatial nodes. Traffic flows propagate and interact across different road segments or regions, but existing methods have limited ability to model these dynamic and differentiated traffic trend changes, making it difficult to fully understand and accurately predict the complex dynamics of urban traffic systems. Second, most traditional studies neglect spatiotemporal delay characteristics. The propagation of traffic flow on spatial networks is not instantaneous but involves a time delay, meaning that traffic changes at downstream nodes lag behind those at upstream nodes. Although a few cutting-edge studies have attempted to incorporate spatiotemporal delay information into modeling, there are still significant shortcomings in effectively capturing and accurately modeling this delay, directly limiting further improvements in model prediction accuracy.
[0006] Therefore, there is an urgent need in this field for a new technology that can explicitly and accurately model spatiotemporal delays and heterogeneity, thereby significantly improving the accuracy of traffic flow prediction. Summary of the Invention
[0007] In view of this, the purpose of the present invention is to provide a traffic flow prediction method and system based on spatiotemporal delay and heterogeneity modeling, so as to improve the accuracy of traffic flow prediction.
[0008] To achieve the above objectives, the present invention provides the following technical solution: A traffic flow prediction method focusing on spatiotemporal delay and heterogeneity modeling, the method specifically includes the following steps: S1: Extract data features and perform standardization; input the data into the STDCM module for data smoothing, obtain spatiotemporal delay data, and fuse it with the original data. S2: Spatial heterogeneity and temporal periodicity and proximity at different granularities are embedded into the model, transforming it into high-dimensional data features that include delay differences and spatiotemporal characteristics; S3: High-dimensional embedding features are processed by the DPOM module, which inputs two-layer attention mechanisms in time and space to generate dynamic weight parameters and bias parameters respectively; the dynamic weight parameters and dynamic bias parameters are then fused into dynamic spatiotemporal optimization parameters through a fusion mechanism. S4: The dynamic spatiotemporal optimization parameters are fused into the Transformer framework, and the temporal Transformer output and spatial Transformer output are fused to obtain the final output. The final prediction result is obtained through the output layer. S5: Input spatial features and temporal flow data into the model for training, and save the best model; the model includes the STDCM module, the spatiotemporal embedding module, the DPOM module, and the Transformer module; among them, the STDCM module represents the spatiotemporal dynamic delay capture module, and the DPOM module represents the dynamic parameter optimization module.
[0009] S6: Input test data into the saved best model to obtain the predicted value of future urban traffic.
[0010] The traffic data used for prediction includes information about the target city, which is collected every five minutes. This data includes the average vehicle speed of the detectors, the average traffic flow of the detectors, and the space occupancy rate. The standardization process uses Z-score normalization to process the data.
[0011] The specific steps of the STDCM module in performing data smoothing and fusing spatiotemporal delay differences are as follows: S111: Transfer the original data Divided into datasets to be compared and target dataset The dataset to be compared is filtered to remove nodes that do not have edges or whose distances are too large or too small as follows:
[0012] in This is the proximity matrix, representing specific node information on the spatial graph, including the specific distances between nodes, the spatial network, and other information. These are trainable parameters.
[0013] S112: Define the sliding convolution operation, using the following formula... and Perform data smoothing operation:
[0014] in The smoothing operation involves using a sliding window averaging method to perform one-dimensional convolution operations to exclude the edge parts of the sequence. The sliding window performs overlapping calculations within the sequence to avoid convolution operations on edge regions and reduce the interference of edge effects on the results.
[0015] S113: Input smoothed data into a bandwidth-constrained dynamic time warping algorithm to calculate latency information using the following formula:
[0016] in This indicates a custom bandwidth limiting matrix. Represented as the Dynamic Time Warping algorithm, it is used to measure the similarity between two time series. To calculate the smoothed dataset to be compared and target dataset The similarity between them.
[0017] S114: Obtain time series data containing delays using the following formula based on the delay information:
[0018] in This indicates that data matching is performed based on delay information.
[0019] Furthermore, the spatiotemporal delay differences and the original data are fused to obtain the final time series data containing spatiotemporal delays; S121: The spatiotemporal delay sequence with fused spatiotemporal delay differences is obtained from the delayed time series using the following formula. :
[0020] in , These are trainable parameters.
[0021] The process of embedding spatial heterogeneity and temporal periodicity and proximity at different granularities into the model transforms it into high-dimensional data features that include delay differences and spatiotemporal characteristics. The specific steps of the spatiotemporal embedding operation are as follows: S21: For embedding merging of the embedding layer, Transform into high-dimensional data embedding .
[0022] S22: Introducing Spatial Embedding Expression Capture spatial proximity and spatial heterogeneity.
[0023] S23: Introduce weekly, daily, and hourly granularities respectively: , and We delved deeper into and modeled the traffic patterns during this period, transforming them into high-order data embeddings: , and Dimensional fusion embedding is performed using the following formula:
[0024] The two-layer attention mechanism that embeds high-dimensional features into time and space respectively generates dynamic weight parameters and bias parameters, and then fuses them into dynamic spatiotemporal optimization parameters through a parameter fusion mechanism. S301: Calculate the attention weight coefficients for the high-order embedded data using the following formula:
[0025] in This is represented as an attention calculation operation to obtain weight coefficients for different spaces and times.
[0026] S302: Perform a linear transformation on the attention coefficients to obtain dynamic weight parameters.
[0027] in and These are trainable parameters.
[0028] S303: Based on dynamic weight matrix and latency difference embedded data Nonlinear features are extracted through element-wise multiplication (Hadamard product) and the ReLU activation function, and then the mean is calculated along the feature dimension to finally generate dynamic bias parameters. :
[0029] Furthermore, the spatiotemporal dynamic weight parameters and bias parameters are converted into dynamic spatiotemporal optimization parameters through a fusion mechanism; S311: Employs a dynamic spatiotemporal parameter fusion mechanism to integrate high-dimensional data. With dynamic spatiotemporal weights and dynamic bias By combining these methods, the final parameters of the spatial dynamic parameters are generated through linear transformation:
[0030] in, Represents dynamic space weights. Indicates dynamic time offset. These are trainable parameters.
[0031] S312: Similarly, the time dynamic parameters are obtained through the following formula:
[0032] in, Indicates dynamic time weights. Indicates dynamic spatial bias. These are trainable parameters.
[0033] S313: Spatial fusion parameters are generated through parameter fusion using the following spatiotemporal parameter fusion mechanism:
[0034] in , For spatial dimensions, trainable parameters , These are the fusion parameters generated by the two attention mechanisms, respectively.
[0035] The dynamic spatiotemporal optimization parameters are fused into the Transformer framework to obtain the final spatiotemporal interactive representation; the fusion steps are as follows: S401: Input advanced embedding representation ,generate , and ; S402: Optimized generation of fusion parameters for DPOM fusion and
[0036] S403: Implements a self-attention mechanism by calculating the dependencies between time slices. Furthermore, the output of the time-fusing Transformer... and spatial Transformer output The final Transformer output is obtained. The final result is obtained through the output layer, which consists of fully connected layers. S411: Calculate the spatial Transformer output according to the following formula:
[0037] S412: Calculate the time Transformer output according to the following formula:
[0038] S413: Transformer output that combines space and time:
[0039] S414: Pass the output features to a prediction network consisting of fully connected layers to generate the final prediction result.
[0040] in, The joint output feature of the spatiotemporal Transformer is represented by fusing the output of the temporal Transformer. and the output of the spatial Transformer The final feature representation obtained.
[0041] A traffic flow prediction system focusing on spatiotemporal delay and heterogeneity modeling includes an STDC module, a spatiotemporal embedding module, a DPO module, a Transformer module, a model training module, and a traffic flow probability prediction module. The data processing operation is used to process the original traffic flow data and spatial map data to obtain standardized data, which is then input into the STDC module for data smoothing and to capture potential delay features in the traffic flow time series data. The obtained delay data is then balanced and fused with the original data.
[0042] The spatiotemporal embedding module is used to convert the periodicity and spatiotemporal proximity of time series data into high-level embeddings for fusion, thereby improving the modeling and generalization capabilities of the spatiotemporal dynamic characteristics of traffic flow. The DPO module introduces a temporal and spatial attention mechanism to generate dynamic weights and bias parameters and perform a fusion mechanism to obtain dynamic spatiotemporal optimization parameters. The Tansformer module aggregates dynamic spatiotemporal optimization parameters to obtain spatiotemporal output, and obtains the final result through the output layer; The model training module is used to train on all input features, with evaluation metrics set as RMSE, MAE, and MAPE. The training dataset includes PeMS03, PeMS04, PeMS07, and PeMS08. The model training module includes an STDC module, a spatiotemporal embedding module, a DPO module, and a Transformer module. The model with the lowest RMSE, MAE, and MAPE is saved as the optimal model.
[0043] The traffic flow prediction module predicts the future trend of urban traffic flow by running the saved best model based on the input test data.
[0044] The beneficial effects of this invention are as follows: (1) Traditional methods and existing deep learning models have inherent limitations in capturing the spatiotemporal dynamics of traffic flow. One of the core innovations of this invention is the introduction of a dedicated spatiotemporal dynamic delay capture module. This module, through a bandwidth-constrained dynamic time warping algorithm, can explicitly quantify and capture the time delay effect generated by the propagation of traffic flow between upstream and downstream nodes. This overcomes the shortcomings of existing technologies that often ignore or coarsely handle spatiotemporal delays, enabling the model to more realistically reflect the propagation patterns of traffic flow in the road network, thereby fundamentally improving the modeling ability for complex traffic dynamics and laying a solid foundation for high-precision prediction.
[0045] (2) Transportation systems exhibit typical spatiotemporal heterogeneity, meaning that traffic patterns vary significantly across different regions and time periods. To address this issue, this invention designs a dynamic parameter optimization module. Instead of using fixed model parameters, this module dynamically generates optimal weights and biases for different spatial nodes and time segments through a parallel spatiotemporal attention mechanism. This dynamic adaptive mechanism enables the model to flexibly adapt to the unique traffic patterns of different functional areas (such as commercial and residential areas) and different time periods (such as morning rush hour and off-peak hours), greatly enhancing the model's ability to characterize spatiotemporal heterogeneity and making predictions more accurate and reliable.
[0046] (3) This invention uses a spatiotemporal embedding module to uniformly embed delayed and enhanced traffic data, spatial topology information, and multi-granular temporal periodic features (week, day, hour) into a high-dimensional feature space. This deep fusion ensures that the model can simultaneously consider the spatial proximity, functional heterogeneity, and regularity at different periodic scales of the traffic system, forming a comprehensive and rich feature representation. Furthermore, by integrating dynamically generated optimization parameters into the powerful Transformer framework, this invention not only utilizes the advantages of Transformer in capturing long-range dependencies but also optimizes its attention mechanism through customized parameters, achieving deeper and more efficient interaction and fusion between spatiotemporal features, ultimately generating a more discriminative feature representation for prediction.
[0047] (4) The technical solution constructed in this invention has inherent robustness. The data smoothing preprocessing operation effectively reduces the interference of noise and outliers in the original data. At the same time, the explicit modeling of spatiotemporal delay reduces the dependence on strict data synchronization, making the model more adaptable to the slight asynchronicity that may exist in data collection in the real world. More importantly, the dynamic parameter generation mechanism enables the model to adapt to changes in data distribution in different urban road network structures or different time periods, rather than relying on a fixed pattern. These characteristics work together to significantly improve the model's generalization ability when facing unseen data or changing environments, making it more stable and reliable in actual deployment.
[0048] (5) This invention systematically addresses the two core challenges of spatiotemporal delay capture and heterogeneity modeling, ultimately achieving a substantial leap in prediction accuracy. More accurate traffic flow prediction results can provide more reliable and forward-looking decision-making basis for key applications such as urban traffic management, travel route planning, congestion early warning, and emergency response. This helps improve the operational efficiency of the entire road network, reduce travel time costs, and provides a powerful technical core for building a more intelligent and efficient next-generation intelligent transportation system.
[0049] Other advantages, objectives, and features of the invention will be set forth in part in the description which follows, and in part will be apparent to those skilled in the art from the following examination, or may be learned from practice of the invention. The objectives and other advantages of the invention can be realized and obtained through the following description. Attached Figure Description
[0050] To make the objectives, technical solutions, and advantages of the present invention clearer, the preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings, wherein: Figure 1 This is a flowchart illustrating the traffic flow prediction method based on spatiotemporal delay and heterogeneity modeling of the present invention. Figure 2 This is a schematic diagram of the model structure of the present invention; Figure 3 This is a schematic diagram of the spatiotemporal delay capture module of the present invention; Figure 4 This is a schematic diagram of the dynamic parameter optimization module of the present invention; Figure 5 This is a schematic diagram of the traffic flow prediction device based on spatiotemporal delay and heterogeneity modeling of the present invention. Detailed Implementation
[0051] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0052] The accompanying drawings are for illustrative purposes only and are schematic diagrams, not actual pictures. They should not be construed as limiting the invention. To better illustrate the embodiments of the invention, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions. It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0053] In the accompanying drawings of the embodiments of the present invention, the same or similar reference numerals correspond to the same or similar components. In the description of the present invention, it should be understood that if terms such as "upper," "lower," "left," "right," "front," and "rear" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, they are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, the terms used to describe positional relationships in the drawings are only for illustrative purposes and should not be construed as limiting the present invention. For those skilled in the art, the specific meaning of the above terms can be understood according to the specific circumstances.
[0054] Please see Figures 1-5 This is a traffic flow prediction method that focuses on modeling spatiotemporal delay and heterogeneity. The method specifically includes the following steps: S1: Extract data features and perform standardization; input the data into the STDCM module for data smoothing, obtain spatiotemporal delay data, and fuse it with the original data. S2: Spatial heterogeneity and temporal periodicity and proximity at different granularities are embedded into the model, transforming it into high-dimensional data features that include delay differences and spatiotemporal characteristics; S3: High-dimensional embedding features are processed by the DPOM module, which inputs two-layer attention mechanisms in time and space to generate dynamic weight parameters and bias parameters respectively; the dynamic weight parameters and dynamic bias parameters are then fused into dynamic spatiotemporal optimization parameters through a fusion mechanism. S4: The dynamic spatiotemporal optimization parameters are fused into the Transformer framework, and the temporal Transformer output and spatial Transformer output are fused to obtain the final output. The final prediction result is obtained through the output layer. S5: Input spatial features and temporal flow data into the model for training, and save the best model; the model includes the STDCM module, the spatiotemporal embedding module, the DPOM module, and the Transformer module; among them, the STDCM module represents the spatiotemporal dynamic delay capture module, and the DPOM module represents the dynamic parameter optimization module.
[0055] S6: Input test data into the saved best model to obtain the predicted value of future urban traffic.
[0056] The traffic data used for prediction includes information about the target city, which is collected every five minutes. This data includes the average vehicle speed of the detectors, the average traffic flow of the detectors, and the space occupancy rate. The standardization process uses Z-score normalization to process the data.
[0057] The specific steps of the STDCM module in performing data smoothing and fusing spatiotemporal delay differences are as follows: S111: Transfer the original data Divided into datasets to be compared and target dataset The dataset to be compared is filtered to remove nodes that do not have edges or whose distances are too large or too small as follows:
[0058] in This is the proximity matrix, representing specific node information on the spatial graph, including the specific distances between nodes, the spatial network, and other information. These are trainable parameters.
[0059] S112: Define the sliding convolution operation, using the following formula... and Perform data smoothing operation:
[0060] in The smoothing operation involves using a sliding window averaging method to perform one-dimensional convolution operations to exclude the edge parts of the sequence. The sliding window performs overlapping calculations within the sequence to avoid convolution operations on edge regions and reduce the interference of edge effects on the results.
[0061] S113: Input smoothed data into a bandwidth-constrained dynamic time warping algorithm to calculate latency information using the following formula:
[0062] in This indicates a custom bandwidth limiting matrix. Represented as the Dynamic Time Warping algorithm, it is used to measure the similarity between two time series. To calculate the smoothed dataset to be compared and target dataset The similarity between them.
[0063] S114: Obtain time series data containing delays using the following formula based on the delay information:
[0064] in This indicates that data matching is performed based on delay information.
[0065] Furthermore, the spatiotemporal delay differences and the original data are fused to obtain the final time series data containing spatiotemporal delays; S121: The spatiotemporal delay sequence with fused spatiotemporal delay differences is obtained from the delayed time series using the following formula. :
[0066] in , These are trainable parameters.
[0067] The process of embedding spatial heterogeneity and temporal periodicity and proximity at different granularities into the model transforms it into high-dimensional data features that include delay differences and spatiotemporal characteristics. The specific steps of the spatiotemporal embedding operation are as follows: S21: For embedding merging of the embedding layer, Transform into high-dimensional data embedding .
[0068] S22: Introducing Spatial Embedding Expression Capture spatial proximity and spatial heterogeneity.
[0069] S23: Introduce weekly, daily, and hourly granularities respectively: , and We delved deeper into and modeled the traffic patterns during this period, transforming them into high-order data embeddings: , and Dimensional fusion embedding is performed using the following formula:
[0070] The two-layer attention mechanism that embeds high-dimensional features into time and space respectively generates dynamic weight parameters and bias parameters, and then fuses them into dynamic spatiotemporal optimization parameters through a parameter fusion mechanism. S301: Calculate the attention weight coefficients for the high-order embedded data using the following formula:
[0071] in This is represented as an attention calculation operation to obtain weight coefficients for different spaces and times.
[0072] S302: Perform a linear transformation on the attention coefficients to obtain dynamic weight parameters.
[0073] in and These are trainable parameters.
[0074] S303: Based on dynamic weight matrix and latency difference embedded data Nonlinear features are extracted through element-wise multiplication (Hadamard product) and the ReLU activation function, and then the mean is calculated along the feature dimension to finally generate dynamic bias parameters. :
[0075] Furthermore, the spatiotemporal dynamic weight parameters and bias parameters are transformed into dynamic spatiotemporal optimization parameters through a fusion mechanism; S311: Employs a dynamic spatiotemporal parameter fusion mechanism to integrate high-dimensional data. With dynamic spatiotemporal weights and dynamic bias By combining these methods, the final parameters of the spatial dynamic parameters are generated through linear transformation:
[0076] in, Represents dynamic space weights. Indicates dynamic time offset. These are trainable parameters.
[0077] S312: Similarly, the time dynamic parameters are obtained through the following formula:
[0078] in, Indicates dynamic time weights. Indicates dynamic spatial bias. These are trainable parameters.
[0079] S313: Spatial fusion parameters are generated through parameter fusion using the following spatiotemporal parameter fusion mechanism:
[0080] in , For spatial dimensions, trainable parameters , These are the fusion parameters generated by the two attention mechanisms, respectively.
[0081] The dynamic spatiotemporal optimization parameters are fused into the Transformer framework to obtain the final spatiotemporal interactive representation; the fusion steps are as follows: S401: Input advanced embedding representation ,generate , and ; S402: Optimized generation of fusion parameters for DPOM fusion and
[0082] S403: Implements a self-attention mechanism by calculating the dependencies between time slices. Furthermore, the output of the time-fusing Transformer... and spatial Transformer output The final Transformer output is obtained. The final result is obtained through the output layer, which consists of fully connected layers. S411: Calculate the spatial Transformer output according to the following formula:
[0083] S412: Calculate the time Transformer output according to the following formula:
[0084] S413: Transformer output that combines space and time:
[0085] S414: Pass the output features to a prediction network consisting of fully connected layers to generate the final prediction result.
[0086] in, The joint output feature of the spatiotemporal Transformer is represented by fusing the output of the temporal Transformer. and the output of the spatial Transformer The final feature representation obtained.
[0087] This embodiment provides a traffic flow prediction system based on spatiotemporal delay and heterogeneity modeling. See [link to relevant documentation]. Figure 4 The system includes the following modules: a data processing module: This data preprocessing module processes the raw traffic flow data and spatial map data, standardizing them before inputting them into the STDC module to achieve data smoothing and capture potential delay characteristics in the traffic flow time series data. Subsequently, the extracted delay information is balanced and fused with the raw data. In a preferred embodiment, this module includes a data receiver, a data processing unit, and a data storage unit. The data receiver is responsible for receiving raw data in CSV and NPY formats and inputting it into the data processing unit; the data processing unit performs cleaning, calculation, and statistical processing on the raw data according to preset rules; the data storage unit stores the processed data for use by subsequent modules.
[0088] Spatiotemporal delay capture module: Spatiotemporal embedding module: embeds spatial heterogeneity and temporal periodicity and proximity at different granularities into the model, transforming it into high-dimensional data features that include delay differences and spatiotemporal characteristics; Dynamic parameter optimization module: The model training module is responsible for receiving and inputting the data after knowledge fusion and feature construction. After adjusting key hyperparameters such as the learning rate and batch size, it trains the model and saves the best-performing model. In a preferred embodiment, this module includes a data processing unit, a model memory, and a computer program that can run on the processing unit. The data processing unit performs computational tasks related to the STDCM, data embedding module, DPOM, and Transformer modules; the model memory stores the best-performing model during training for later use.
[0089] The traffic flow prediction module runs a saved optimal model based on the input test data to predict future traffic flow. In a preferred embodiment, the module includes a data receiver, a model reader, a model processor, and a data outputter. The data receiver receives the test data and transmits it to the model processor. The model processor loads the optimal model through the model reader and performs prediction calculations, finally transmitting the prediction results to the data outputter, which outputs the final traffic flow prediction value.
[0090] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A traffic flow prediction method based on spatio-temporal delay and heterogeneity modeling, characterized in that: The method specifically comprises the following steps: S1: data preprocessing and space-time delay capture: obtaining raw traffic flow data and performing standardization processing, inputting the processed data into a space-time dynamic delay capture module, calculating space-time delay information through data smoothing and a dynamic time warping algorithm with bandwidth limitation, and fusing the space-time delay information with the raw data to obtain a space-time delay sequence containing space-time delay differences; S2: space-time feature embedding: converting the space-time delay sequence obtained in S1 into high-dimensional embedding features containing delay differences and space-time characteristics in combination with spatial embedding representation and cycle characteristics of week granularity, day granularity and hour granularity; S3: dynamic parameter optimization: inputting the high-dimensional embedding features obtained in S2 into a dynamic parameter optimization module, generating dynamic weight parameters and dynamic bias parameters through time attention mechanism and space attention mechanism respectively, and fusing the dynamic weight parameters and dynamic bias parameters into dynamic space-time optimization parameters through a fusion mechanism; S4: space-time modeling and prediction: fusing the dynamic space-time optimization parameters obtained in S3 into a Transformer framework, performing attention calculation in time dimension and space dimension respectively to obtain time Transformer output and space Transformer output; fusing the time Transformer output and the space Transformer output, and obtaining a final traffic flow prediction result through an output layer; S5: model training: inputting historical traffic flow data and corresponding spatial features into a model comprising the modules S1 to S4 for training, and saving an optimal model according to a preset evaluation index; S6: flow prediction: inputting test data into the optimal model saved in S5 to obtain a prediction value of future traffic flow.
2. The traffic flow prediction method based on spatio-temporal delay and heterogeneity modeling according to claim 1, characterized in that: In S1, the raw traffic flow data includes average vehicle speed, average flow information and space occupancy rate collected by a detector every five minutes in a target city; and the standardization processing adopts a Z-score normalization method. 3.The traffic flow prediction method based on spatio-temporal delay and heterogeneity modeling according to claim 1, characterized in that: The specific operations performed by the space-time dynamic delay capture module in S1 include: S111: divide the raw data into a to-be-compared data set and a target data set filter out nodes with non-existent edges or excessively large or small distances from the to-be-compared data set by wherein is a proximity matrix, representing specific node information on the spatial graph, including specific distance between nodes, spatial network graph, etc. is a trainable parameter; S112: define a sliding convolution operation, which performs a data smoothing operation on and by the following equation: wherein The smoothing operation is implemented by using a sliding window average method to realize one-dimensional convolution operation, which excludes the edge part of the sequence. The sliding window overlaps in the internal calculation of the sequence to avoid convolution operation on the edge area and reduce the interference of edge effect on the result. S113: inputting smoothed data into a dynamic time warping algorithm with bandwidth limitation, and calculating delay information through the following formula: wherein represents a custom restricted bandwidth matrix, represents a dynamic time warping algorithm for measuring the similarity of two time series, the similarity between the smoothed dataset to compare and the target dataset is calculated. S114: obtaining time series data containing delay according to the delay information through the following formula: wherein represents a data matching operation according to the delay information. 4.The traffic flow prediction method based on spatio-temporal delay and heterogeneity modeling according to claim 1, characterized in that: In S1, the space-time delay information is fused with the original data by the following formula to obtain a space-time delay sequence. : wherein , are trainable parameters.
5. The traffic flow prediction method based on spatio-temporal delay and heterogeneity modeling according to claim 1, characterized in that: The specific operations of the space-time feature embedding in S2 include: S21: To embed the embedding merge of the embedding layer, the embedding merge of the embedding layer is converted into high-dimensional data embedding transformed into high-dimensional data embedding ; S22: Introduce spatial embedding representation Capture spatial proximity and spatial heterogeneity; S23: Introduce weekly granularity, daily granularity and hourly granularity respectively: , and , deeply mine and model the traffic law in this period, and respectively convert it into high-bit data embedding: , and , dimension fusion embedding is carried out through the following formula: 。 6. The traffic flow prediction method based on spatio-temporal delay and heterogeneity modeling according to claim 1, characterized in that: The specific operations of generating dynamic weight parameters and dynamic bias parameters in S3 include: S301: calculating attention weight coefficients of high-dimensional embedding data through the following formula: wherein is represented as an attention computation operation to obtain different spatial and temporal weight coefficients; S302: performing linear transformation operation on the attention coefficients to obtain dynamic weight parameters: wherein and are trainable parameters; S303: based on the dynamic weight matrix and delay difference embedded data , extract nonlinear features by element-wise multiplication (Hadamard product) and ReLU activation function, then calculate the mean along the feature dimension, and finally generate dynamic bias parameters : 。 7. The traffic flow prediction method based on spatio-temporal delay and heterogeneity modeling according to claim 1, characterized in that: The specific operations of fusing the dynamic weight parameters and the dynamic bias parameters into dynamic space-time optimization parameters in S3 include: S311: Adopting dynamic space-time parameter fusion mechanism, combining high-dimensional data with dynamic space-time weight and dynamic bias , generating space dynamic parameter final parameters through linear transformation: wherein, denotes a dynamic spatial weight, denotes a dynamic temporal bias, are trainable parameters; S312: similarly, obtaining time dynamic parameters through the following formula: wherein, denotes a dynamic temporal weight, denotes a dynamic spatial bias, are trainable parameters; S313: performing parameter fusion through the following space-time parameter fusion mechanism to generate space fusion parameters: wherein , are trainable parameters for spatial dimensions, , are fusion parameters generated by two layers of attention mechanisms, respectively. 8.The traffic flow prediction method based on spatio-temporal delay and heterogeneity modeling according to claim 1, characterized in that: The specific operations of fusing the dynamic space-time optimization parameters into the Transformer framework in S4 include: S401 : input high-level embedding representation , generate , and ; S402: generating the optimized fusion parameters of the fusion DPOM and ; S403: Perform self-attention mechanism to calculate the dependency between time slices. 9.The traffic flow prediction method based on spatio-temporal delay and heterogeneity modeling according to claim 1, characterized in that: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: S411: Calculate the space Transformer output according to the following formula: S412: Calculate the time Transformer output according to the following formula: S413: Fuse the space and time Transformer outputs: S414: Pass the output features to a prediction network composed of fully connected layers to generate the final prediction result: wherein, represents the joint output feature of the spatio-temporal Transformer, which is obtained by fusing the output of the temporal Transformer and the output of the spatial Transformer to obtain the final feature representation.
10. A spatio-temporal delay and heterogeneity modeling based traffic flow prediction system for implementing the method of any one of claims 1-9, characterized by: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific operation of fusing the time Transformer output and the space Transformer output in S4 includes: The specific
