A traffic flow prediction method and system based on delay modeling

Through a deep learning method based on delay modeling, a traffic flow prediction model is constructed with a data embedding layer, a dynamic graph neural network layer, and a spatiotemporal coding layer. This solves the nonlinear and delay characteristics problems of traditional methods when processing complex traffic data, and achieves efficient and accurate multi-step prediction.

CN120199081BActive Publication Date: 2025-09-12OCEAN UNIV OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510685568.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2025-09-12
Estimated Expiration
2045-05-27

AI Technical Summary

Technical Problem

Traditional traffic prediction methods are unable to effectively handle the nonlinear and complex dynamic changes of real traffic data, and ignore the delay characteristics and spatiotemporal correlation between different nodes in the traffic network, resulting in low prediction accuracy and poor computational efficiency and scalability.

Method used

A deep learning method based on delay modeling is adopted to construct a traffic flow prediction model with data embedding layer, dynamic graph neural network layer, spatiotemporal coding layer and multi-layer stacking. The historical traffic time series data and road topology structure are used to capture the spatiotemporal relationship and delay characteristics of the traffic network and perform multi-step prediction.

Benefits of technology

It improves the timeliness and accuracy of traffic flow forecasts, can automatically extract useful features and rules from large-scale historical data, adapt to changes in traffic networks, avoid cumulative errors, and maintain high prediction accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120199081B_ABST
    Figure CN120199081B_ABST
Patent Text Reader

Abstract

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 delay modeling. The method comprises obtaining historical traffic time series data and road topology; defining a traffic flow prediction problem based on the historical traffic time series data and road topology; and constructing a traffic flow prediction model based on delay modeling, which includes modeling a data embedding layer, a dynamic graph neural network layer, a spatiotemporal coding layer, a multi-layer stacking of delay modeling and spatiotemporal coding, and the construction of a data output layer. Compared with traditional statistical models and machine learning methods, the deep learning method based on delay modeling can effectively handle the nonlinear and complex dynamic changes in real-world traffic data, while also addressing the low computational efficiency and poor scalability of machine learning.
Need to check novelty before this filing date? Find Prior Art

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 delay modeling. Background Art

[0002] With the accelerating pace of urbanization, people's travel needs have increased significantly, the number of motor vehicles in cities has rapidly increased, and road congestion has become increasingly serious. Congestion not only reduces travel efficiency but also increases the risk of traffic accidents and environmental pollution, causing significant inconvenience to urban management and residents' lives. Simultaneously, the rapid development of modern technology has led to the widespread deployment of various sensors, such as electronic police cameras, checkpoint detectors, and GPS devices, throughout urban transportation networks. These devices collect vast amounts of real-time traffic data, such as traffic flow, speed, and vehicle density. The rapid accumulation of this data provides a rich information resource for traffic forecasting and management, making traffic forecasting technology a crucial tool for alleviating traffic congestion and optimizing transportation resource allocation. Leveraging this rich data to effectively predict future traffic conditions, timely adjust traffic signal control strategies, and optimize road network efficiency has become a hot topic in Intelligent Transportation Systems (ITS) research.

[0003] Traditional traffic forecasting methods primarily include statistical models and traditional machine learning approaches. Statistical models, such as the Autoregressive Integrated Moving Average (ARIMA), are a representative example. This method effectively predicts future traffic flow by analyzing historical traffic data and has been widely used in traffic forecasting practices. Additionally, methods such as exponential smoothing and regression analysis are also widely used in traffic flow forecasting. However, these methods generally assume simple linear or stationary data characteristics, making them difficult to address the complex dynamics found in real-world traffic flow data.

[0004] Traditional machine learning methods include feature-based methods, Gaussian process models, and state-space models. Feature-based methods typically construct prediction models by extracting and selecting artificially designed traffic features. Gaussian process models are able to effectively capture spatial and temporal correlations. State-space models leverage the relationship between observed data and hidden states for prediction, offering unique advantages in modeling the uncertainty of traffic systems. However, these methods often face challenges with high computational complexity and storage requirements when dealing with large-scale data and high-dimensional feature spaces.

[0005] An analysis of existing prediction methods reveals the following key shortcomings: 1) Statistical models assume simple linear or stationary data characteristics, making it difficult to effectively handle the nonlinear and complex dynamics of real-world traffic data. 2) Traditional machine learning methods suffer from significant computational efficiency and scalability issues when dealing with high-dimensional or large-scale data, making them inadequate for real-time prediction. 3) Existing methods often overlook the latency characteristics and spatiotemporal correlations between different nodes in the traffic network, failing to effectively utilize the spatiotemporal coupling of traffic data, which impacts prediction accuracy. Summary of the Invention

[0006] To address the aforementioned issues, the present invention provides a traffic flow prediction method and system based on delay modeling, which can effectively solve the aforementioned problems, achieve more efficient state updates, and improve the timeliness and accuracy of traffic flow predictions.

[0007] In a first aspect, the present invention provides a traffic flow prediction method based on delay modeling, which adopts the following technical solutions:

[0008] A traffic flow prediction method based on delay modeling, comprising:

[0009] Obtain historical traffic time series data and road topology;

[0010] Define the traffic flow prediction problem based on historical traffic time series data and road topology;

[0011] Construct a traffic flow prediction model based on delay modeling, which includes data embedding layer modeling, dynamic graph neural network layer modeling, spatiotemporal coding layer modeling, multi-layer stacking of delay modeling and spatiotemporal coding, and data output layer construction;

[0012] Model training is performed based on the defined traffic flow prediction problem;

[0013] Use the trained model to predict traffic flow.

[0014] Furthermore, the acquisition of historical traffic time series data and road topology includes defining the traffic network as a directed graph ,in It represents a node set consisting of sensor nodes in the urban traffic network. Each node corresponds to a traffic monitoring device at a specific location in the network. A set of edges representing the connection relationship between nodes; is an adjacency matrix, which is used to represent the connection strength or interaction strength between nodes; and the historical traffic time series data is represented as a three-dimensional tensor ,in represents the historical observation time step, is the number of nodes, is the traffic feature dimension of each node.

[0015] Furthermore, the traffic flow prediction problem is defined based on the historical traffic time series data and the road topology structure, including assuming that the historical traffic time series data is known. ,in is the length of the historical observation window, is the total number of nodes, is the node feature dimension, and the goal of the prediction task is to build a prediction function , using historical observation data and traffic network structure , to predict future traffic flow data, that is, to predict the future The data of time steps is expressed as:

[0016] ,

[0017] in, Indicates the The traffic flow prediction results of future time steps, and .

[0018] Furthermore, the data embedding layer modeling includes using a data embedding method that fuses temporal information and spatial information to generate a high-dimensional embedding representation of each node at each time step, wherein the original input Transformed into a fully connected layer MLP ,in For the specified embedding dimension, the initial time embedding representation is generated by one-hot encoding the discrete time variables and processing them through the fully connected layer; in the spatial dimension, the normalized Laplacian matrix is ​​constructed based on the adjacency matrix , and perform eigendecomposition on it to obtain eigenvalues ​​and eigenvectors; finally, the embedded representation is combined with After the dimensions are aligned, the tensors are element-wise summed to obtain the output of the data embedding layer.

[0019] Furthermore, the dynamic graph neural network layer modeling includes designing a dynamic graph neural network to implement delay-aware modeling. First, a normalized adjacency matrix is ​​used in the graph neural network, and a symmetric normalization method is used to adjust the contribution of each neighbor to an average weight. On the input data of the delay modeling, a delayed version is constructed. , let each time step Corresponding to the previous moment The node features are concatenated with the original sequence in the feature dimension to obtain the combined input ; Then at each time step Build a graph structure independently and extract each time step The input feature matrix , and use the graph convolutional neural network GCN to extract graph features. Finally, the output sequence is obtained based on the output of each time step, and the fully connected mapping layer is used to restore the hidden feature dimension to the input feature dimension.

[0020] Furthermore, the spatiotemporal coding layer modeling includes constructing a multi-head self-attention mechanism to extract the spatiotemporal features of traffic data. In the temporal coding attention, the features of the input data in the time dimension are mapped to the reference point representation space through multi-head self-attention, and the reference points are then used to capture the long-term dynamic associations between each time slice; in the spatial coding attention, the features of the input data in the spatial dimension are mapped to the reference point representation space, thereby capturing the spatial associations between nodes; finally, the outputs of the two attention mechanisms are fused through an MLP to form a unified spatiotemporal coding output representation:

[0021] ,

[0022] in, is a learnable parameter, is the offset, is the activation function, is the output of the temporally encoded attention, is the output of the spatially encoded attention, This is the final output representation of the spatiotemporal coding layer.

[0023] Furthermore, the multi-layer stacking of delay modeling and spatiotemporal coding includes capturing the information transmission delay characteristics between different time steps through the dynamic graph convolutional network DGCN in the delay modeling layer according to the dynamic characteristics of the traffic network; then using the output of the delay modeling layer as the input of the spatiotemporal coding layer, the spatiotemporal coding layer calculates attention in parallel in the time dimension and spatial dimension respectively, and mines the intrinsic correlation between nodes and time steps through the Transformer's multi-head self-attention mechanism to output a unified spatiotemporal feature representation; the next layer of stacking units is connected to the output features of each stacking unit for continuous iterative modeling, thereby extracting more abstract and high-order spatiotemporal delay feature representations layer by layer.

[0024] Furthermore, the data output layer is constructed by stacking multiple layers to obtain a high-level feature representation and adding the output of each layer to obtain the final hidden state. ; To get multi-step predictions, use the output layer to transform the final hidden state Convert to the required dimension and get the predicted value through two 1×1 convolution kernels Here, a direct approach is chosen instead of a recursive approach to perform multi-step prediction, taking into account the cumulative error and model efficiency.

[0025] Furthermore, the model training based on the defined traffic flow prediction problem includes dividing the input data into a training set and a test set, adopting a batch gradient descent algorithm to divide the data in the training set into multiple small batches, updating the model parameters batch by batch, traversing all the data in the training set in each round of training, and calculating the value of the loss function, and then adjusting the model parameters according to the gradient of the loss function, wherein the mean absolute error is selected as the loss function, and the prediction error of the model is measured by calculating the average value of the absolute value of the difference between the predicted value and the true value, and the expression is:

[0026]

[0027] in Represents a node in the model exist Traffic flow forecast at all times, Representation node exist Actual traffic flow at all times.

[0028] In a second aspect, a traffic flow prediction system based on delay modeling includes:

[0029] The data acquisition module is configured to acquire traffic history time series data and road topology;

[0030] A definition module is configured to define a traffic flow prediction problem based on historical traffic time series data and road topology structure;

[0031] The model building module is configured to build a traffic flow prediction model based on delay modeling, which includes data embedding layer modeling, dynamic graph neural network layer modeling, spatiotemporal coding layer modeling, multi-layer stacking of delay modeling and spatiotemporal coding, and data output layer construction;

[0032] The model training module is configured to perform model training based on a defined traffic flow prediction problem;

[0033] The prediction module is configured to use the trained model to predict traffic flow.

[0034] In a third aspect, the present invention provides a computer-readable storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded and executed by a processor of a terminal device for the traffic flow prediction method based on delay modeling.

[0035] In a fourth aspect, the present invention provides a terminal device comprising a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; and the computer-readable storage medium is used to store a plurality of instructions, wherein the instructions are suitable for being loaded and executed by the processor for the traffic flow prediction method based on delay modeling.

[0036] In summary, the present invention has the following beneficial technical effects:

[0037] Compared with traditional statistical models and machine learning methods, deep learning methods based on delay modeling can effectively handle the nonlinear and complex dynamic changes in real traffic data, while making up for the problems of low computational efficiency and poor scalability of machine learning.

[0038] The deep learning method based on delay modeling can directly perform multi-step predictions without recursively using single-step prediction results. By directly converting the final hidden state into multi-step prediction results, the model can avoid the influence of cumulative errors and improve the accuracy of multi-step predictions.

[0039] The deep learning model based on latency modeling learns entirely from data, automatically extracting useful features and patterns from large amounts of historical data without the need for manual feature design. Furthermore, through regular retraining and fine-tuning, the model parameters are continuously updated to adapt to changes in the traffic network and new data. This continuous optimization capability ensures that the model maintains a high level of prediction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 is a schematic diagram of a traffic flow prediction method based on delay modeling according to the present invention;

[0041] Figure 2 is a flow chart of the dynamic graph neural network layer based on delay modeling of the present invention;

[0042] Figure 3 It is a flow chart of the spatiotemporal coding layer;

[0043] Figure 4 It is a flowchart of multi-layer delay modeling and spatiotemporal coding;

[0044] Figure 5 It is the overall framework diagram for realizing traffic prediction;

[0045] Figure 6 This is a diagram verifying the experimental results. DETAILED DESCRIPTION

[0046] The present invention will be further described in detail below with reference to the accompanying drawings.

[0047] Example 1

[0048] Reference Figure 1 , a traffic flow prediction method based on delay modeling in this embodiment includes:

[0049] Obtain historical traffic time series data and road topology;

[0050] Define the traffic flow prediction problem based on historical traffic time series data and road topology;

[0051] Construct a traffic flow prediction model based on delay modeling, which includes data embedding layer modeling, dynamic graph neural network layer modeling, spatiotemporal coding layer modeling, multi-layer stacking of delay modeling and spatiotemporal coding, and data output layer construction;

[0052] Model training is performed based on the defined traffic flow prediction problem;

[0053] Use the trained model to predict traffic flow.

[0054] Specifically:

[0055] Step 1: Build the traffic network and input data.

[0056] This step aims to address the challenge of effectively modeling complex traffic network structures and input data in real-world traffic flow forecasting. In real-world traffic flow forecasting, the structural complexity of traffic networks and the diversity of input data pose significant challenges to model construction and optimization. To address these challenges, this paper proposes a systematic solution. By defining the definition of the traffic network and the structure of input data, it effectively captures the spatiotemporal relationships and delay characteristics between nodes in the traffic network, thereby achieving highly accurate traffic flow forecasting.

[0057] According to the actual traffic scenario, the present invention defines the traffic network as a directed graph ,in It represents a node set consisting of sensor nodes in the urban traffic network. Each node corresponds to a traffic monitoring device at a specific location in the network, such as an electronic police camera or a checkpoint detector. The edge set representing the connection relationship between nodes reflects the traffic flow path and its interaction between nodes; It is an adjacency matrix used to represent the connection strength or interaction strength between nodes, where the matrix elements can reflect the connectivity, distance or traffic flow intensity between roads.

[0058] In terms of input data, the present invention uses historical traffic time series data and road topology as the input of the model. Specifically, the historical traffic time series data is represented as a three-dimensional tensor ,in represents the historical observation time step, is the number of nodes, The traffic characteristic dimensions of each node, such as flow, speed, vehicle density, etc. Through this structured input data, the present invention can efficiently mine the spatiotemporal characteristics of the traffic network, the delay effect between nodes, and the overall traffic trend.

[0059] Step 2, traffic flow prediction problem definition,

[0060] The core task of this module is to transform the complex traffic flow prediction problem into a clear, actionable mathematical problem, thereby providing a solid foundation for subsequent model design, training, and optimization. Based on the traffic network and input data constructed in step 1, the present invention further defines a specific traffic flow prediction problem. The core goal of traffic flow prediction is to use known historical traffic data and the traffic network topology to predict the traffic flow conditions at each node over a period of time in the future. With the help of predicted traffic flow data, transportation departments or individual users can effectively guide them to better organize travel methods and travel times.

[0061] Specifically, assuming that the historical traffic time series data is known ,in is the length of the historical observation window, is the total number of nodes, is the node feature dimension. The goal of the prediction task is to build a prediction function , using historical observation data and traffic network structure , to predict future traffic flow data, that is, to predict the future Data for time steps:

[0062] , (1)

[0063] in, Indicates the The traffic flow prediction results of future time steps, and The prediction task of the present invention defines this problem, clarifies the input-output relationship of traffic flow prediction, and provides clear objectives and method guidance for subsequent prediction model design.

[0064] Step 3: Data embedding layer modeling method,

[0065] To effectively extract temporal and spatial features from input traffic data, we propose a data embedding method that fuses temporal and spatial information to generate a high-dimensional embedding representation of each node at each time step. This embedding layer aims to fully incorporate the contextual characteristics of the source data, improving the model's ability to model spatiotemporal dynamics.

[0066] First, the original input Transformed into ,in is the specified embedding dimension.

[0067] In the time dimension, we consider two time information that are highly correlated with traffic flow changes: the specific "time of day" and the "day of week". By performing one-hot encoding on these two discrete time variables and processing them through a fully connected layer (MLP), we generate the initial time embedding representation. ,in is the specified embedding dimension. This representation can reflect the changing patterns of traffic flow over different time periods, meaning that traffic flow is highly correlated with the time of day. Additional temporal information is included because traffic flow is highly influenced by cyclical variations. For example, traffic flow on major urban roads is very high during rush hour in the morning and evening, while it decreases at other times. Furthermore, the intensity of rush hour on weekends is lower than on weekdays. This temporal factor, influenced by cyclical fluctuations, should be taken into account.

[0068] In the spatial dimension, we construct the normalized Laplacian matrix based on the adjacency matrix , and perform eigendecomposition on it to obtain its eigenvalues ​​and eigenvectors. The smallest non-trivial eigenvector constructs the initial spatial position embedding , which expresses the global structural characteristics of nodes in the transportation network. The design space dimension is based on the fact that traffic flows vary significantly across locations. For example, industrial and residential areas have different peak hours in the morning and evening, while traffic flows near shopping areas are consistently high. This design space dimension is driven by these considerations.

[0069] Finally, to enhance the model's ability to model the original input, we further combine the embedding representation with After the dimensions are aligned, the tensors are element-wise summed to obtain the output of the data embedding layer:

[0070] (2)

[0071] It will be used as the input for subsequent delay modeling to further improve the modeling capability of the dynamic evolution of traffic flow. replace .

[0072] Step 4: Dynamic graph neural network layer modeling method for delay modeling.

[0073] In a traffic system, traffic impacts between different nodes are not generated synchronously, but rather have a certain propagation delay. To capture this asynchrony, we designed a dynamic graph neural network architecture based on delay modeling.

[0074] This method implements delay-aware modeling by designing a dynamic graph neural network. First, in the graph neural network, we use a normalized adjacency matrix. In order to prevent high-order nodes from dominating information propagation, that is, high-degree nodes in the original adjacency matrix may accumulate a large amount of neighbor information, resulting in serious information imbalance, gradient instability or training failure, the symmetric normalization method is used to adjust the contribution of each neighbor to an "average" weight, effectively preventing the "degree hegemony" problem. We use Represents the normalized symmetric adjacency matrix:

[0075] , (3)

[0076] in is the original adjacency matrix, is the identity matrix, is the degree matrix.

[0077] On the input data of delay modeling, we construct a delayed version , let each time step Corresponding to the previous moment The node features (copy themselves at the first moment) are concatenated with the original sequence in the feature dimension to obtain the combined input . Specifically, when hour, = .when hour, = The additional sequence obtained through delay modeling can fully reflect the time information of the previous step, that is, how the time information of the previous step affects the current step. Generally speaking, the delay time of nodes with adjacent relationships is not fixed. That is, because the distance between different nodes is different, the delay relationship also changes with distance and real-world traffic conditions.

[0078] After obtaining the delayed data, we concatenate the current and delayed features (along the last dimension) to obtain:

[0079] (4)

[0080] In order to adapt to the dynamically changing traffic conditions, we Build the graph structure independently, that is, extract each time step The input feature matrix , use graph convolutional neural network (GCN) to extract graph features. Specifically, for the first time step Single-layer GCN:

[0081] , (5)

[0082] in, represents the output of a single-layer GCN, is a learnable weight matrix. GCN can learn the influence of adjacency relationships and further learn the delay relationship of the current step.

[0083] For subsequent time steps GCN, that is , the information transmission process is the same as the first time step The single-layer GCN is similar. For the input graph convolution at the current time step:

[0084] (6)

[0085] Based on each time step The output sequence is obtained by ,final .

[0086] Finally, a fully connected mapping layer is used to restore the hidden feature dimension to the input feature dimension:

[0087] (7)

[0088] The dynamic graph neural network for delay modeling not only considers the impact of the previous step on the current step, but also considers the impact of multiple time steps. The dynamics of the model means that the structure effectively integrates the current input and delay feature evolution, while maintaining input-output alignment, and enhances the model's ability to model temporal state changes and spatial delays.

[0089] Step 5, spatiotemporal coding layer modeling method,

[0090] To further enhance the model's ability to capture the complex spatiotemporal dynamics of traffic networks, this paper introduces an efficient spatiotemporal coding layer modeling method. This method draws on the attention mechanism and performs attention calculations in both the temporal and spatial dimensions, thereby extracting the spatiotemporal features of traffic data in parallel. Finally, a multi-layer perceptron (MLP) fuses the outputs of the two attention mechanisms to achieve a unified representation of spatiotemporal coding.

[0091] Specifically, the spatiotemporal encoding layer contains two core attention mechanisms: Temporal Encode Attention (TEA) and Spatial Encode Attention (SEA). Both attention mechanisms are based on the Transformer's Multi-Head Self-Attention (MHSA). The Transformer architecture uses a multi-head attention mechanism to first project the query, key, and value onto different dimensional subspace, and then execute the attention function in parallel:

[0092] , (8)

[0093] in , are trainable parameters, Q, K, and V represent query, key, and value respectively. is the spatial dimension and softmax is the activation function.

[0094] According to step 4, we can get the output of the delay modeling layer .use Represents the time slices about the node Input, use Indicates the time slice All node inputs.

[0095] First, in temporal encoding attention, we use multi-head self-attention to map the temporal features of the input data to a reference point representation space, and then use these reference points to capture the long-term dynamic correlations between time slices. Specifically, we use two multi-head attention mechanisms. The first attention is expressed as follows:

[0096] (9)

[0097] The second attention uses the output of the first attention as input, i.e.:

[0098] , (10)

[0099] in, Represents the nodes in the input data The features at all time steps, Indicates the The output of the layer after temporal attention. is the temporal encoding representation of all spatial nodes. In this way, we perform an attention mechanism on the temporal dimension, learning the influence relationship between different steps of the same node and obtaining a multi-step temporal representation.

[0100] Secondly, in spatial encoding attention, in a similar way, the features of the input data in the spatial dimension are mapped to the reference point representation space, thereby capturing the spatial correlation between nodes, which is specifically expressed as follows:

[0101] (11)

[0102] , (12)

[0103] in, Represents the input data at time step The characteristics of all nodes, Represents the output after spatial attention. It is a spatial encoding representation at all time steps. In this way, we perform an attention mechanism in the spatial dimension, that is, we learn the influence relationship between different nodes at the same time step and obtain a multi-point spatial representation.

[0104] Finally, the outputs of the two attention mechanisms are fused through an MLP to form a unified spatiotemporal encoding output representation:

[0105] , (13)

[0106] in, is a learnable parameter, is the offset, is the activation function, and are the outputs of temporal encoding attention and spatial encoding attention, respectively. This is the final output representation of the spatiotemporal coding layer proposed in this invention, which can effectively capture and express the long-term spatiotemporal dynamic relationship of the traffic network and provide accurate spatiotemporal feature support for subsequent traffic flow prediction tasks.

[0107] Step 6, multi-layer stacking and data output layer of delay modeling and spatiotemporal coding,

[0108] In order to more deeply capture the long-term dynamic change characteristics in the process of traffic flow prediction, the present invention further proposes a multi-layer stacking method of delay modeling and spatiotemporal coding layers. In the task of traffic flow prediction, the spatiotemporal characteristics of the traffic network are complex and multi-scale. Although single-layer delay modeling and spatiotemporal coding can capture a certain degree of characteristics, for the dynamic changes of complex traffic networks, especially long-term delay effects and complex dynamic relationships between nodes, single-layer models are often difficult to fully express. Therefore, the present invention deepens the model's understanding of the spatiotemporal characteristics of the traffic network layer by layer through multi-layer stacking, and enhances the depth of modeling of delay effects and dynamic relationships between nodes.

[0109] Specifically, each stacked unit consists of a delay modeling layer and a spatiotemporal encoding layer. First, the delay modeling layer uses a dynamic graph convolutional network (DGCN) to capture the information transmission delay characteristics between different time steps based on the dynamic characteristics of the traffic network, thereby outputting a traffic representation with delay evolution characteristics.

[0110] Subsequently, the output of the delay modeling layer serves as the input of the spatiotemporal encoding layer, which calculates attention in parallel in the time dimension and spatial dimension respectively. Through the Transformer's multi-head self-attention mechanism, it deeply explores the intrinsic correlation between nodes and time steps, and outputs a unified spatiotemporal feature representation.

[0111] The present invention integrates the output features of each stacked unit with the next layer of stacked units for continuous iterative modeling, thereby extracting increasingly abstract and advanced spatiotemporal delay feature representations layer by layer. This multi-layered design enables the model to adaptively learn and aggregate spatiotemporal information at different scales, effectively improving its ability to predict complex evolving trends in traffic flow data.

[0112] Finally, the high-level feature representation obtained by stacking multiple layers and adding the output of each layer to obtain the final hidden state ; To get multi-step predictions, we use the output layer to transform the final hidden state Convert to the required dimension and get the predicted value through two 1×1 convolution kernels Traffic flow data:

[0113] (15)

[0114] in yes The prediction result of the step is 1×1 convolution.

[0115] The delay modeling and spatiotemporal coding multi-layer stacking method proposed in this invention significantly enhances the accuracy and generalization ability of the model in traffic prediction tasks.

[0116] Step 7: Model training.

[0117] To ensure the effectiveness and reliability of model training, we scientifically and rationally divided the traffic flow data. Specifically, we divided the traffic flow data into a training set, a validation set, and a test set, with a ratio of 60%, 20%, and 20%. The training set is used for model parameter learning and optimization, the validation set is used to monitor the model's performance in real time during training to prevent overfitting or underfitting, and the test set is used to ultimately evaluate the model's generalization ability and actual application performance. This dataset division method fully utilizes data resources while ensuring the stability and consistency of the model across different datasets.

[0118] During model training, the choice of loss function is crucial for model optimization. After in-depth research and analysis, we chose Mean Absolute Error (MAE) as our loss function. MAE is a commonly used regression loss function that measures the model's prediction error by calculating the average of the absolute differences between the predicted and true values. Its mathematical expression is:

[0119] (16)

[0120] in Represents a node in the model exist Traffic flow forecast at all times, Representation node exist The advantage of MAE is that it is relatively insensitive to outliers and can intuitively reflect the average level of model prediction error.

[0121] Model training is performed on the training set. We employed an efficient deep learning framework to build the model and used the data in the training set to learn and optimize the model parameters. During training, we employed the Batch Gradient Descent algorithm, dividing the training set data into multiple small batches and updating the model parameters batch by batch. Each training epoch iterates over all the data in the training set, calculates the loss function, and then adjusts the model parameters based on the gradient of the loss function. To accelerate training and improve model convergence, we also employed a learning rate decay strategy, gradually reducing the learning rate as the number of training epochs increases, enabling more refined parameter adjustments in the later stages of training.

[0122] After each round of training, we test the model's performance on the validation set. By calculating the MAE value of the model on the validation set, we can monitor the performance changes of the model in real time. Throughout the training process, we will save the model that performs best on the validation set. This model is the model with the smallest MAE value across all training rounds, and it represents the model's optimal performance under the current training strategy. Finally, we apply this optimal model to the test set for a comprehensive evaluation of the model's performance. On the test set, we also calculate the model's MAE value, as well as the root mean square error (RMSE) and mean absolute percentage error (MAPE) to evaluate the model's predictive ability for unseen data.

[0123] Experimental verification:

[0124] In order to verify the theoretical feasibility and practical effectiveness of the traffic flow prediction method based on delay modeling proposed in this invention, we have explained it theoretically and experimentally.

[0125] To achieve highly accurate traffic flow forecasting, this system has been designed and integrated with five key modules. These modules systematically enhance the modeling capabilities of the complex spatiotemporal dynamics of traffic systems, ensuring the model's efficiency and accuracy in practical applications. These modules are: a traffic network and flow data construction module, a traffic flow forecasting problem definition module, a data embedding layer module, a multi-layer delay modeling and spatiotemporal encoding module, and a data output layer module. These modules work closely together and complement each other to create a robust traffic flow forecasting system.

[0126] After the system design is complete, the entire model is systematically trained and optimized based on the powerful training capabilities of deep learning. By training on large-scale traffic flow datasets, the model automatically learns the complex patterns and regularities in traffic flow data, continuously adjusting and optimizing its parameters to achieve optimal prediction results.

[0127] like Figure 6 As shown in the figure, the experiment used the publicly available traffic datasets PEMS-04 and Jinan, which contain traffic flow data from Los Angeles freeways and Jinan city, respectively. A number of representative road segments were selected as nodes to construct the traffic graph topology. A prediction step length of 60 minutes was chosen for training and testing, and mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE) were used as evaluation metrics, as shown in the bar graph below. The results demonstrate the feasibility of our method for traffic flow data prediction.

[0128] Compared with the historical average (HA) method, the proposed method does not rely on periodic assumptions and can adapt to complex and dynamically changing traffic patterns. Compared with statistical methods such as ARIMA and VAR, this method breaks through the limitations of linear stationarity assumptions and possesses stronger nonlinear modeling capabilities. Compared with traditional machine learning methods such as support vector regression (SVR), this method has significant advantages in capturing traffic network structure information and modeling propagation delays and indirect dependencies between different nodes. Table 1 compares the proposed method with the aforementioned methods, and the data results verify the effectiveness of the proposed method.

[0129] Table 1 Comparison of this solution with other methods

[0130]

[0131] Example 2

[0132] This embodiment provides a traffic flow prediction system based on delay modeling. To achieve high-precision traffic flow prediction, this system design includes five key modules: traffic network and flow data construction module, traffic flow prediction problem definition module, data embedding layer module, multi-layer delay modeling and spatiotemporal coding module, and data output layer module. Figure 1 As shown, each component works together to systematically improve the modeling capabilities of the complex spatiotemporal dynamics of the transportation system. Specific details are as follows:

[0133] Module 1: Building a traffic network and traffic data module,

[0134] This module is the foundation of the entire traffic flow prediction system. It processes structured input information from the traffic system, providing high-quality, uniformly formatted data for subsequent deep learning models. Through carefully designed data preprocessing and structuring steps, this module ensures the accuracy and usability of input data, laying a solid foundation for the efficient operation of the system.

[0135] This module abstracts the traffic network into a directed graph structure, where nodes represent monitoring devices (such as checkpoint detectors and cameras) distributed throughout the urban road network, and edges represent traffic flow paths and directions. An adjacency matrix is ​​used to quantify the connection strength and spatial dependencies between nodes. For input data, the system uses historical traffic time series data and topology as input, organized into a three-dimensional tensor (time steps × number of nodes × feature dimensions). This structure defines the model's input boundaries and provides a foundation for subsequent delay modeling and graph neural network operations.

[0136] Module 2: Traffic flow prediction problem definition module,

[0137] This module mathematically models and formally defines the prediction task, providing a clear goal and direction for the operation of the entire system. Historical observation sequence, predicting the future The traffic status of all nodes in the time step, that is, to build a mapping function Make .in, For historical sequence, is the adjacency matrix, This definition clarifies the input and output formats and lays the foundation for the functional boundaries and optimization goals of the model design.

[0138] Module 3: Data embedding layer module,

[0139] To fully extract the spatiotemporal semantic information from the original input, this module designs an embedding mechanism that integrates temporal periodicity and spatial topology. Temporal embedding is constructed using two periodic features, "Time of Day" and "Day of Week", using one-hot encoding and mapping to embedding representation through MLP; spatial embedding extracts the previous information by eigendecomposition of the normalized Laplacian matrix. The two are dimensionally aligned with the original input and fused element-wise to form a unified high-dimensional embedding tensor. , as the input of the delay modeling module.

[0140] Module 4: Multi-layer delay modeling and spatiotemporal coding module,

[0141] like Figure 2 and Figure 3 ,This module is the core of the system modeling capability, integrating ,“delay-aware” and “time-space coupling” modeling strategies.

[0142] Figure 2 In terms of delay modeling, by splicing the node features of the current time step and the previous time step, the propagation delay of traffic impact in the network is simulated, and a symmetric normalized dynamic graph convolutional network is used to independently build a graph and extract features for each time step, effectively preventing information overload caused by high node degree.

[0143] Figure 3 In terms of spatiotemporal coding, temporal encoding attention (TEA) and spatial encoding attention (SEA) are introduced. The multi-head self-attention mechanism in Transformer is used to parallelly model the time series association and spatial structure dependency, and finally a unified spatiotemporal coding representation is generated through MLP fusion.

[0144] Figure 4 It realizes the multi-layer stacking of delay modeling and spatiotemporal coding, gradually deepening the model's understanding of the spatiotemporal characteristics of the traffic network and enhancing the depth of modeling of delay effects and dynamic relationships between nodes.

[0145] Module 5: Data output layer module,

[0146] As the terminal module of the system, the data output layer is responsible for mapping the high-order spatiotemporal feature representation back to the original traffic state space. The specific method is to feed the output of the previous module into a multi-layer perceptron (MLP) to generate a prediction tensor with the same dimension as the input feature. This layer not only ensures the dimensional alignment of the prediction results but also provides nonlinear integration and feature compression capabilities. Combined with residual connections and normalization strategies, it further improves the stability and robustness of the model in complex scenarios.

[0147] like Figure 5 As shown in the figure, the entire system realizes a complete chain from data structure modeling, input embedding, spatiotemporal feature extraction to prediction generation through modular design, providing a systematic guarantee for improving the timeliness, accuracy and generalization ability of traffic flow prediction.

[0148] A computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded and executed by a processor of a terminal device for a traffic flow prediction method based on delay modeling.

[0149] A terminal device includes a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; the computer-readable storage medium is used to store multiple instructions, wherein the instructions are suitable for being loaded and executed by the processor to implement a traffic flow prediction method based on delay modeling.

[0150] The above are all preferred embodiments of the present invention, and are not intended to limit the scope of protection of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the scope of protection of the present invention.

Claims

1. A traffic flow prediction method based on delay modeling, characterized in that: include: Obtain historical traffic time series data and road topology; Define the traffic flow prediction problem based on historical traffic time series data and road topology; Constructing a traffic flow prediction model based on delay modeling, which includes modeling a data embedding layer, a dynamic graph neural network layer, a spatiotemporal coding layer, a multi-layer stacking of delay modeling and spatiotemporal coding, and a data output layer. The delay modeling includes dynamically updating the adjacency matrix based on the delay characteristics at each time step, and concatenating the node characteristics of the current time step with the neighbor characteristics of the previous time step and inputting them into a dynamic graph convolutional network to model the time-varying propagation delay. Model training is performed based on the defined traffic flow prediction problem; Use the trained model to predict traffic flow; The acquisition of historical traffic time series data and road topology includes defining the traffic network as a directed graph ,in It represents a node set consisting of sensor nodes in the urban traffic network. Each node corresponds to a traffic monitoring device at a specific location in the network. A set of edges representing the connection relationship between nodes; is an adjacency matrix, which is used to represent the connection strength or interaction strength between nodes; and the historical traffic time series data is represented as a three-dimensional tensor ,in represents the historical observation time step, is the number of nodes, is the traffic characteristic dimension of each node; The traffic flow prediction problem is defined based on historical traffic time series data and road topology structure, including assuming that the historical traffic time series data is known. ,in is the length of the historical observation window, is the total number of nodes, is the node feature dimension, and the goal of the prediction task is to build a prediction function , using historical observation data and traffic network structure , to predict future traffic flow data, that is, to predict the future The data of time steps is expressed as: , in, Indicates the The traffic flow prediction results of future time steps, and ; The data embedding layer modeling includes using a data embedding method that integrates time information and spatial information to generate a high-dimensional embedding representation of each node at each time step, wherein the original input Transformed into a fully connected layer MLP ,in For the specified embedding dimension, the initial time embedding representation is generated by one-hot encoding the discrete time variables and processing them through the fully connected layer; in the spatial dimension, the normalized Laplacian matrix is ​​constructed based on the adjacency matrix , and perform eigendecomposition on it to obtain eigenvalues ​​and eigenvectors; finally, the embedded representation is combined with After the dimensions are aligned, the tensors are element-wise summed to obtain the output of the data embedding layer. The dynamic graph neural network layer modeling includes designing a dynamic graph neural network to implement delay-aware modeling. First, a normalized adjacency matrix is ​​used in the graph neural network, and a symmetric normalization method is used to adjust the contribution of each neighbor to an average weight. On the input data of the delay modeling, a delayed version is constructed. , let each time step Corresponding to the previous moment The node features are concatenated with the original sequence in the feature dimension to obtain the combined input ; Then at each time step Build a graph structure independently and extract each time step The input feature matrix Graph convolutional neural network (GCN) is used to extract graph features. Finally, the output sequence is obtained based on the output of each time step, and the fully connected mapping layer is used to restore the hidden feature dimension to the input feature dimension. The spatiotemporal coding layer modeling includes constructing a multi-head self-attention mechanism to extract the spatiotemporal features of traffic data. In the temporal coding attention, the features of the input data in the time dimension are mapped to the reference point representation space through multi-head self-attention, and the reference points are then used to capture the long-term dynamic associations between each time slice. In the spatial coding attention, the features of the input data in the spatial dimension are mapped to the reference point representation space to capture the spatial associations between nodes. Finally, the outputs of the two attention mechanisms are fused through an MLP to form a unified spatiotemporal coding output representation: , in, are learnable parameters, is the activation function, This is the final output representation of the spatiotemporal coding layer; The multi-layer stacking of delay modeling and spatiotemporal coding includes capturing the information transmission delay characteristics between different time steps through a dynamic graph convolutional network (DGCN) in the delay modeling layer based on the dynamic characteristics of the traffic network. The output of the delay modeling layer is then used as the input of the spatiotemporal coding layer. The spatiotemporal coding layer calculates attention in parallel in the time and space dimensions, and uses the Transformer's multi-head self-attention mechanism to mine the intrinsic correlation between nodes and time steps, outputting a unified spatiotemporal feature representation. The output features of each stacking unit are then connected to the next layer of stacking units for continuous iterative modeling, thereby extracting more abstract and high-order spatiotemporal delay feature representations layer by layer. The data output layer construction includes high-level feature representation obtained by stacking multiple layers and adding the output of each layer to obtain the final hidden state. ; Finally, in order to make multi-step predictions, the output layer is used to directly convert the final hidden state Convert to the required dimension and get the predicted value through two 1×1 convolution kernels The first step traffic flow data, that is, the final traffic flow prediction result; The model training based on the defined traffic flow prediction problem includes dividing the input data into a training set and a test set, adopting a batch gradient descent algorithm to divide the data in the training set into multiple small batches, updating the model parameters batch by batch, traversing all the data in the training set in each round of training, and calculating the value of the loss function, and then adjusting the model parameters according to the gradient of the loss function, wherein the mean absolute error is selected as the loss function, and the prediction error of the model is measured by calculating the average value of the absolute value of the difference between the predicted value and the true value. The expression is: , in Represents a node in the model exist Traffic flow forecast at all times, Representation node exist Actual traffic flow at all times.

2. A traffic flow prediction system based on delay modeling, executing the traffic flow prediction method based on delay modeling according to claim 1, characterized in that: include: The data acquisition module is configured to acquire traffic history time series data and road topology; A definition module is configured to define a traffic flow prediction problem based on historical traffic time series data and road topology structure; The model building module is configured to build a traffic flow prediction model based on delay modeling, which includes data embedding layer modeling, dynamic graph neural network layer modeling, spatiotemporal coding layer modeling, multi-layer stacking of delay modeling and spatiotemporal coding, and data output layer construction; The model training module is configured to perform model training based on a defined traffic flow prediction problem; The prediction module is configured to use the trained model to predict traffic flow.