Long-term traffic flow prediction model and method based on low-rank graph and stl time series decomposition
Patent Information
- Application Number
- CN202311213664.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-20
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2043-09-20
AI Technical Summary
但现有针对交通流长时预测的研究工作中,利用前一时刻的输入对下一时刻的特征进行关系建模,但是基于这种输入-输出型的关系建模理论往往忽略了序列之间的关联性和差别性,导致预测结果出现误差,难以实现交通流量更长时间的准确预测
[0065] (1) Based on existing research, the prediction method of this invention assumes that there is a certain relationship between traffic flow sequences and decomposes the input sequence into several different representation sequences. These representation sequences represent different characteristics of the sequence in the process of change. Through decomposition, the sequence data can be effectively decomposed, the variation law of different decomposition items can be explored, and low-rank graph convolutional layers can be integrated to mine the spatial heterogeneity between different nodes.
Smart Images

Figure CN117523817B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent transportation technology, and in particular to a long-term traffic flow prediction model and method based on low-rank graphs and STL time-series decomposition. Background Technology
[0002] Traffic flow forecasting can be divided into short-term and long-term forecasting. Since the early 1990s, there has been a large amount of research on short-term traffic flow forecasting; however, long-term traffic flow forecasting has not received much attention. The goal of long-term forecasting is to predict traffic flow over periods longer than one hour. Accurate long-term forecasts can guide traffic management agencies to intervene appropriately, avoid potential traffic congestion, and thus ensure operational efficiency. Compared to short-term forecasting, providing more accurate long-term forecasts can offer more references for improving the efficiency of limited traffic management resources and is of great significance for the scientific management of traffic. There are two main methods for traffic flow forecasting: one is single-step forecasting, which outputs the traffic flow for the forecast period all at once. Due to the dynamic nature of the traffic system, it is impossible to directly and accurately predict long-term traffic flow, making this method quite limited in long-term forecasting; the other is multi-step forecasting, where the model uses previously predicted results as historical data and then uses them as new inputs to gradually output the forecast. However, existing research on long-term traffic flow prediction uses the input of the previous moment to model the relationship between the features of the next moment. However, this input-output relationship modeling theory often ignores the correlation and differences between sequences, resulting in errors in the prediction results and making it difficult to achieve accurate prediction of traffic flow over a longer period. Summary of the Invention
[0003] To achieve the above objectives, the present invention provides the following technical solution:
[0004] This invention provides a long-term traffic flow prediction model based on low-rank graphs and STL temporal decomposition. The prediction model adopts an encoder-decoder framework structure as the overall framework of the model, including an encoder structure network and a decoder structure network.
[0005] The encoder structure network includes a first self-attention mechanism, a first LGCN module, and a first STL timing decomposition module;
[0006] The decoder network structure includes a second self-attention mechanism, a second LGCN module, a second STL temporal decomposition module, an encoding / decoding cross-attention fusion module, and a linear module;
[0007] The encoder network encodes the sequence of input data through a first autocorrelation mechanism module, a first LGCN module, and a first STL temporal decomposition module. The decoder network learns the first-order sub-sequence items from the encoder input data through a second self-attention mechanism, a second LGCN module, and a second STL temporal decomposition module. Then, it outputs the second-order sub-sequence items by combining the encoding and decoding cross-attention fusion module. Finally, it performs association rule mining on the second-order sub-sequence items by combining the second LGCN module and the Linear module. The elements of the three sub-sequence items are superimposed and output. By combining the encoder network and the decoder network, a long-term traffic flow prediction model is obtained.
[0008] In the output of the long-term traffic flow prediction model, the traffic flow trend term, random term and periodic term output by the decoder at different times are saved and combined with the fully connected component to complete the output.
[0009] Furthermore, the construction steps of the encoder structure network are as follows:
[0010] (11) Perform Fourier transform on the sequence of input data, and combine the first self-attention mechanism to realize the message passing of the sequence, calculate its autocorrelation matrix, and then obtain the periodic regularity information in the input sequence.
[0011] (12) Using the information in the autocorrelation matrix, find the positions in the input sequence that have significant periodicity, and then use these positions as a reference to aggregate the information of the input sequence by means of a sliding window to generate the output of each position;
[0012] (13) Stack the multi-layer coding network to form the encoder structure network.
[0013] Furthermore, the construction steps of the decoder structure network are as follows:
[0014] (21) Perform STL time series decomposition on the input data, extract the target sequence at each level, namely the periodic term subsequence, the trend term subsequence and the random term subsequence, and focus on the periodic term subsequence to learn the time dimension of the self-attention mechanism, mine the node information of the spatial dimension of the LGCN module, and the first subsequence term after the spatiotemporal network message transmission of the result of the second STL decomposition module.
[0015] (22) The previously retained periodic subsequence items and the periodic subsequence items output by the encoder are used as Q and K, V of the cross-attention mechanism for time information exchange and spatial information exchange through the second LGCN module. The sequence after the spatiotemporal information transmission obtains more potential information and can be decomposed into secondary subsequence items by the second STL temporal decomposition module.
[0016] (23) The message passing of the trend item and the residual item is realized by superimposing the elements of the first subsequence item and the second subsequence item. The trend item and the random item are respectively input into the second LGCN module and the Linear module for the final association rule mining. The elements of the three subsequence items are superimposed as the output of the decoding network layer.
[0017] (24) Stack the decoding network layers in multiple layers to form the decoder structure network.
[0018] Furthermore, the construction process of the first or second self-attention mechanism is as follows:
[0019] The mathematical expression for linear mapping of input sequence X is as follows:
[0020] Q = XW q
[0021] K = XW k
[0022] V = XW v
[0023] in, These correspond to the query, key, and value vector matrices, respectively. There are three trainable parameter matrices, d q d k d v Its dimension size; input sequence X∈R n×F ;
[0024] The attention weights are calculated using the SoftMax function, with the following formula:
[0025]
[0026] Among them, K T Let Q be the transpose of matrix K, and let Q be the transpose of matrix K. T Multiplication generates similar matrices, when d k When the variance of the similarity matrix is large, it also increases. Therefore, a scaling operation is needed to scale the similarity matrix, i.e., dividing each element by a factor of 1.
[0027] Based on the single-layer self-attention mechanism and combined with the Autoformer algorithm, a multi-head attention mechanism is designed in the encoder and decoder network structures. This mechanism projects the input vector to different representation subspaces, as shown in the following formula:
[0028]
[0029] Meanwhile, the Autoformer algorithm was used to design cross-attention in the decoder to fuse and iterate the information from the encoder and decoder to complete the final information exchange and transmission.
[0030] Furthermore, the construction process of the first LGCN module or the second LGCN module is as follows: constructing an affinity matrix. Specifically:
[0031] According to graph theory, the degree d of node i in a road segment is... i for:
[0032]
[0033] The degree matrix D of the road network is obtained, where the degree value of a node i is D. ii =d i D ii This represents the values of the elements on the diagonal of the degree matrix. Since D is a diagonal matrix, the values on the diagonal represent the degree values of each node. ii Apart from the above, all others are 0, thus obtaining the Laplace matrix L, L = DA. After symmetric normalization of the Laplace matrix L, the affinity matrix is obtained.
[0034]
[0035] Where N represents the number of road segments;
[0036] A i:j This indicates the connectivity between node i and node j.
[0037] A is the adjacency matrix, representing the connection relationships between nodes in the current road network;
[0038] Construct a spatial graph convolutional layer based on the Lanczos method, taking an initial non-zero vector s and a positive integer M less than N, and perform the Lanczos similarity transformation algorithm;
[0039] Based on the results of the Lanczos similarity transformation algorithm, the orthogonal matrix V is obtained. M =[v1,…,v M ], and a triangular symmetric matrix H M Its diagonal and superdiagonal elements are {α1, α2, ..., α...} M} and {β1,β2,…,β M};
[0040] By analyzing the triangular symmetric matrix H M Perform eigenvalue decomposition H M =BRB * R, B, B *They are triangular symmetric matrices H M The decomposed eigenvalue matrix, eigenvector matrix, and their transpose are given, where M*M diagonal matrices, R contains Ritz values, and B∈R. M×M It is an orthogonal matrix, and the approximate eigenvector matrix V is obtained. B =V M B, therefore the affinity matrix can be approximated. The solution of eigenvalues and eigenvectors Affinity Matrix Due to its symmetry and positive semi-definite properties, it can be further decomposed into U = [u0, u1, ..., u N-1 ] is by The orthogonal matrix obtained from the decomposition, the transpose of U, is denoted as U*. As can be seen from the above, Thus far, the graph convolution operation T based on the Lanczos approximation algorithm... k (X) is expressed as:
[0041] T k (X)=Ug(Λ)U * X = [X, VRV] * X, ..., VR K V * X]Θ
[0042] Where g(Λ)=[1,Λ,...,Λ K ]Θ, X are the input sequences (input historical data), R k For the k-th power operation of the eigenvalue matrix R, V B * V represents B The transpose of Θ; Θ is the set of all trainable parameters;
[0043] By combining the gated low-rank GCN learning filter with the graph convolution operation of the Lanczos approximation algorithm mentioned above, the LGCN module—Lanczos-GCN (LGCN)—is constructed. The model is mainly expressed by the following formula:
[0044]
[0045]
[0046] Where E is the adaptive dynamic matrix of the diagonal matrix R, satisfying: There is an independent calculation process for each individual k, k1...k i That is, to simultaneously perform i calculations on different powers of k;
[0047] [·]and And respectively represent tensor connectivity and pointwise Hadamar product; P and Q are the output splits in the LGCN layer, with the same channel size; weight parameter Θ∈R (i+1)h×2o It is learnable, representing the set of all trainable parameters, where h and o are the input and output channels in the Lanczos hidden layer, respectively; the multi-span parameter set S = {s1, s2, ..., s...} i} is a set of hyperparameters that need to be preset, and these parameters have non-negative integer values.
[0048] This invention provides a long-term traffic flow prediction method based on low-rank graphs and STL time-series decomposition. The prediction method includes:
[0049] (1) Constructing structured traffic flow data and road network data:
[0050] Road network data and traffic flow data consist of node data from detectors in the target road network, which are then processed using data processing methods to construct structured data.
[0051] (2) Real-time prediction using long-term traffic flow prediction models:
[0052] Traffic flow data is input into the constructed long-term prediction model for training and optimization. The most suitable combination of hyperparameters is found to obtain the best prediction model for traffic flow prediction.
[0053] Furthermore, the construction steps of step (1) are as follows:
[0054] (1.1) N road segments are sampled by sensors laid in the highway network. The sampling time is T, the total sampling duration is Y, the sampling time interval is Δt, and the sampled traffic flow data is Y / Δt.
[0055] (1.2) Based on the spatial connection relationship between real sensors, the highway network is modeled using the node and edge relationships in the graph structure;
[0056] Each sensor is defined as a node, the connectivity between nodes is defined as an edge E, and the road network structure state G at time t is defined as... t For: G t =(V t ,E,A),
[0057] Where V t =(v t,1 ,v t,2 ,…,v t,N ), representing the state among the N nodes at time t;
[0058] A is an adjacency matrix, representing the connection relationships between nodes in the current road network. When node i is connected to node j, A... i,j =1, otherwise 0, where Ai,j =A j,i That is, the adjacency matrix A used is a symmetric matrix.
[0059] Furthermore, in step (2), the long-term traffic flow prediction model is optimized using an optimizer and a loss function. The optimizer is set to Adam, and the loss function is the mean squared error (MSE) from the regression task, with the following mathematical formula:
[0060]
[0061] Where n′ is the total number of samples, and Y :,i It represents the actual traffic flow at all nodes at time I, while It is the corresponding traffic flow forecast value.
[0062] After obtaining the prediction results, the model is repeatedly trained until it converges; the model results are saved, the model hyperparameters are changed and retrained until the optimal model hyperparameters and optimal model weights are found.
[0063] The model is deployed on a relevant platform, and the trained model is used to predict traffic flow at actual road traffic nodes.
[0064] The present invention has the following beneficial effects:
[0065] (1) Based on existing research, the prediction method of this invention assumes that there is a certain relationship between traffic flow sequences and decomposes the input sequence into several different representation sequences. These representation sequences represent different characteristics of the sequence in the process of change. Through decomposition, the sequence data can be effectively decomposed, the variation law of different decomposition items can be explored, and low-rank graph convolutional layers can be integrated to mine the spatial heterogeneity between different nodes.
[0066] (2) The prediction model of this invention consists of an encoder and a decoder. The encoder uses a self-attention mechanism module, an LGCN module, and an STL temporal decomposition module to decompose the periodicity, trend, and randomness of traffic flow sequences and capture spatiotemporal correlations. After the encoder encodes historical traffic flow data, the decoder learns a primary sequence from the encoder input data using the same structure as the encoder. Then, it combines the cross-attention mechanism, the LGCN module, and the STL temporal decomposition module to output a secondary sequence. Finally, the LGCN and Linear modules are used to mine association rules between the two sequences. The three elements are superimposed and output, which can better handle the periodicity and trend patterns that are widely present in long-term sequences of highway networks, effectively capture the spatiotemporal correlation of traffic flow, and make feature extraction more robust and generalizable, thereby improving the accuracy of long-term traffic flow prediction.
[0067] (3) This invention is applicable to long-term prediction of dynamic highway traffic flow. With real-time collected highway traffic flow data, it achieves high accuracy in long-term prediction. This invention uses real-time collected traffic flow data for training; it exhibits strong stability and accuracy in long-term prediction scenarios. Furthermore, the network model used in this invention can be directly deployed on the corresponding platform for effective prediction output after training, without requiring further learning and training. Attached Figure Description
[0068] Figure 1 This is a diagram of the spatiotemporal network structure for long-term prediction based on low-rank graphs and STL decomposition.
[0069] Figure 2 This is a schematic diagram of a deep temporal decomposition module based on the STL algorithm.
[0070] Figure 3 This is a spatiotemporal error distribution diagram of the HHY dataset. Detailed Implementation
[0071] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings. It should be noted that the embodiments are merely specific illustrations of the invention and should not be considered as limitations on the invention. The purpose of the embodiments is to enable those skilled in the art to better understand and reproduce the technical solution of the present invention. The scope of protection of the present invention should still be determined by the scope defined in the claims. The terms "first" and "second" in the present invention are merely used for descriptive distinction and have no special meaning.
[0072] This article provides explanations for some of the proper nouns used in it.
[0073] STL (Standard Trajectory Time Series) is a method for time series analysis, specifically a local trend decomposition method. By decomposing the time series into trend, seasonality, and stochastic components, it provides a better understanding of the time series' patterns and characteristics. Effective and in-depth decomposition of complex nonlinear trend sequences in road network traffic flow reveals the periodicity, trend, and stochastic components of long-term traffic flow series, leading to more accurate traffic flow predictions.
[0074] Lanczos Graph Convolution (LGCN): Derived from GCN, the Lanczos method is an efficient, controllable, and parallelizable low-rank decomposition method suitable for large-scale datasets. The improved LGCN can effectively capture the spatiotemporal correlation of traffic flow and utilize the low-rank property to make feature extraction more robust and generalizable.
[0075] Cross-Attention: Cross-attention is an improvement on the self-attention mechanism. Its Q (Query) and K (Key) come from different matrices. The attention score between the elements of the two matrices is calculated. The attention score is multiplied by a matrix element to obtain V (Value), which is the representation of the other matrix element in the feature space of the matrix elements.
[0076] Multi-head attention: Multi-head attention involves establishing different projection information in multiple different feature spaces, projecting the input matrix into different locations, obtaining many output matrices, and then concatenating them together to obtain the final output.
[0077] Linear Module: In the decoder prediction output, this invention combines Linear with LGCN to perform final association rule mining on the trend and random items of the sequence, extracting more information.
[0078] Self-attention mechanism: Based on the autocorrelation attention mechanism, this invention designs an autocorrelation mechanism for extracting sequence feature patterns using STL. By performing a Fourier transform on the input sequence and calculating its autocorrelation matrix, the periodic information in the input sequence is obtained. Based on time-delay aggregation, the attention weights of the k most relevant positions to the current position are calculated to realize the correlation calculation between sequences, thereby improving the expressive power of the sequence.
[0079] like Figure 1-2 As shown, the present invention provides a long-term traffic flow prediction model based on low-rank graph and STL temporal decomposition. The prediction model adopts an encoder-decoder framework structure as the overall framework of the model, including an encoder structure network and a decoder structure network.
[0080] The encoder structure network includes a first self-attention mechanism, a first LGCN module, and a first STL timing decomposition module;
[0081] The steps for constructing the encoder structure network are as follows:
[0082] (11) Perform a Fourier transform on the sequence of input data, and combine it with the first self-attention mechanism to realize the message passing of the sequence, calculate its autocorrelation matrix, and then obtain the periodic regularity information in the input sequence; specifically, for the input Q t =(q t+1 ,q t+2 ,…q t+τ )∈R τ×N×F K t =(k t+1 ,k t+2,…k t+τ )∈R τ×N×F and V t =(v t+1 ,v t+2 ,…v t+τ )∈R τ×N×F For a sequence, its mathematical form is as follows:
[0083]
[0084]
[0085] Correlation(Q t ,K t V t ) = Agg(V t Corr(Q) t ,K t ))
[0086] In the above formula, Indicates Fourier transform, and These represent the conjugate transformation and inverse Fourier transform of the Fourier transform, respectively, and Agg represents the aggregation method, namely the time-delay-based aggregation function in the second stage.
[0087] (12) Using the information in the autocorrelation matrix, find the positions in the input sequence that have significant periodicity. Then, using these positions as a reference, aggregate the information of the input sequence through a sliding window to generate the output for each position. Specifically, for an input:
[0088]
[0089]
[0090]
[0091] in, This indicates rounding down, c is the delay factor, arg Topk(·) means calculating the first k maximum values, and Roll(χ,τ) means delaying χ by τ, so that the elements after being shifted to the first position will reappear in the last position.
[0092] (13) Stack the multi-layer coding network to form the encoder structure network.
[0093] The decoder network structure includes a second self-attention mechanism, a second LGCN module, a second STL temporal decomposition module, an encoding / decoding cross-attention fusion module, and a linear module;
[0094] The steps for constructing the decoder network structure are as follows:
[0095] (21) Perform STL time series decomposition on the input data to extract the target sequence at each level, namely the periodic term subsequence, the trend term subsequence and the random term subsequence. Focus on the periodic term subsequence to learn the time dimension of the self-attention mechanism, mine the node information of the spatial dimension of the LGCN module, and the first subsequence term after the spatiotemporal network message transmission of the result of the second STL decomposition module.
[0096] (22) The previously retained periodic subsequence items and the periodic subsequence items output by the encoder are used as Q and K, V of the cross-attention mechanism for time information exchange and spatial information exchange through the second LGCN module. The sequence after the spatiotemporal information transmission obtains more potential information and can be decomposed into secondary subsequence items by the second STL temporal decomposition module.
[0097] (23) The message passing of the trend term and the residual term is realized by superimposing the elements of the first subsequence term and the second subsequence term, and the trend term and the random term are respectively input into the second LGCN module and the Linear module for the final association rule mining; the elements of the three subsequence terms are superimposed as the output of the decoding network layer;
[0098] (24) Stack the decoding network layers in multiple layers to form the decoder structure network.
[0099] Furthermore, the construction process of the first or second self-attention mechanism is as follows:
[0100] The linear mapping of the input sequence X can be expressed mathematically as follows:
[0101] Q = XW q
[0102] K = XW k
[0103] V = XW v
[0104] in, These correspond to the query, key, and value vector matrices, respectively. There are three trainable parameter matrices, d q d k d v Its dimension size; input sequence X∈R n×F n is the number of road segment nodes; F is the number of input features;
[0105] The attention weights are calculated using the SoftMax function, with the following formula:
[0106]
[0107] Among them, K T Let Q be the transpose of matrix K, and let Q be the transpose of matrix K. T Multiplication generates similar matrices, when d k When the variance of the similarity matrix is large, it also increases. Therefore, a scaling operation is needed to scale the similarity matrix, i.e., dividing each element by a factor of 1.
[0108] Based on the single-layer self-attention mechanism and combined with the Autoformer algorithm, a multi-head attention mechanism is designed in the encoder and decoder network structures. This mechanism projects the input vector to different representation subspaces, as shown in the following formula:
[0109]
[0110] Meanwhile, the Autoformer algorithm was used to design cross-attention in the decoder to fuse and iterate the information from the encoder and decoder to complete the final information exchange and transmission.
[0111] The construction process of the first LGCN module or the second LGCN module is as follows:
[0112] Constructing an affinity matrix Specifically:
[0113] According to graph theory, the degree of node i in a certain road segment is... N represents the number of road segments, A i:j This indicates the connectivity between node i and node j.
[0114] A is the adjacency matrix, representing the connection relationships between nodes in the current road network; the degree matrix D of the road network is obtained, where the degree value of a node i is D. ii =d i , representing the values of the elements on the diagonal of the degree matrix, since D is a diagonal matrix, except for the values on the diagonal, which represent the degree values of each node. ii Except for D, all others are 0. ii =d i This leads to the Laplace matrix. L = DA, and the affinity matrix is obtained by symmetric normalization of the Laplace matrix L.
[0115]
[0116] Spatial graph convolutional layers based on the Lanczos method, taking an initial non-zero vector s and a positive integer M less than N.
[0117] The Lanczos similarity transform algorithm is performed, and the specific steps are as follows:
[0118] Input: Normalized Laplacian matrix A non-zero vector s ≠ 0, and a positive integer M << N.
[0119] Output: A set of orthogonal basis vectors v1, v2, ..., v M ∈R N And two sets of scalars {α1, α2, ..., α M ∈R} and {β1,β2,…,β M ∈R}
[0120] process:
[0121] (1) Initialization: β0 = 0, v0 = 0,
[0122] (2) For j = 1, 2, ..., M:
[0123] (3)
[0124] (4)
[0125] (5) z = zv j α j -β j-1 v j-1
[0126] (6)β j =|z|2
[0127] (7)
[0128] Where M is the number of iterations in the Lanczos algorithm when the recursion is zero; z is an intermediate variable in the pseudocode, which has no practical meaning.
[0129] Based on the results of the Lanczos similarity transformation algorithm, the orthogonal matrix V can be obtained from this set of orthogonal basis vectors. M =[v1,…,v M ], and a triangular symmetric matrix H M Its diagonal and superdiagonal elements are {α1, α2, ..., α...} M} and {β1,β2,…,β M}, its H M The construction rules are as follows:
[0130]
[0131] Based on the properties of the algorithm, we have Where V M * It is V MThe transpose of .
[0132] After obtaining H M Then, by examining the triangular symmetric matrix H M Perform eigenvalue decomposition H M =BRB * R, B, B * H respectively M The decomposed eigenvalue matrix, eigenvector matrix, and their transpose, where the M*M diagonal matrix R contains the Ritz values, and B∈R M×M It is an orthogonal matrix, and the approximate eigenvector matrix V is obtained. B =V M B, therefore the affinity matrix can be approximated. The solution of eigenvalues and eigenvectors Affinity Matrix Due to its symmetry and positive semi-definite properties, it can be further decomposed into U = [u0, u1, ..., u N-1 ] is by The orthogonal matrix obtained from the decomposition, the transpose of U, is denoted as U*. As can be seen from the above, Thus far, the graph convolution operation T based on the Lanczos approximation algorithm... k (X) is expressed as:
[0133] T k (X)=Ug(Λ)U * X = [X, VRV] * X, ..., VR K V * X]Θ
[0134] Where g(Λ)=[1,Λ,...,Λ K ]Θ, X are the input sequences, R k For the k-th power operation of the eigenvalue matrix R, V B * V represents B The transpose of Θ; Θ is the set of all trainable parameters;
[0135] By combining the gated low-rank GCN learning filter with the graph convolution operation of the Lanczos approximation algorithm mentioned above, the LGCN module—Lanczos-GCN (LGCN)—is constructed. The model is mainly expressed by the following formula:
[0136]
[0137]
[0138] Where E is the adaptive dynamic matrix of the diagonal matrix R, satisfying: There is an independent calculation process for each individual k, k1...k i That is, to simultaneously perform i calculations on different powers of k;
[0139] [·]and And respectively represent tensor connectivity and pointwise Hadamar product; P and Q are the output splits in the LGCN layer, with the same channel size; weight parameter Θ∈R (i+1)h×2o It is learnable; h and o are the input and output channels in the Lanczos hidden layer, respectively; the multi-span parameter set S = {s1, s2, ..., s...} i} is a set of hyperparameters that need to be preset, and these parameters have non-negative integer values. For example, S = {1, 3, 5, ...}.
[0140] The specific algorithm steps of the LGCN module are as follows:
[0141] Input: Normalized Laplacian matrix Feature data X′∈R N×C Multi-span parameter sets S, H M It is a triangular symmetric matrix;
[0142] 1: Eigenvalue decomposition H M =BRB *
[0143] 2:V=V M B
[0144] 3: For k∈S do
[0145] 4:
[0146] 5:
[0147] 6:
[0148] 7:Y←GLU(Concat(Y)Θ)
[0149] 8: Return Y
[0150] Among them, GLU (Gated Linear Unit) is a gating mechanism in convolutional neural networks. When applied to LGCN, it makes the entire convolution a non-linear gating mechanism. The formula is as follows: x′ is the feature, b and c are constant terms, and W and V are feature matrices.
[0151]
[0152] The STL timing decomposition module is mainly implemented through the following sub-steps:
[0153] This invention utilizes the STL time series decomposition algorithm to obtain the trend, periodic, and random terms by performing locally estimated scatterplot smoothing (LOESS) on the original time series, periodic decomposition on the subsequences, and denoising on the residual sequence. This invention incorporates AvgPool2d as an improved local weighting operator, assuming the input sequence is... Where x t ∈R N′×F Let N' be the feature vector at time t, N′ be the number of nodes in the traffic network, and F be the number of input features. The mathematical form of the decomposition is as follows:
[0154]
[0155]
[0156]
[0157]
[0158] Among them, T t S t R t These represent three subsequences: trend, period, and random. AvgPool2d(·) is a two-dimensional average pooling operation in the convolutional neural network to perform a moving average operation, and uses padding to keep the sequence length constant.
[0159] The encoder network encodes the sequence of input data through a first autocorrelation mechanism module, a first LGCN module, and a first STL temporal decomposition module. The decoder network learns sub-sequence items from the encoder input data through a second self-attention mechanism, a second LGCN module, and a second STL temporal decomposition module. Then, it outputs secondary sub-sequence items by combining the encoding and decoding cross-attention fusion module. Finally, it performs association rule mining on the secondary sub-sequence items by combining the second LGCN module and the Linear module, and outputs the elements of the three sub-sequence items by superimposing them. By combining the encoder network and the decoder network, a long-term traffic flow prediction model is obtained.
[0160] In the output of the long-term traffic flow prediction model, the traffic flow trend term, random term and periodic term output by the decoder at different times are saved and combined with the fully connected component to complete the output.
[0161] This invention provides a long-term traffic flow prediction method based on low-rank graphs and STL time-series decomposition. The prediction method includes:
[0162] (1) Constructing structured traffic flow data and road network data:
[0163] Road network data and traffic flow data consist of node data from detectors in the target road network, which are then processed using data processing methods to construct structured data.
[0164] The construction steps are as follows:
[0165] (1.1) N road segments are sampled by sensors laid in the highway network. The sampling time is T, the total sampling duration is Y, the sampling time interval is Δt, and the sampled traffic flow data is Y / Δt.
[0166] (1.2) Based on the spatial connection relationship between real sensors, the highway network is modeled using the node and edge relationships in the graph structure;
[0167] Each sensor is defined as a node, the upstream and downstream traffic flow connections between sensors are defined as edges E, and the road network structure state at time t is described as G. t =(V t Let V(E,A) represent the road network state at time t, where V t =(v t,1 ,v t,2 ,…,v t,N Let ), where represents the state of N nodes at time t, E represents the connectivity between nodes, and A is the adjacency matrix, representing the connection relationships between nodes in the current road network. When node i is connected to node j, A is... i,j =1, otherwise 0, where A i,j =A j,i That is, the adjacency matrix A used is a symmetric matrix.
[0168] (2) Real-time prediction using long-term traffic flow prediction models:
[0169] Traffic flow data is input into the constructed long-term prediction model for training and optimization. After multiple iterations until the loss function value reaches an acceptable threshold, the model parameters are adjusted, and the model is retrained. Finally, the most suitable hyperparameter combination is found, resulting in the best prediction model for traffic flow prediction. The long-term traffic flow prediction model is optimized using an optimizer and a loss function. The optimizer is set to Adam, and the loss function is the mean squared error (MSE) from regression tasks, with the following mathematical formula:
[0170]
[0171] In the above formula, n′ represents the total number of samples, and here Y :,i It represents the actual traffic flow at all nodes at time I, while This is the corresponding traffic flow forecast value;
[0172] After obtaining the prediction results, the model is repeatedly trained until it converges; the model results are saved, the model hyperparameters are changed and retrained until the optimal model hyperparameters and optimal model weights are found.
[0173] The model is deployed on a relevant platform, and the trained model is used to predict traffic flow at actual road traffic nodes. Specific Implementation
[0175] To verify the performance of the prediction algorithm in this application, traffic data from a highway network (hereinafter referred to as the HHY dataset) and the PEMSD8 dataset were selected. The HHY dataset consists of 276 road segments from 16 roads, containing information from 490 ETC gantries. It includes four feature parameters: traffic flow, average speed, maximum speed, and minimum speed. Data from 229 ETC gantries within a specific time period was selected. The PEMSD8 dataset is a public dataset from the Caltrans performance measurement system, used to record traffic flow, speed, and occupancy. It contains data from 170 node sensors, spanning from July 1, 2016 to August 31, 2016.
[0176] The dataset consists of 5-minute time slices, generating 288 time samples per day. The training, validation, and test sets are split in a 6:2:2 ratio. Optimization is performed using the Adam optimizer with a maximum training epoch of 100. A 15-epoch early stopping threshold is set, and the optimal parameters are selected through parameter tuning on the validation set. The model's learning rate is 0.005. The model uses one Endoer and one Decoder layer, with 64 d_models for the attention mechanism, 4 multi-head attention mechanisms, 100 M low-rank graph convolutional layers, and a delay aggregation factor of 1. The model uses three different prediction strides of 48, 60, and 72, respectively, using 4, 5, and 6-hour historical data windows to predict traffic flow for the next 4, 5, and 6 hours.
[0177] The test set uses MAE (mean absolute error), MAPE (mean absolute percentage error), and RMSE (root mean square error).
[0178] The three indicators were used as evaluation indicators, and the test results of each indicator are shown in Table 1.
[0179] Table 1
[0180]
[0181] This result represents the prediction results on the partitioned dataset. It can be seen that the shorter the prediction time, the better the performance of each indicator. Meanwhile, as the prediction step size increases, each error indicator shows a slight increase.
[0182] The prediction results represent the prediction results for one month of the test set. It can be seen that the closer the prediction step size is to the actual data, the better the performance of each indicator. In addition, the prediction error variation of MAE, MAPE, and RRSE indicators with different prediction durations is controlled within 8.61%, 3.46%, 3.91%, 7.76%, 6.66%, and 2.73% for HHY and PEMSD8, respectively. From the perspective of stability affected by the duration, the prediction results are within an acceptable range.
[0183] like Figure 3 As shown, this is a spatiotemporal distribution error plot on the HHY dataset, where the x-axis represents the time step within 360 minutes, the y-axis represents the number of spatial nodes in both datasets, and the z-axis represents the MAE error index value. The results show that over 90% of the spatial nodes achieve a prediction accuracy of less than 25%.
[0184] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
Claims
1. A long-term traffic flow prediction model based on low-rank graphs and STL time-series decomposition, characterized in that, The prediction model adopts an encoder-decoder framework structure as the overall framework of the model, including encoder structure network and decoder structure network; The encoder structure network includes a first self-attention mechanism, a first LGCN module, and a first STL timing decomposition module; The decoder network structure includes a second self-attention mechanism, a second LGCN module, a second STL temporal decomposition module, an encoding / decoding cross-attention fusion module, and a linear module. The encoder network structure encodes the sequence of input data through a first autocorrelation mechanism module, a first LGCN module, and a first STL temporal decomposition module. The decoder network structure learns first-order sub-sequence items from the encoder input data through the second self-attention mechanism, the second LGCN module, and the second STL temporal decomposition module. Then, it outputs second-order sub-sequence items by combining the encoding / decoding cross-attention fusion module. Finally, it performs association rule mining on the second-order sub-sequence items by combining the second LGCN module and the linear module, and outputs the superimposed elements of the three sub-sequence items. By combining the encoder network structure and the decoder network structure, a long-term traffic flow prediction model is obtained. In the output of the long-term traffic flow prediction model, the traffic flow trend term, random term and periodic term output by the decoder at different times are saved and combined with the fully connected component to complete the output. The construction process of the first LGCN module or the second LGCN module is as follows: Constructing an affinity matrix Specifically: According to graph theory, the degree of node i in a road segment is... for: , We obtain the degree matrix D of the road network, where the degree value of a node i is... = , representing the values of the elements on the diagonal of the degree matrix, since D is a diagonal matrix, except for the values on the diagonal, which represent the degree values of each node. Apart from that, all other values are 0, thus yielding the Laplace matrix. L=DA, and the affinity matrix is obtained by symmetric normalization of the Laplace matrix L. : ; Where N represents the number of road segments; This indicates the connectivity between node i and node j. ; A is the adjacency matrix, representing the connection relationships between nodes in the current road network; Construct a spatial graph convolutional layer based on the Lanczos method, taking an initial non-zero vector s and a positive integer M less than N, and perform the Lanczos similarity transformation algorithm; Based on the results of the Lanczos similarity transformation algorithm, the orthogonal matrix is obtained. and a triangular symmetric matrix Its diagonal and superdiagonal elements are respectively and ; By examining triangular symmetric matrices Perform eigenvalue decomposition , , , They are respectively The decomposed eigenvalue matrix, eigenvector matrix, and their transpose are as follows: M*M diagonal matrix R Includes Ritz value, It is an orthogonal matrix, and the approximate eigenvector matrix is obtained. Therefore, the affinity matrix can be approximated. The solution of eigenvalues and eigenvectors Affinity matrix Due to its symmetry and positive semi-definite properties, it can be further decomposed into , It is an orthogonal matrix obtained by decomposing Ĺ. The transpose of U is denoted as U*. As can be seen from the above, Thus far, graph convolution operations based on the Lanczos approximation algorithm have been completed. The expression is as follows: , in, X is the input sequence. For the eigenvalue matrix R k Power calculation. Represents the eigenvector matrix The transpose of the matrix; It is the set of all trainable parameters; V is the value vector matrix; By combining the gated low-rank GCN learning filter with the graph convolution operation of the Lanczos approximation algorithm mentioned above, an LGCN module—Lanczos-GCN—is constructed. The model is expressed by the following formula: , , Where E is the adaptive dynamic matrix of the diagonal matrix R, satisfying: For each individual k Each has an independent calculation process. That is, to simultaneously perform calculations on different k powers. i Second-rate; [·] and And respectively represent tensor connectivity and pointwise Hadhamar product; P and Q This is the segmentation output from the LGCN layer, with the same channel size; weight parameters It is learnable, and is the set of all trainable parameters. h and o These are the input and output channels in the Lanczos hidden layer; multi-span parameter set. It is a set of hyperparameters that need to be preset, and these parameters have non-negative integer values; The prediction method of the prediction model includes: (1) Constructing structured traffic flow data and road network data: Road network data and traffic flow data consist of node data from detectors in the target road network, which are then processed using data processing methods to construct structured data. (2) Real-time prediction using long-term traffic flow prediction models: Traffic flow data is input into the constructed long-term prediction model for training and optimization. The most suitable combination of hyperparameters is found to obtain the best prediction model for traffic flow prediction.
2. The long-term traffic flow prediction model based on low-rank graphs and STL time-series decomposition according to claim 1, characterized in that, The steps for constructing the encoder structure network are as follows: (11) Perform Fourier transform on the sequence of input data, and combine it with the first self-attention mechanism to realize the message passing of the sequence, calculate its autocorrelation matrix, and then obtain the periodic regularity information in the input sequence; (12) Using the information in the autocorrelation matrix, find the positions in the input sequence that have significant periodicity, and then use these positions as a reference to aggregate the information of the input sequence by means of a sliding window to generate the output of each position; (13) Stack the multi-layer coding network to form the encoder structure network.
3. The long-term traffic flow prediction model based on low-rank graphs and STL time-series decomposition according to claim 1, characterized in that, The steps for constructing the decoder network structure are as follows: (21) Perform STL time series decomposition on the input data to extract the target sequence at each level, namely the periodic term subsequence, the trend term subsequence and the random term subsequence. Focus on the periodic term subsequence to learn the time dimension of the self-attention mechanism, mine the node information of the spatial dimension of the LGCN module, and the first subsequence term after the spatiotemporal network message transmission of the result of the second STL decomposition module. (22) The previously retained periodic subsequence items and the periodic subsequence items output by the encoder are used as Q and K, V of the cross-attention mechanism for time information exchange and spatial information exchange through the second LGCN module. The sequence after the spatiotemporal information transmission obtains more potential information and can be decomposed into secondary subsequence items by the second STL temporal decomposition module. (23) The message passing of the trend item and the residual item is realized by superimposing the elements of the first subsequence item and the second subsequence item. The trend item and the random item are respectively input into the second LGCN module and the Linear module for the final association rule mining. The elements of the three subsequence items are superimposed as the output of the decoding network layer. (24) Stack the decoding network layers in multiple layers to form the decoder structure network.
4. The long-term traffic flow prediction model based on low-rank graphs and STL time-series decomposition according to claim 1, characterized in that, The construction process of the first or second self-attention mechanism is as follows: The linear mapping of the input sequence X can be expressed mathematically as follows: , , , in, These correspond to the query, key, and value vector matrices, respectively. There are three trainable parameter matrices. Its dimension size; input sequence Where n is the number of road segment nodes and F is the number of input features; The attention weights are calculated using the SoftMax function, with the following formula: ; in, It is the transpose of matrix K. and Multiplication generates similar matrices, when When the variance of the similarity matrix is large, it also increases. Therefore, a scaling operation is needed to scale the similarity matrix, i.e., dividing each element by a factor of 1. ; Based on the single-layer self-attention mechanism and combined with the Autoformer algorithm, a multi-head attention mechanism is designed in the encoder and decoder network structures. This mechanism projects the input vector to different representation subspaces, as shown in the following formula: ; Meanwhile, the Autoformer algorithm was used to design cross-attention in the decoder to fuse and iterate the information from the encoder and decoder to complete the final information exchange and transmission.
5. The long-term traffic flow prediction model based on low-rank graphs and STL time-series decomposition according to claim 1, characterized in that, The construction steps of step (1) are as follows: (1.1) N road segments are sampled by sensors laid in the highway network. The sampling time is T, the total sampling duration is Y, the sampling time interval is Δt, and the sampled traffic flow data is Y / Δt. (1.2) Based on the spatial connection relationship between real sensors, the highway network is modeled using the node and edge relationships in the graph structure; Each sensor is defined as a node, and the connectivity between nodes is defined as an edge E. The road network structure state at time t is... for: , in , representing the state among the N nodes at time t; A is an adjacency matrix, representing the connection relationships between nodes in the current road network. When a node... With nodes When connected, Otherwise, it is 0, where That is, the adjacency matrix A used is a symmetric matrix.
6. The long-term traffic flow prediction model based on low-rank graph and STL time series decomposition according to claim 1, characterized in that, In step (2), the long-term traffic flow prediction model is optimized using an optimizer and a loss function. The optimizer is set to Adam, and the loss function is the mean squared error from the regression task, with the following mathematical formula: , in, Here, the total number of samples is... Are all nodes in The actual traffic flow at any given moment, and This is the corresponding traffic flow forecast value; After obtaining the prediction results, the model is repeatedly trained until it converges; the model results are saved, the model hyperparameters are changed and retrained until the optimal model hyperparameters and optimal model weights are found. The model is deployed on a relevant platform, and the trained model is used to predict traffic flow at actual road traffic nodes.