A Traffic Flow Prediction Method and Device Based on Spatiotemporal Graph Convolutional Networks
By constructing a traffic congestion index matrix and a spatiotemporal synchronous graph convolutional network, and combining the wave loss function and an improved optimization algorithm, the shortcomings of existing traffic flow prediction methods in capturing spatiotemporal correlations are addressed, achieving efficient and accurate traffic flow prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2026-04-03
AI Technical Summary
Existing traffic flow prediction methods have limitations in terms of accuracy and efficiency. Traditional models struggle to effectively capture spatiotemporal correlations, deep learning methods are highly complex, graph convolutional networks incur significant computational overhead on large-scale road networks, and hybrid models lack sufficient local spatiotemporal feature learning, all of which limit prediction accuracy.
A traffic flow prediction method based on spatiotemporal graph convolutional networks is adopted. By constructing a traffic congestion index matrix and performing fast temporal convolution processing, the spatiotemporal synchronous graph convolutional network is used to learn the spatial topology, and a random vector function linking network based on wave loss function is used for prediction. The model parameters are optimized by combining improved exponential and trigonometric function optimization algorithms.
It significantly improves the accuracy and efficiency of traffic flow prediction, especially in complex road network environments, and can capture spatiotemporal information more comprehensively, balance the impact of noise and outliers, and improve the model's generalization ability and robustness.
Smart Images

Figure CN120748194B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to traffic flow prediction methods and devices, specifically to a traffic flow prediction method and device based on spatiotemporal graph convolutional networks. Background Technology
[0002] Traffic flow forecasting aims to predict future road network traffic conditions by analyzing historical and real-time data, thereby providing decision support for traffic management, route planning, and congestion mitigation. However, existing traffic flow forecasting methods still have limitations in terms of accuracy and efficiency:
[0003] Traditional time series models (such as ARIMA and Kalman filtering) rely solely on historical time data and cannot model spatial dependencies between nodes in a road network (such as the traffic impact of adjacent road segments). While GIS (Geographic Information System)-based methods can reflect spatial topology, they struggle to dynamically integrate nonlinear changes in the temporal dimension (such as traffic fluctuations during peak hours). Traffic data is frequently affected by sensor errors and unexpected events (such as accidents), and traditional loss functions (such as mean squared error) over-penalize outliers, leading to decreased model generalization ability. Deep learning methods (such as RNNs and CNNs) require separate processing of spatiotemporal features, resulting in high model complexity, and Graph Convolutional Networks (GCNs) incur significant overhead for adjacency matrix operations on large-scale road networks. Existing time series models ignore the spatial dimension and are only suitable for single-point prediction. While GNNs can model spatial relationships, they do not simultaneously optimize temporal convolution, making it difficult to capture dynamic spatiotemporal interactions. Hybrid models (such as STGCNs) simplify computation by separating spatiotemporal modules, but insufficient joint learning of local spatiotemporal features limits prediction accuracy. Summary of the Invention
[0004] Purpose of the invention: The purpose of this invention is to provide a traffic flow prediction method and device based on spatiotemporal graph convolutional networks that can effectively capture the spatiotemporal correlation in traffic flow data and improve prediction efficiency and accuracy.
[0005] Technical solution: The present invention provides a traffic flow prediction method based on spatiotemporal graph convolutional networks, comprising:
[0006] (1) Collect road traffic flow data and construct a traffic congestion index matrix model to characterize the flow relationship between nodes in the traffic network; based on the collected road traffic flow data, calculate the road traffic congestion index to quantify the traffic flow difference between nodes, and use the road traffic congestion index to construct a traffic flow adjacency matrix.
[0007] (2) Perform fast temporal convolution on the traffic flow adjacency matrix to generate a traffic flow data sequence containing spatiotemporal information;
[0008] (3) Input the traffic flow data sequence into the spatiotemporal synchronous graph convolutional network model STSGCN to further learn the spatial topology and extract spatiotemporal features by stacking multiple layers of spatiotemporal synchronous graph convolutional layers.
[0009] (4) Input the spatiotemporal features into the Wave-RVFL stochastic vector function linked network model based on the wave loss function to predict traffic flow.
[0010] Further, step (1) includes: acquiring RTSP image data of fixed surveillance video of road intersections, calibrating and tracking the approach lanes and stop lines in the images to obtain traffic flow, occupancy rate, and average speed; representing the road network as an undirected graph to simplify the network structure representation, the expression of the traffic structure graph G is as follows:
[0011] G = (V, E, A)
[0012] Where V is the set of nodes; E is the set of links between nodes; A∈R N×N Let R be the adjacency matrix, R represent the set of real numbers, and N represent the total number of nodes in the traffic network.
[0013] Furthermore, step (1) also includes: selecting time congestion, spatial congestion and vehicle congestion as indicators of road traffic congestion;
[0014] Time-to-Distance (TTD) refers to the time difference between vehicles passing the same location, calculated using the following formula:
[0015]
[0016] Among them, T a The average flow rate of the node;
[0017] Spatial Congestion Degree (SDD) refers to the spatial distance between a vehicle and the vehicle in front when passing through the same location. The calculation formula is as follows:
[0018]
[0019] Where, α t V represents the weight at time t; a The average vehicle speed at each node; the smaller the spatial interval, the higher the vehicle density at that node, and correspondingly, the more severe the spatial congestion.
[0020] Vehicle Congestion Time (VTD) refers to the density of vehicles and their congestion status at a specific traffic node or road segment within a specific time interval. The calculation formula is as follows:
[0021]
[0022] Where δ represents the number of vehicles passing through the speed detection sensor; Li V is the length of vehicle i; d is the speed returned by the speed detection sensor; V i T represents the speed of vehicle i; total It is the sum of the headway of the train.
[0023] Furthermore, step (1) also includes: calculating the following three weights based on the road traffic congestion index:
[0024]
[0025] in, Let be the weight of the edge with time congestion between node i and node j; Let be the weight of the edge with spatial congestion degree between node i and node j; Let TTD be the weight of the edge with spatial congestion degree between node i and node j, and the weight of the edge with vehicle congestion degree. i TTD j These represent the time-based congestion levels for nodes i and j, respectively; SDD i SDD j The spatial congestion levels of nodes i and j are respectively; VTD i VTD j Let i and j be the vehicle congestion levels, respectively.
[0026] Traffic flow adjacency matrix Where ⊙ represents the Hadamard product operation.
[0027] Further, step (3) includes: concatenating the nodes at the three times t-1, t, and t+1 to construct a local spatiotemporal graph; using A∈R N×N Let A'∈R be the adjacency matrix of the space. 3N×3N Let represent the adjacency matrix of the local spatiotemporal graph constructed on three consecutive spaces; for node i in the spatial graph, calculate its new index graph (t-1)N+i in the local spatiotemporal graph, where t is the time step in the local spatiotemporal graph, 0 < t ≤ 3; i represents the node index in the spatial graph.
[0028] The adjacency matrix of a local spatiotemporal graph is represented as:
[0029]
[0030] Where i and j are nodes in the local spatiotemporal graph, and the adjacency matrix A' contains 3N nodes;
[0031] For the spatiotemporal network sequence X G ∈R N×C×T Create a learnable temporal embedding matrix T emb ∈R C×T and a learnable spatial embedding matrix Semb ∈R N×C C represents the dimension of the input features, and T represents the total number of time steps.
[0032] Two embedding matrices are added to the spatiotemporal network sequence via a broadcast operation to obtain a new representation of the network sequence:
[0033]
[0034] A spatiotemporally synchronized graph convolution module (STSGCM) is established to capture local spatiotemporal correlations. The formula for graph convolution operation is as follows:
[0035] GCN(h (l-1) ) = h (l) =σ(A'h (l-1) W+b)
[0036] Among them, h (l-1) ∈R 3N×C This represents the input to the l-th graph convolutional layer; W and b are learnable parameters; σ is the activation function.
[0037] GLU is chosen as the activation function for the graph convolutional layer, which is described as follows:
[0038]
[0039] Where W1, W2, b1, and b2 are learnable parameters; For activation functions; It is the element-wise product;
[0040] Multiple graph convolution operations are stacked to expand the aggregation region. The outputs of each graph convolution operation layer are concentrated, and the maximum value of each component is obtained using the max pooling method to obtain the aggregated intermediate spatiotemporal information representation.
[0041]
[0042] Among them, C out The number of convolution kernels in the graph convolution operation; L represents the total number of stacked graph convolution layers;
[0043] After completing the graph convolution operation, a pruning operation is used to remove information from previous and next time steps, retaining only the aggregated features of the current time step.
[0044] A set of spatiotemporal synchronization graph convolutional modules (STSGCM) is used as the spatiotemporal synchronization graph convolutional layer (STSGCL) to extract long-range spatiotemporal features. The input matrix of the spatiotemporal synchronization graph convolutional layer (STSGCL) is denoted as X∈R. T×N×CSpatiotemporal embeddings are added to each spatiotemporal synchronization graph convolutional layer (STSGCL). Then, a sliding window in the STSGCL truncates the input to a T-2 spatiotemporal network sequence, where each spatiotemporal network sequence is represented as X'∈R. 3N×C The outputs of T-2 spatiotemporal synchronization graph convolutional modules (STSGCM) are concatenated into a matrix, which is represented as the output of the spatiotemporal synchronization graph convolutional layer (STSGCL):
[0045] H = [H1,H2,...,H] T-2 ]
[0046] in, This is the output of the i-th spatiotemporal synchronization graph convolutional module STSGCM.
[0047] Further, step (4) includes: the Wave-RVFL model calculates the prediction error using the wave loss function, where the wave loss function is l wave The calculation is as follows:
[0048]
[0049] Where η is the boundary parameter; γ is the shape parameter; and v is the error variable in the model;
[0050] The Wave-RVFL is calculated as follows:
[0051]
[0052] Where β is the output layer weight; C is an adjustable parameter; n is the total number of training samples; z i =[x i ,h(x i )],x i ∈R 1×m Let m be the input sample and m be the input dimension; h(x) i ) is the sample x i The corresponding hidden layer; Y i To output the sample matrix;
[0053] The Adam adaptive moment estimation algorithm is used to solve the optimization problem:
[0054]
[0055] Where, ξ i =z i β-Y i For error variables;
[0056] In the t-th iteration, m samples are randomly selected, and the gradient with respect to β is obtained:
[0057]
[0058] Where T represents the total number of time steps;
[0059] Construct the first-order moment vector g t and the second-order moment vector u t as follows:
[0060]
[0061] Where λ1 is the attenuation rate estimated by the first moment, and λ2 is the attenuation rate estimated by the second moment;
[0062] Calculate the first and second moment estimates after bias correction:
[0063]
[0064] in, To estimate the decay rate of the first moment in iteration t, The decay rate at iteration t is estimated for the second moment;
[0065] The parameter β is updated as follows:
[0066]
[0067] Where ε is a constant and δ is the learning rate.
[0068] Furthermore, step (4) also includes: optimizing the weights and learning rate in the Wave-RVFL model using the improved exponential and trigonometric function optimization algorithm IETO.
[0069] Furthermore, the optimization of the weights and learning rate in the Wave-RVFL model using the improved exponential and trigonometric function optimization algorithm includes:
[0070] The first step is to constrain exploration methods.
[0071] E i+1 =E i +floor[2-2×t×(Max_Iter-E i ×a)]
[0072]
[0073] Among them, E i+1 For the iteration count of subsequent constraint exploration methods; E i The iteration count is used to start the current constraint exploration method; floor is the function that performs rounding operations; t is the current iteration number; Max_Iter is the corresponding total number of iterations; a and b are adjustment coefficients;
[0074] Update the upper and lower limits of the search space:
[0075]
[0076] Among them, Up i This represents the upper limit of the expected search space; This represents the j-th position of the currently obtained optimal solution; r1 and r2 are random coefficients between [0,1]. The position of the suboptimal solution at index j; Low i This represents the lower bound of the expected search space;
[0077] Step 2: Initialize the population
[0078] X i,j =(Up) j -Low j )×rand()+Low j ,i=1,2,…N and j=1,2,…d
[0079] Among them, X i,j Indicates population location; Up j Low represents the upper bound of the j-th dimension; j This represents the lower bound of the j-th dimension; rand() takes a random value between [0,1]; N is the population size; d is the population dimension;
[0080] Step 3: Exploration Phase, which is divided into the first exploration phase and the second exploration phase.
[0081] During the first exploration phase, the individual locations were updated as follows:
[0082]
[0083] in, This represents the j-th position of the i-th solution during subsequent iterations; q1 is a random number between [0,1]; α1 is the weighting coefficient; This represents the j-th position of the i-th solution during the current iteration; d1 and d2 are scalar parameters;
[0084] During the second exploration phase, the individual locations were updated as follows:
[0085]
[0086] Where α2 is the weighting coefficient; q2 is a random number between [0,1];
[0087] Step 4: Development Phase. The development phase is divided into Phase 1 and Phase 2.
[0088] In the first phase of development, the individual location was updated as follows:
[0089]
[0090] Where α3 is the weighting coefficient; q3 and q4 are random numbers between [0,1];
[0091] In the second phase of development, the individual location is updated as follows:
[0092]
[0093] Step 5: The transition between the exploration and development phases, employing a CM mechanism to match and optimize the efficiency of the exponential and trigonometric function optimization algorithm ETO:
[0094]
[0095] Furthermore, the chaotic properties generated by the Logistic mapping are used to enhance the randomness of the initial distribution of the population. The calculation formula is as follows:
[0096] x n+1 =μ·x n ·(1-x n )
[0097] Where μ is the control coefficient and n is the number of iterations.
[0098] This invention employs an improved exponential and trigonometric function optimization algorithm (IETO) to optimize the Wave-RVFL model. The exponential and trigonometric function optimization algorithm can effectively search the weight and learning rate parameter space in the Wave-RVFL model, thereby improving the model's generalization ability and robustness.
[0099] Based on the same inventive concept, the present invention provides a traffic flow prediction device based on a spatiotemporal graph convolutional network, comprising a processor and a memory. The memory stores computer instructions, and the processor executes the computer instructions stored in the memory. When the computer instructions are executed by the processor, the traffic flow prediction device implements the steps of the traffic flow prediction method described above.
[0100] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages:
[0101] (1) This invention obtains traffic flow data sequences containing spatiotemporal information through a traffic congestion index matrix model and fast temporal convolution, which can more comprehensively obtain traffic flow characteristics and improve the accuracy of prediction.
[0102] (2) The present invention uses the spatiotemporal synchronous graph convolutional network model STSGCN to learn the spatial topology, which can simultaneously capture the spatial dependence and temporal dynamics in traffic flow data, making it more efficient in processing graph structure data.
[0103] (3) The present invention uses the Wave-RVFL stochastic vector function linked network model based on wave loss function to predict traffic flow, which can effectively balance the influence of noise and outliers in traffic flow prediction.
[0104] In summary, this invention can significantly improve the accuracy and efficiency of traffic flow prediction, especially in complex road network environments. Attached Figure Description
[0105] Figure 1 This is a flowchart of a traffic flow prediction method based on spatiotemporal graph convolutional networks provided in an embodiment of the present invention.
[0106] Figure 2 This is a schematic diagram of the Wave-RVFL model in an embodiment of the present invention. Detailed Implementation
[0107] The invention will now be further described with reference to the accompanying drawings.
[0108] Example 1
[0109] like Figure 1 As shown in Example 1, a traffic flow prediction method based on spatiotemporal graph convolutional networks is provided, including the following steps:
[0110] (1) Collect road traffic flow data and construct a traffic congestion index matrix model to characterize the flow relationship between nodes in the traffic network; based on the collected road traffic flow data, calculate the road traffic congestion index to quantify the traffic flow differences between nodes, and use the road traffic congestion index to construct a traffic flow adjacency matrix. Specifically:
[0111] (101) Obtain RTSP (Real-Time Streaming Protocol) image data from fixed surveillance videos of road intersections. In the images, calibrate and track the approach lanes and stop lines to obtain information such as traffic flow, occupancy rate, and average speed. Represent the road network as an undirected graph to simplify the network structure representation. The expression for the traffic structure graph G is as follows:
[0112] G = (V, E, A)
[0113] Where V is the set of nodes; E is the set of links between nodes; A∈R N×N For an adjacency matrix, R represents the set of real numbers, used to describe the numerical range of the matrix or vector; N represents the total number of nodes in the traffic network (i.e., the number of intersections or road segments).
[0114] (102) Select time congestion, spatial congestion and vehicle congestion as road traffic congestion indicators, and use the road traffic congestion index to characterize the operating status of each node.
[0115] Time-to-Distance (TTD) refers to the time difference between vehicles passing the same location, calculated using the following formula:
[0116]
[0117] Among them, T a The average traffic flow of the node is configured in this embodiment as the number of vehicles passing through the node every 5 minutes.
[0118] Spatial Congestion Degree (SDD) refers to the spatial distance between a vehicle and the vehicle in front when passing through the same location. The calculation formula is as follows:
[0119]
[0120] Where, α t V represents the weight at time t, which is randomly obtained; a The average speed of vehicles at each node; the smaller the spatial interval, the higher the density of vehicles at that node, and correspondingly, the more severe the spatial congestion.
[0121] Vehicle Congestion Time (VTD) refers to the density of vehicles and their congestion status at a specific traffic node or road segment within a specific time interval. The calculation formula is as follows:
[0122]
[0123] Where δ represents the number of vehicles passing the speed detection sensor, which is located next to the road camera; L i V is the length of vehicle i; d is the speed returned by the speed detection sensor; V i T represents the speed of vehicle i; total It is the sum of the headway of the train.
[0124] Constructing a traffic flow adjacency matrix using road traffic congestion indicators:
[0125] Based on the obtained road traffic congestion index, the following three weights are calculated:
[0126]
[0127] in, Let be the weight of the edge with time congestion between node i and node j; Let be the weight of the edge with spatial congestion degree between node i and node j; Let TTD be the weight of the edge with spatial congestion degree between node i and node j, and the weight of the edge with vehicle congestion degree. i TTD j These represent the time-based congestion levels for nodes i and j, respectively; SDD i SDD jThe spatial congestion levels of nodes i and j are respectively; VTD i VTD j Let i and j be the vehicle congestion levels, respectively.
[0128] Traffic flow adjacency matrix Where ⊙ represents the Hadamard product operation.
[0129] (2) Perform fast temporal convolution on the traffic flow adjacency matrix to generate a traffic flow data sequence containing spatiotemporal information.
[0130] A fast temporal convolutional network is used to convolve the traffic flow adjacency matrix, with each convolutional kernel responsible for extracting dynamic interaction features between adjacent time points. By recursively combining the output of the previous convolutional layer with the input of the subsequent convolutional layer, the temporal dimension is expanded, thereby simulating and learning traffic flow patterns over longer time intervals, ultimately yielding a traffic flow data sequence.
[0131] Step (2) mainly extracts time dimension features (such as the flow change pattern between adjacent time points), and outputs a data sequence that incorporates time dynamics.
[0132] (3) Input the traffic flow data sequence into the spatiotemporal synchronous graph convolutional network model STSGCN to further learn the spatial topology and extract spatiotemporal features by stacking multiple layers of spatiotemporal synchronous graph convolutional layers.
[0133] To effectively capture the spatial features of traffic flow data, this invention proposes using a Spatiotemporal Synchronous Graph Convolutional Network (STSGCN) model to learn the spatial topology. This model connects spatial graphs from adjacent time steps into a local spatiotemporal graph. Local spatiotemporal correlations are captured through a Spatiotemporal Synchronous Graph Convolutional Module (STSGCM). Then, by linking STSGCM modules at different time steps to form a Spatiotemporal Synchronous Graph Convolutional Layer (STSGCL), spatiotemporal correlations at longer time scales are learned. By stacking multiple layers of spatiotemporal synchronous graph convolutional layers, spatiotemporal features are extracted at depth, and the spatiotemporal correlations of traffic flow within the input time window are learned to obtain traffic flow characteristics.
[0134] Specifically:
[0135] (301) The core principle of STSGCN model construction includes local spatiotemporal graph and spatiotemporal synchronization graph convolution modules, which model the heterogeneity in spatiotemporal network sequences.
[0136] To simultaneously consider the temporal interactivity, spatial topology, and spatiotemporal correlation of traffic flow data, nodes at times t-1, t, and t+1 are concatenated to construct a local spatiotemporal graph. Based on the topological structure of the local spatiotemporal graph, the correlation between each node and its spatiotemporal neighbors is captured. Let A∈R... N×N Let A'∈R be the adjacency matrix of the space. 3N×3NThe adjacency matrix representing the local spatio-temporal graph constructed on three consecutive spaces. For node i in the spatial graph, calculate its new index graph (t - 1)N + i in the local spatio-temporal, where t is the time step in the local spatio-temporal graph, 0 < t ≤ 3; i represents the node index in the spatial graph.
[0137] The adjacency matrix of the local spatio-temporal graph is represented as:
[0138]
[0139] where i, j are nodes in the local spatio-temporal graph, and the adjacency matrix A' contains 3N nodes.
[0140] Considering that the localized spatio-temporal graph places nodes at different time steps in the same environment without differentiating them, the position is embedded into the spatio-temporal network sequence to enhance the ability to model spatio-temporal correlations. For the spatio-temporal network sequence X G ∈R N×C×T , create a learnable time embedding matrix T emb ∈R C×T and a learnable spatial embedding matrix S emb ∈R N ×C ; C represents the dimension (number of channels) of the input features, and T represents the total number of time steps. After the training process is completed, the two embedding matrices will contain the necessary time and spatial information to help the model capture spatio-temporal correlations.
[0141] Add the two embedding matrices to the spatio-temporal network sequence through a broadcast operation to obtain a new representation of the network sequence:
[0142]
[0143] (302) Establish a spatio-temporal synchronous graph convolution module STSGCM to capture local spatio-temporal correlations. The STSGCM module consists of a set of graph convolution operations, and each node aggregates its own and its neighbors' features at adjacent time steps. The aggregation function is a linear combination, and its weight is equal to the weight of the edge between the node and its neighbor. Through a fully connected layer with an activation function, the features of the node are transformed into a new space. The formula for the graph convolution operation is as follows:
[0144] GCN(h (l-1) ) = h (l) = σ(A'h (l-1) W + b)
[0145] where A' is the adjacency matrix of the local spatio-temporal graph; h (l-1) ∈R 3N×C represents the input of the l-th graph convolution layer; W and b are learnable parameters; σ is the activation function.
[0146] GLU is chosen as the activation function for the graph convolutional layer, which is described as follows:
[0147]
[0148] Where W1, W2, b1, and b2 are learnable parameters; For activation functions; It is the element-wise product.
[0149] (303) Stacking multiple graph convolution operations expands the aggregation region and increases the receptive field of the graph convolution operation to capture local spatiotemporal correlations. The aggregation operation consists of two steps: aggregation and pruning.
[0150] The outputs of the convolutional layers in each graph are collected, and the maximum value of each component is obtained using the max pooling method to obtain the aggregated intermediate spatiotemporal information representation:
[0151]
[0152] Among them, C out L represents the number of convolution kernels in the graph convolution operation; L represents the total number of stacked graph convolutional layers (GCN layers).
[0153] After the graph convolution operation is completed, each node has aggregated node information from previous and subsequent time steps. The information from previous and subsequent time steps is removed by a pruning operation, and only the aggregated features at the current time step are retained, so as to greatly reduce redundant information and improve the generalization performance of the model.
[0154] (304) To capture the long-term spatiotemporal correlation of the entire network sequence, a sliding window is used to cut different time periods. A set of spatiotemporal synchronization graph convolutional modules STSGCM is used as the spatiotemporal synchronization graph convolutional layer STSGCL to extract long-range spatiotemporal features. The input matrix of the spatiotemporal synchronization graph convolutional layer STSGCL is denoted as X∈R. T×N×C Spatiotemporal embeddings are added to each spatiotemporal synchronization graph convolutional layer (STSGCL). Then, a sliding window in the STSGCL truncates the input to a T-2 spatiotemporal network sequence, where each spatiotemporal network sequence is represented as X'∈R. 3N×C The outputs of T-2 spatiotemporal synchronization graph convolutional modules (STSGCM) are concatenated into a matrix, which is represented as the output of the spatiotemporal synchronization graph convolutional layer (STSGCL):
[0155] H = [H1,H2,...,H] T-2 ]
[0156] in, This is the output of the i-th spatiotemporal synchronization graph convolutional module STSGCM.
[0157] (4) The improved exponential and trigonometric function optimization algorithm IETO is used to optimize the weights and learning rate in the Wave-RVFL stochastic vector function link network model based on wave loss function. The spatiotemporal features are then input into the optimized Wave-RVFL model to predict traffic flow.
[0158] To further ensure a balanced handling of noise and outliers, this invention proposes using the Wave-RVFL (Random Vector Function Linked Network) model based on the wave loss function to predict traffic flow. By preventing excessive penalties for biases, it effectively balances the impact of noise and outliers in traffic flow prediction, thereby achieving accurate traffic flow prediction. To further improve the efficiency of the model's prediction, this invention proposes using an improved exponential and trigonometric function optimization algorithm (IETO) to optimize the weights and learning rate in the Wave-RVFL model, thereby improving the generalization ability and computational speed of the Wave-RVFL model. This method utilizes the unique properties of exponential and trigonometric functions to accurately optimize the model parameters, thus accelerating the model's prediction speed. Specifically:
[0159] (401) The RVFL network is a single-layer feedforward neural network consisting of three layers: an input layer, a hidden layer, and an output layer. The training dataset for the RVFL network is represented as follows:
[0160] χ={(x i ,y i |i∈{1,2,...,n}}
[0161] Where, x i ∈R 1×m Here, m represents the input sample, m is the input dimension, and the superscript l is the lowercase form of L; y i ∈{+1,-1} represents the corresponding target vector; n is the total number of training samples; The input sample matrix; This is the output sample matrix.
[0162] (402) The RVFL network uses the squared difference to calculate the prediction error. Considering the inherent dependence of the RVFL network on the squared loss function, which makes it susceptible to noise and outliers, this invention proposes to use the Wave-RVFL model to predict traffic flow and calculate the prediction error through the wave loss function to enhance smoothness and robustness against noise and outliers. Wave loss function l wave The calculation is as follows:
[0163]
[0164] Where η is the boundary parameter; γ is the shape parameter; and v is the error variable in the model.
[0165] The Wave-RVFL is calculated as follows:
[0166]
[0167] Where β is the output layer weight; C is an adjustable parameter; n is the total number of training samples; z i =[x i ,h(x i )],h(x i ) is the sample x i The corresponding hidden layer; Y i This is the output sample matrix.
[0168] (403) The Adam adaptive moment estimation algorithm is used to solve the optimization problem:
[0169]
[0170] Where, ξ i =z i β-Y i This is the error variable.
[0171] In the t-th iteration, m samples are randomly selected for calculating the gradient and subsequent steps. Taking the gradient with respect to β, we get:
[0172]
[0173] Where T represents the total number of time steps; construct the first-order moment vector g. t and the second-order moment vector u t as follows:
[0174]
[0175] Where λ1 is the decay rate estimated by the first moment, set to 0.9; λ2 is the decay rate estimated by the second moment, set to 0.999; and t is the number of iterations.
[0176] Calculate the first and second moment estimates after bias correction:
[0177]
[0178] in, To estimate the decay rate of the first moment in iteration t, The second moment is used to estimate the decay rate at iteration t.
[0179] The parameter β is updated as follows:
[0180]
[0181] Where ε is a constant and δ is the learning rate.
[0182] See the schematic diagram of the Wave-RVFL model. Figure 2 .
[0183] (404) The ETO algorithm is a metaheuristic optimization algorithm. The exponential function guides the global search, helping the algorithm to cover the solution space more broadly; while the trigonometric function is mainly used for local refinement, improving the convergence speed and enhancing the quality of local optima. The specific implementation process of ETO is as follows:
[0184] The first step is to constrain the exploration method. To efficiently explore and utilize the search space, optimize the search process, and reduce the required time and computational resources, a finite exploration method is proposed, calculated as follows:
[0185] E i+1 =E i +floor[2-2×t×(Max_Iter-E i ×a)]
[0186]
[0187] Among them, E i+1 For the iteration count of subsequent constraint exploration methods; E i The iteration count is used to start the current constraint exploration method; floor is the function that performs rounding operations; t is the current iteration number; Max_Iter is the corresponding total number of iterations; a and b are adjustment coefficients;
[0188] Update the upper and lower limits of the search space to ensure dynamic adjustment of the search space, thereby improving the efficiency of the optimization process. The adjustments to the upper and lower limits are as follows:
[0189]
[0190] Among them, Up i This represents the upper limit of the expected search space; This represents the j-th position of the currently obtained optimal solution; r1 and r2 are random coefficients between [0,1]. The position of the suboptimal solution at index j; Low i This represents the lower bound of the expected search space.
[0191] Step 2: Initialize the population
[0192] X i,j =(Up) j -Low j )×rand()+Low j ,i=1,2,…N and j=1,2,…d
[0193] Among them, X i,j Indicates population location; Up jLow represents the upper bound of the j-th dimension; j This represents the lower bound of the j-th dimension; rand() takes a random value between [0,1]; N is the population size; d is the population dimension.
[0194] Step 3: Exploration phase. The exploration phase is divided into the first exploration phase and the second exploration phase. To prevent convergence to a local optimum, this phase needs to be maintained in subsequent iterations.
[0195] During the first exploration phase, the individual locations were updated as follows:
[0196]
[0197] in, This is the optimal solution for the j-th position; This represents the j-th position of the i-th solution during subsequent iterations. q1 is the j-th position of the i-th solution during the current iteration; q1 is a random number between [0,1]; α1 is the weight coefficient; d1 and d2 are scalar parameters; t is the current iteration; Max_Iter is the total number of iterations.
[0198] During the second exploration phase, the individual locations were updated as follows:
[0199]
[0200] Where α2 is the weighting coefficient; q2 is a random number between [0,1].
[0201] Step 4: Development Phase. The development phase is divided into Phase 1 and Phase 2.
[0202] In the first phase of development, the individual location was updated as follows:
[0203]
[0204] Where α3 is the weighting coefficient; q3 and q4 are random numbers between [0,1].
[0205] In the second phase of development, the individual location is updated as follows:
[0206]
[0207] Here, c is determined by a combination of exponential and trigonometric functions.
[0208] Step 5: The transition between the exploration and development phases, employing a CM mechanism to match and optimize the efficiency of the exponential and trigonometric function optimization algorithm ETO:
[0209]
[0210] During the algorithm optimization process, after a certain number of iterations, the search region of the entire population will automatically converge to the optimal solution set. To improve the global search capability of ETO, this invention proposes to use the chaotic characteristics generated by the Logistic mapping to enhance the randomness of the initial distribution of the population. The calculation formula is as follows:
[0211] x n+1 =μ·x n ·(1-x n )
[0212] Where μ is the control coefficient and n is the number of iterations.
[0213] Example 2
[0214] Example 2 provides a traffic flow prediction device based on a spatiotemporal graph convolutional network. The traffic flow prediction device may include a processor and a memory. The memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the traffic flow prediction device implements the steps of the traffic flow prediction method described in Example 1 above, and can achieve the same technical effect as the above traffic flow prediction method.
[0215] The memory may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the memory may be used to read and write non-removable, non-volatile magnetic media (commonly referred to as a "hard disk drive"). A program / utility having a set (at least one) of program modules may be stored in, for example, memory. Such program modules include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. The program modules typically perform the functions and / or methods described in the embodiments of the present invention.
[0216] The processor executes various functional applications and data processing by running programs stored in memory, such as implementing the traffic flow prediction method provided in Embodiment 1 of the present invention.
Claims
1. A traffic flow prediction method based on spatiotemporal graph convolutional networks, characterized in that, include: (1) Collect road traffic flow data and construct a traffic congestion index matrix model to characterize the flow relationship between nodes in the traffic network; based on the collected road traffic flow data, calculate the road traffic congestion index to quantify the traffic flow difference between nodes, and use the road traffic congestion index to construct a traffic flow adjacency matrix. (2) Perform fast temporal convolution on the traffic flow adjacency matrix to generate a traffic flow data sequence containing spatiotemporal information; (3) Input the traffic flow data sequence into the spatiotemporal synchronous graph convolutional network model STSGCN to further learn the spatial topology and extract spatiotemporal features by stacking multiple layers of spatiotemporal synchronous graph convolutional layers. (4) Input the spatiotemporal features into the Wave-RVFL stochastic vector function link network model based on the wave loss function to predict traffic flow; Step (4) includes: The Wave-RVFL model calculates the prediction error using the wave loss function, the wave loss function... The calculation is as follows: in, These are boundary parameters; For shape parameters; For error variables in the model; The Wave-RVFL is calculated as follows: in, These are the output layer weights; These are adjustable parameters; The total number of training samples; , Let m be the input sample and m be the input dimension; For the sample The corresponding hidden layer; To output the sample matrix; The Adam adaptive moment estimation algorithm is used to solve the optimization problem: in, For error variables; In the In the next iteration, randomly select A sample, take about The gradient is obtained as follows: in, Indicates the total number of time steps; Construct first-order moment vector and second-order moment vector as follows: in, The attenuation rate is estimated by the first moment. The attenuation rate is estimated by the second moment; Calculate the first and second moment estimates after bias correction: in, For first-order moment estimation in The decay rate of the next iteration For second-order moment estimation in The decay rate of the next iteration; parameter The update is as follows: in, It is a constant. The learning rate; Step (4) also includes: optimizing the weights and learning rate in the Wave-RVFL model using the improved exponential and trigonometric function optimization algorithm IETO; The optimization of the weights and learning rate in the Wave-RVFL model using an improved exponential and trigonometric function optimization algorithm includes: The first step is to constrain exploration methods. in, For iteration counting of subsequent constraint exploration methods; To initiate the iteration count for the current constraint exploration method; A function to perform rounding operations; This represents the current iteration number; This corresponds to the total number of iterations; For adjustment coefficients; Update the upper and lower limits of the search space: in, This represents the upper limit of the expected search space; The th best solution obtained so far One location; and for Random coefficients between; For the suboptimal solution in The position at each index; This represents the lower bound of the expected search space; Step 2: Initialize the population in, Indicates the location of the population; Indicates the first The upper limit of dimensions; Indicates the first The lower bound of the dimension; Pick Random values between; Population size; From a population perspective; Step 3: Exploration Phase, which is divided into the first exploration phase and the second exploration phase. During the first exploration phase, the individual locations were updated as follows: in, For the subsequent iterations The solution of the first... One location; for Random numbers between; These are the weighting coefficients; For the current iteration period The solution of the first... One location; and It is a scalar parameter; During the second exploration phase, the individual locations were updated as follows: in, These are the weighting coefficients; for Random numbers between; Step 4: Development Phase. The development phase is divided into Phase 1 and Phase 2. In the first phase of development, the individual location was updated as follows: in, These are the weighting coefficients; and for Random numbers between; In the second phase of development, the individual location is updated as follows: Step 5: The transition between the exploration and development phases, employing a CM mechanism to match and optimize the efficiency of the exponential and trigonometric function optimization algorithm ETO: 。 2. The traffic flow prediction method based on spatiotemporal graph convolutional networks according to claim 1, characterized in that, Step (1) includes: acquiring RTSP image data from fixed surveillance videos of road intersections; calibrating and tracking the approach lanes and stop lines in the images to obtain traffic flow, occupancy rate, and average speed; representing the road network as an undirected graph to simplify the network structure representation; and creating a traffic structure diagram. The expression is as follows: in, A set of nodes; A set of links between nodes; It is an adjacency matrix. Represents the set of real numbers. This represents the total number of nodes in the transportation network.
3. The traffic flow prediction method based on spatiotemporal graph convolutional networks according to claim 2, characterized in that, Step (1) also includes: selecting time congestion, spatial congestion and vehicle congestion as indicators of road traffic congestion; Time congestion This refers to the time difference between vehicles passing through the same location, calculated using the following formula: in, The average flow rate of the node; spatial congestion This refers to the spatial distance between vehicles when passing the same location, and the calculation formula is as follows: in, express The weight of each moment; The average vehicle speed at each node; the smaller the spatial interval, the higher the vehicle density at that node, and correspondingly, the more severe the spatial congestion. Traffic congestion This refers to the density of vehicle distribution and congestion status at a specific traffic node or road segment within a specific time interval. The calculation formula is as follows: in, The number of vehicles passing through the speed detection sensor; For vehicles Length; The speed is detected by the speed sensor. For vehicles speed; It is the sum of the headway of the train.
4. The traffic flow prediction method based on spatiotemporal graph convolutional networks according to claim 3, characterized in that, Step (1) also includes: calculating the following three weights based on the road traffic congestion index: in, For nodes With nodes The weights of the edges between them, based on their time congestion levels; For nodes With nodes The weights of edges with spatial congestion levels; For nodes With nodes The weights of edges with spatial congestion and the weights of edges with vehicle congestion. , They are nodes , Time congestion level; , They are nodes , Spatial congestion; , They are nodes , Traffic congestion level; Traffic flow adjacency matrix ,in This is for the Hadamard product operation.
5. The traffic flow prediction method based on spatiotemporal graph convolutional networks according to claim 4, characterized in that, Step (3) includes: These three time points are linked together to construct a local spatiotemporal graph; using The adjacency matrix represents the space. This represents the adjacency matrix of a local spatiotemporal graph constructed over three consecutive spaces; for nodes in the spatial graph... Calculate its new index graph in local spacetime. ,in The time step in the local spatiotemporal graph. ; This represents the node index in the representation space graph; The adjacency matrix of a local spatiotemporal graph is represented as: in, For nodes in a local spatiotemporal graph, the adjacency matrix is... Include One node; spatiotemporal network sequences Create a learnable temporal embedding matrix and a learnable spatial embedding matrix ; Indicates the dimension of the input features. Indicates the total number of time steps; Two embedding matrices are added to the spatiotemporal network sequence through a broadcast operation to obtain a new representation of the network sequence: A spatiotemporally synchronized graph convolution module (STSGCM) is established to capture local spatiotemporal correlations. The formula for graph convolution operation is as follows: in, Indicates the first The input to a graph convolutional layer; and These are learnable parameters; For activation functions; GLU is chosen as the activation function for the graph convolutional layer, which is described as follows: in, , , , These are learnable parameters; , is the activation function; It is the element-wise product; Multiple graph convolution operations are stacked to expand the aggregation region. The outputs of each graph convolution operation layer are concentrated, and the maximum value of each component is obtained using the max pooling method to obtain the aggregated intermediate spatiotemporal information representation. in, The number of convolution kernels in the graph convolution operation; Represents the total number of stacked graph convolutional layers; After completing the graph convolution operation, a pruning operation is used to remove information from previous and next time steps, retaining only the aggregated features of the current time step. A set of spatiotemporal synchronization graph convolutional modules (STSGCM) is used as the spatiotemporal synchronization graph convolutional layer (STSGCL) to extract long-range spatiotemporal features. The input matrix of the spatiotemporal synchronization graph convolutional layer (STSGCL) is denoted as... Spatiotemporal embeddings are added to each spatiotemporal synchronization graph convolutional layer (STSGCL), and then a sliding window in the STSGCL truncates the input to... In the spatiotemporal network sequence, each spatiotemporal network sequence is represented as: ;Will The outputs of the spatiotemporal synchronization graph convolutional modules STSGCM are concatenated into a matrix, which is represented as the output of the spatiotemporal synchronization graph convolutional layer STSGCL as follows: in, For the first The output of the spatiotemporal synchronization graph convolutional module STSGCM.
6. The traffic flow prediction method based on spatiotemporal graph convolutional networks according to claim 1, characterized in that, The chaotic properties generated by the Logistic mapping are used to enhance the randomness of the initial distribution of the population. The calculation formula is as follows: in, For control coefficients; This represents the number of iterations.
7. A traffic flow prediction device based on spatiotemporal graph convolutional networks, characterized in that, The device includes a processor and a memory, the memory storing computer instructions, and the processor executing the computer instructions stored in the memory. When the computer instructions are executed by the processor, the traffic flow prediction device implements the steps of the traffic flow prediction method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Traffic prediction method, system and device based on dynamic space-time diagram convolutional neural network, and medium
CN117218837A
Traffic flow prediction method based on dynamic space-time similar pyramid network
CN118230548A