Traffic flow adaptive prediction method based on multi-time step diagram

By integrating the adaptive prediction method of multi-time step graph and reinforcement learning control module, the problem of insufficient temporal and spatial relationship capture in traditional traffic flow prediction is solved, and high accuracy and timely prediction of traffic flow are achieved to adapt to the dynamic changes of urban traffic data.

CN120260263APending Publication Date: 2025-07-04XIDIAN UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510224957.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-27
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

Traditional traffic flow prediction methods are difficult to capture complex spatiotemporal and spatial relationships, and cannot adaptively optimize prediction time, resulting in insufficient prediction time and accuracy, and the accumulation of prediction errors affects traffic management decisions.

Method used

Adaptive prediction method of traffic flow based on multi-time step graph is adopted, and an adaptive topology graph network is constructed by fusion distance graph, time-varying edge weight topology graph and multi-time step graph, and an adaptive topology graph network is introduced, and the attention turning mechanism and reinforcement learning control module are introduced to adaptively determine the best prediction moment.

Benefits of technology

It improves the accuracy and timeliness of traffic flow prediction, effectively alleviates the accumulation of prediction errors, improves the reliability and flexibility of predictions, and adapts to the dynamic changes of urban traffic data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120260263A_ABST
    Figure CN120260263A_ABST
Patent Text Reader

Abstract

The invention relates to a traffic flow self-adaptive prediction method based on a multi-time step diagram, and belongs to the technical field of intelligent traffic and data mining analysis. The traffic flow self-adaptive prediction method based on the multi-time step diagram obtains a self-adaptive topological graph network by fusing a distance diagram, a time-varying edge weight topological graph and the multi-time step diagram; and by introducing an attention conversion mechanism, utilizing a reinforcement learning control module and designing a prediction technology combining the attention mechanism and an adaptive topological graph network, comprehensive capture of space-time dynamic characteristics, effective alleviation of prediction errors and adaptive determination of an optimal prediction moment are realized, so that the prediction accuracy is ensured, and the prediction efficiency is improved. And the timeliness and the reliability of prediction are obviously improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of intelligent transportation and data mining and analysis, and in particular relates to a traffic flow adaptive prediction method based on a multi-time step graph. Background Art

[0002] With the acceleration of urbanization and the continuous growth of traffic demand, urban transportation systems are facing increasingly severe congestion problems. As one of the core tasks of intelligent transportation systems, traffic flow prediction is of great significance in optimizing traffic resource allocation, reducing congestion, and improving traffic efficiency.

[0003] Traditional traffic flow prediction technology faces the following major technical challenges. First, the dynamic characteristics of spatiotemporal data. Traffic flow has obvious spatiotemporal dynamic characteristics. Traditional prediction models based on static graphs or single time series are difficult to capture complex spatiotemporal correlations. Second, the balance between timeliness and accuracy of prediction. In traffic management, timely predictions can provide support for early decision-making, but premature predictions may lead to reduced accuracy, while late predictions may miss the best time to take intervention measures. Third, the cumulative effect of prediction errors. In multi-step prediction tasks, prediction errors will gradually accumulate over time, resulting in a decrease in the reliability of prediction results, which has a negative impact on timely and accurate traffic management decisions.

[0004] Traditional spatiotemporal graph convolutional networks perform well in capturing complex spatiotemporal dependencies, but they usually rely on fixed prediction time or a single static graph structure, and cannot fully adapt to the dynamic and changeable traffic flow patterns in actual scenarios. They lack the ability to adaptively optimize the prediction time, and cannot flexibly respond to the real-time changes in different regions. This is very unfavorable for adaptively predicting traffic flow and avoiding congestion accidents. Therefore, a traffic flow adaptive prediction method is needed to improve the timeliness and reliability of the prediction while ensuring the accuracy of the prediction. Summary of the invention

[0005] In order to solve the above problems existing in the prior art, the present invention provides a traffic flow adaptive prediction method based on a multi-time step graph. The technical problem to be solved by the present invention is achieved through the following technical solutions:

[0006] The present invention provides a traffic flow adaptive prediction method based on a multi-time step graph, comprising:

[0007] Obtain traffic sensor data, and construct distance graph, time-varying edge weight topology graph, and multi-time step graph to extract temporal and spatial features respectively;

[0008] Fuse the distance map, the time-varying edge weight topology map, and the multi-time step map to obtain an adaptive topology map. Among them, use the adaptive topology map as an encoder to encode the extracted time features and space features;

[0009] Perform spatio-temporal embedding modeling on the encoded time features and space features to obtain comprehensive spatio-temporal features;

[0010] Construct a decoder, use the decoder to decode the comprehensive spatio-temporal features to obtain a preliminary prediction result, and adopt a cross-attention mechanism to weightedly fuse the feature information of the encoder and the decoder to establish a mapping relationship of spatio-temporal features between the encoder and the decoder;

[0011] Through the reinforcement learning control module, adaptively determine the best prediction moment of each node in the adaptive topology map, generate a prediction action vector, and obtain a prediction result according to the prediction action vector and the preliminary prediction result;

[0012] Combine the performance loss function, the controller loss function, and the early loss function to obtain a weighted total loss function, optimize the training model, and output an accurate prediction result of traffic flow.

[0013] In an embodiment of the present invention, the obtaining traffic sensor data and respectively constructing a distance map, a time-varying edge weight topology map, and a multi-time step map to respectively extract time features and space features includes:

[0014] Obtain traffic sensor data, where the traffic sensor data includes time information and space information;

[0015] Construct a graph structure, and the graph structure contains several nodes;

[0016] Use a distance matrix to quantify the spatial relationship between the nodes to generate a distance map;

[0017] Introduce self-loop connections into each node, and integrate the node information and its adjacent node information, and its expression is:

[0018]

[0019] Among them, is the output feature of the node after convolution fusion calculation processing based on the distance map; W d is a learnable weight matrix; H in is the input node feature; is the degree matrix, and the degree matrix is a diagonal matrix calculated according to the distance matrix, and the elements on its diagonal is the degree of node i, that is, the sum of the weights of the edges directly connected to node i; through Perform normalization to balance the impact of degree differences among different nodes on feature propagation; Represents the correlation calculated based on distance between nodes; β1 and β2 are hyperparameters, representing the importance of the features of the node itself and neighboring nodes in the output feature respectively;

[0020] Construct a time-varying edge-weight topological graph, and its expression is:

[0021]

[0022] Among them, is the time-varying edge-weight topological graph; the ReLU function is a function to ensure that the elements of the output matrix are non-negative; the tanh function is a function to normalize the values of the matrix elements; α is a hyperparameter used to adjust the saturation of the activation function; X se is the dynamic embedding vector of the source node; X te is the dynamic embedding vector of the target node; is the transpose of the dynamic embedding vector of the target node;

[0023] Use the dynamic time warping method to generate a multi-time-step graph to calculate the similarity between time series, and its expression is:

[0024]

[0025] Among them, is the multi-time-step graph; DTW is the distance for calculating the similarity metric between traditional time series; the parameter κ is used to control the attenuation rate of the dynamic time warping distance.

[0026] In an embodiment of the present invention, fusing the distance graph, the time-varying edge-weight topological graph and the multi-time-step graph to obtain an adaptive topological graph includes:

[0027] Fuse the distance graph and the time-varying edge-weight topological graph through a weighted fusion strategy, and its expression is:

[0028]

[0029] Among them, is the fused distance graph and the variable edge-weight topological graph; is the degree matrix of the time-varying edge-weight topological graph; is the degree matrix of the distance graph, which has been normalized; the entire weighted fusion process is adjusted by the hyperparameters β1, β2, β3, and β1, β2, β3 are all hyperparameters, representing the contribution degrees of self-loop connection, distance graph and time-varying edge-weight topological graph in the output feature representation respectively; I is the identity matrix; is the time-varying edge-weight topological graph at time t;

[0030] Introduce a hyperparameter β4 to characterize the contribution of the multi-time-step graph to the feature representation of the final fused graph, and obtain an adaptive topological graph, whose expression is:

[0031]

[0032] Among them, H out is the adaptive topological graph; H t is the hidden state at time t.

[0033] In an embodiment of the present invention, perform spatio-temporal embedding modeling on the encoded time feature and the spatial feature to obtain a comprehensive spatio-temporal feature, including:

[0034] Use one-hot encoding to perform result conversion on the encoded time feature and the spatial feature, and generate a time embedding and a spatial embedding respectively;

[0035] Integrate the time embedding and the spatial embedding to obtain a comprehensive spatio-temporal feature, whose expression is:

[0036]

[0037] Among them, is the comprehensive spatio-temporal feature; is the spatial embedding; is the time embedding.

[0038] In an embodiment of the present invention, construct a decoder, decode the comprehensive spatio-temporal feature through the decoder to obtain a preliminary prediction result, and use a trans-attention mechanism to weightedly fuse the feature information of the encoder and the decoder to establish a mapping relationship of spatio-temporal features between the encoder and the decoder, including:

[0039] Construct a decoder, decode the comprehensive spatio-temporal feature through the decoder to obtain a preliminary prediction result;

[0040] Use a trans-attention mechanism to model the connection between the encoder and the decoder, and its expression is:

[0041]

[0042] Among them, ε i,t (t1,t2) is the attention score; e i,t′ is the spatio-temporal embedding processed by the ReLU activation function; both t1 and t2 are time nodes; W is the weight; b is the bias parameter; <·,·> is the vector inner product; is the scaling factor;

[0043] The decoder performs weighted summation on the hidden states of the previous time points according to the attention score, and its expression is:

[0044]

[0045] where \(t_2 = t, \ldots, T - 1\); \(\sigma(\cdot)\) is the sigmoid function; \(W\) h is the weight parameter of the network in the decoder; \(b\) h is the bias parameter; \(\varepsilon\) t is the attention score; is the hidden state at time \(t_1\).

[0046] In one embodiment of the present invention, through the reinforcement learning control module, the optimal prediction time of each node in the adaptive topology graph is adaptively determined, a prediction action vector is generated, and a prediction result is obtained based on the prediction action vector and the preliminary prediction result, including:

[0047] Through the reinforcement learning control module, the optimal prediction time of each node in the adaptive topology graph is adaptively determined;

[0048] Through the reinforcement learning control module, based on the current state and the current policy, the prediction policy is optimized, and its expression is:

[0049] p t = \(\sigma(W\) c S t + b c );

[0050] a t = \(\pi(S\) t );

[0051] where \(p\) t is the pause probability; \(W\) c is the weight parameter of the reinforcement learning control module; \(\sigma\) is the activation function; \(b\) c is the bias parameter of the reinforcement learning control module; \(S\) t is the current state; \(a\) t is the prediction action vector indicating the optimal prediction time; \(\pi\) is the current policy;

[0052] The prediction action vector is multiplied element-wise by the non-linear transformation result of the hidden state to obtain the prediction result, and its expression is:

[0053]

[0054] where is the prediction result; \(W\) p is the weight; \(b\) p is the bias parameter; is the decoder output hidden state for processing each time step \(t\).

[0055] In one embodiment of the present invention, if the predicted action vector of a certain node i is 0 at all time steps, the default best prediction time for this node is T-1, and the prediction result is obtained.

[0056] In one embodiment of the present invention, the weighted total loss function is obtained by combining the performance loss function, the controller loss function, and the early loss function, the training model is optimized, and the accurate prediction result of the traffic flow is output, including:

[0057] Calculate the mean absolute error between the prediction result and the true value to obtain the performance loss function, and its expression is:

[0058]

[0059] where L p is the performance loss function; N is the number of nodes; X T,i is the true value;

[0060] Calculate the negative logarithm of the pause probability to obtain the early loss function, and its expression is:

[0061]

[0062] where L e is the early loss function; For each node i, it is the best prediction time obtained by calculating through the policy π;

[0063] Use the reward tensor to maximize the expected reward to improve the prediction accuracy, and obtain the controller loss function, and its expression is:

[0064]

[0065] where L c is the controller loss function; E represents taking the expectation of the sub-expression in the parentheses; b t′ is the baseline; S t is the hidden state; r t ' is the updated reward; r is the overall reward;

[0066] According to the performance loss function, the early loss function, and the controller loss function, the weighted loss function is obtained through hyperparameters, and its expression is:

[0067] L = L p + ω1L c + ω2L e ;

[0068] where L is the weighted loss function; ω1 and ω2 are hyperparameters;

[0069] Optimize the training model according to the weighted loss function to make the model training converge, and obtain a trained model that outputs accurate prediction results of traffic flow.

[0070] The present invention also provides an electronic device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the above-mentioned traffic flow adaptive prediction method based on a multi-time step graph is implemented.

[0071] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned traffic flow adaptive prediction method based on a multi-time step graph is implemented.

[0072] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0073] The traffic flow adaptive prediction method based on a multi-time step graph of the present invention obtains an adaptive topology graph network by fusing a distance graph, a time-varying edge weight topology graph, and a multi-time step graph, introduces a transfer attention mechanism, and uses a reinforcement learning control module to design a prediction technology that combines the attention mechanism and the adaptive topology graph network, so as to comprehensively capture the spatio-temporal dynamic characteristics, effectively alleviate the prediction error, and adaptively determine the optimal prediction moment, thereby significantly improving the timeliness and reliability of the prediction while ensuring the prediction accuracy.

[0074] The present invention inputs the real-time data samples collected by sensors into the model. The adaptive topology graph network serves as an encoder to extract data features, initializes the decoder with the output of the encoder. The reinforcement learning control module determines whether the current moment meets the condition of the optimal step length according to the network hidden state output by the decoder. If it meets, it generates a prediction result and uses it as the final prediction result, that is, the number of vehicles passing through each sensor area within a certain future time period. Through the above steps, the present invention can effectively improve the prediction accuracy and timeliness of traffic flow, especially showing higher prediction accuracy and flexibility than traditional methods when dealing with complex urban traffic data.

[0075] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the following specifically gives preferred embodiments and, in conjunction with the drawings, details are described as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0076] Figure 1 It is an overall framework diagram of a traffic flow adaptive prediction method based on a multi-time step graph provided by an embodiment of the present invention;

[0077] Figure 2It is a flowchart of a traffic flow adaptive prediction method based on a multi-time step graph provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0078] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined purpose of the invention, the following is a detailed description of a traffic flow adaptive prediction method based on a multi-time step graph proposed by the present invention in combination with the accompanying drawings and specific implementation methods.

[0079] The above and other technical contents, features and effects of the present invention are clearly presented in the following detailed description of the specific implementation modes in conjunction with the accompanying drawings. Through the description of the specific implementation modes, the technical means and effects adopted by the present invention to achieve the predetermined purpose can be more deeply and specifically understood. However, the attached drawings are only for reference and explanation purposes and are not used to limit the technical solutions of the present invention.

[0080] Embodiment 1

[0081] Traditional spatiotemporal graph convolutional networks perform well in capturing complex spatiotemporal dependencies, but they usually rely on fixed prediction time or a single static graph structure and cannot fully adapt to the dynamic and changeable traffic flow patterns in actual scenarios. In particular, they lack the ability to adaptively optimize the prediction time and are difficult to flexibly respond to the real-time changing needs of different regions, which is very unfavorable for adaptively predicting traffic flow and avoiding congestion accidents. In order to solve the problem of insufficient dynamic data capture of time series in existing traffic flow prediction, especially short-term high-frequency fluctuations and long-term trend changes, the present invention provides a traffic flow adaptive prediction method based on a multi-time step graph.

[0082] like Figure 1 and Figure 2 As shown, Figure 1 It is an overall framework diagram of a traffic flow adaptive prediction method based on a multi-time step graph provided by an embodiment of the present invention; Figure 2 It is a flowchart of a traffic flow adaptive prediction method based on a multi-time step graph provided by an embodiment of the present invention.

[0083] In this embodiment, the traffic flow adaptive prediction method based on the multi-time step graph includes the following steps:

[0084] Step 1: Obtain traffic sensor data and construct a distance graph, a time-varying edge weight topology graph, and a multi-time step graph to extract temporal and spatial features respectively.

[0085] In an optional embodiment, step 1 comprises:

[0086] Step 1.1: Obtain traffic sensor data, which includes time information and spatial information;

[0087] Step 1.2: Construct a graph structure that contains several nodes.

[0088] Specifically, define the graph structure The graph contains N nodes v i ∈ V, where V is the set of vertices and E is the set of edges; the relationship between nodes (i.e., the edges (v i , v j ) ∈ E) is determined according to the correlation between nodes. To quantify the connection strength between these nodes, use the matrix A ∈ R N×N to represent the edge data, where R is the set of real numbers, meaning that each element in the matrix is a real number; through the node data X t ∈ R N to record the information of each node at time t.

[0089] Step 1.3: Use a distance matrix to quantify the spatial relationship between nodes to generate a distance graph.

[0090] Specifically, use the distance matrix to quantify the spatial relationship between nodes. The expression of the distance matrix is:

[0091]

[0092] where d ij is the distance between nodes v i , v j ; each element represents the correlation between nodes i and j calculated based on distance; exp is the exponential function; for an undirected graph, is a symmetric matrix; η is the attenuation parameter used to adjust the range of the distance effect. Through the attenuation function, it is ensured that even for relatively distant nodes, as long as the geographical distance is within a certain range, it can be considered that there is a spatial dimension correlation between the nodes.

[0093] Step 1.4: Introduce self-loop connections to each node and integrate the node information and its adjacent node information. The expression is:

[0094]

[0095] where is the output feature of the node after convolution fusion calculation processing based on the distance graph; W d is the learnable weight matrix; H in is the input node feature; is the degree matrix, and the degree matrix is a diagonal matrix calculated according to the distance matrix, and the elements on its diagonal is the degree of node i, that is, the sum of the weights of the edges directly connected to node i; by perform normalization to balance the influence of the degree difference of different nodes on feature propagation; represents the correlation calculated based on distance between nodes; β1 and β2 are hyperparameters, representing the importance of the node's own features and the features of neighboring nodes in the output features respectively.

[0096] Specifically, introduce self-loop connections to each node to maintain the node's own feature information, and consider the influence of neighboring nodes while updating features, thereby integrating the information of the node itself and its adjacent nodes.

[0097] Step 1.5: Construct a time-varying edge-weight topological graph, and its expression is:

[0098]

[0099] where, is the time-varying edge-weight topological graph; the ReLU function is a function to ensure that the elements of the output matrix are non-negative; the tanh function is a function to normalize the values of the matrix elements, by mapping to between -1 and 1 to control the output intensity of the activation function; α is a hyperparameter used to adjust the saturation of the activation function to control the sensitivity of the model to the connection strength between nodes in the graph structure; X se is the dynamic embedding vector of the source node; X te is the dynamic embedding vector of the target node; is the transpose of the dynamic embedding vector of the target node.

[0100] Specifically, at time t, concatenate the hidden state H t-1 with the current node value X t and use the concatenated comprehensive feature representation as the input. After feeding it into the graph convolutional neural network, multiply the output of the neural network with the randomly initialized learnable distance graph node embedding vector bit by bit to generate a dynamic node embedding of dimension N. The node embedding operation of this time-varying edge-weight topological graph has X se for the source node and X te for the target node. Subsequently, obtain the adjacency matrix

[0101] Step 1.6: Use the dynamic time warping method to generate a multi-time-step graph to calculate the similarity between time series, and its expression is:

[0102]

[0103] where, It is a multi - time - step graph; DTW is used to calculate the distance as a similarity measure between traditional time series; the parameter κ is used to control the decay rate of the dynamic time warping distance.

[0104] Specifically, for each time step, a multi - time - step similarity matrix is created, which is denoted as at the current time step. This matrix (i.e., the multi - time - step graph) is used to calculate the similarity between each pair of nodes from the start of time to the current time step t, and for each element (i, j) in the matrix, the similarity between nodes v i and v j is calculated between each time step t′(0 ≤ t′ ≤ t).

[0105] It can be understood that dynamic time warping (DTW) is a method for measuring the similarity between two time series, especially suitable for dealing with differences caused by time offsets or different time steps. Its basic principle is to non - linearly align two time series to find the optimal matching path between them, thereby evaluating their similarity. Dynamic time warping allows time series to be non - linearly deformed on the time axis, stretching or compressing some parts, so that the two time series can be better aligned. By recursively calculating the distance between each time point and accumulating these distances, a shortest matching path is finally found. The cumulative distance corresponding to this path reflects the similarity between the two sequences, and the smaller the distance, the higher the similarity.

[0106] Step 2: Fuse the distance graph, the time - varying edge - weighted topology graph, and the multi - time - step graph to obtain an adaptive topology graph. Among them, the adaptive topology graph is used as an encoder to encode the extracted time features and spatial features.

[0107] In an optional implementation, step 2 includes:

[0108] Step 2.1: Fuse the distance graph and the time - varying edge - weighted topology graph through a weighted fusion strategy. The expression for the fusion process is:

[0109]

[0110] where is the fused distance graph and the variable - edge - weighted topology graph; is the degree matrix of the time - varying edge - weighted topology graph; is the degree matrix of the distance graph, which has been normalized. The entire weighted fusion process is adjusted by hyperparameters β1, β2, β3. β1, β2, β3 are all hyperparameters, representing the contribution degrees of self - loop connections, the distance graph, and the time - varying edge - weighted topology graph in the output feature representation respectively; I is the identity matrix; is the time - varying edge - weighted topology graph at time t.

[0111] Step 2.2: Introduce the hyperparameter β4, which characterizes the contribution of the multi-time-step graph to the final fused graph feature representation, to obtain the adaptive topological graph, and its expression is:

[0112]

[0113] where, H out is the adaptive topological graph; H t is the hidden state at time t.

[0114] So far, the modeling of the adaptive topological graph for characterizing the final feature representation after the multi-graph fusion operation is completed, which can be briefly recorded as:

[0115] Furthermore, the matrix multiplication operation in the traditional gated recurrent unit (GRU) can be replaced by the multi-graph fusion calculation operation in the above steps, and its calculation formula is as follows:

[0116]

[0117] where, and respectively represent the multi-graph fusion operations applied in different gating and state update processes. Specifically, replace the matrix operation terms of the "update gate", "reset gate" and "current hidden state" in the traditional gated recurrent unit with the above three graph fusion calculation terms and

[0118]

[0119] The principle is to construct the basic graph structure for traffic flow prediction, including: defining the basic graph structure including the node set and the edge set, representing the edge weights with matrices, and recording the spatial associations between nodes; generating the distance graph adjacency matrix based on the exponential decay function of the node geographical distance to obtain the constructed distance graph structure for quantifying the spatial relationships between nodes; introducing self-loop connections to the graph structure to retain its own features, and integrating the information of the node itself and its neighboring nodes through the graph fusion convolution calculation operation to obtain the preliminary spatio-temporal feature representation of the node.

[0120] Furthermore, construct the preliminary fused graph of the distance graph and the time-varying edge weight topological graph, including: at each time step, combine the hidden state of the previous moment and the current node value, and input it into the graph convolutional neural network; calculate the adjacency matrix of the time-varying edge weight topological graph based on the node embedding of the time-varying edge weight topological graph, use the activation function to standardize the similarity between nodes, and adjust the sensitivity of the model to the connection strength in the graph; jointly combine the feature information of the distance graph and the time-varying edge weight topological graph, and generate the preliminary fused graph representation through the weighted fusion strategy, where the weights are adjusted by hyperparameters.

[0121] Step 3: Perform spatio-temporal embedding modeling on the encoded temporal features and spatial features to obtain comprehensive spatio-temporal features.

[0122] In an optional embodiment, Step 3 includes:

[0123] Step 3.1: Use one-hot encoding to perform result conversion on the encoded temporal features and spatial features, and generate temporal embedding and spatial embedding respectively;

[0124] Step 3.2: Integrate the temporal embedding and spatial embedding to obtain comprehensive spatio-temporal features, and its expression is:

[0125]

[0126] where, is the comprehensive spatio-temporal feature, that is, the spatio-temporal embedding result tensor; is the spatial embedding; is the temporal embedding.

[0127] Specifically, use one-hot encoding to convert the encoding result through a two-layer fully connected neural network to generate an embedding result vector in the temporal dimension where D represents the dimension of the embedding. Node v i The spatial data at time t is processed through a similar neural network to generate an embedding result vector in the spatial dimension Integrate the embedding vector in the temporal dimension and the embedding vector in the spatial dimension to obtain the spatio-temporal embedding result tensor after integrating the two spatio-temporal dimensions

[0128]

[0129] Step 4: Construct a decoder, and decode the comprehensive spatio-temporal features through the decoder to obtain a preliminary prediction result. Adopt a trans-attention mechanism to weightedly fuse the feature information of the encoder and the decoder to establish a mapping relationship of spatio-temporal features between the encoder and the decoder.

[0130] In an optional embodiment, Step 4 includes:

[0131] Step 4.1: Construct a decoder, and decode the comprehensive spatio-temporal features through the decoder to obtain a preliminary prediction result;

[0132] Step 4.2: Use a trans-attention mechanism to model the connection between the encoder and the decoder, and its expression is:

[0133]

[0134] where ε i,t (t1,t2) is the attention score; e i,t′is the spatio-temporal embedding processed by the ReLU activation function; both t1 and t2 are time nodes; W is the weight; b is the bias parameter; <·,·> is the vector inner product; is the scaling factor, and through the scaling factor controls the impact caused by the increase in dimension to prevent the model from entering the low-gradient region.

[0135] Specifically, the Transformer-Attention mechanism is adopted to model the relationship between the encoder (recorded value) and the decoder (predicted result). For the node i at time t, the similarity score between time t1 and t2 is calculated according to the Transformer-Attention mechanism to model the internal relationship of the features.

[0136] Step 4.3: The decoder performs a weighted sum of the hidden states at the previous time points according to the attention scores, and its expression is:

[0137]

[0138] where t2 = t,…,T - 1; σ(·) is the normalized exponential function, and the attention scores are normalized through the normalized exponential function to ensure that the sum of the scores is 1; W h is the weight parameter of the network in the decoder; b h is the bias parameter; ε t is the attention score; is the hidden state at time t1.

[0139] The principle is that, first, the spatio-temporal embedding of the nodes is modeled based on time and space data to generate a spatio-temporal tensor; among them, the Transformer-attention mechanism is used to establish a mapping relationship of spatio-temporal features between the encoder and the decoder, calculate the similarity scores between time steps, and perform a weighted sum of the hidden states of the decoder; finally, the weighted prediction information in both the spatial and temporal dimensions is generated.

[0140] Step 5: Through the reinforcement learning control module, adaptively determine the best prediction moment for each node in the adaptive topological graph, generate a prediction action vector, and obtain the prediction result according to the prediction action vector and the preliminary prediction result.

[0141] In an optional implementation manner, Step 5 includes:

[0142] Step 5.1: Through the reinforcement learning control module, adaptively determine the best prediction moment for each node in the adaptive topological graph, where the best prediction moment can be expressed as

[0143] Specifically, the optimal prediction time is an earlier prediction time that can balance the accuracy and timeliness of prediction, so that preparations can be made in advance and the high accuracy of the prediction result can be ensured.

[0144] Step 5.2: Through the reinforcement learning control module, optimize the prediction policy based on the current state and the current policy, and its expression is:

[0145] p t = σ(W c S t + b c ) (12);

[0146] a t = π(S t ) (13);

[0147] Among them, p t is the pause probability; W c is the weight parameter of the reinforcement learning control module; σ is the activation function; b c is the bias parameter of the reinforcement learning control module; S t is the current state, S t ∈ R N×(H+1) ; a t is the prediction action vector indicating the optimal prediction time; π is the current policy.

[0148] Furthermore, after Step 5.2, the ε-greedy policy can be further applied to optimize the prediction policy, and its expression is:

[0149]

[0150] Specifically, the ε-greedy policy follows the greedy policy (i.e., selects the current optimal action) in most cases, but will select a random action with a small probability ε to ensure a certain degree of exploration. Adopting the ε-greedy policy can avoid falling into local optima and gradually explore a larger state space to find a better policy.

[0151] Step 5.3: Multiply the prediction action vector element by element with the non-linear transformation result of the hidden state to obtain the prediction result, and its expression is:

[0152]

[0153] Among them, is the prediction result; W p is the weight; b p is the bias parameter; is the decoder output hidden state for processing each time step t, and the prediction result is generated through the rectified linear unit (ReLU activation function)

[0154] Furthermore, if the predicted action vector of a certain node i is 0 at all time steps, the default best prediction time for this node is T - 1, and the prediction result is obtained. That is, when reaching the maximum time window, if no action is triggered, the time T - 1 is taken as the best prediction time to obtain the prediction result.

[0155]

[0156] The principle lies in that the reinforcement learning control module calculates the action vector at the best prediction time based on the current state and policy; applies the ε-greedy policy to balance exploration and exploitation to determine the prediction timing; and calculates the prediction value at each time step according to the decision of the reinforcement learning control module and the decoder output, thus realizing the optimization of the prediction time.

[0157] Step 6: Combine the performance loss function, the controller loss function, and the early loss function to obtain the weighted total loss function, optimize the training model, and output the accurate prediction result of the traffic flow.

[0158] In an optional implementation manner, Step 6 includes:

[0159] Step 6.1: Calculate the mean absolute error between the prediction result and the true value to obtain the performance loss function, and its expression is:

[0160]

[0161] where L p is the performance loss function; N is the number of nodes; is the prediction result; X T,i is the true value;

[0162] Step 6.2: Calculate the negative logarithm of the pause probability to obtain the early loss function, and its expression is:

[0163]

[0164] where L e is the early loss function; is, for each node i, the best prediction time calculated through the policy π;

[0165] Step 6.3: Use the reward tensor to maximize the expected reward to improve the prediction accuracy and obtain the controller loss function, and its expression is:

[0166]

[0167] where L c is the controller loss function; E represents taking the expectation of the sub-expression in the parentheses; b t′Take the baseline as the baseline, baseline b t′ Depends on the hidden state S of the controller t , learned by minimizing the mean square error between it and the overall reward r; S t Is the hidden state; r t ' is the updated reward; r is the overall reward;

[0168] Step 6.4: According to the performance loss function, the early loss function and the controller loss function, obtain the weighted loss function through hyperparameters, and its expression is:

[0169] L = L p + ω1L c + ω2L e (21);

[0170] Among them, L is the weighted loss function; ω1 and ω2 are hyperparameters;

[0171] Step 6.5: Optimize the training model according to the weighted loss function to make the model training converge, and obtain the trained model and output the accurate prediction result of the traffic flow.

[0172] Specifically, combining performance, timeliness and controller loss, calculate the weighted loss function L through hyperparameters ω1 and ω2:

[0173] The expression of the mean absolute error MAE is:

[0174]

[0175] The expression of the root mean square error RMSE is:

[0176]

[0177] The expression of the mean absolute percentage error MAPE is:

[0178]

[0179] Specifically, optimize the training of the model through a comprehensive loss function composed of aspects such as prediction accuracy, prediction timeliness, and rewards generated by the control module until the model converges to obtain the prediction output result.

[0180] The principle lies in modeling the model performance loss, early prediction loss, and controller loss, and then weighted integration of the above three loss functions into a total loss function, where the weights are controlled by hyperparameters; next, the model is trained using the Adaptive Moment Estimation optimizer (Adam), and hyperparameters such as the initial learning rate, batch size, and node embedding dimension are set; finally, an early stopping mechanism is adopted to monitor the validation set error until the model converges, obtaining a model capable of adaptively predicting traffic flow output in complex traffic scenarios, thus realizing model training and optimization.

[0181] It can be understood that after obtaining the prediction model by adopting the traffic flow adaptive prediction method based on multi-time step graph of the present invention, other model training methods can also be used, such as: gradient descent optimization training, mini-batch training, RMSProp adaptive optimization training, etc. Therefore, the training and optimization process of the model is not limited in the present invention.

[0182] Exemplarily, the initial learning rate is configured as 0.001, the depth of the convolutional layer for multi-graph fusion is 1, the hidden state H is set to 32, the node embedding dimension D is set to 40, the batch size is set to 32, the maximum observation window length T is selected as 12, and the hyperparameters β1, β2, β3, β4 are respectively set to 0.05, 0.95, 0.95, and 0.95, and the loss function weight hyperparameters ω1, ω2 are respectively set to 1 and a value between 0 and 0.1. The early stopping mechanism is adopted during the training process, and the Adaptive Moment Estimation optimizer (Adam) is selected as the model training tool for training on the NVIDIA GeForce RTX 3070Ti high-performance computing platform. When the model training converges, the finally trained model is obtained to realize the output of traffic flow prediction results.

[0183] The data used in the simulation experiment of the present invention is the public traffic speed dataset collected by the Los Angeles freeway loop detectors, which contains the data collected by 207 selected sensors with a sampling rate of 5 minutes. The time span is from March 1, 2012 to June 30, 2012, providing in-depth insights into the traffic patterns and congestion conditions in the Los Angeles area and being an ideal choice for evaluating the accuracy of the model in traffic flow prediction. By comparing the framework of the present invention with the following baselines, the results are shown in Table 1.

[0184] Table 1 Performance metrics of different models on the dataset

[0185]

[0186] Table 1 shows the prediction results based on the present invention and other comparative baselines on the public transportation speed dataset collected by the Los Angeles freeway loop detectors, that is, the comparison results of three indicators: mean absolute error, root mean square error, and mean absolute percentage error under the same percentage of average best prediction time. It can be seen from the prediction results in Table 1 that the traffic flow adaptive prediction method based on multi-time step graphs of the present invention can accurately achieve the traffic flow prediction of the public transportation speed dataset collected by the Los Angeles freeway loop detectors. Therefore, by using the traffic flow adaptive prediction model based on multi-time step graphs of the present invention, the best performance with statistical significance can be obtained in all evaluation indicators.

[0187] The traffic flow adaptive prediction method based on multi-time step graphs of the present invention also has the following advantages:

[0188] (1) Dynamic spatio-temporal feature capture ability: The model of the present invention realizes the effective modeling of spatio-temporal features through the multi-graph fusion convolution calculation module, combining the distance graph and the time-varying edge weight topology graph. The time-varying edge weight topology graph captures the complex spatio-temporal correlations in traffic flow data more easily than the single graph structure in other existing invention technologies by updating the relationships between nodes in real time, and is particularly suitable for scenarios where traffic flow changes rapidly.

[0189] (2) Adaptive prediction moment determination: Through the reinforcement learning control module, the model can adaptively determine the best prediction moment for each node dynamically. Compared with the traditional method with a fixed prediction time, adopting an adaptive strategy will effectively reduce the prediction error caused by data delay and will be much superior to the existing technologies in terms of prediction timeliness.

[0190] (3) Error propagation suppression mechanism: By using the trans-attention mechanism, a strong correlation is established between the encoder and the decoder. By weighted calculation of important features, the problem of error accumulation in long time series prediction is effectively alleviated. Therefore, compared with the technologies in this field, the stability and accuracy of the prediction of the present invention will also be more fully guaranteed and enhanced.

[0191] (4) Deep fusion of multi-graphs: The multi-level fusion mechanism of the distance graph, the time-varying edge weight topology graph, and the multi-time step graph enables the model to flexibly adapt to the characteristics of different time nodes and spatial positions. This cannot be achieved by a single graph structure. The present invention adaptively adjusts the weights of the distance graph and the time-varying edge weight topology graph through hyperparameters. The adaptive topology graph after multi-graph fusion can achieve a good balance between global structural stability and local dynamic changes, and thus will also make more full use of the hidden feature information between multi-nodes and multi-time step graphs, which is also ignored in the previous technologies in this field.

[0192] The present invention also provides an electronic device, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the computer program, a traffic flow adaptive prediction method based on a multi-time-step graph is implemented.

[0193] The present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, a traffic flow adaptive prediction method based on a multi-time-step graph is implemented.

[0194] The traffic flow adaptive prediction method based on a multi-time-step graph of the present invention obtains an adaptive topology graph network by fusing a distance graph, a time-varying edge-weight topology graph, and a multi-time-step graph, introduces a transfer attention mechanism, and uses a reinforcement learning control module to design a prediction technology that combines the attention mechanism and the adaptive topology graph network, so as to comprehensively capture the spatio-temporal dynamic characteristics, effectively mitigate the prediction error, and adaptively determine the optimal prediction moment, thereby significantly improving the timeliness and reliability of the prediction while ensuring the prediction accuracy.

[0195] The present invention inputs the real-time data samples collected by sensors into the model. The adaptive topology graph network is used as an encoder to extract data features, and the decoder is initialized with the output of the encoder. The reinforcement learning control module determines whether the current moment meets the condition of the optimal step length according to the network hidden state output by the decoder. If it meets, a prediction result is generated and used as the final prediction result, that is, the number of vehicles passing through each sensor area within a certain future time period. Through the above steps, the present invention can effectively improve the prediction accuracy and timeliness of traffic flow, especially when dealing with complex urban traffic data, showing higher prediction accuracy and flexibility than traditional methods.

[0196] It should be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant is intended to cover non-exclusive inclusion, so that an article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the article or device comprising said element. Similar words such as "connected" or "coupled" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The orientation or positional relationship indicated by "up", "down", "left", "right", etc. is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as a limitation on the present invention.

[0197] The above content is a further detailed description of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is only limited to these descriptions. For those of ordinary skill in the technical field to which the present invention pertains, without departing from the concept of the present invention, several simple deductions or substitutions can be made, and all should be regarded as belonging to the protection scope of the present invention.

Claims

1. A traffic flow adaptive prediction method based on a multi-time step graph, characterized in that Including: Obtain traffic sensor data, and respectively construct a distance graph, a time-varying edge-weight topological graph, and a multi-time-step graph to extract time features and spatial features respectively; Fuse the distance graph, the time-varying edge-weight topological graph, and the multi-time-step graph to obtain an adaptive topological graph, wherein the extracted time features and spatial features are encoded by using the adaptive topological graph as an encoder; Perform spatio-temporal embedding modeling on the encoded time features and spatial features to obtain comprehensive spatio-temporal features; Construct a decoder, decode the comprehensive spatio-temporal features through the decoder to obtain a preliminary prediction result, and use a trans-attention mechanism to weightedly fuse the feature information of the encoder and the decoder to establish a mapping relationship of spatio-temporal features between the encoder and the decoder; Through a reinforcement learning control module, adaptively determine the best prediction moment of each node in the adaptive topological graph, generate a prediction action vector, and obtain a prediction result according to the prediction action vector and the preliminary prediction result; Combine a performance loss function, a controller loss function, and an early loss function to obtain a weighted total loss function, optimize the training model, and output an accurate prediction result of traffic flow.

2. The traffic flow adaptive prediction method based on a multi-time-step graph according to claim 1, wherein The obtaining traffic sensor data, and respectively constructing a distance graph, a time-varying edge-weight topological graph, and a multi-time-step graph to extract time features and spatial features respectively, includes: Obtain traffic sensor data, where the traffic sensor data includes time information and spatial information; Construct a graph structure, where the graph structure contains several nodes; Quantify the spatial relationship between the nodes by using a distance matrix to generate a distance graph; Introduce self-loop connections to each node, and integrate the node information and its adjacent node information, and its expression is: Among them, is the output feature of the node after convolution fusion calculation based on the distance map; W d is a learnable weight matrix; H in is the input node feature; is the degree matrix, and the degree matrix is a diagonal matrix calculated according to the distance matrix, and the elements on its diagonal is the degree of node i, that is, the sum of the weights of the edges directly connected to node i; through perform normalization processing to balance the influence of the degree differences of different nodes on feature propagation; A s represents the correlation between nodes calculated based on distance; β1 and β2 are hyperparameters, which respectively represent the importance of the node's own feature and the feature of neighboring nodes in the output feature; Construct a time-varying edge-weight topological graph, and its expression is: Among them, is a time-varying edge-weight topological graph; the ReLU function is a function to ensure that the elements of the output matrix are non-negative values; the tanh function is a function to normalize the values of the matrix elements; α is a hyperparameter used to adjust the saturation of the activation function; X se is the dynamic embedding vector of the source node; X te is the dynamic embedding vector of the target node; is the transpose of the dynamic embedding vector of the target node; Use the dynamic time warping method to generate a multi-time-step graph to calculate the similarity between time series, and its expression is: Among them, is a multi-time step graph; DTW is the distance calculated by the similarity measure between traditional time series; the parameter κ is used to control the decay rate of the dynamic time warping distance.

3. The traffic flow adaptive prediction method based on a multi-time-step graph according to claim 1, wherein Fusing the distance graph, the time-varying edge-weight topological graph, and the multi-time-step graph to obtain an adaptive topological graph, includes: Fuse the distance graph and the time-varying edge-weight topological graph through a weighted fusion strategy, and its expression is: Among them, is the fused distance map and the time-varying edge-weighted topological map; is the degree matrix of the time-varying edge-weighted topological map; is the degree matrix of the distance map, which has been normalized; the entire weighted fusion process is adjusted by hyperparameters β1, β2, β3. β1, β2, β3 are all hyperparameters, representing the contribution degrees of self-loop connection, distance map, and time-varying edge-weighted topological map in the output feature representation respectively; I is the identity matrix; is the time-varying edge-weighted topological map at time t; Introduce a hyperparameter β4 to represent the contribution degree of the multi-time-step graph to the feature representation of the final fusion graph, and obtain an adaptive topological graph, and its expression is: where, H out is an adaptive topology graph; H t is the hidden state at time t.

4. The traffic flow adaptive prediction method based on a multi-time step graph according to claim 1, wherein Performing spatio-temporal embedding modeling on the encoded time features and spatial features to obtain comprehensive spatio-temporal features, includes: Use one-hot encoding to perform result conversion on the encoded time features and spatial features, and respectively generate a time embedding and a spatial embedding; Integrate the time embedding and the spatial embedding to obtain comprehensive spatio-temporal features, and its expression is: Among them, is the comprehensive spatio-temporal feature; is the spatial embedding; is the temporal embedding.

5. The traffic flow adaptive prediction method based on a multi-time step graph according to claim 1, characterized in that Construct a decoder, decode the comprehensive spatio-temporal features through the decoder to obtain a preliminary prediction result, and use a trans-attention mechanism to weightedly fuse the feature information of the encoder and the decoder to establish a mapping relationship of spatio-temporal features between the encoder and the decoder, includes: Construct a decoder, decode the comprehensive spatio-temporal features through the decoder to obtain a preliminary prediction result; Use a trans-attention mechanism to model the connection between the encoder and the decoder, and its expression is: Among them, ε i,t (t1, t2) is the attention score; e i,t′ is the spatio-temporal embedding processed by the ReLU activation function; both t1 and t2 are time nodes; W is the weight; b is the bias parameter; <·,·> is the vector inner product; is the scaling factor; The decoder performs a weighted sum of the hidden states at previous time points according to the attention scores, and its expression is: where \(t_2 = t,\ldots,T - 1\); \(\sigma(\cdot)\) is the sigmoid function; \(W\) h is the weight parameter of the network in the decoder; \(b\) h is the bias parameter; \(\varepsilon\) t is the attention score; is the hidden state at time \(t_1\).

6. The traffic flow adaptive prediction method based on a multi-time-step graph according to claim 1, wherein Through the reinforcement learning control module, adaptively determine the optimal prediction time for each node in the adaptive topology graph, generate a prediction action vector, and obtain a prediction result based on the prediction action vector and the preliminary prediction result, including: Through the reinforcement learning control module, adaptively determine the optimal prediction time for each node in the adaptive topology graph; Through the reinforcement learning control module, optimize the prediction policy based on the current state and the current policy, and its expression is: p t = σ(W c S t + b c ); a t = π(S t ); Among them, p t is the pause probability; W c is the weight parameter of the reinforcement learning control module; σ is the activation function; b c is the bias parameter of the reinforcement learning control module; S t is the current state; a t is the prediction action vector indicating the optimal prediction moment; π is the current policy; Element-wise multiply the prediction action vector by the non-linear transformation result of the hidden state to obtain the prediction result, and its expression is: Among them, is the prediction result; W p is the weight; b p is the bias parameter; is the decoder output hidden state for processing each time step t.

7. The traffic flow adaptive prediction method based on a multi-time-step graph according to claim 6, wherein If the predicted action vector of a certain node i is 0 at all time steps, the default best prediction time for this node is T - 1, and the prediction result is obtained 8. The traffic flow adaptive prediction method based on a multi-time-step graph according to claim 1, wherein Combine the performance loss function, the controller loss function, and the early loss function to obtain a weighted total loss function, optimize the training model, and output an accurate prediction result of traffic flow, including: Calculate the mean absolute error between the prediction result and the true value to obtain the performance loss function, and its expression is: Among them, L p is the performance loss function; N is the number of nodes; X T,i is the true value; Calculate the negative logarithm of the pause probability to obtain the early loss function, and its expression is: Among them, L e is the early loss function; For each node i, it is the best prediction time obtained by calculating through the policy π; Use the reward tensor to maximize the expected reward to improve the prediction accuracy, and obtain the controller loss function, and its expression is: Among them, L c is the controller loss function; E represents taking the expectation of the sub-expression within the parentheses; b t′ is the baseline; S t is the hidden state; r t ' is the updated reward; r is the overall reward; According to the performance loss function, the early loss function, and the controller loss function, obtain the weighted loss function through hyperparameters, and its expression is: L = L p + ω1L c + ω2L e ; where L is the weighted loss function; ω1 and ω2 are hyperparameters; Optimize the training model according to the weighted loss function to make the model training converge, and obtain the trained model and output an accurate prediction result of traffic flow.

9. An electronic device, comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the computer program, it implements the traffic flow adaptive prediction method based on a multi-time step graph according to any one of claims 1 to 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the traffic flow adaptive prediction method based on a multi-time step graph according to any one of claims 1 to 8.

Citation Information

Cited By

  • Internet of vehicles cooperative attack anomaly detection method and device

    CN120785662A