A method for intelligent prediction of highway traffic flow by fusing internet of things data
Patent Information
- Application Number
- CN202611089626.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-22
- Publication Date
- 2026-08-21
AI Technical Summary
当极端天气或突发事故造成交通流分布发生剧烈概念漂移时,模型此前学习的历史相关特征在异常干扰下预测准确率较低
1、通过引入连续时间图神经微分方程,将数据修复与时空特征学习融合为单一端到端框架,模型能够在连续时间隐空间中自然演化出缺失时间点的交通流特征,降低数据块状缺失导致的误差。
Smart Images

Figure CN122618809A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of IoT-based smart transportation technology, specifically to a method for intelligent prediction of highway traffic flow that integrates IoT data. Background Technology
[0002] Highway traffic flow prediction is a core function of intelligent transportation systems. Accurate traffic flow prediction results can provide important decision-making basis for traffic management departments to formulate traffic management strategies, optimize signal timing, and issue early warnings of road conditions.
[0003] Existing methods receive raw data from various IoT sensors and then perform static interpolation on missing observations of each road segment node. For example, Chinese patent CN115376309A (publication date: November 22, 2022) discloses a method for repairing missing traffic data based on multi-view temporal matrix decomposition. Commonly used methods include linear interpolation, mean imputation, and low-rank matrix decomposition. When the missing proportion is low and randomly distributed, linear interpolation is acceptable. However, when a road segment experiences block-like missing data for hundreds of consecutive time steps due to communication interruptions or regional equipment failures, mean imputation introduces static historical statistics rather than the actual dynamic traffic evolution at that time, and matrix decomposition cannot restore spatial propagation patterns due to severe rank deficiency. This results in a systematic deviation between the repaired data and the actual traffic conditions. Subsequent prediction models learn incorrect spatiotemporal dependencies based on this biased data, ultimately leading to a significant decrease in the accuracy of the output prediction data.
[0004] Existing spatiotemporal graph neural network models primarily use historical normal data during the training phase. The spatiotemporal correlations they learn are essentially statistical correlations, lacking causal relationships. For example, Chinese patent CN118966479A (publication date: November 15, 2024) discloses a traffic flow prediction method based on a multi-scale joint spatiotemporal hypergraph neural network. However, this method suffers from a sharp drop in sensor signal-to-noise ratio and drastic conceptual drift in traffic flow distribution when encountering extreme scenarios such as heavy rain, dense fog, or sudden traffic accidents. When extreme weather or sudden accidents cause drastic conceptual drift in traffic flow distribution, the historical correlation features previously learned by the model have low prediction accuracy under abnormal interference.
[0005] Based on this, the present invention designs an intelligent prediction method for highway traffic flow that integrates Internet of Things data to solve the above problems. Summary of the Invention
[0006] To address the aforementioned shortcomings of existing technologies, this invention provides a method for intelligent prediction of highway traffic flow that integrates Internet of Things (IoT) data.
[0007] To achieve the above objectives, the present invention is implemented through the following technical solution: A method for intelligent prediction of highway traffic flow integrating Internet of Things (IoT) data includes the following steps: Step S1: Collect heterogeneous data streams through loop detectors, millimeter-wave radar, GPS floating cars and weather stations, and perform anomaly detection on the heterogeneous data streams based on the moving average algorithm. Perform spatial matching on each road segment node, retain missing state data marked with mask vectors, and for block missing intervals with continuous missing duration exceeding the threshold, fuse the most recent effective observations of upstream and downstream nodes with the LWR traffic flow model to perform traffic flow physical propagation prior, generate physical prior completion values for block missing intervals, and obtain a heterogeneous dataset containing multimodal feature vectors, mask vectors and time offsets. Step S2: Based on the physical topology of the highway and the direction of traffic flow, construct the road network adjacency weight matrix. Input the directed adjacency weight matrix and the heterogeneous dataset into the continuous-time graph neural differential equation module. Parameterize the time derivative of the hidden state of each node through the graph attention network. Adaptively divide the subgraph and use a dynamic step-size ordinary differential equation solver to integrally evolve in the continuous-time domain, and output the traffic flow feature matrix after the reconstruction of each road segment node. Step S3: Concatenate the traffic flow feature matrix with the event signal to construct a state vector. The reinforcement learning agent outputs a gating decision based on the state vector and activates the normal prediction branch based on the gating decision. When the gating decision indicates an extreme scenario, the prediction is performed by the extreme scenario robust prediction branch. After verification by the physical constraint verification layer, the traffic flow prediction value is output.
[0008] Furthermore, anomaly detection is performed on the heterogeneous data stream based on weighted moving average; Hidden Markov Model map matching is performed on the GPS floating car data to align the geographic coordinates to the nearest road segment node, and the node is merged into the node-level feature table as the key; within the current processing window, the effective observation sequence, mask sequence, and time offset sequence of each node are arranged by timestamp; the road segment node corresponds to the road segment detection section with IoT sensing device, and the adjacency weight between nodes is calculated by the road distance using a Gaussian kernel function, and the weight of nodes exceeding the distance threshold is reset to zero.
[0009] Furthermore, the earliest valid observation record of each node within the current processing window is sent to the encoder, which consists of a two-layer fully connected network with a normalization layer, and the initial hidden state vector of each node is output. The initial hidden states of all nodes are stacked into a matrix as the initial value condition for solving the ordinary differential equation. When the size of the road network nodes exceeds the preset large-scale threshold, the hierarchical node clustering acceleration strategy is automatically switched to: the road network nodes are divided into several subgraph clusters according to traffic functional areas, and the interaction between the clusters is synchronized once at each fixed time step by cross-cluster directed attention. In each solution step of the ordinary differential equation, based on the current hidden state matrix and the road network adjacency weight matrix, the hidden state vector of each node is projected into the query vector and the key vector respectively. After calculating the dot product score, the time-varying attention weight is obtained by Softmax normalization. The value vectors of neighboring nodes are weighted and aggregated and self-connected terms are added. After ELU activation, the time derivative of the hidden state of each node is obtained. The dynamic step-size ordinary differential equation solver uses the Dormand-Prince method. After integration, the hidden state matrix of all nodes is fed into the decoder, which consists of a two-layer fully connected network, and the reconstructed traffic flow feature matrix is output.
[0010] Furthermore, it consists of a weighted sum of reconstruction loss and prediction task supervision loss, where reconstruction loss is the mean square error between the model output and the true observation, and prediction task supervision loss is the mean absolute error between the prediction branch output and the true future flow. The gradient is backpropagated through the adjoint state method to achieve end-to-end parameter updates via the frequent differential equation solver.
[0011] Furthermore, based on the macroscopic fundamental graph physics equations, the free flow velocity and congestion density parameters of each road segment node are pre-calibrated. The predicted flow value is checked node by node and time step by step to see if it meets the physical feasible region constraint. The predicted value that exceeds the feasible region is truncated to the flow peak value of the corresponding node determined by the free flow velocity and congestion density. The sum of the default magnitudes is accumulated as the physical default penalty term and fed back to the reward function of the reinforcement learning agent.
[0012] Furthermore, the reinforcement learning agent is trained based on a proximal policy optimization algorithm; the state vector is formed by concatenating a road network-level feature summary vector obtained by global mean pooling of the reconstructed feature matrix along the node dimension with meteorological and event signal vectors containing the average visibility of the road network, rainfall intensity level, and proportion of accident alarm nodes; the reward function is composed of a weighted sum of the negative value of the prediction mean absolute error and the physical default penalty term; the policy network consists of two fully connected layers plus a Softmax output layer, with ReLU as the activation function; the policy network updates its parameters once after accumulating trajectory data for a preset time step, and the advantage estimation adopts the generalized advantage estimation method.
[0013] Furthermore, the normal prediction branch is a spatiotemporal attention network. It takes the reconstructed feature matrix as input, and after alternating stacking of spatial self-attention layer and temporal causal attention layer, it projects the predicted value of future multi-step traffic flow through a fully connected layer. The spatial self-attention layer performs multi-head attention in the node dimension, and the temporal causal attention layer performs masked multi-head attention in the time step dimension.
[0014] Furthermore, the extreme scenario robust prediction branch is a causal invariant network. The feature extractor is trained using the invariant risk minimization criterion. The training set is divided into four environmental subsets according to weather conditions and accident indicators: no accidents on sunny days, no accidents on rainy days, accidents on sunny days, and accidents on extreme weather days. The prediction loss and gradient penalty on all environmental subsets are jointly optimized so that the feature extractor retains only causally stable features in all environments. After training converges, the feature extractor parameters are fixed, and the output projection layer is fine-tuned only during the online training phase of the reinforcement learning agent.
[0015] Furthermore, the data sensing access layer is used to collect heterogeneous data streams from coil detectors, millimeter-wave radar, GPS floating cars and weather stations, perform spatial matching on nodes of each road segment, retain missing states marked with mask vectors, and construct heterogeneous datasets. The core algorithm processing layer includes a continuous-time graph neural differential equation module and a causal reinforcement learning dynamic routing module. The continuous-time graph neural differential equation module is used to parameterize the time derivatives of the hidden states of each node by the graph attention network, and then integrates and evolves them in the continuous time domain through an adaptive step-size ordinary differential equation solver to output a reconstructed feature matrix. The causal reinforcement learning dynamic routing module is used to output gating decisions based on the state vector to activate the corresponding prediction branches, and outputs traffic flow prediction values after verification by the physical constraint verification layer. The prediction service output layer is used to send the predicted values to the traffic management platform; The system adopts a cloud-edge collaborative architecture. Edge computing nodes deploy a continuous-time graph neural differential equation inference engine and a normal prediction branch in ONNX format, while the cloud cluster deploys a reinforcement learning agent training module and an extreme scenario robust prediction branch, and periodically distributes model weights to edge nodes in a differential update manner.
[0016] Furthermore, the heterogeneous data streams reported in real time by IoT sensing devices are aggregated through the message middleware and first enter the adaptive data reconstruction module to complete the feature reconstruction in the continuous time domain. Then, the reconstructed latent state features are passed to the causal reinforcement learning dynamic routing module, where RLAgent determines to activate the normal prediction branch or the extreme scenario robust branch based on the current scenario state, and finally outputs the traffic flow prediction values for multiple future time steps.
[0017] Compared with the prior art, the beneficial effects of this invention are as follows: 1. By introducing continuous-time graph neural differential equations, data repair and spatiotemporal feature learning are integrated into a single end-to-end framework. The model can naturally evolve traffic flow features at missing time points in the continuous-time latent space, reducing the error caused by missing data blocks.
[0018] 2. By establishing a causal reinforcement learning dynamic routing mechanism that integrates physical constraints, the model automatically activates a robust prediction branch with causal invariance in extreme weather or sudden accident scenarios, effectively eliminating the interference of spurious correlation features and controlling the prediction error in extreme scenarios within the theoretical boundary allowed by physical constraints, thus solving the problem of prediction performance degradation. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.
[0020] Figure 1 This is a flowchart of the present invention; Figure 2 This is a flowchart of the continuous-time graph neural differential equation module algorithm of the present invention; Figure 3 This is a flowchart of the causal reinforcement learning dynamic routing algorithm of the present invention; Figure 4 This is a diagram of the cloud-edge collaborative deployment architecture of the present invention. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0022] Example 1: Figure 1 The overall architecture diagram of this invention is given. A method for intelligent prediction of highway traffic flow integrating Internet of Things data includes the following steps: Step S1: Collect heterogeneous data streams through loop detectors, millimeter-wave radar, GPS floating cars and weather stations, and perform anomaly detection on the heterogeneous data streams based on the moving average algorithm. Perform spatial matching on each road segment node, retain missing state data marked with mask vectors, and for block missing intervals with continuous missing duration exceeding the threshold, fuse the most recent effective observations of upstream and downstream nodes with the LWR traffic flow model to perform traffic flow physical propagation prior, generate physical prior completion values for block missing intervals, and obtain a heterogeneous dataset containing multimodal feature vectors, mask vectors and time offsets. Step S1 includes the following steps: The data sensing access layer is responsible for unifying the access of multi-source heterogeneous IoT data to the system. Coil detectors report binary pulse streams to the Kafka message queue via 4G / 5G links; millimeter-wave radar reports 3D point cloud frame data encapsulated in JSON format to Kafka; GPS floating cars report text messages containing latitude, longitude, speed, and timestamps via the MQTT protocol; and weather stations forward data to Kafka via the edge gateway using the Modbus / TCP protocol.
[0023] The system deploys a lightweight data alignment preprocessor on edge computing nodes. This preprocessor performs the following operations: spatial matching of each data stream by road segment node number; for GPS floating car data, it first performs Hidden Markov Model map matching to align the geographic coordinates to the nearest road network node, and merges them into the node-level feature table using that node as the key; it records the receiving timestamp for each data stream, but does not perform any interpolation, and fills in missing states by explicitly masking them. For block-shaped missing intervals with a continuous missing duration exceeding a threshold, physical completion is performed by integrating the most recent effective observations from upstream and downstream nodes with the LWR traffic flow model: extracting the most recent effective observations from upstream and downstream; loading pre-calibrated LWR model parameters; and calculating the flow evolution within the block-shaped missing interval based on the propagation law of traffic flow waves.
[0024] For each node At any moment The system maintains a heterogeneous dataset for observation. ,in: For multimodal feature vectors, dimension It is composed of coil current, radar speed, GPS density, and meteorological characteristics. This is the corresponding observation mask vector, where an element of 1 indicates that the observation in that dimension is valid, and an element of 0 indicates that it is missing. This is the time offset of the observation relative to the start of the current prediction window, in seconds.
[0025] Step S2: Construct a road network adjacency weight matrix based on the road physical topology and traffic flow direction. Input the directed adjacency weight matrix and the heterogeneous dataset into the continuous-time graph neural differential equation module. Parameterize the time derivative of the hidden state of each node through a graph attention network. Adaptively divide the subgraph and use a dynamic step-size ordinary differential equation solver to integrally evolve in the continuous-time domain, outputting the traffic flow feature matrix after reconstruction of each road segment node.
[0026] Step S2 includes the following steps: Step 2.1: Abstract the highway network into a weighted directed graph. ,in: For a set of nodes, Each node corresponds to a road segment detection section equipped with an IoT sensing device. Let edge be a set representing the physical connectivity between road segments. This is an adjacency weight matrix, with elements... By node With nodes The road distance between them was calculated using the Gaussian kernel function:
[0027] in, For nodes in the adjacency weight matrix For nodes Influence weight, For nodes With nodes The distance between the road networks, in meters. This is the Gaussian kernel bandwidth parameter, in meters, which controls the rate at which the weights decay with distance. This is a distance threshold in meters. Nodes exceeding this threshold have their weights reset to zero. This is an indicator function.
[0028] Step 2.2, Encoder Map the valid observations to the initial hidden state:
[0029] in, This is element-wise multiplication, used to mask missing dimensions. For nodes exist The initial hidden state vector at time t. For hidden state dimensions; It consists of two fully connected network layers plus a normalization layer. for Node at Multimodal feature vectors at time step for Node at The mask vector at each time step. When a node has no data within the current window, it is replaced with a vector of all zeros as the initial hidden state. The initial hidden states of all nodes are stacked into a matrix. , as the initial value condition for solving the ordinary differential equation.
[0030] Step 2.3, the core of CT-GNDE is to parameterize the time derivative of the hidden state using a graph neural network, so that the hidden states of all nodes evolve collaboratively on a continuous time axis, such as... Figure 2 As shown. Its dynamic equation is:
[0031] in, For a moment The hidden state matrix of all nodes, with each row corresponding to a node; For The graph attention network function has parameters. The graph attention aggregation formula is:
[0032] in, For nodes The set of neighboring nodes, For a moment node For nodes The attention weights are determined by the query vector. With key vector dot product score The query vector and key vector are obtained by linear projection of the current hidden state vector after Softmax normalization. The value transformation matrix, It is a self-connected transformation matrix. This is the ELU activation function.
[0033] From the initial moment Target time The above equation is integrated using an adaptive step-size ordinary differential equation solver:
[0034] When the size of the road network nodes exceeds the preset large-scale threshold, switch to the hierarchical node clustering acceleration strategy: divide the road network nodes into several subgraph clusters according to traffic functional areas, and synchronize the interaction between clusters with cross-cluster directed attention once at each fixed time step, and output the traffic flow feature matrix after the reconstruction of each road segment node.
[0035] The solver employs the Dormand-Prince fourth- or fifth-order adaptive step size method, with an absolute error tolerance threshold set to... The relative error tolerance threshold is set to Within each adaptive step size, the difference between the fourth-order and fifth-order estimates is compared. If the error exceeds the tolerance threshold, the step size is automatically reduced and the calculation is recalculated to ensure integration accuracy. Since the evolution process takes place in the continuous time domain, regardless of which discrete time points the missing values occur at, the model can naturally complete the hidden states at the missing time points using the gradient information of available observations and the spatial dependencies of graph neighbors, without any explicit interpolation operations.
[0036] The hidden state matrix of all nodes at the target time. The signal is fed into a decoder consisting of two fully connected layers. Output the reconstructed traffic flow feature matrix ,in For feature dimension, It serves as input for the subsequent causal reinforcement learning dynamic routing module.
[0037] Step 2.4 Figure 2 This is a flowchart of the continuous-time graph neural differential equation module algorithm of the present invention, showing the training loss of the continuous-time graph neural differential equation module. It consists of two parts:
[0038] in, To account for the reconstruction loss of effective observation points, the mean square error between the model output and the true observations is calculated, only in the mask. Accumulate across dimensions, The supervision loss for the downstream forecasting task consists of the mean absolute error between the forecasting branch output and the actual future flow. The equilibrium coefficient is set to 0.2. The gradient is backpropagated through the adjoint state method to the frequent differential equation solver, achieving solution for all parameters. End-to-end updates.
[0039] Step S3: Concatenate the traffic flow feature matrix with the event signal to construct a state vector. The reinforcement learning agent outputs a gating decision based on the state vector and activates the normal prediction branch based on the gating decision. When the gating decision indicates an extreme scenario, the prediction is performed by the extreme scenario robust prediction branch. After verification by the physical constraint verification layer, the traffic flow prediction value is output.
[0040] Step S3 includes the following steps: Figure 3 This is a flowchart of the causal reinforcement learning dynamic routing algorithm of the present invention.
[0041] Step 3.1: Describe the traffic flow of road segments using a macro-level basic map. (vehicles / hour), density (vehicles / km) and speed The fundamental physical conservation relationships among the three (km / h):
[0042] in, Free-flow speed, which is the design speed of the road segment under uncongested conditions, is expressed in kilometers per hour. Here, congestion density refers to the maximum number of vehicles per kilometer that a road segment can accommodate when it is completely congested, expressed in vehicles per kilometer. Combining the two equations, we obtain the physical constraint on flow rate with density as the independent variable:
[0043] The system pre-calibrates each road segment node. and The parameters are embedded as physical priors into a physical constraint verification layer. This layer verifies whether the prediction results satisfy the above constraints after output; if a default is found, it is truncated and corrected using the boundary values of the macroscopic basic graph, and the degree of default is fed back to RLAgent as a negative reward. Node Macro basic diagram of peak flow for:
[0044] in, For nodes free flow velocity, For nodes The blocking density. For nodes Predicting time steps Traffic forecast If it exceeds the peak value Then it is truncated to and the cumulative default range To the penalty items for breach of contract .
[0045] Step 3.2: RLAgent is trained based on the near-end policy optimization algorithm, such as... Figure 4 As shown. Its input state It consists of two parts: one part is the road network feature summary output by CT-GNDE, which is used to reconstruct the feature matrix. Perform global mean pooling along the node dimension to obtain The other part consists of meteorological and event IoT signal vectors. This includes average visibility across the road network, rainfall intensity level, snow depth, and the proportion of accident warning nodes. Scalar features. Concatenated to obtain the input state vector. .
[0046] Policy Network by The input consists of two fully connected layers with a hidden layer dimension of 256, using the ReLU activation function, and a softmax output layer. The output is the discrete probability distribution of the gating decision. Among them, gating decision A value of 0 indicates activation of the normal prediction branch, while a value of 1 indicates activation of the robust prediction branch for extreme scenarios. During the training phase, gating decisions are sampled using this probability; during the inference phase, the decision with the highest probability is selected as the deterministic output.
[0047] The reward function is designed as follows:
[0048] in, For the model at time The output predicted flow vector, For the corresponding actual traffic vector, The mean absolute error, For physical breach of contract penalties, The penalty coefficient is set to 2.0, which is used to balance the target of prediction accuracy with the target of physical constraints.
[0049] The PPO algorithm maintains an old strategy. To maximize the expected cumulative reward by pruning the objective function:
[0050] in, This represents the probability ratio between the old and new strategies. For generalized advantage estimation, The hyperparameter is set to 0.2 to prune the network. The strategy network parameters are updated every 512 time steps of trajectory data.
[0051] Step 3.3: The normal prediction branch employs a spatiotemporal attention network to reconstruct the feature matrix. As input, the system alternately stacks spatial self-attention layers and temporal causal attention layers to fully model the spatiotemporal correlations in normal traffic scenarios. The output, a predicted hidden layer representation, is then projected onto the future data through a fully connected layer. Step-by-step traffic forecast .
[0052] Step 3.4: The robust prediction branch for extreme scenarios employs a causal invariant network. Its core design idea is to intervene with environmental variables, grouping the training set into multiple environmental subsets based on weather conditions and accident indicators. The feature extractor is trained using the invariant risk minimization criterion, ensuring it retains only causally stable features across all environments and eliminates spurious features generated by extreme events.
[0053] The training objective function for CIN is:
[0054] in, For feature extractors with shared parameters, This is a virtual scalar classifier, fixed at 1, used only for calculating gradient penalties. For the training environment set, each environment Corresponding to a type of scenario conditions; In the environment The predicted loss is as follows. As an IRM penalty term, it encourages features that are sufficiently causal invariant in all environments. This is used to penalize the hyperparameter of intensity. After training converges, The extracted features retain causal stability even in extreme scenarios and can output robust predictions. .
[0055] During the offline training phase before system deployment, historical data was divided into four environmental subsets based on weather conditions and accident indicators: sunny days with no accidents, rainy days with no accidents, sunny days with accidents, and extreme weather with accidents. The loss and gradient penalty for all environments were jointly optimized using the IRM criterion to train the feature extractor. After the causal invariant network was trained, its parameters were fixed, with fine-tuning only performed on the output projection layer during the online training phase of RLAgent.
[0056] Figure 4 This is a diagram of the cloud-edge collaborative deployment architecture of the present invention. The present invention adopts a three-layer system deployment architecture of cloud-edge collaboration: Edge computing nodes undertake routine real-time prediction tasks at the millisecond to second level: the CT-GNDE inference engine is exported in ONNX format and the spatiotemporal attention network of the routine prediction branch is deployed on the roadside edge server to achieve real-time traffic prediction for local road segments, with end-to-end inference latency controlled within 100 milliseconds.
[0057] The cloud cluster undertakes the following tasks: periodically receiving raw IoT data streams uploaded by each edge node and performing complete streaming calibration of CT-GNDE; continuously running online training of RLAgent and updating the policy network parameters based on the latest real traffic feedback; when RLAgent makes decisions indicating extreme scenarios, the cloud cluster calls the causal invariant network to perform inference and sends the results to the control terminal of the corresponding road segment via a low-latency dedicated line. Model weights are periodically distributed to each edge node by the cloud cluster in a differential update manner to achieve continuous iterative optimization of the model.
[0058] Example 2: An experimental case of an intelligent prediction method for highway traffic flow integrating IoT data: We selected Shenjiaqiao Second Road and its upstream and downstream sections in Weiyang District, Xi'an City (latitude and longitude range: 108.885°E\108.900°E, 34.175°N\34.185°N) and collected multi-source heterogeneous data streams during the morning rush hour from 8:00 to 10:00 on September 6, 2024.
[0059]
[0060] For the time series data of each detector, a sliding window moving average algorithm is used for anomaly detection to identify abnormal data such as sensor impulse noise.
[0061] The sliding window size is set to 4 time steps (corresponding to 8 minutes of historical observation data), and for each time step... Calculate the mean of the data within the window. and standard deviation ,by The range is considered normal; data outside this range are marked as outliers.
[0062] The raw traffic flow data from the target road segment loop detector at 8:12 was 102 veh / 2 min. The historical traffic flows for the previous four time periods (8:04-8:10) were 51, 53, 52, and 53, respectively. Calculations yielded: Moving average Standard deviation Normal range: The original value of 102 is outside the normal range and is determined to be an abnormal detector pulse noise. The abnormal value is corrected using a moving average of 52.3.
[0063] Spatiotemporal alignment of observations from heterogeneous data sources is performed to match observations from different sources to a unified road network node.
[0064] GPS trajectory map matching: The Hidden Markov Map matching algorithm is used to match the original trajectory points of the floating car to the road network segments. The spatial alignment error is reduced from the original 5.8m to 0.9m, and the temporal alignment jitter is compressed from ±2.4s to ±120ms.
[0065] Radar detection range projection: The detection range of the millimeter-wave radar is spatially projected and matched to the upstream node N036 and the target node N037 to clarify the road segment coverage.
[0066] Meteorological data regional matching: Matching the regional observation data of meteorological stations to all road segment nodes within that region as global environmental features.
[0067] Missing data is detected after matching. The missing duration threshold is set to 15 minutes (7 time steps). Missing data is divided into single-point missing data and block missing data and processed separately.
[0068] Target node N037 has a single missing data point at 8:15, with a missing duration of only 2 minutes, which is less than the threshold. At this time, this position is marked as missing only by a mask vector with a mask value of 0, while normal observations are marked as 1. The missing state is preserved for subsequent autonomous learning by the model.
[0069] Due to a transmission link failure, the loop detector at target node N037 experienced a continuous loss of 40 time steps from 8:20 to 9:40, totaling 80 minutes, exceeding the missing threshold and constituting a typical block-shaped missing interval. The missing time steps were filled by combining effective observations from upstream and downstream nodes with the LWR traffic flow model.
[0070] LWR Model Parameter Learning: By using historical observation data from upstream and downstream nodes, a computational graph method is employed to learn the basic traffic flow parameters for this road segment, resulting in: free-flow velocity. Blocking density .
[0071] Spatiotemporal propagation alignment: Based on the traffic flow propagation patterns of the LWR model, the propagation time from upstream to downstream observation of the target road segment is calculated: the distance from upstream N035 to target N037 is 2.1km, and the propagation time is... Minutes, the distance from downstream N038 to target N037 is 1.4km, and the backpropagation time is... minute.
[0072] Evolutionary Completion of Conservation Equations: Based on LWR Conservation Equations Combined with basic diagram The flow, density, and velocity of the missing intervals are continuously calculated to fill in the missing data.
[0073]
[0074] The completed data was compared with the actual observations after subsequent detector repair. The mean absolute error was 1.2veh / 2min, and the relative error was only 3.2%, which verified the effectiveness of the completion method.
[0075] After final processing, a heterogeneous dataset that meets the requirements is generated, containing three core parts: Multimodal feature vector: 2-minute granular features for each road segment node, totaling 8 dimensions, including: coil flow, occupancy rate, vehicle speed, radar average vehicle speed, GPS floating car average vehicle speed, and meteorological temperature, humidity, and air pressure.
[0076] Mask vector: A 1-dimensional binary vector that marks the state at each time step. 1 indicates a normal observation and 0 indicates a missing value (including single-point missing and block missing). It is used by the subsequent model to distinguish between observed values and imputed values.
[0077] Time offset: Records the offset between the original observations from each data source and the unified time axis, which is used for time calibration of the subsequent continuous time plot neural differential equation module.
[0078] The regional road network comprises 6 road segment nodes, with details as follows:
[0079] Based on the physical topology of highways and traffic flow direction, a directed adjacency weight matrix that integrates geographical distance and traffic flow semantics is constructed: Based on the actual traffic flow direction, the directed edges are defined as follows: Main road direction: N035→N036, N036→N037, N037→N038 Branch road direction: N037→N039 (exit), N040→N037 (entrance).
[0080] Geographic weight: Based on the road segment length, the weight is the reciprocal of the distance between nodes, and the closer the distance, the greater the weight.
[0081] Semantic weight: Based on the sparse dynamic time warping (SDTW) similarity of historical traffic sequences, it captures the association between functionally similar nodes. For example, the traffic trend similarity between N035 and N038 is 0.78.
[0082] The geographic weights and semantic weights are linearly fused to obtain the final directed adjacency weight matrix:
[0083] Note: 0 indicates no direct connection.
[0084] Input the heterogeneous dataset processed in step S1 into the continuous-time graph neural differential equation module. The input data includes: Multimodal features: 8-dimensional node features (coil flow, occupancy rate, vehicle speed, radar vehicle speed, GPS vehicle speed, meteorological temperature, humidity, and air pressure); mask vector: a binary vector marking missing states; time offset: time calibration offset for each data source; initial hidden state: encoding the input features into a 64-dimensional initial hidden state vector. , .
[0085] A graph attention network (GAT) is used to parameterize the time derivatives of the hidden states of each node, thereby achieving adaptive modeling of spatiotemporal dependencies.
[0086] For each node, calculate the attention weights of its neighboring nodes to capture the degree of influence of different nodes on the evolution of the current state: The neighbor attention weights of target node N037 are: N036 (0.68), N040 (0.22), and N038 (0.10). This indicates that upstream main road nodes have the greatest impact on the state evolution of the target road segment, followed by branch road entrances, and downstream nodes have the least impact. The output of the graph attention network is used as the time derivative of the hidden state:
[0087] Among them, for The hidden state of a node at a given time. It is a directed adjacency weight matrix. for The network parameters. This method transforms discrete graph convolution operations into continuous state evolution rules.
[0088] To improve computational efficiency and accuracy, an adaptive subgraph partitioning and a dynamic step-size ordinary differential equation solver are employed. Based on the current traffic flow status, the road network is adaptively divided into two subgraphs: the main road subgraph (including N035, N036, N037, and N038), where traffic flow changes drastically during the morning rush hour and requires more refined calculations; and the secondary road subgraph (including N039 and N040), where traffic flow changes more gradually and the computational granularity can be appropriately increased. The subgraph partitioning is dynamically adjusted over time; for example, during off-peak hours, subgraphs are merged into a single subgraph to improve efficiency.
[0089] The Dormand-Prince adaptive step size solver is used to dynamically adjust the integration step size according to the rate of change of traffic flow.
[0090]
[0091] During the solution process, a time alignment mechanism is used to automatically update the graph structure at each integration step, ensuring the synchronization between the graph topology and traffic status, and avoiding the time mismatch problem of traditional fixed step size models.
[0092] Starting from the initial time of 8:00, the hidden state is integrally evolved in the continuous time domain until the target time of 10:00, and finally the traffic flow feature matrix of each road segment node is output.
[0093] Example of reconstruction results
[0094] Comparison of reconstructed features with subsequent real observations: The mean absolute error (MAE) is 1.1 veh / 2 min, and the relative error is only 2.9%, which is 3.6% lower than the traditional discrete-time graph model, consistent with the experimental results of the AGNODE model on the PeMS dataset. The computational efficiency is improved by 27% compared to the fixed-step model, significantly reducing inference time while maintaining accuracy. The reconstructed traffic flow feature matrix will be used as input for subsequent gating prediction branch decisions.
[0095] On September 6, 2024, during the morning rush hour, at 8:30 AM, a minor traffic accident occurred on the target road section N037, blocking one lane of the road and temporarily reducing the traffic capacity of the section. This was a typical extreme and sudden scenario. The event signal was captured in real time by the traffic control platform and recorded as an abnormal event input.
[0096] The output reconstructed traffic flow feature matrix is concatenated with the real-time event signal to construct the state vector of the reinforcement learning agent:
[0097] The final concatenation yields a 72-dimensional state vector, which is then input into the reinforcement learning agent for gating decisions.
[0098] The DoubleDQN reinforcement learning agent was trained based on 1200 hours of historical traffic data and is responsible for outputting gating decisions based on the state vector.
[0099] The agent learns scene classification strategies for different states and outputs a gating signal of 0 (normal scene) or 1 (extreme scene): 8:00-8:30: No abnormal event signal in the state vector, the agent outputs gating signal 0 with a confidence level of 0.98, classifying it as a normal scene; 8:30: After an event signal is input, the KL divergence of the state vector jumps from 0.12 to 0.41, the agent outputs gating signal 1 with a confidence level of 0.92, classifying it as an extreme scene; 9:15: The incident is handled, the event signal is cleared, and the agent automatically switches back to gating signal 0, resuming normal decision-making. The agent's decision accuracy reaches 93.7% on the real test set.
[0100] Based on the gating decision, the corresponding prediction branch is automatically activated.
[0101] During the normal traffic flow period from 8:00 to 8:30, the normal prediction branch is activated. This branch, based on the continuous-time graph neural differential equation model in step S2, predicts the normal traffic flow.
[0102] This branch has a prediction MAE of 1.1veh / 2min under normal conditions, with a relative error of only 2.9%, which is consistent with the reconstruction accuracy of the preceding steps.
[0103] During the extreme period of 8:30-9:15, the robust prediction branch for extreme scenarios is activated. This branch uses an online transfer learning model, which is trained based on more than 1,200 extreme scenario samples of traffic accidents and large-scale events across the country.
[0104] Samples from extreme scenarios such as the collapse of Shenyang Railway Station Front Street and the end of G.E.M.'s concert were transferred to the current scenario using TrAdaBoost, with a training time of only 8 minutes.
[0105] Based on the number of lanes occupied by the accident, the instantaneous capacity of the target road section N037 will be adjusted from 1800 pcu / h to 1200 pcu / h.
[0106] Predict the reverse propagation of the congestion shockwave caused by the accident and output the traffic status for the next 15 minutes:
[0107] This branch achieves a prediction MAE of 2.3veh / 2min in extreme scenarios with a relative error of only 8.7%, which is far superior to the 46% error of the traditional single model and is basically consistent with the actual results in the Shenyang extreme scenario.
[0108] The output of the prediction branch is validated by a physical constraint verification layer to ensure that the prediction results conform to the physical laws of traffic flow.
[0109] Verify whether the predicted traffic volume exceeds the instantaneous capacity of the road segment. For example, if the initial predicted traffic volume of extreme branch N037 is 32veh / 2min, which exceeds the current remaining capacity of 30veh / 2min, it will be automatically corrected to 30veh / 2min.
[0110] Verify whether the predicted speed conforms to the road speed limit and basic map constraints. For example, if the initial predicted speed of N036 is 8 km / h, which is lower than the minimum congestion speed of 10 km / h, it will be automatically corrected to 10 km / h.
[0111] Flow conservation constraint: Verify whether the inflow and outflow of the node are conserved. For example, if the initial prediction of the inflow of N037 is 45veh / 2min and the outflow is 28veh / 2min, and the difference is too large, the upstream queuing flow will be automatically adjusted to ensure conservation.
[0112] Basic graph constraints: Verify whether the flow-density-speed curve conforms to the Greenshields basic graph to avoid outliers that do not conform to traffic flow patterns.
[0113] During the verification process, three abnormal prediction values that did not conform to physical laws were corrected to ensure that the final output result was physically feasible.
[0114] After verification, the final traffic flow prediction value is output, fully covering both normal and extreme scenarios during the morning rush hour.
[0115]
[0116] The results show that the dual-branch gating prediction model can maintain high accuracy in both normal and extreme scenarios. In particular, in extreme scenarios of sudden accidents, the error is reduced by 81.1% compared with the traditional model, effectively solving the problem of prediction failure of the traditional model in extreme scenarios.
[0117] The final prediction results will provide a reliable basis for traffic management decisions, such as issuing congestion warnings in advance and guiding vehicles to detour via secondary roads N039 and N040 to alleviate congestion on the target road sections.
[0118] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions will not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for intelligent prediction of highway traffic flow integrating Internet of Things (IoT) data, characterized in that, The method includes: Step S1: Collect heterogeneous data streams through loop detectors, millimeter-wave radar, GPS floating cars and weather stations, and perform anomaly detection on the heterogeneous data streams based on the moving average algorithm. Perform spatial matching on each road segment node, retain missing state data marked with mask vectors, and for block missing intervals with continuous missing duration exceeding the threshold, fuse the most recent effective observations of upstream and downstream nodes with the LWR traffic flow model to perform traffic flow physical propagation prior, generate physical prior completion values for block missing intervals, and obtain a heterogeneous dataset containing multimodal feature vectors, mask vectors and time offsets. Step S2: Construct a road network adjacency weight matrix based on the road physical topology and traffic flow direction. Input the road network adjacency weight matrix and the heterogeneous dataset into the continuous-time graph neural differential equation module. Parameterize the time derivative of the hidden state of each node through a graph attention network. Adaptively divide the subgraph and use a dynamic step-size ordinary differential equation solver to integrally evolve in the continuous-time domain, outputting the traffic flow feature matrix after the reconstruction of each road segment node. Step S3: Concatenate the traffic flow feature matrix with the event signal to construct a state vector. The reinforcement learning agent outputs a gating decision based on the state vector and activates the normal prediction branch based on the gating decision. When the gating decision indicates an extreme scenario, the prediction is performed by the extreme scenario robust prediction branch. After verification by the physical constraint verification layer, the traffic flow prediction value is output.
2. The intelligent prediction method for highway traffic flow integrating IoT data according to claim 1, characterized in that, In step S1, the method of performing spatial matching on each road segment node, performing anomaly detection on the heterogeneous data stream based on weighted moving average, and retaining missing state data marked with a mask vector specifically includes: Anomaly detection is performed on the heterogeneous data stream based on weighted moving average; Hidden Markov Model map matching is performed on the GPS floating car data to align the geographic coordinates to the nearest road segment node, and the node is merged into the node-level feature table as the key; within the current processing window, the effective observation sequence, mask sequence, and time offset sequence of each node are arranged by timestamp; the road segment node corresponds to the road segment detection section with IoT sensing device, and the adjacency weight between nodes is calculated by the road distance using a Gaussian kernel function, and the weight of nodes exceeding the distance threshold is reset to zero.
3. The intelligent prediction method for highway traffic flow integrating Internet of Things data according to claim 1, characterized in that, In step S2, the solution method for the continuous-time graph neural differential equation module specifically includes: The earliest valid observation record of each node within the current processing window is sent to the encoder, which consists of a two-layer fully connected network with a normalization layer. The initial hidden state vector of each node is output, and the initial hidden states of all nodes are stacked into a matrix as the initial value condition for solving the ordinary differential equation. When the size of the road network nodes exceeds the preset large-scale threshold, the hierarchical node clustering acceleration strategy is automatically switched to: the road network nodes are divided into several subgraph clusters according to traffic functional areas, and the interaction between the clusters is synchronized once at each fixed time step by cross-cluster directed attention. In each solution step of the ordinary differential equation, based on the current hidden state matrix and the road network adjacency weight matrix, the hidden state vector of each node is projected into the query vector and the key vector respectively. After calculating the dot product score, the time-varying attention weight is obtained by Softmax normalization. The value vectors of neighboring nodes are weighted and aggregated and self-connected terms are added. After ELU activation, the time derivative of the hidden state of each node is obtained. The dynamic step-size ordinary differential equation solver uses the Dormand-Prince method. After integration, the hidden state matrix of all nodes is fed into the decoder, which consists of a two-layer fully connected network, and the reconstructed traffic flow feature matrix is output.
4. The intelligent prediction method for highway traffic flow integrating Internet of Things data according to claim 1, characterized in that, In step S2, the training loss of the continuous-time graph neural differential equation module specifically includes: It consists of a weighted sum of reconstruction loss and prediction task supervision loss, where reconstruction loss is the mean square error between the model output and the true observation, and prediction task supervision loss is the mean absolute error between the prediction branch output and the true future flow. The gradient is backpropagated through the adjoint state method to achieve end-to-end parameter updates via the frequent differential equation solver.
5. The intelligent prediction method for highway traffic flow integrating Internet of Things data according to claim 1, characterized in that, In step S3, the verification method of the physical constraint verification layer specifically includes: Based on the macroscopic fundamental graph physics equations, the free flow velocity and congestion density parameters of each road segment node are pre-calibrated. The predicted flow value is checked node by node and time step by step to see if it meets the physical feasible region constraint. The predicted value that exceeds the feasible region is truncated to the flow peak value of the corresponding node determined by the free flow velocity and congestion density. The sum of the default magnitudes is accumulated as the physical default penalty term and fed back to the reward function of the reinforcement learning agent.
6. The intelligent prediction method for highway traffic flow integrating Internet of Things data according to claim 1, characterized in that, In step S3, the reinforcement learning agent specifically includes: The reinforcement learning agent is trained based on a proximal policy optimization algorithm; the state vector is formed by concatenating a road network-level feature summary vector obtained by global mean pooling of the reconstructed feature matrix along the node dimension with meteorological and event signal vectors containing the average visibility of the road network, rainfall intensity level, and proportion of accident alarm nodes; the reward function is composed of a weighted sum of the negative value of the prediction mean absolute error and the physical default penalty term; the policy network consists of two fully connected layers plus a Softmax output layer, with ReLU as the activation function; the policy network updates its parameters once after accumulating trajectory data for a preset time step, and the advantage estimation adopts the generalized advantage estimation method.
7. The intelligent prediction method for highway traffic flow integrating Internet of Things data according to claim 1, characterized in that, In step S3, the solution method for the normal prediction branch specifically includes: The normal prediction branch is a spatiotemporal attention network. It takes the reconstructed feature matrix as input, and after alternating stacking of spatial self-attention layer and temporal causal attention layer, it projects the future multi-step traffic flow prediction value through a fully connected layer. The spatial self-attention layer performs multi-head attention in the node dimension, and the temporal causal attention layer performs masked multi-head attention in the time step dimension.
8. The intelligent prediction method for highway traffic flow integrating Internet of Things data according to claim 1, characterized in that, In step S3, the solution method for the robust prediction branch in extreme scenarios specifically includes: The extreme scenario robust prediction branch is a causal invariant network. The feature extractor is trained using the invariant risk minimization criterion. The training set is divided into four environmental subsets according to weather conditions and accident indicators: no accidents on sunny days, no accidents on rainy days, accidents on sunny days, and accidents on extreme weather days. The prediction loss and gradient penalty on all environmental subsets are jointly optimized so that the feature extractor retains only causally stable features in all environments. After training converges, the feature extractor parameters are fixed, and the output projection layer is fine-tuned only during the online training phase of the reinforcement learning agent.
9. The intelligent prediction method for highway traffic flow integrating Internet of Things data according to claim 1, characterized in that, The architecture specifically includes: The data sensing access layer is used to collect heterogeneous data streams from coil detectors, millimeter-wave radar, GPS floating cars and weather stations, perform spatial matching on nodes of each road segment, retain missing states marked with mask vectors, and construct heterogeneous datasets. The core algorithm processing layer includes a continuous-time graph neural differential equation module and a causal reinforcement learning dynamic routing module. The continuous-time graph neural differential equation module is used to parameterize the time derivatives of the hidden states of each node by the graph attention network, and then integrates and evolves them in the continuous time domain through an adaptive step-size ordinary differential equation solver to output a reconstructed feature matrix. The causal reinforcement learning dynamic routing module is used to output gating decisions based on the state vector to activate the corresponding prediction branches, and outputs traffic flow prediction values after verification by the physical constraint verification layer. The prediction service output layer is used to send the predicted values to the traffic management platform; The cloud-edge collaborative architecture is adopted. The edge computing nodes deploy the continuous-time graph neural differential equation inference engine and normal prediction branch in ONNX format, while the cloud cluster deploys the reinforcement learning agent training module and extreme scenario robust prediction branch, and periodically distributes model weights to the edge nodes in a differential update manner.
10. The intelligent prediction method for highway traffic flow integrating Internet of Things data according to claim 9, characterized in that, The architecture processing flow specifically includes: The heterogeneous data streams reported in real time by IoT sensing devices are aggregated through the message middleware and first enter the adaptive data reconstruction module to complete the feature reconstruction in the continuous time domain. Then, the reconstructed latent state features are passed to the causal reinforcement learning dynamic routing module, where RLAgent determines to activate the normal prediction branch or the extreme scenario robust branch based on the current scenario state, and finally outputs the traffic flow prediction values for multiple future time steps.
Citation Information
Patent Citations
Missing traffic data restoration method based on multi-view time matrix decomposition
CN115376309A
Traffic flow prediction method based on multi-scale joint space-time hypergraph neural network
CN118966479A