Traffic flow prediction method and system based on diffusion model
By constructing a space-time-dependent structure diagram and prediction method based on diffusion model, the problem that the existing technology is difficult to integrate long-term characteristics and recent dynamics is solved, and a better understanding of complex space-time structures and the capture of multi-scale features is achieved, and the accuracy and robustness of traffic flow prediction are improved.
Patent Information
- Application Number
- CN202411851701.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-12-16
AI Technical Summary
Existing traffic flow prediction technologies are difficult to integrate long-term characteristics and recent dynamics, lack of understanding of complex spatiotemporal structures, and lack of generative modeling capabilities under noisy data.
By obtaining historical traffic data, a space-time dependence structure diagram describing space-time dependence is constructed, periodic features and target features are extracted, and feature fusion is fusion using dynamic time regularization method, and the fusion features are input into the traffic flow prediction model based on the diffusion model for training. Multi-scale and multi-stage spatio-time feature distribution is captured through forward noise addition and reverse diffusion reduction processes.
Explicit modeling of the topological relationships of complex road networks is realized, the prediction accuracy and robustness are improved, the coordinated evolution trend between multiple road segments can be better captured, and the impact of noise on prediction is reduced.
Smart Images

Figure CN119889026A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent traffic prediction, and in particular to a traffic flow prediction method and system based on a diffusion model. Background Art
[0002] Traditional traffic flow forecasting methods mostly rely on statistical models or methods based on classical time series analysis, such as the autoregressive moving average model (ARIMA), seasonal ARIMA (SARIMA), and periodic decomposition methods based on Fourier transform. These traditional methods can provide short-term forecasts with a certain degree of accuracy under specific conditions, but their model structures are relatively simple, their robustness to abnormal data is weak, and it is difficult to fully exploit the inherent spatial correlation and nonlinear dynamic characteristics in road networks.
[0003] At present, although the existing technology has solved the shortcomings of traditional statistical models in capturing nonlinear features poorly, it still faces many challenges. In particular, most of the existing deep models are unable to fully integrate long-term cyclical characteristics with recent dynamic data. They usually require manual or empirical decomposition and fusion of cyclical and trend information, and lack an adaptive feature fusion mechanism under a unified framework.
[0004] The shortcomings of existing technologies are mainly reflected in the inability to efficiently and uniformly integrate long-term periodic laws and short-term dynamic changes, and to accurately capture the multi-stage feature distribution under different time scales and spatial associations in the prediction model. Specifically, traditional methods are difficult to cope with the nonlinear interaction effects under complex road network structures, and it is difficult to take into account both long-term stable patterns and sudden fluctuations in recent periods in the same model framework; even if some methods introduce graph neural network structures in order to use topological information to extract spatial features, they are still weak in multi-scale representation and fusion in the time dimension; in addition, conventional deep prediction models often rely on simple regularization methods when dealing with data noise or uncertain data, and are unable to deeply model the potential spatiotemporal distribution through systematic diffusion and reverse diffusion processes, which limits the prediction accuracy and robustness.
[0005] Therefore, there is an urgent need for a technical solution that can capture the changes in long-term and short-term spatiotemporal characteristics from multiple angles and has the ability to effectively reduce noise and improve prediction accuracy through adaptive feature fusion and diffusion generation processes. Summary of the invention
[0006] The purpose of this section is to summarize some aspects of the embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the abstract of the specification and the title of the invention of this application to avoid blurring the purpose of this section, the abstract of the specification and the title of the invention, and such simplifications or omissions cannot be used to limit the scope of the present invention.
[0007] In view of the above existing problems, the present invention is proposed.
[0008] Therefore, the technical problem solved by the present invention is that the existing traffic flow prediction technology has the problems of difficulty in integrating long-term characteristics with recent dynamics, insufficient understanding of complex spatiotemporal structures, and lack of generative modeling capabilities under noisy data.
[0009] In order to solve the above technical problems, the present invention provides the following technical solutions: historical traffic data is acquired and data preprocessing is performed to form a sample data set including traffic flow, traffic speed and road occupancy;
[0010] The road segments of the road network in the sample data set are taken as nodes, and edges are constructed according to the geographical proximity and historical traffic association between the road segments to form a spatiotemporal dependency structure graph describing the spatiotemporal dependency;
[0011] Performing period feature extraction and target feature extraction on the historical traffic data in the spatiotemporal dependency structure graph;
[0012] Using a dynamic time warping method to measure the similarity between the periodic feature and the target feature in the time dimension, and based on the similarity, selectively migrating and weighted fusion of the periodic feature to obtain a fusion feature;
[0013] The fusion features are input into a traffic flow prediction model built based on a diffusion model for training, and the multi-scale and multi-stage spatiotemporal feature distribution is captured through a forward noise addition and a reverse diffusion reduction process, and a representation vector for predicting future traffic flow is output;
[0014] Then the current traffic data is input into the trained prediction model to predict the traffic flow, and through the reverse diffusion process, the traffic flow prediction results for the future time period are output.
[0015] As a preferred solution of the traffic flow prediction method based on the diffusion model described in the present invention, historical traffic data within a specified time period is exported from the traffic control system, and missing value processing, outlier detection and normalization processing are performed on it to obtain the sample data set.
[0016] As a preferred solution of the traffic flow prediction method based on the diffusion model described in the present invention, the sample data set is represented as a three-dimensional tensor, and its mathematical expression formula is:
[0017] X∈R N×T s ×F
[0018] Where N is the number of road section nodes, T s is the number of time slices, F is the number of feature dimensions, and X is the sample data set.
[0019] As a preferred solution of the traffic flow prediction method based on the diffusion model described in the present invention, the forming of a spatiotemporal dependency structure diagram describing the spatiotemporal dependency includes:
[0020] Take the road section as the node, and take N road sections as N nodes in the node set V;
[0021] Establish edges between nodes based on geographical proximity and historical traffic correlation to form an adjacency matrix A;
[0022] Based on the node set V and the adjacency relationship matrix A, a graph structure G describing spatiotemporal dependency is formed.
[0023] As a preferred solution of the traffic flow prediction method based on the diffusion model described in the present invention, extracting the period feature and the target feature includes:
[0024] Select historical data with a longer time span as periodic data, and define the length of the periodic data as T cyc time slices, and after feature extraction, the periodic feature Z is obtained cyc ;
[0025] Select the data of the recent time period as the target data, and define the length of the target data as T tar time slices, and after feature extraction, we get the target feature Z tar .
[0026] As a preferred solution of the traffic flow prediction method based on the diffusion model described in the present invention, the fusion feature is obtained, including:
[0027] Z fus =αZ cyc +(1-α)Z tar
[0028]
[0029] Among them, Z fus is the fusion feature, Z cyc is the periodic characteristic, Z tar is the target feature, T fu s is the number of time slices with unified length in the time dimension after fusion, N is the number of road sections, F* is the feature dimension, and α is the similarity.
[0030] As a preferred solution of the traffic flow prediction method based on the diffusion model described in the present invention, the current traffic data is input into the trained prediction model, and the traffic flow prediction result of the future time period is output through the reverse diffusion process, including:
[0031]
[0032] Among them, Tpred is the future Tpred time slices, N is the number of road sections, that is, the number of nodes, For the road section in the future pred Traffic flow prediction value for a time slice.
[0033] As a preferred solution of the traffic flow prediction system based on the diffusion model described in the present invention, it includes:
[0034] one or more processors;
[0035] A memory storing operable instructions, wherein when the instructions are executed by the one or more processors, the one or more processors are caused to perform operations, wherein the operations include the process of the aforementioned traffic flow prediction method based on the diffusion model.
[0036] As a preferred embodiment of a computer-readable medium storing software described in the present invention, the software includes instructions that can be executed by one or more computers, and the instructions enable the one or more computers to perform operations through such execution, and the operations include the process of the aforementioned traffic flow prediction method based on the diffusion model.
[0037] Beneficial effects of the present invention:
[0038] 1. Through the construction of graph structure, explicit modeling of complex road network topological relationships is realized, so that the model no longer relies solely on local time series information, but can comprehensively consider the traffic behavior and potential influencing factors of adjacent road sections, so that the subsequent feature extraction and prediction model can more accurately understand the interaction and correlation between different road sections, thereby improving the overall prediction accuracy and robustness, effectively reducing the limitations of single-point prediction of traffic data, and enabling the model to better capture the collaborative evolution trend between multiple road sections;
[0039] 2. Through flexible matching of DTW on the time axis, the model can identify the corresponding relationship between periodic patterns and recent data in time series. When the similarity is high, the system preferentially migrates periodic features and assigns them higher weights. When the similarity is low, it tends to strengthen the influence of recent dynamic features. This adaptive selective weighted fusion ensures that the model can refer to long-term stable periodic laws and quickly respond to recent sudden changes and trend fluctuations, thereby achieving deep integration at the feature level, improving the overall perception of subsequent prediction models on features at different time scales, reducing information redundancy and deviation caused by blindly superimposing features, and thus improving the flexibility and accuracy of predictions;
[0040] 3. The training strategy based on the diffusion process can not only capture fine-grained local changes, but also present the hierarchical distribution of the global spatiotemporal structure, making the final prediction results more robust and diverse. When the model faces noise, emergencies or abnormal data, the restoration mechanism of the diffusion process can effectively alleviate the impact of uncertainty, thereby significantly improving the prediction accuracy and stability. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:
[0042] Figure 1 It is a flow chart of the traffic flow prediction method based on the diffusion model shown in the present invention;
[0043] Figure 2 Schematic diagram comparing the traffic flow prediction accuracy of the traditional method shown in the present invention and the method of the present invention in medium and high traffic scenarios. DETAILED DESCRIPTION
[0044] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings. It is obvious that the described embodiments are only part of the embodiments of the present invention, but not all of the embodiments.
[0045] Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without making any creative work should fall within the scope of protection of the present invention.
[0046] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0047] According to an embodiment of the present invention, Figure 1 The flow chart shown in the figure shows a traffic flow prediction method based on a diffusion model, which specifically includes the following steps:
[0048] S1. Obtain historical traffic data and perform data preprocessing to form a sample data set including traffic flow, traffic speed and road occupancy rate. The following points need to be explained in this step:
[0049] Export historical traffic data within a specified time period from a traffic control system (such as a city traffic sensing platform or a sensor network deployed by an intelligent traffic management department);
[0050] For example, suppose the time period is T days, and a fixed time interval Δt is used in the data acquisition system to record data, for example, data is recorded every 5 minutes, then T s The mathematical expression of a time slice is as follows:
[0051]
[0052] Define that there are N road sections in the road network. Then, in each time slice t (t = 1, 2, ..., T s ) will record the traffic index data for each road section i (i = 1, 2, ..., N), including at least the flow rate f i,t , speed d i,t , Occupancy rate i,t ;
[0053] At this point, the collected historical traffic data is viewed as a three-dimensional data structure:
[0054] D raw ={(f i,t , d i,t , o i,t )|i=1,...,N; t=1,...,T s}
[0055] That is, for each road segment i and time slice t, there is a set of records (f i,t , d i,t , o i,t );
[0056] For the missing traffic index values in the historical traffic data (such as missing flow data), the average value of the adjacent time slices is filled and the outlier detection is processed. If some sections cannot be filled in the data of some time slices or there are too many outliers, the section will be removed or the time slice will be truncated to make the data set consistent in time and space (section) dimensions;
[0057] Then the historical traffic data is normalized and mapped to the [0, 1] interval;
[0058] After normalization, each road segment i has a feature vector at time slice t:
[0059] x i,t =[f′ i,t , d′ i,t , l′ i,t ]
[0060] In a preferred embodiment, other indicators (such as weather conditions w i,t , emergency information), and add it to the data vector, such as:
[0061] x i,t =[f′ i,t , d′ i,t , o′ i,t , w′ i,t , ...]
[0062] The final sample data set can be represented as a three-dimensional tensor X:
[0063]
[0064] Where N is the number of road section nodes, T s is the number of time slices, F is the number of feature dimensions (F ≥ 3, including at least f′ i,t, d′ i,t , l′ i,t ), x i,t represents the feature vector of the ith road segment at time slice t, and X is the sample data set.
[0065] It should be noted that, through the above data preprocessing process, the final sample data set X is a tensor structure, in which each row corresponds to a road section (node), each column corresponds to a time slice, and the component in each element row vector is the normalized traffic index of the road section in the time slice (at least including f flow, d′ speed and o′ occupancy), so that the data representation is clear and standardized, and can be directly input into the subsequent spatiotemporal modeling and prediction model training, thereby improving the accuracy and efficiency of model training.
[0066] S2. The road segments of the road network in the sample data set are taken as nodes, and edges are constructed based on the geographical proximity and historical traffic association between the road segments to form a spatiotemporal dependency structure diagram that describes the spatiotemporal dependency. Among them, what needs to be explained in this step is:
[0067] Take the road section as the node, and take N road sections as N nodes in the node set V;
[0068] It is not difficult to understand that the road network is composed of multiple road sections, each of which is regarded as an independent spatial unit. It is defined that there are N road sections in the sample data set obtained in step S1, and these road sections are numbered from 1 to N. Each road section is recorded as a node, and the node set V is obtained, which is expressed as:
[0069] V={V1,V2,...,v N}
[0070] Among them, v i Indicates the node corresponding to the i-th road segment;
[0071] Furthermore, edges are established between nodes based on the geographical proximity and historical traffic correlation to form an adjacency matrix A. The above nodes will represent the spatial correlation and potential spatiotemporal influence relationship between road sections through the established edges; where:
[0072] If two road segments are directly connected in the road network, or the distance is within a set threshold, an undirected edge can be established for these two nodes;
[0073] As an example, the coordinates of the starting and ending points (such as longitude and latitude) of the road sections are extracted from the urban road GIS (Geographic Information System) data. Let the geographical distance between section i and section j be dist(i, j). When dist(i, j) is lower than the set threshold D th When v i With v j With geographical adjacency:
[0074]
[0075] in, Indicates a temporary adjacency mark based on geographic adjacency;
[0076] Furthermore, the statistical correlation of historical traffic conditions between road sections is considered, that is, statistical analysis is performed on the sample data set X. For example, for road section i and road section j, a certain feature (such as flow rate f′) is taken. i,t and f′ j,t ) at t = 1, 2, ..., T s time series and calculate their Pearson correlation coefficient:
[0077]
[0078] in, and is the average flow rate of sections i and j in the entire time range;
[0079] When ρ(i, j) is greater than the set threshold C th When , it means that the historical traffic of road sections i and j is significantly correlated, and an edge can be connected in the graph:
[0080]
[0081] Otherwise, ignore it;
[0082] Taking into account the above geographical adjacency and historical traffic correlation, the adjacency matrix A is constructed:
[0083] A=[A ij ] N×N , A ij∈{0, 1}
[0084] Among them, A ij =1 indicates node v i With v j There is an undirected edge (e ij ), A ij =0 means there is no direct spatial relationship or statistical correlation between the two;
[0085] Based on the node set V and the adjacency matrix A, a graph structure G describing spatiotemporal dependencies is formed:
[0086] G=(V,E)
[0087] Where E represents the edge set, including all edges that satisfy A ij =1 for a node pair (i, j). At this time, the spatiotemporal dependency structure graph G is used to characterize the spatial relationship between the road sections in the road network, as well as the time series features implied by the node features (the data set X provided by step S1), to form a "spatiotemporal dependency" data structure.
[0088] It should be noted that G describes the spatial connection structure, while the sample data set X describes the feature evolution in the time series. In the subsequent processing steps, the graph G and the data set X will be used as input together, so that the model can mine the spatiotemporal correlation patterns in the data, thereby improving the accuracy of traffic flow prediction.
[0089] S3, extract periodic features and target features from the historical traffic data in the spatiotemporal dependency structure diagram. It should be noted that this step extracts periodic features (periodic features) from long-term historical data (such as long-term statistics with a weekly cycle), and extracts features that reflect short-term dynamic changes (target features) from recent historical data (such as data from the last 7 days); the periodic features and target features are used as inputs for subsequent steps (such as dynamic time warping similarity measurement and feature fusion in step S4);
[0090] Specifically, the following steps are included:
[0091] Select historical data with a longer time span as periodic data (for example, the past few weeks), and set the length of the periodic data to T cyc Time slices, the corresponding data subset is:
[0092]
[0093] Use the adjacency matrix A in step S2 to construct the normalized Laplacian matrix L of the undirected graph G:
[0094] L=CA
[0095] Where C is a diagonal matrix, and L is decomposed by eigenvalues:
[0096] L=UΛU T
[0097] Among them, U is the eigenvector matrix, U T is the eigenvalue diagonal matrix, U is regarded as the Fourier basis of the graph G;
[0098] The period data X cyc Projected to the frequency domain of graph G in the node dimension:
[0099]
[0100] Among them, X cyc is regarded as a feature tensor expanded by node, and the features of N nodes are mapped in each time slice. After transformation, It is the representation of periodic data in the frequency domain, and its dimension is still [N, T cyc , F], but after U T After mapping, the spatial component corresponding to each dimension has been converted into a frequency domain feature component;
[0101] In the frequency domain, different characteristic frequency components represent different levels of spatial correlation patterns. A set of trainable parameters W_Q and W_K are used to transform each frequency component Mapped to the query (Q) and key (K) vector space, and then calculate the attention weight α f :
[0102]
[0103] Where f represents the frequency index, F freq is the frequency range considered, is the characteristic vector of periodic data at frequency f (including time series information), W K , W Q is the learning parameter;
[0104] Using alpha f The frequency components are weighted and summed to highlight the frequency components with significant periodicity and suppress the irregular noise frequency, thus obtaining the characteristic representation of the periodic data after frequency domain weighting:
[0105]
[0106] Among them, Z cyc It is the feature representation of the periodic data after frequency domain weighting, and its dimension is expressed as [N, T cyc , F′], F′ is the feature dimension obtained after dimensionality reduction or projection, that is, F′ is the number of feature dimensions;
[0107] Select the data of the recent time period as the target data (such as the last 7 days), and set the length of the target data to T tar Time slices, the corresponding data subset is:
[0108]
[0109] Use graph convolutional network to train target data X tar The node characteristics of each time slice t in Perform graph convolution operation:
[0110]
[0111] in, is the extracted spatiotemporal features, W (l) is the training parameter of the lth layer, σ is the nonlinear activation function (such as ReLU), A is the adjacency matrix, and after multiple layers of superposition, the features of each time slice are embedded into a high-level representation for the entire T tar By performing this processing on the time series, we can obtain a spatiotemporal representation of recent data;
[0112] Combined with the time series modeling unit to further capture the dynamic changes in the time dimension, the target feature Z is finally obtained. tar :
[0113] Z tar =GNN(X tar , A)
[0114] Among them, the target feature Z tar The dimension is expressed as [N, T tar , F″], F″ is the number of feature dimensions.
[0115] In an optional embodiment, if F′≠F″, the periodic feature and the target feature are mapped to the same feature dimension space by a linear projection method, that is, F′=F″=F * , in order to carry out subsequent similarity measurement and fusion processing.
[0116] It should be noted that by combining the spatiotemporal dependency structure graph G with the dataset X, periodic features are extracted from long-term data, and target features are extracted from recent data, so as to obtain feature representations reflecting long-term regularity and short-term dynamics respectively, providing high-quality and available feature input for subsequent feature fusion and prediction steps.
[0117] S4. Use the dynamic time warping method to measure the similarity between the periodic features and the target features in the time dimension, and selectively migrate and weightedly fuse the periodic features based on the similarity to obtain fused features. It should be noted that this step measures the matching degree between the periodic features and the target features in the time dimension, thereby selectively migrating and weightedly fusing the periodic features into the target features, and finally obtaining fused features that have both long-term periodic patterns and recent dynamic changes. Specifically:
[0118] Z cyc With Z tar The features of are aggregated in the node dimension (such as averaging N road sections), and two time series are obtained:
[0119]
[0120] The feature vector at each time step and Yes F * dimensional, which can be regarded as F * A point in dimensional Euclidean space;
[0121] The difference between feature vectors is measured by the Euclidean distance formula:
[0122]
[0123] Find a line from D(1,1) to D(T cyc , T tar ) satisfies the temporal consistency (the path cannot go backwards, but can only move forward, downward or diagonally downward), so that the cumulative sum of distances on the path is minimized:
[0124]
[0125] Among them, P is the set of all possible matching paths;
[0126] Using dynamic programming method to DTW Recursive solution:
[0127] γ(t,τ)=D(t,τ)+min{γ(t-1,τ), γ(t,T--1), γ(t-1,τ--1)}
[0128] Among them, γ(t, τ) is the minimum cumulative distance from (1, 1) to (t, τ), and finally γ(T cyc , T tar ) is DDTW(Z cyc , Z tar );
[0129] Get the distance D DTWAfter that, it is mapped into a similarity score. The smaller the distance, the higher the similarity should be. The similarity α is defined as:
[0130] α(=exp(-D DTW (Z cyc , Z tar ))
[0131] When D DTW When it is small, α is close to 1; D DTW When it is larger, α is close to 0;
[0132] When the similarity between the periodic feature and the target feature is high (α is close to 1), it means that the periodic feature is similar to the recent data pattern, and the weight of the periodic feature in the fusion should be increased;
[0133] When the similarity is low (α is close to 0), it means that the periodic features are very different from the recent data, and the contribution of the periodic features in the fusion should be reduced;
[0134] Then the fusion feature Z fus The calculation formula is:
[0135] Z fus =αZ cyc +(1-α)Z tar
[0136]
[0137] Among them, Z cyc With Z tar They are all feature tensors related to road sections and time. The larger α is, the higher the migration degree is. cyc Weighted, (1-α) to Z tar Weighted, to achieve selective migration of periodic features, T fu s is the number of time slices with uniform length in the time dimension after fusion, N is the number of road sections, and F * is the feature dimension;
[0138] It should be noted that the DTW method is used to calculate the degree of matching between the time dimension of the periodic feature and the target feature to obtain the DTW distance, which is then converted into a similarity score through exponential mapping. The periodic feature is weighted and integrated into the target feature to obtain the fused feature. As an adaptive feature representation, the fused feature not only integrates the long-term regularity, but also retains the recent dynamic change characteristics, providing accurate calculation services for subsequent diffusion model training and final traffic prediction.
[0139] S5. Input the fused features into the traffic flow prediction model built based on the diffusion model for training, capture the multi-scale and multi-stage spatiotemporal feature distribution through the forward noise addition and reverse diffusion reduction process, and output the representation vector for predicting future traffic flow. Among them, what needs to be explained in this step is:
[0140] Through the forward diffusion process in the diffusion model (from the initial input Z fus Start to gradually add Gaussian noise to the data), reverse diffusion model (a trainable neural network model used to learn how to denoise high-noise data in the reverse direction to reconstruct noise-free data representation, that is, learn the potential distribution representation of the data, so as to achieve future traffic flow prediction), and build a traffic flow prediction model;
[0141] Randomly extract a batch of data samples from the fusion feature dataset, each sample is Z fus a slice of
[0142] For each sample in the batch, a diffusion time step t (1≤t≤T) is randomly selected;
[0143] According to the selected t, the noise-free data x0 = Z fus Add noise to x t (Data representation after adding noise at step t in the diffusion process);
[0144] x t and time step t input model ∈ θ , and get the model prediction noise ∈ θ (x t , t);
[0145] Calculate the loss function L(θ) and use backpropagation and gradient descent algorithm to update the model parameters θ;
[0146] Traverse all data sets and continuously optimize θ. When the maximum number of training rounds Epoch is reached max Then stop training;
[0147] After training is completed, the model parameters are fixed to θ * , at this time, the reverse diffusion model is recorded as:
[0148]
[0149] The corresponding noise prediction function is:
[0150]
[0151] When predicting, given the initial noise distribution, the model will gradually denoise from the noise through a multi-step reverse diffusion reduction process, and finally generate a potential representation vector of future traffic flow. After appropriate mapping and inverse normalization, the predicted traffic flow value for the future time period can be obtained, that is:
[0152]
[0153] in, is the future traffic flow index sequence predicted by the model, Z fus is the fused feature input (the fused feature obtained by processing the current time data with the period and target data during prediction), A is the adjacency matrix of the spatiotemporal dependency structure graph, and θ* is the final learned model parameter.
[0154] It should be noted that through the training process of forward noise addition and reverse diffusion restoration, the diffusion model learns the ability to reconstruct the spatiotemporal characteristics of traffic flow from noise. After the training is completed, a model for prediction is obtained, and the predicted future traffic flow representation vector is output through the future reverse diffusion generation process. The model takes fusion features as input and can comprehensively utilize long-term periodic patterns and recent dynamic change characteristics, thereby having higher prediction accuracy and robustness.
[0155] S6: Input the current traffic data into the trained prediction model to predict traffic flow, and output the traffic flow prediction results for the future time period through the reverse diffusion process.
[0156] The current traffic data is obtained as input. Let the current time be t0. The traffic indicators (flow rate, speed, occupancy rate) of all road sections at the current time are obtained from the traffic control system and recorded as:
[0157] X curr ∈R N×F
[0158] For the current moment data X curr Perform the same preprocessing as in step S1, and then perform the fusion feature processing as in step S4 to obtain the fusion feature It is the final fusion feature of the input prediction model, which contains the dynamic information of the current moment and the short-term periods before and after it, as well as the long-term periodic pattern information;
[0159] Initialize a random noise tensor x according to the number of diffusion steps T determined during the training phase T ;
[0160] The dimension of this random noise is Match, that is, (N,T fus , F * ), where T fus Set to include the length of the forecast period required in the future (e.g., the number of time slices required for the next 30 minutes or 1 hour);
[0161] Using the trained parameters θ * , at each diffusion step t, from t = T down to t = 1, calculate in sequence: is the predicted noise, and then the denoised x is obtainedt-1 ;
[0162] The update rule of the back-diffusion model is expressed as:
[0163]
[0164] After T steps of iterative denoising and restoration, when t=0 is reached, we can get:
[0165]
[0166] in, That is, it is the potential representation that matches the fused feature distribution in the reverse diffusion generation process, and the potential representation contains the predicted information of traffic flow in the future period;
[0167] Furthermore, It is the feature representation restored by the diffusion model, including the feature distribution of future time slices. Through the mapping defined by the model setting and training steps, The corresponding features are decoded into a specific traffic flow prediction value sequence;
[0168] It should also be noted that, since the input current traffic data has been normalized in step S1, it is necessary to perform inverse normalization on the prediction result and map the normalized prediction value back to the actual magnitude.
[0169]
[0170] Finally, the predicted future time period (for example, the future T pred Traffic flow in time slices):
[0171]
[0172] That is, each road segment will have pred Traffic flow prediction value for time slices
[0173] Preferably, this embodiment is based on the trained diffusion model, and the current moment data is subjected to the same feature extraction and fusion process to obtain Through the reverse diffusion process starting from random noise, the potential feature representation of the future time period is generated, and finally mapped back to the actual magnitude of the traffic flow prediction sequence, which covers the traffic flow of each road section on multiple time slices in the future, thereby achieving accurate prediction of future traffic status, so that the method of the present invention has high prediction accuracy and robustness in complex spatiotemporal traffic environments.
[0174] In order to verify the beneficial effects and superiority of the method of the present invention in traffic flow prediction, the method of the present invention is experimentally compared with the traditional traffic flow prediction method, wherein the traditional method selects a time series statistical model (such as the seasonal autoregressive moving average model SARIMA) as a control object. The SARIMA method has certain advantages in dealing with periodic characteristics, but it has shortcomings in dealing with complex road network spatiotemporal correlation, multi-scale dynamic changes and data noise. This experiment compares the prediction performance of the two methods under the same experimental conditions, thereby verifying the method of the present invention in capturing multi-scale spatiotemporal features and improving robustness;
[0175] This experiment selected the central area road network of a second-tier city as the experimental object. The area contains several key sections. The geographical location and road grade of each section are relatively fixed, but in actual operation, it is significantly affected by seasonal changes, holidays, and the switching between peak and off-peak periods on weekdays.
[0176] The experimental environment includes a data acquisition and processing terminal (a high-performance computing server equipped with MATLAB and Python operating environment), and the time span is selected as 30 consecutive days of historical traffic data, wherein the flow data (the flow time series of N sections within 30 days (a total of 30 days × 24 hours × (60 / 5) = 8640 time slices)) (unit: vehicle / 5 minutes), speed data (unit: km / h), and road occupancy rate data (unit: %) are recorded every 5 minutes. The training data is selected from the first 20 days, and the verification and test data is selected from the last 10 days. In the prediction task, the prediction accuracy of traffic flow in the next hour (12 time slices) is mainly investigated. The method of the present invention completes the training through the steps described above; the traditional method (represented by SARIMA) performs model fitting based on the same data sequence parameters;
[0177] The implementation process of the method of the present invention is as follows: extracting periodic features (such as long-term data patterns with a weekly period) and short-term target features (such as data from the past 7 days as target features) on a spatiotemporal dependency structure diagram; using a dynamic time warping (DTW) method to measure the time dimension similarity between periodic features and target features, and selectively migrating and weighted fusion of periodic features according to the similarity to obtain fused features; inputting the fused features into a prediction model based on a diffusion model for training, capturing multi-scale and multi-stage spatiotemporal feature distributions through forward denoising and reverse diffusion restoration, and after the training is completed, predicting the traffic sequence for the next hour for any selected time point in the test set by inputting the features of the current moment and executing the reverse diffusion process;
[0178] The implementation process of the traditional method (taking SARIMA as an example) is as follows: the historical traffic sequence of each road section is modeled separately, the data of the past few days is used as the training set, and the SARIMA model parameters are grid searched and ordered; the model is only predicted based on the single-dimension traffic data of a single road section, and the traffic sequence of the next hour is extrapolated;
[0179] Reference Figure 2 It can be seen intuitively that in the high-flow scenario, the prediction curve (solid line) of the method of the present invention is closely aligned with the actual flow curve, with a small error in the entire prediction period, and the error rate is controlled at 3%-5%. The prediction curve of the traditional method (dashed line) lags significantly during the period of rapid flow increase, and has a large deviation at the peak of high flow, with an error rate of 8%-12%. This shows that the traditional SARIMA method is difficult to adjust the prediction results in time when facing nonlinear and rapidly changing flow trends, while the method of the present invention achieves higher flexibility and accuracy by virtue of multi-scale spatiotemporal feature extraction and diffusion process;
[0180] In medium traffic scenarios, the method of the present invention always maintains a small deviation from the true value, and the error rate is controlled at 2%-4%. In contrast, the traditional method produces additional errors due to the inability to effectively integrate spatial correlation and multi-dimensional features. Therefore, the method of the present invention uses the similarity measurement and weighted fusion strategy of periodic features and target features to enable the model to quickly adapt to various complex road networks and multi-time period features, thereby improving the stability and accuracy of the prediction.
[0181] Preferably, the method of the present invention can provide more accurate and robust prediction performance in different scenarios of medium and high traffic. Compared with the traditional method that only relies on single time series statistical analysis, the method of the present invention embeds multi-dimensional features into the spatiotemporal dependency structure graph, fuses periodic and recent features through dynamic time regularization, and uses a diffusion model to capture multi-scale feature distribution, thereby significantly reducing the error rate and improving adaptability to complex dynamic traffic environments.
[0182] The aforementioned filling of the missing traffic index values in the historical traffic data (such as missing flow data) with the average value of adjacent time slices, the outlier detection processing, and the normalization processing can be performed using the methods and means in the existing technology and will not be repeated in this example.
[0183] It should also be noted that some other aspects disclosed in the embodiments of the present invention further propose a traffic flow prediction system based on a diffusion model, including: one or more processors and a memory.
[0184] The memory is used to store operable instructions, which, when executed by the one or more processors, cause the one or more processors to perform operations, including the process of the traffic flow prediction method based on the diffusion model of the aforementioned embodiment, in particular Figure 1 The process of the method shown.
[0185] In other aspects disclosed in the embodiments of the present invention, a computer-readable medium storing software is provided. The software includes instructions that can be executed by one or more computers. The instructions, through such execution, cause one or more computers to perform operations. The operations include the process of the traffic flow prediction method based on the diffusion model of the aforementioned embodiment, especially Figure 1 The process of the method shown.
[0186] It should be appreciated that embodiments of the present invention can be implemented or carried out by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer-readable memory.
[0187] The method may be implemented in a computer program using standard programming techniques, including a non-transitory computer-readable storage medium configured with a computer program, wherein the storage medium so configured causes a computer to operate in a specific and predefined manner.
[0188] Each program can be implemented in a high-level procedural or object-oriented programming language to communicate with a computer system, however, the program can be implemented in assembly or machine language if desired.
[0189] In any case, the language may be a compiled or interpreted language.
[0190] Furthermore, the program can be run on an application specific integrated circuit programmed for this purpose.
[0191] The processes described herein (or variations and / or combinations thereof) may be performed under the control of one or more computer systems configured with executable instructions, and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) that is executed collectively on one or more processors, by hardware, or a combination thereof. The computer program includes a plurality of instructions that can be executed by one or more processors.
[0192] Further, the method may be implemented in any type of computing platform operably connected to a suitable computer, including but not limited to a personal computer, a minicomputer, a mainframe, a workstation, a network or distributed computing environment, a separate or integrated computer platform, or in communication with a charged particle tool or other imaging device.
[0193] Various aspects of the present invention may be implemented in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, optical read and / or write storage media, RAM, ROM, etc., so that it can be read by a programmable computer, which, when the storage medium or device is read by the computer, can be used to configure and operate the computer to perform the processes described herein.
[0194] Additionally, the machine-readable code, or portions thereof, can be transmitted over a wired or wireless network.
[0195] The invention described herein includes these and other various types of non-transitory computer-readable storage media when such media include instructions or programs that implement the steps described above in conjunction with a microprocessor or other data processor.
[0196] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A traffic flow prediction method based on a diffusion model, characterized in that: include: Obtain historical traffic data and perform data preprocessing to form a sample data set including traffic flow, traffic speed and road occupancy; The road segments of the road network in the sample data set are taken as nodes, and edges are constructed according to the geographical proximity and historical traffic association between the road segments to form a spatiotemporal dependency structure graph describing the spatiotemporal dependency; Performing period feature extraction and target feature extraction on the historical traffic data in the spatiotemporal dependency structure graph; Using a dynamic time warping method to measure the similarity between the periodic feature and the target feature in the time dimension, and based on the similarity, selectively migrating and weighted fusion of the periodic feature to obtain a fusion feature; The fusion features are input into a traffic flow prediction model built based on a diffusion model for training, and the multi-scale and multi-stage spatiotemporal feature distribution is captured through a forward noise addition and a reverse diffusion reduction process, and a representation vector for predicting future traffic flow is output; Then the current traffic data is input into the trained prediction model to predict the traffic flow, and through the reverse diffusion process, the traffic flow prediction results for the future time period are output.
2. The traffic flow prediction method based on the diffusion model according to claim 1 is characterized in that: The historical traffic data within a specified time period is exported from the traffic control system, and missing value processing, outlier detection and normalization processing are performed on the historical traffic data to obtain the sample data set.
3. The traffic flow prediction method based on the diffusion model according to claim 1 or 2, characterized in that: The sample data set is represented as a three-dimensional tensor, and its mathematical expression formula is: X∈R N×T s ×F Where N is the number of road section nodes, T s is the number of time slices, F is the number of feature dimensions, and X is the sample data set.
4. The traffic flow prediction method based on the diffusion model according to claim 1 is characterized in that: The forming of a spatiotemporal dependency structure diagram describing the spatiotemporal dependency includes: Take the road section as the node, and take N road sections as N nodes in the node set V; Establish edges between nodes based on geographical proximity and historical traffic correlation to form an adjacency matrix A; Based on the node set V and the adjacency relationship matrix A, a graph structure G describing spatiotemporal dependency is formed.
5. The traffic flow prediction method based on the diffusion model according to claim 1 is characterized in that: Extracting the periodic feature and the target feature includes: Select historical data with a longer time span as periodic data, and define the length of the periodic data as T cyc time slices, and after feature extraction, the periodic feature Z is obtained cyc ; Select the data of the recent time period as the target data, and define the length of the target data as T tar time slices, and after feature extraction, we get the target feature Z tar .
6. The traffic flow prediction method based on the diffusion model according to claim 1 is characterized in that: Obtaining the fusion feature includes: WITH fus =αZ cyc +(1-α)Z tar Among them, Z fus is the fusion feature, Z cyc is the periodic characteristic, Z tar is the target feature, T fus is the number of time slices with uniform length in the time dimension after fusion, N is the number of road sections, and F * is the feature dimension, and α is the similarity.
7. The traffic flow prediction method based on the diffusion model according to claim 1 is characterized in that: The current traffic data is input into the trained prediction model, and through the reverse diffusion process, the traffic flow prediction results for the future time period are output, including: Among them, T pred For the future pred time slices, N is the number of road sections, that is, the number of nodes, For the road section in the future pred Traffic flow prediction value for a time slice.
8. A traffic flow prediction system based on a diffusion model, characterized in that: include: one or more processors; A memory storing operable instructions, wherein when the instructions are executed by the one or more processors, the one or more processors perform operations, wherein the operations include the process of the traffic flow prediction method based on the diffusion model as described in any one of claims 1 to 7.
9. A computer-readable medium storing software, characterized in that: The software includes instructions that can be executed by one or more computers, and the instructions enable the one or more computers to perform operations through such execution, and the operations include the process of the traffic flow prediction method based on the diffusion model as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Road traffic flow prediction method based on graph aggregation mechanism of reconstructed traffic network
CN113129585A
Construction method of traffic flow prediction model based on space-time multi-scale graph convolutional network and traffic flow prediction method
CN114611383A
Signal transmission system for measuring traffic state by using road network sensor
CN117037479A
Data processing method and device
CN117217284A
Traffic flow prediction method based on de-noising diffusion space-time residual multi-graph convolutional network
CN117973605A
Cited By
Sea surface chlorophyll concentration prediction method and system based on remote sensing and deep learning
CN120067872A
Internet of vehicles channel prediction method in complex traffic scene and related equipment
CN120238221A
Network flow detection method and system based on diffusion model and graph contrast learning
CN122093196A