Urban traffic flow prediction and signal optimization method based on space-time diagram neural network
By constructing a spatiotemporal graph neural network architecture, combining graph convolution and temporal prediction models, and integrating multi-source data for traffic flow prediction and signal optimization, the problem of low efficiency in traffic resource utilization in traditional methods is solved, and efficient and real-time traffic management is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU HOPERUN SOFTWARE CO LTD
- Filing Date
- 2026-01-26
- Publication Date
- 2026-05-26
AI Technical Summary
Traditional traffic signal control systems cannot fully utilize massive traffic data and complex road network topology, making it difficult to cope with dynamic changes and spatiotemporal correlations in traffic flow. This results in low efficiency in traffic resource utilization, a disconnect between prediction and optimization, and high computational complexity that makes it difficult to meet real-time requirements.
A spatiotemporal graph neural network architecture is constructed, which combines graph convolutional networks and time-series prediction models to integrate multi-source heterogeneous data, enabling accurate short-term prediction of traffic flow at intersections and road segments. Based on the prediction results, a dynamic signal optimization algorithm is designed to improve the efficiency of road network traffic.
It achieves high-precision prediction of traffic flow and signal optimization, reduces vehicle delays and queue lengths, improves road network efficiency, adapts to different weather conditions and emergencies, meets real-time requirements, and has good robustness and scalability.
Smart Images

Figure CN122090610A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of intelligent transportation systems and deep learning technology, specifically to a method for urban traffic flow prediction and signal optimization based on spatiotemporal graph neural networks, applicable to various application scenarios such as smart city traffic management, intelligent signal control systems, traffic guidance systems, and emergency traffic dispatch. Background Technology
[0002] With the acceleration of urbanization and the rapid growth of motor vehicle ownership, urban traffic congestion has become increasingly serious, posing a key challenge to urban operational efficiency and residents' quality of life. Traditional traffic signal control systems mainly employ fixed timing or dynamic timing methods based on simple rules, which cannot fully utilize massive amounts of traffic data and complex road network topology. They struggle to cope with the dynamic changes and spatiotemporal correlations of traffic flow, resulting in low efficiency in the utilization of traffic resources.
[0003] In recent years, data-driven intelligent traffic management methods have received widespread attention. Traditional traffic flow prediction methods mainly include time series analysis and machine learning regression models, but these methods have the following limitations:
[0004] 1. Lack of spatial correlation modeling: Existing methods typically treat each intersection or road segment as an independent unit for prediction, failing to effectively model the spatial correlation between adjacent intersections in the road network and the propagation and diffusion effects of traffic flow. In reality, changes in traffic flow at upstream intersections can propagate through the road network and affect downstream intersections; this spatial dependency is crucial for accurate prediction.
[0005] 2. Insufficient extraction of temporal features: Traditional time series models (such as ARIMA and state-space models) struggle to capture the long-term dependencies and periodic patterns in traffic flow. Traffic flow exhibits complex temporal patterns with obvious daily and weekly cycles, and also shows short-term fluctuations and long-term trends. Traditional models struggle to simultaneously model these multi-level temporal features.
[0006] 3. Insufficient multi-source data fusion capabilities: Traffic flow is influenced by various factors, including historical traffic volume, real-time monitoring data, weather conditions, traffic accidents, and large-scale events. Existing methods often only utilize a single data source or simply piece together data, failing to deeply explore the correlations between different data sources and their synergistic impact on traffic flow.
[0007] 4. Insufficient utilization of road network topology: Urban road networks have complex topologies, including road segment connectivity, road class, number of lanes, and turning restrictions. Existing methods rarely explicitly encode this topological information into the prediction model, resulting in the model's inability to understand the spatial constraints of the road network and the propagation paths of traffic flow.
[0008] 5. Disconnect between signal optimization and prediction: Most systems treat traffic flow prediction and signal optimization as two separate modules, resulting in a lack of effective connection between prediction results and optimization objectives. Signal optimization is often based on the current state rather than future predictions, failing to achieve proactive scheduling and struggling to cope with sudden congestion and traffic surges.
[0009] 6. Computational efficiency and real-time bottlenecks: Although deep learning methods can capture complex patterns, they have high computational complexity and large inference latency, making it difficult to meet the real-time requirements of traffic signal control (prediction and optimization calculations usually need to be completed within seconds).
[0010] Therefore, there is an urgent need for an intelligent traffic management method that can deeply integrate road network topology, effectively model spatiotemporal relationships, fully utilize multi-source heterogeneous data, and achieve integrated prediction and optimization design. This invention solves the aforementioned technical challenges by constructing a spatiotemporal graph neural network architecture, combining the spatial relationship modeling capabilities of graph convolutional networks with the time dependency capture capabilities of temporal networks, and designing an efficient signal optimization algorithm. This provides an efficient and reliable technical solution for smart city traffic management. Summary of the Invention
[0011] To address the aforementioned issues, this invention provides a method for urban traffic flow prediction and signal optimization based on spatiotemporal graph neural networks. By constructing a topological graph representation of the urban road network and fusing multi-source heterogeneous traffic data, a deep learning architecture combining graph convolutional networks and temporal prediction models is adopted to achieve accurate short-term prediction of traffic flow at intersections and road segments. Based on the prediction results, a dynamic signal optimization algorithm is designed to achieve adaptive adjustment of traffic signal timing, thereby improving road network efficiency and reducing vehicle delays.
[0012] The specific plan is as follows:
[0013] A method for urban traffic flow prediction and signal optimization based on spatiotemporal graph neural networks includes the following steps:
[0014] S1. Construction of urban road network topology; First, the urban road network is abstracted into a graph structure to utilize graph neural networks to model spatial relationships;
[0015] S2. Multi-source heterogeneous data fusion and feature extraction: Based on the completion of the road network topology map construction, multi-source data such as historical traffic data, real-time detection data, and external influencing factors are fused to construct a dynamic feature matrix for each node; these multi-source features will provide rich input information for the subsequent spatiotemporal graph neural network, enabling the model to comprehensively consider the impact of historical patterns, current state, and external environmental factors on traffic flow;
[0016] S3. Spatio-Temporal Graph Convolutional Network (ST-GCN) Prediction Model: After completing multi-source data fusion and feature extraction, a spatio-temporal graph convolutional network (ST-GCN) architecture is designed. It utilizes the constructed road network topology graph and node feature vectors to model the spatial association and temporal dependency of the road network. The spatial graph convolution module captures the spatial propagation effect, and the temporal evolution law is captured by the temporal modeling module. The spatio-temporal feature fusion and prediction mechanism combines the two to obtain accurate traffic prediction.
[0017] S4. Signal optimization algorithm based on prediction results: Based on the future traffic flow prediction results obtained from the spatiotemporal graph neural network, a dynamic signal optimization algorithm is designed to realize the integrated design of prediction and optimization. It takes the predicted future traffic flow as the optimization input, calculates the expected delay of each phase, establishes the optimization objective function, solves the optimal signal timing scheme, and thus realizes forward-looking traffic signal control.
[0018] S5. Model Training and Online Update Strategy: To enable the constructed spatiotemporal graph neural network prediction model to accurately learn the spatiotemporal evolution of traffic flow, a multi-stage training strategy and online update mechanism are adopted. The model parameters are trained using historical data and continuously adapted to changes in traffic patterns to improve the model's prediction accuracy and adaptability.
[0019] S6. System Integration and Real-Time Inference Optimization: Based on the completion of prediction model construction and training, in order to meet the real-time requirements of traffic signal control (prediction and optimization calculations need to be completed within 5 seconds), this invention adopts technologies such as model compression, distributed computing and caching strategies to improve system efficiency, ensuring that the entire prediction-optimization system can meet the real-time response requirements in actual deployment, and realizing the effective transformation from algorithm design to engineering application.
[0020] Furthermore, in step S1, it is assumed that the urban road network includes Each intersection is a node. Each road segment is an edge; construct a directed graph. ,in For the set of nodes, Let be the set of edges. Let's consider the adjacency matrix; adjacency matrix The definition considers multiple factors such as road segment connectivity, distance attenuation, and road grade; for nodes and If there are directly connected road segments, the adjacency weight is defined as follows:
[0021]
[0022] in For nodes To the node The distance of the road segment (unit: meters). This is the distance attenuation coefficient (which controls the degree of influence of distance on the correlation strength). The weights for road classification are as follows: 1.0 for arterial roads, 0.7 for secondary roads, and 0.4 for local roads, reflecting the importance of roads of different classifications. For connectivity indicators (when node) and When there is a direct connection ,otherwise When there is no direct connection between nodes, This weighting design ensures a stronger correlation between adjacent intersections that are closer in distance and have higher road grades, which aligns with the physical laws of traffic flow propagation.
[0023] To enhance the expressive power of graph representation, each node It also has static feature vectors This includes attribute information such as intersection type (crossroads, T-junctions, etc.), number of lanes, turning restrictions, and whether it is a signal-controlled intersection. It is a static feature dimension; each edge also has a feature vector, including information such as road segment length, number of lanes, road grade, speed limit, etc.
[0024] Furthermore, in step S2,
[0025] Historical traffic data: for each node Extract the past Historical flow sequence at each time step ,in Represents a node At any moment Traffic flow (unit: vehicles / hour); to further extract temporal patterns, a one-dimensional convolutional neural network is used to extract features from the historical sequence; the one-dimensional convolution operation captures local temporal patterns and trend features in the historical traffic flow sequence by sliding the convolution kernel in the time dimension; the specific implementation is as follows:
[0026]
[0027] in This represents a one-dimensional convolution operation. Multiple convolution kernels (e.g., kernel size 3, stride 1) are used to perform convolution operations on the input sequence. Each kernel extracts temporal features at different scales. Then, pooling is used to reduce the dimensionality, resulting in... For the extracted historical traffic feature vector, This method uses historical traffic characteristics as a dimension, and can effectively capture short-term fluctuations and trend changes in historical traffic.
[0028] Real-time detection data: Acquire real-time vehicle count, queue length, occupancy rate, and other detection data for each intersection to form a real-time feature vector. ,in For real-time feature dimensions;
[0029] External influencing factors: The external feature vector is constructed by integrating meteorological data (rainfall, visibility, temperature, etc.), traffic events (accidents, construction, large-scale events, etc.), and time characteristics (hours, days of the week, whether it is a holiday). ,in External feature dimension;
[0030] The above features are concatenated to obtain nodes. At any moment Complete feature vector:
[0031]
[0032] in This represents a vector concatenation operation. The total dimension of node features. This is a static feature dimension.
[0033] Furthermore, in step S3,
[0034] The spatial graph convolution module includes: using a Graph Convolutional Network (GCN) to aggregate feature information from neighboring nodes to capture the spatial propagation effect of traffic flow; the core idea of graph convolution is: for each node, its own features are weighted and aggregated with the features of its neighboring nodes, with the weights determined by the adjacency matrix, thus allowing traffic flow information from adjacent intersections to influence each other. The specific implementation process is as follows:
[0035] First, for the original adjacency matrix Normalization is performed to obtain a normalized symmetric adjacency matrix. ,in A degree matrix (a diagonal matrix, whose diagonal elements) Represents a node The degree is the number of neighboring nodes connected to the node plus 1, because the identity matrix... (Introduced self-connection) It is an identity matrix (used for self-joins to preserve the node's own information); the normalization operation can balance nodes of different degrees and prevent nodes with large degrees from having an excessive impact on the result.
[0036] Then, for the node Its spatial features are updated as follows:
[0037]
[0038] in For nodes In the Layer feature representation ( (corresponding to input features) and For the first The learnable parameter matrix and bias vector of layer graph convolution. For activation functions (such as ReLU). For nodes In the Spatial aggregation features after layer graph convolution; the calculation process is as follows: first, for each neighbor node... Linear transformation of features Then, based on the normalized adjacency weights Weighted summation is performed, and finally a bias is added and the result is passed through an activation function. Through multi-layer graph convolution, each node can aggregate information from multi-hop neighbors, capture a wider range of spatial relationships, and enable traffic changes at upstream intersections to propagate to downstream intersections.
[0039] The temporal modeling module includes: modeling the temporal evolution of traffic flow using a gated recurrent unit (GRU) network; GRU is a common type of recurrent neural network that selectively memorizes historical information through a gating mechanism. For each node, the spatially convolutional feature sequence is input into the GRU:
[0040]
[0041] in For the process The final spatial features after layer graph convolution ( (Number of convolutional layers in the graph) For the previous moment The hidden state, For the current moment The hidden state, The hidden layer dimension of GRU; GRU can capture the long-term and short-term dependencies and periodic patterns (such as daily cycle, weekly cycle, etc.) of traffic flow through the selective memory mechanism of update gate and reset gate; specifically, update gate controls the degree of retention of historical information, and reset gate controls the degree of forgetting of historical information. The two work together to enable the model to adaptively balance long-term trends and short-term fluctuations.
[0042] The spatiotemporal feature fusion and prediction mechanism includes fusing spatial features and temporal hidden states, and outputting the future through a fully connected layer. Traffic prediction at each time step:
[0043]
[0044] in and The weight matrix and bias vector of the output layer ( The spatial feature dimension after graph convolution. (where GRU is the hidden layer dimension) For nodes future The predicted flow sequence at each time step ( To predict the number of time steps, For the first Predicted traffic value at each time step. This prediction takes into account both the current spatial correlation state and temporal evolution patterns, enabling more accurate short-term predictions (typically). This corresponds to a forecast for the next hour, with a time step of 5 minutes.
[0045] Furthermore, in step S4,
[0046] For each signalized intersection, the objective is to minimize the total vehicle delay within the prediction period, while considering the priority of different turning flows; let the intersection... have The phase, the first The green light duration for each phase is (Unit: seconds), period duration is ( (Total lost time, including yellow light and all-red light time).
[0047] Based on predicted flow , Calculate the first Average arrival flow for each phase within the forecast period:
[0048]
[0049] in For the intersection phase At any moment The corresponding predicted traffic flow (unit: vehicles / hour) is obtained by allocating the total predicted traffic flow to each phase according to the historical steering ratio; according to the Webster delay formula, the first... The average vehicle delay per phase is:
[0050]
[0051] in For phase The green light ratio (the proportion of effective green light time to the cycle length). For phase Saturation (the ratio of arrival flow to capacity) For phase The saturation flow rate, in vehicles per hour, represents the maximum capacity of that phase under ideal conditions); the first term of the formula... For uniform delay (average delay caused by periodic stops), the second term Random delays (additional delays caused by the randomness of vehicle arrivals);
[0052] The signal optimization problem is described as follows:
[0053]
[0054] The objective of the signal optimization problem is to minimize the weighted total delay across all phases, where For phase The weighting coefficients (which can be set according to factors such as road grade, turning flow rate, and priority level, reflecting the importance of different phases) For phase Predicted traffic, For phase The delay (calculated using the Webster formula above);
[0055] The constraints include: minimum green light duration constraint. (Typically 15 seconds, to ensure basic passage for pedestrians and vehicles), maximum green light duration constraint. (Typically 60 seconds, to avoid excessively long waiting times for other phases), period duration constraint. (Typically 60-180 seconds, ensuring a reasonable range for the signal period), and constraints on the total green signal ratio. (Ensure that the sum of the green light ratios of each phase does not exceed the proportion of effective time, including lost time) (Including yellow light and all-red time);
[0056] The signal optimization problem is a nonlinear programming problem (both the objective function and constraints contain nonlinear terms). The solution methods are as follows: For scenarios with high accuracy requirements, the Sequential Quadratic Programming (SQP) algorithm is used. The SQP algorithm transforms the nonlinear problem into a series of quadratic programming subproblems and solves them step by step, obtaining a relatively optimal solution. For scenarios with limited computational resources, a genetic algorithm can be used, which searches for the optimal solution by simulating the biological evolution process. Considering real-time requirements, a fast approximation algorithm based on gradient descent can be used in practical applications. This algorithm calculates the gradient of the objective function with respect to the decision variables and iteratively updates the algorithm along the gradient descent direction, significantly reducing computation time (typically within 1 second) while ensuring solution quality.
[0057] For multiple adjacent signal-controlled intersections, green wave coordination optimization is considered to enable vehicles to pass through multiple intersections at a certain speed without encountering red lights, forming a "green wave" effect. The optimization method involves calculating the coordinated phase difference (i.e., the time difference between the start of green lights in the same phase at adjacent intersections) between predicted traffic flow, allowing vehicles to pass through multiple intersections consecutively at their designed speeds. The objective function of the coordination optimization is extended to include joint optimization of multiple intersections, considering both minimizing delays within each intersection and the coordination effect between intersections. Specific implementation methods include: distributed optimization algorithms (each intersection optimizes independently but exchanges boundary information, achieving coordination through iteration), or centralized coordination controllers (uniformly calculating the timing schemes for all intersections to achieve globally optimal coordination).
[0058] Further, step S5 includes:
[0059] Offline pre-training phase: The spatiotemporal graph neural network is trained on historical traffic data; the training dataset includes historical traffic flow sequences, road network topology information, meteorological data, etc., from the past few months; the loss function is defined as a weighted combination of the mean squared error (MSE) and the mean absolute error (MAE) between predicted and actual traffic flow.
[0060]
[0061] in For nodes At any moment The actual flow rate (the actual observation value obtained from historical data). The corresponding model prediction value, The weighting coefficients for MSE and MAE losses are set to 0.7 (typically 0.7, indicating greater emphasis on mean squared error); the Adam optimizer is used, with a learning rate set to... The batch size is 32, and the training lasts for 50 epochs. To prevent overfitting, an early stopping strategy (stop training when the validation set loss no longer decreases) and Dropout regularization (Dropout rate of 0.3, randomly dropping 30% of neuron connections) are used.
[0062] Online incremental updates: To adapt to dynamic changes in traffic patterns (such as newly opened roads and seasonal changes in traffic flow patterns), an online incremental learning mechanism is designed; at fixed time intervals (such as weekly), the model is fine-tuned and updated using the latest data from the recent period, with a small learning rate during the update. To avoid disrupting the learned general patterns, only some network layer parameters are adjusted.
[0063] Further, step S6 includes:
[0064] Model compression: Using knowledge distillation technology, the deep ST-GCN model is distilled into a lightweight student model. While maintaining a prediction accuracy loss of less than 5%, the number of model parameters is reduced by 60% and the inference speed is increased by 3 times.
[0065] Distributed deployment: The large-scale road network is divided into multiple sub-regions, and an independent prediction model is deployed in each sub-region; the sub-regions are coordinated through boundary node information, which ensures both computational efficiency and maintains the ability to model spatial relationships.
[0066] Prediction result caching: For traffic flows with strong periodicity (such as weekday morning rush hour), prediction results are cached and recalculated only when abnormal patterns are detected, further reducing computational overhead.
[0067] This invention constructs an end-to-end intelligent traffic flow prediction and signal optimization system through the aforementioned technical solution. The system first establishes a spatial correlation foundation by constructing a road network topology map. Then, it extracts rich feature information through multi-source data fusion. Next, it employs a spatiotemporal graph neural network to simultaneously model spatial correlation and temporal dependence, achieving accurate prediction of future traffic flow. Finally, it performs forward-looking signal optimization based on the prediction results, achieving seamless integration of prediction and optimization. The entire system realizes deep integration of road network topology, spatiotemporal correlation, and multi-source data, achieving forward-looking signal optimization based on accurate prediction. This effectively improves traffic management efficiency and road network capacity, providing efficient and reliable technical support for smart city traffic management.
[0068] The beneficial effects of this invention are as follows: By constructing a topological graph structure of the urban road network and integrating multi-source heterogeneous data such as historical traffic flow data, real-time detection data, meteorological information, and traffic events, a deep learning architecture combining graph convolutional networks and time-series prediction models is adopted to achieve accurate short-term prediction of traffic flow at intersections and road segments. Based on the prediction results, traffic signal timing schemes are dynamically optimized, thereby effectively alleviating urban traffic congestion, improving road network efficiency, and reducing vehicle delays and environmental pollution. Specific advantages are as follows:
[0069] 1. By deeply integrating road network topology, spatiotemporal correlation, and multi-source heterogeneous data, this invention reduces the average absolute error of traffic flow prediction by 30-40% and controls the average relative error to within 10% compared to traditional time series methods and single data source methods, providing a reliable data foundation for subsequent signal optimization.
[0070] 2. This invention innovatively applies graph neural networks to traffic flow prediction, aggregating neighbor node information through graph convolution to effectively capture the spatial propagation effect of traffic flow. Compared to methods that treat intersections as independent units, this invention can understand the impact of upstream traffic changes on downstream flow, improving prediction accuracy by 15-25%, and showing significant advantages, especially in the process of traffic congestion propagation and dissipation.
[0071] 3. By optimizing signals based on predictions rather than the current state, proactive scheduling is achieved. Actual deployment data shows that compared to traditional fixed timing and dynamic timing methods based on the current state, average vehicle delays are reduced by 15-25%, queue lengths are reduced by 20-30%, and road network efficiency is improved by 12-18%, significantly alleviating traffic congestion.
[0072] 4. By integrating multi-source data such as meteorological, event, and temporal characteristics, the model can adapt to complex scenarios such as different weather conditions, emergencies, and holidays, significantly improving the stability of prediction and optimization results. Even under severe weather or sudden accidents, the system maintains good performance, demonstrating strong robustness.
[0073] 5. Through optimization techniques such as model compression and distributed deployment, the prediction and optimization calculation time is controlled within 5 seconds, meeting the real-time requirements of traffic signal control. The system can update signal timing every minute, achieving true dynamic optimization and supporting real-time deployment applications on large-scale road networks.
[0074] 6. The online incremental learning mechanism enables the model to adapt to long-term changes in traffic patterns, such as newly opened roads, seasonal traffic changes, and urban development. Through regular updates, the model's performance remains stable over long-term operation, avoiding the drawbacks of traditional methods that require retraining and reducing maintenance costs.
[0075] 7. By considering the coordinated optimization of multiple adjacent intersections, the optimization has been expanded from single-point optimization to regional coordination. The formation of green wave zones on main roads allows vehicles to pass through multiple intersections continuously at a certain speed, further improving the overall traffic efficiency of the road network, and is particularly suitable for traffic management on urban main roads.
[0076] 8. The technical framework has good scalability and can be applied to different scenarios from small-scale areas (a dozen intersections) to large-scale urban road networks (hundreds of intersections). Through distributed deployment and modular design, the system can be flexibly configured and expanded according to actual needs, and has broad application prospects.
[0077] 9. By optimizing signal timing to reduce vehicle delays and queuing, the number of vehicle start-stop cycles and idling time are significantly reduced, thereby reducing exhaust emissions and fuel consumption. It is estimated that CO2 emissions can be reduced by 8-12% in the areas where this invention is implemented, demonstrating significant environmental benefits.
[0078] 10. Alleviating traffic congestion not only improves residents' travel experience but also brings significant economic benefits. Reduced vehicle delays lower time and fuel costs, while improved logistics efficiency promotes economic development. In terms of commercial value, this invention can be widely applied in various fields such as smart city construction, traffic management services, and signal equipment optimization, and has broad market prospects. Attached Figure Description
[0079] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0080] The present invention will be further illustrated below with reference to the accompanying drawings and specific embodiments. It should be understood that the following specific embodiments are for illustrative purposes only and are not intended to limit the scope of the invention.
[0081] As shown in the figure, this embodiment provides a method for urban traffic flow prediction and signal optimization based on spatiotemporal graph neural networks. Taking a road network in the central area of a city containing 25 signal-controlled intersections as the application scenario, the specific solution is as follows:
[0082] I. System Architecture and Road Network Modeling
[0083] This embodiment constructs an intelligent traffic flow prediction and signal optimization system, comprising a data acquisition module, a road network topology construction module, a feature extraction module, a prediction model module, a signal optimization module, and a control execution module. Each module executes sequentially according to the technical solutions described in the invention, forming a complete prediction-optimization-execution closed-loop system. First, road network topology construction is performed to lay the foundation for subsequent spatial correlation modeling.
[0084] Road network topology construction: The central area contains 25 intersections (numbered as follows) to ), 58 directed road segments. Construct a directed graph. ,in , Adjacency matrix The construction uses the following formula:
[0085]
[0086] Where the distance attenuation coefficient (Distance unit: meters), road grade weight set as: main road Secondary roads branch road For example, intersections and If directly connected by a main road of 350 meters in length, then For intersections without direct connections, .
[0087] Each node static feature vectors This includes: intersection type coding (one-hot, 4-dimensional: crossroads, T-junctions, Y-junctions, roundabouts), whether it is a signal-controlled intersection (1-dimensional, 0 or 1), average number of lanes (1-dimensional), presence of turning restrictions (1-dimensional), and whether it is a major road node (1-dimensional). Through static features, the model can understand the structural differences between different intersections.
[0088] II. Implementation of Multi-Source Data Acquisition and Feature Extraction
[0089] Historical traffic data: The system connects to geomagnetic induction coil detectors at 25 intersections, collecting traffic data for the past 12 time steps (corresponding to the past hour, with a time step length of 5 minutes). For intersections Assuming the historical flow sequence is (Unit: vehicles / hour) This sequence shows a trend of gradually increasing traffic flow during the morning peak.
[0090] According to the method for extracting historical traffic features in the invention, a one-dimensional convolutional neural network is used to extract features from the historical traffic sequence. The specific calculation formula is as follows:
[0091]
[0092] The convolution kernel size is 3, the stride is 1, and the number of output channels is 64. After convolution and pooling operations, the historical traffic feature vector is obtained. ,Right now .
[0093] Real-time detection data: Video detection equipment is also deployed at each intersection to collect real-time data such as the number of vehicles, queue length, and occupancy rate. For intersections... Real-time feature vectors This includes: current number of vehicles (85), average queue length (45 meters), occupancy rate (0.72), average vehicle speed (28 km / h), delay time (32 seconds), and throughput rate (0.68 vehicles / second). .
[0094] External influencing factors: The system accesses the meteorological bureau's API to obtain real-time weather data, and the traffic management center's API to obtain information on traffic accidents, construction, etc. External feature vectors Includes: rainfall (0mm), visibility (10km), temperature (22°C), wind speed (3m / s), whether there is an accident (0 indicates no, 1 indicates yes), whether there is construction (0 indicates no), whether it is a weekday (1 indicates yes, 0 indicates no), current hour (8, indicating 8 o'clock), current day of the week (1 indicates Monday), whether it is a holiday (0 indicates no), whether it is morning rush hour (1 indicates yes), whether it is evening rush hour (0 indicates no). .
[0095] According to the feature splicing method in the invention, the above-mentioned historical traffic features, real-time detection features, external influence features and static features are spliced together to obtain nodes. At any moment Complete feature vector:
[0096]
[0097] in ,Right now This complete feature vector integrates information from multiple sources, providing rich input for subsequent spatiotemporal graph neural network predictions.
[0098] III. Implementation of Spatiotemporal Graph Neural Network Prediction
[0099] Based on the previously constructed road network topology map and extracted node feature vectors, this embodiment performs prediction according to the spatiotemporal graph neural network architecture described in the invention. The prediction process consists of three stages: spatial graph convolution, temporal modeling, and prediction output. Through joint modeling of spatial correlation and temporal dependence, accurate prediction of future traffic flow is achieved.
[0100] Implementation of spatial graph convolution: Following the spatial graph convolution method described in the invention, a two-layer graph convolutional network is employed. Spatial feature aggregation is performed. Input feature dimensions. The first layer of graph convolution expands the node feature dimension from 90 to 128, while the second layer maintains 128 dimensions.
[0101] Normalized adjacency matrix The calculation method is as follows: First, calculate the degree matrix. (Diagonal matrix, diagonal elements) Represents a node The degree, i.e., the number of neighboring nodes connected to the node plus 1), and then... Perform symmetric normalization, i.e. ,in The identity matrix is used for self-joins. The normalization operation can balance nodes of different degrees, preventing nodes with high degrees (intersections that connect more neighbors) from having an excessive impact on the results.
[0102] For nodes According to the spatial graph convolution formula in the invention, the first layer graph convolution is calculated as follows:
[0103]
[0104] in For nodes The feature representation at layer 0 (i.e., the input layer), and The learnable parameter matrix and bias vector of the first layer graph convolution. This is the ReLU activation function. The calculation process of this formula is as follows: for node... Each neighbor node (Including itself), first its characteristics Through linear transformation matrix Mapped to a 128-dimensional space, then based on normalized adjacency weights. The weighted features are then summed, and finally a bias is added to the sum of the weighted features of all neighboring nodes. After passing through the ReLU activation function, the following is obtained: Spatial aggregation characteristics. Due to exist direct neighbor nodes (such as Larger values at these locations indicate that the characteristics of these neighbors will contribute more to the overall score. The spatial aggregation characteristics reflect the spatial propagation effect of traffic flow.
[0105] After two layers of graph convolution, the nodes are obtained. Spatial features in the second layer This feature integrates information from multi-hop neighbor nodes, capturing a wider range of spatial relationships.
[0106] Temporal modeling implementation: After completing spatial graph convolution, a gated recurrent unit (GRU) network is used to model temporal dependencies, with hidden layer dimensions... For nodes The spatial characteristics at the current moment and the hidden state of the previous moment Input the GRU network and calculate according to the time-series modeling formula in the invention:
[0107]
[0108] in The final spatial features are obtained after two layers of graph convolution. The hidden state of the previous moment ( ), The hidden state at the current moment. By selectively memorizing historical information through updating and resetting gates, GRU can capture the periodic patterns (such as the repetitiveness of weekday morning rush hour) and long-term trend changes of traffic flow, thus enabling effective modeling of long- and short-term dependencies.
[0109] Predictive output implementation: After completing spatial graph convolution and temporal modeling, spatial features and temporal hidden states are fused, and the future output is generated through a fully connected layer. Traffic prediction for each time step (corresponding to the next hour, with a time step size of 5 minutes). For nodes The calculation is performed according to the predicted output formula in the invention description:
[0110]
[0111] in The spatial features are 128 in dimension (after two layers of graph convolution). Temporally hidden state ( ), This represents a vector concatenation operation. (Spatial feature dimension 128 and GRU hidden layer dimension) (After splicing, it becomes 256-dimensional) and The weight matrix and bias vector of the output layer. For nodes The predicted flow sequence for the next 12 time steps. Assume the prediction result is... (Unit: vehicles / hour) This shows the trend of traffic flow first increasing and then decreasing in the next hour, consistent with the traffic flow pattern during the morning rush hour. This prediction result will be used as input for subsequent signal optimization.
[0112] IV. Implementation of Signal Optimization Algorithm
[0113] Based on the traffic flow prediction results obtained from the spatiotemporal graph neural network described above, this embodiment performs dynamic timing optimization according to the signal optimization algorithm described in the invention. (Taking an intersection...) For example, this intersection uses four-phase signal control (east-west straight, east-west left turn, north-south straight, north-south left turn), that is... Cycle duration seconds, total lost time The time is 1 second (including the total time of yellow and all-red lights in all phases, with an average loss of about 3 seconds per phase).
[0114] Predicted traffic flow to phase-based traffic flow mapping: Based on historical statistics of intersection turning ratios, the predicted total traffic flow is mapped... ( The traffic flow is allocated to each phase. Assume east-west traffic accounts for 60%, north-south traffic for 40%; straight-through traffic accounts for 70%, and left-turn traffic for 30%. Then the east-west straight-through phase ( The predicted flow is According to the phase-average flow calculation formula in the invention, the first... Average arrival flow for each phase within the forecast period:
[0115]
[0116] in Assume the average flow rate for the east-west straight phase is calculated. Vehicles per hour. Similarly, the average flow rate for other phases can be calculated. , , .
[0117] Delay calculation: Assuming saturation flow rate in the east-west straight phase. Vehicles per hour. Current green light duration. Seconds, according to the definition in the invention, are green light ratios. saturation This indicates that the phase is in an oversaturated state, resulting in a large delay.
[0118] Calculate the average vehicle delay for this phase using the Webster delay formula described in the invention:
[0119]
[0120] Substitute specific values: Seconds per vehicle. Since the saturation level exceeds 1, the second term becomes negative, leading to potentially higher actual delays. Therefore, a correction formula is used to handle the oversaturation situation, approximating the oversaturation delay as... Seconds per vehicle.
[0121] Optimization Solution: Following the optimization objective function described in the invention, the goal is to minimize the weighted total delay of the four phases.
[0122]
[0123] Set phase weight (The main road runs east-west). (North-south direction is a secondary arterial road). Constraints include: minimum green light duration constraint. Seconds, maximum green light duration constraint Seconds, period duration constraint Fixed seconds and total green light ratio constraint ,in .
[0124] According to the optimization solution method described in the invention, the Sequential Quadratic Programming (SQP) algorithm is used to solve this nonlinear programming problem. The specific steps of the SQP algorithm are as follows: First, the nonlinear optimization problem is approximated twice at the current solution, transforming it into a quadratic programming subproblem; then, this quadratic programming subproblem is solved to obtain the search direction; next, a line search is performed along the search direction to determine the step size; finally, the solution is updated and convergence is checked. If convergence is not achieved, the above process is repeated. After iterative solving and optimization, a new timing scheme is obtained. Second, Second, Second, The total effective green light duration is 108 seconds, plus a 12-second lost time, for a cycle of 120 seconds. After optimization, the green light ratio for east-west straight-ahead phases is improved to [missing information]. saturation decreased (Still slightly greater than 1 but improved), delays were reduced by about 15%, effectively alleviating congestion in this phase.
[0125] V. Model Training Implementation
[0126] To ensure that the spatiotemporal graph neural network prediction model described above can accurately predict traffic flow, this embodiment trains the model according to the training strategy described in the invention. The training process is divided into two stages: offline pre-training and online incremental updating, learning the spatiotemporal evolution patterns of traffic flow through historical data.
[0127] Training dataset: Historical traffic data collected over the past 6 months, including 25 intersections ( The system records traffic every 5 minutes, totaling approximately 130,000 data samples. The data is divided chronologically, with the first 5 months' data used for training (108,000 records) and the last month's data used for validation (22,000 records).
[0128] Offline pre-training phase: Adam optimizer is used, initial learning rate... The batch size is 32. A learning rate decay strategy is used during training, multiplying the learning rate by 0.9 every 10 epochs. To prevent overfitting, Dropout is used in the GRU and fully connected layers, with a Dropout rate set to 0.3.
[0129] According to the definition of the loss function in the invention, the total loss function adopts a weighted combination of MSE and MAE, with weighting coefficients... :
[0130]
[0131] in , , For nodes At any moment The actual traffic value, This corresponds to the predicted flow rate. Substitute the specific values:
[0132]
[0133] After training for 50 epochs, the MSE on the validation set decreased to 1250 (vehicles / hour)², the MAE decreased to 28 vehicles / hour, and the average relative error was 8.5%, indicating that the model has good prediction accuracy and can provide reliable prediction input for signal optimization.
[0134] Online Incremental Update: To adapt to dynamic changes in traffic patterns (such as newly opened roads and seasonal changes in traffic flow), following the online incremental update strategy described in the invention, the system incrementally updates the model every Sunday evening using new data from the past week. During the update, only the parameters of the fully connected layers are adjusted, and the learning rate is set to... The model is trained for 5 epochs. Through online updates, it can adapt to seasonal changes in traffic patterns and the impact of newly opened roads, maintaining the stability of long-term prediction accuracy.
[0135] VI. System Deployment and Performance Optimization
[0136] Model compression: Knowledge distillation technique was used to distill the deep ST-GCN model (approximately 1.2 million parameters) into a lightweight model (approximately 450,000 parameters). The student model uses fewer graph convolutional layers (1 layer) and a smaller hidden dimension (64), with a prediction accuracy loss of only 4.2% on the validation set, but an inference speed improvement of 3.5 times.
[0137] Distributed deployment: Divide the 25 intersections into 3 sub-regions (Region 1: intersections) - Area 2: Intersection - Area 3: Intersection - Each sub-region deploys an independent prediction model. Sub-regions exchange information through traffic information at boundary nodes to ensure prediction consistency.
[0138] Real-time performance: After optimization, the total time for a single prediction and optimization calculation is approximately 3.2 seconds (2.1 seconds for prediction and 1.1 seconds for optimization), meeting the 5-second real-time requirement. The system performs prediction and optimization once per minute, dynamically adjusting the signal timing scheme.
[0139] Actual results: After three months of deployment and operation, statistics show that the average vehicle delay at the 25 intersections decreased by 18.3%, the average queue length decreased by 22.1%, and the road network traffic efficiency increased by 15.6%, achieving significant practical results.
[0140] Through the detailed description of this embodiment, those skilled in the art can clearly understand the technical solution of the present invention, and can implement the present invention in actual application scenarios according to the described method and system configuration, so as to achieve efficient and accurate traffic flow prediction and signal optimization.
[0141] This invention abstracts urban road networks into a graph structure, encoding multi-dimensional information such as road segment connectivity, distance decay, and road class through an adjacency matrix. This enables the graph neural network to understand the spatial constraints of the road network and the propagation paths of traffic flow. The design of the adjacency weights takes into account distance decay and road class, conforming to the physical laws of traffic flow propagation and laying a solid foundation for subsequent spatial feature aggregation.
[0142] This invention innovatively combines graph convolutional networks with temporal networks to construct a spatiotemporal graph neural network architecture. The graph convolutional module aggregates multi-hop neighbor information through multi-layer convolution, effectively capturing the spatial propagation effect of traffic flow; the temporal module models long- and short-term dependencies and periodic patterns through a GRU network. Working together, these two modules achieve comprehensive modeling of the spatiotemporal evolution of traffic flow.
[0143] This invention not only utilizes historical traffic flow data, but also integrates multi-source heterogeneous data such as real-time detection data, meteorological information, traffic events, and time features. By using feature splicing and neural networks to automatically learn the correlation between different data sources and their synergistic impact on traffic flow, the robustness and accuracy of the prediction model are improved.
[0144] This invention differs from traditional methods that separate prediction and optimization. Instead, it directly designs the optimization objective function and constraints based on the prediction results, achieving a seamless integration of prediction and optimization. The optimization algorithm considers the overall performance during the prediction period, rather than just the current state, enabling proactive scheduling and better handling of sudden congestion and traffic spikes.
[0145] This invention significantly reduces computational complexity while maintaining prediction accuracy through techniques such as model compression, distributed deployment, and prediction result caching. The signal optimization algorithm employs a fast approximate solution method, meeting the real-time requirements of traffic signal control and realizing the transformation from theoretical research to engineering application.
[0146] This invention designs an online incremental learning mechanism that periodically fine-tunes and updates the model using new data, enabling the model to adapt to dynamic changes in traffic patterns and maintain long-term effectiveness and accuracy. This adaptive capability is crucial for addressing long-term influencing factors such as urban development and road network changes.
[0147] This invention considers green wave coordination optimization for multiple adjacent signal-controlled intersections, calculating the coordination phase difference based on predicted traffic flow to optimize traffic efficiency in the arterial direction. Through distributed optimization or centralized coordination, it extends from single-point optimization to regional coordination, further improving system performance.
[0148] The above embodiments are merely typical illustrative methods of the present invention, and the scope of protection of the present invention is not limited thereto. All equivalent substitutions and improvements made under the concept of the present invention should fall within the scope of protection. It should be emphasized that any modifications or minor adjustments made by those skilled in the art without departing from the basic principles of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A method for urban traffic flow prediction and signal optimization based on spatiotemporal graph neural networks, characterized in that, Specifically, the following steps are included: S1. First, the urban road network is abstracted into a graph structure, so as to use graph neural networks to model spatial relationships and realize the construction of urban road network topology graph; S2. Based on the completion of the road network topology map construction, integrate multi-source data such as historical traffic data, real-time detection data, and external influencing factors to construct a dynamic feature matrix for each node, thereby realizing the fusion of multi-source heterogeneous data and feature extraction. S3. After completing the multi-source data fusion and feature extraction, a spatiotemporal graph neural network prediction model is constructed. Specifically, the spatiotemporal graph convolutional network ST-GCN architecture is designed. It utilizes the constructed road network topology map and node feature vectors to model the spatial association and temporal dependency of the road network. The spatial propagation effect is captured through the spatial graph convolution module, and the temporal evolution law is captured through the temporal modeling module. The two are combined by adopting a spatiotemporal feature fusion and prediction mechanism to obtain accurate traffic prediction. S4. Based on the future traffic prediction results obtained from the spatiotemporal graph neural network prediction model, design a dynamic signal optimization algorithm to realize the integrated design of prediction and optimization. It uses the predicted future traffic flow as the optimization input, calculates the expected delay of each phase, establishes the optimization objective function, solves the optimal signal timing scheme, and thus achieves forward-looking traffic signal control. S5. In order to enable the constructed spatiotemporal neural network prediction model to accurately learn the spatiotemporal evolution of traffic flow, a multi-stage training strategy and an online update mechanism are adopted. The model parameters are trained using historical data and continuously adapted to changes in traffic patterns. S6. Based on the completion of prediction model construction and training, improve efficiency by adopting model compression, distributed computing and caching strategies.
2. The urban traffic flow prediction and signal optimization method based on spatiotemporal graph neural networks according to claim 1, characterized in that, In step S1, it is assumed that the urban road network includes Each intersection is a node. Each road segment is an edge; construct a directed graph. ,in For the set of nodes, Let be the set of edges. Let's consider the adjacency matrix; adjacency matrix The definition considers multiple factors, including road segment connectivity, distance attenuation, and road grade; for nodes and If there are directly connected road segments, the adjacency weight is defined as follows: in For nodes To the node The distance of the road section This is the distance attenuation coefficient. Assigning weights to road classifications It serves as a connectivity indicator; when there is no direct connection between nodes, To enhance the expressive power of graph representation, each node... It also has static feature vectors , It is a static feature dimension; each edge also has a feature vector.
3. The urban traffic flow prediction and signal optimization method based on spatiotemporal graph neural networks according to claim 1, characterized in that, In step S2, Historical traffic data: for each node Extract the past Historical flow sequence at each time step ,in Represents a node At any moment Traffic flow data; to further extract temporal patterns, a one-dimensional convolutional neural network is used to extract features from historical sequences; the one-dimensional convolution operation captures local temporal patterns and trend features in historical traffic sequences by sliding the convolution kernel along the time dimension; the specific implementation is as follows: in This represents a one-dimensional convolution operation, which involves performing convolution operations on the input sequence using multiple convolution kernels. Each kernel extracts temporal features at different scales, and then the sequence is reduced in dimensionality through pooling. For the extracted historical traffic feature vector, Historical traffic characteristics dimension; Real-time detection data: Acquire real-time vehicle count, queue length, and occupancy rate data for each intersection to form a real-time feature vector. ,in For real-time feature dimensions; External influencing factors: The external feature vector is constructed by integrating meteorological data, traffic events, and time characteristics. ,in External feature dimension; The above features are concatenated to obtain nodes. At any moment Complete feature vector: in This represents a vector concatenation operation. The total dimension of node features. This is a static feature dimension.
4. The urban traffic flow prediction and signal optimization method based on spatiotemporal graph neural network according to claim 1, characterized in that, In step S3, The spatial graph convolution module includes: using a graph convolutional network (GCN) to aggregate feature information of neighboring nodes to capture the spatial propagation effect of traffic flow; the specific implementation process is as follows: First, for the original adjacency matrix Normalization is performed to obtain a normalized symmetric adjacency matrix. ,in For degree matrix, It is the identity matrix; Then, for the node Its spatial features are updated as follows: in For nodes In the Layer feature representation, and For the first The learnable parameter matrix and bias vector of layer graph convolution. For activation function, For nodes In the Spatial aggregation features after layer graph convolution; the calculation process is as follows: first, for each neighbor node... Linear transformation of features Then, based on the normalized adjacency weights Perform a weighted summation, then add a bias and pass it through an activation function; The temporal modeling module includes: modeling the temporal evolution of traffic flow using a gated recurrent unit (GRU) network; for each node, the spatially convolutional feature sequence is input into the GRU: in For the process The final spatial features after layer graph convolution, For the previous moment The hidden state, For the current moment The hidden state, This represents the hidden layer dimension of GRU. GRU, through its selective memory mechanism of update gates and reset gates, is able to capture the long-term and short-term dependencies and periodic patterns of traffic flow. Specifically, the update gate controls the degree of retention of historical information, while the reset gate controls the degree of forgetting of historical information. The spatiotemporal feature fusion and prediction mechanism includes fusing spatial features and temporal hidden states, and outputting the future through a fully connected layer. Traffic prediction at each time step: in and The weight matrix and bias vector of the output layer. For nodes future Predicted flow sequence at each time step.
5. The urban traffic flow prediction and signal optimization method based on spatiotemporal graph neural network according to claim 1, characterized in that, In step S4, For each signalized intersection, the objective is to minimize the total vehicle delay within the prediction period, while considering the priority of different turning flows; let the intersection... have The phase, the first The green light duration for each phase is The cycle duration is , Total lost time, including yellow light and all-red light time; Based on predicted flow , Calculate the first Average arrival flow for each phase within the forecast period: in For the intersection phase At any moment The corresponding predicted flow is obtained by allocating the total predicted flow to each phase according to the historical turning ratio; according to the Webster delay formula, the first... The average vehicle delay per phase is: in For phase The green credit ratio, For phase The saturation; the first term of the formula To ensure even delays, the second item For random delays; The signal optimization problem is described as follows: The objective of the signal optimization problem is to minimize the weighted total delay across all phases, where For phase The weighting coefficients, For phase Predicted traffic, For phase The delay; The constraints include: minimum green light duration constraint. Maximum green light duration constraint Period duration constraint and the total constraint of green credit ratio .
6. The urban traffic flow prediction and signal optimization method based on spatiotemporal graph neural network according to claim 1, characterized in that, Step S5 includes: Offline pre-training phase: The spatiotemporal graph neural network is trained on historical traffic data; the training dataset includes historical traffic flow sequences, road network topology information, and meteorological data from the past few months; the loss function is defined as a weighted combination of the mean squared error (MSE) and mean absolute error (MAE) of the predicted and actual traffic flows. in For nodes At any moment The actual traffic value, The corresponding model prediction value, Here are the weighting coefficients for MSE and MAE losses; the Adam optimizer is used, and the learning rate is set to... The batch size is 32, and the training lasts for 50 epochs. To prevent overfitting, early stopping and Dropout regularization are used. Online incremental update: To adapt to the dynamic changes in traffic patterns, an online incremental learning mechanism is designed; at fixed time intervals, the model is fine-tuned and updated using the latest data from the recent period. A small learning rate is used during the update to avoid disrupting the learned general patterns, and only some network layer parameters are adjusted.
7. The urban traffic flow prediction and signal optimization method based on spatiotemporal graph neural network according to claim 1, characterized in that, Step S6 includes: Model compression: The deep ST-GCN model is distilled into a lightweight student model using knowledge distillation technology; Distributed deployment: The large-scale road network is divided into multiple sub-regions, and an independent prediction model is deployed in each sub-region; the sub-regions are coordinated through boundary node information; Prediction result caching: For traffic flows with strong periodicity, prediction results are cached and recalculated only when abnormal patterns are detected.