A large-scale urban road network traffic state prediction method based on a graph neural network

By constructing a spatiotemporal graph neural network that integrates dedicated road-level components, the problems of missing semantic information and noise interference at the road level in existing technologies are solved, enabling efficient traffic state prediction for large-scale urban road networks and improving prediction accuracy and robustness.

CN122135561APending Publication Date: 2026-06-02CHINESE RES ACAD OF ENVIRONMENTAL SCI
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINESE RES ACAD OF ENVIRONMENTAL SCI
Filing Date
2026-02-09
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing traffic prediction methods cannot effectively model the complex spatiotemporal dependencies and topological structures in large-scale road networks, and ignore road-level semantic information, resulting in insufficient global perception, lack of cross-level interaction, and noise interference from low-level roads, which affects prediction accuracy.

Method used

A spatiotemporal graph neural network integrating road-level dedicated components is constructed. Through a road-level embedding layer, a hierarchical global context module, and a dynamic cross-level attention module, semantic enhancement and global and dynamic relationship modeling of roads of different levels are achieved, while suppressing low-level noise interference.

Benefits of technology

It improves the prediction accuracy and robustness of critical roads in large-scale urban road networks, significantly enhances the modeling capabilities of global perception and cross-level interaction, and ensures the accuracy and practicality of predictions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122135561A_ABST
    Figure CN122135561A_ABST
Patent Text Reader

Abstract

This invention discloses a method for predicting traffic conditions in large-scale urban road networks based on graph neural networks. The method first acquires road network topology and traffic time-series data, extracts road hierarchy information, and constructs graph data. The core lies in building a spatiotemporal graph neural network model that integrates dedicated road hierarchy components: a road hierarchy embedding layer maps discrete levels to continuous vectors to enhance feature semantics; a hierarchical global context module aggregates the global states of similar roads with linear complexity; and a dynamic cross-level attention module models the dynamic interaction dependencies between roads of different levels. This method suppresses noise interference from low-level roads through a hierarchical differentiation strategy and uses a separate weighted loss function for training. This invention effectively solves the problems of insufficient global perception, missing interaction modeling, and significant noise interference caused by neglecting road hierarchy semantics in existing technologies, significantly improving the accuracy and robustness of traffic condition prediction for large-scale urban road networks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of intelligent transportation systems technology, specifically relating to a method for predicting traffic conditions in large-scale urban road networks based on graph neural networks. Background Technology

[0002] With the acceleration of urbanization, traffic congestion has become increasingly serious. Accurate prediction of traffic conditions (such as speed and flow) is crucial for urban traffic management, travel planning, and the construction of smart cities. Early prediction methods were mainly based on statistical models (such as ARIMA) and traditional machine learning methods (such as support vector machines). Although these methods have a certain degree of interpretability, they are difficult to effectively model the complex spatiotemporal dependencies and topological structures in large-scale road networks.

[0003] In recent years, graph neural networks have been widely used in traffic prediction due to their advantages in processing non-Euclidean data (such as road networks). Representative models significantly improve prediction accuracy by constructing a road segment adjacency matrix and combining it with recurrent neural networks or convolutional neural networks to capture spatiotemporal features. However, these existing methods typically treat the road network as a homogeneous graph, meaning that all road nodes are treated equally.

[0004] Analysis revealed the following major shortcomings in existing technologies: First, the semantic information of road levels is lacking, making it impossible for the model to distinguish the essential differences in traffic patterns between different levels of roads, such as highways, arterial roads, and local roads. Second, there is insufficient global context awareness; traditional graph convolution operations are limited to local neighbors and cannot capture the state relationships of similar roads in a global context. Third, cross-level dynamic dependency modeling is lacking, failing to effectively model the time-varying interactive effects between different levels of roads (such as highway congestion causing traffic diversion on national highways). Finally, low-level road noise interference is a significant issue; due to the sparse and noisy nature of low-level road data, global modeling is easily contaminated, affecting the prediction accuracy of high-level critical roads.

[0005] Therefore, there is an urgent need for a large-scale road network traffic prediction method that can integrate prior knowledge of road levels and perform efficient global and cross-level modeling. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method for predicting traffic conditions in large-scale urban road networks based on graph neural networks.

[0007] To achieve the above objectives, the present invention provides the following technical solution:

[0008] This application provides a method for predicting traffic conditions in large-scale urban road networks based on graph neural networks, including the following steps:

[0009] Obtain topology data and traffic time-series data of the target city's road network;

[0010] Based on the topology data, road grade information for each road segment is extracted, and graph data is constructed to represent the spatial structure of the road network.

[0011] The traffic time series data is preprocessed to obtain a normalized dynamic traffic feature sequence;

[0012] A spatiotemporal graph neural network model is constructed, which takes the graph data, the dynamic traffic feature sequence, and the road grade information as input.

[0013] The spatiotemporal graph neural network model includes a dedicated component for fusing the road grade information. This component is used at least for: semantically enhancing node features based on the road grade information, and modeling the global and dynamic relationships between roads of different grades.

[0014] The model is trained using historical data to optimize its parameters;

[0015] Use the trained model to predict future traffic conditions.

[0016] Furthermore, the specific components in constructing the spatiotemporal graph neural network model include:

[0017] The road grading embedding layer is used to map discrete road grading labels into continuous learnable embedding vectors, which are then concatenated with the initial node features to form a grade-aware enhanced feature representation.

[0018] Furthermore, the specific components in constructing the spatiotemporal graph neural network model include:

[0019] The hierarchical global context module is used to group and aggregate node features according to road level, generate global context representations for each level, and fuse the global context representations with local node features through a gating mechanism.

[0020] Furthermore, the hierarchical global context module also includes a hierarchical differentiation strategy:

[0021] Preset a set of active road levels;

[0022] For nodes belonging to the active road level, their fusion process is regulated by the gating mechanism;

[0023] For nodes that do not belong to the active road level, the fusion process performs an identity mapping to ensure that the features of low-level roads are not affected by global context modulation, thereby avoiding noise information from polluting the global aggregation results and interfering with the feature learning of high-level roads.

[0024] Furthermore, the specific components in constructing the spatiotemporal graph neural network model include:

[0025] The dynamic cross-level attention module is used to apply a multi-head self-attention mechanism to a sequence composed of global features of each level, so as to dynamically model the interaction dependencies between different road levels, and fuse the modeling results back to the node features through residual gating.

[0026] Furthermore, the preprocessing of the traffic time-series data specifically includes:

[0027] Clean the raw floating car data, filtering out invalid and abnormal records;

[0028] The cleaned data is aggregated at fixed time intervals to calculate the average speed and cumulative flow of each road segment at each time step;

[0029] For time steps with missing values, periodic replication or linear interpolation strategies are used to repair them.

[0030] Furthermore, the construction of graph data for representing the spatial structure of the road network specifically includes:

[0031] The original road network is topologically simplified by merging continuous road segments with the same attributes;

[0032] Based on the simplified road network, an endpoint matching method is used to construct a directed adjacency matrix, and spatial weights are further calculated by combining road segment distances using a Gaussian kernel function.

[0033] Add self-loops to the directed adjacency matrix and perform normalization.

[0034] Furthermore, the method also includes the step of extracting static node features from the topology data, wherein the static node features include at least the encoded road grade, number of lanes, and normalized road length.

[0035] Furthermore, the loss function of the spatiotemporal graph neural network model is a split weighted loss function, which calculates the speed prediction loss and the flow prediction loss separately, and assigns a higher weight to the flow prediction loss, while applying a lower loss weight to data points with a true value of zero.

[0036] Secondly, this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described above.

[0037] Compared with the prior art, this application has the following beneficial effects:

[0038] This invention effectively solves the problems of insufficient global perception, lack of cross-level interaction, and significant noise interference caused by neglecting the semantics of road hierarchy in existing technologies by constructing a spatiotemporal graph neural network that integrates dedicated components for road hierarchy. Its beneficial effects are mainly reflected in: explicitly introducing prior knowledge of road hierarchy, enabling the model to learn the specific traffic patterns of roads of different levels; achieving accurate modeling of the global state of similar roads and the interaction dependencies between dissimilar roads through efficient hierarchical global aggregation and dynamic cross-level attention mechanisms; and effectively suppressing the interference of noise from low-level roads by using a hierarchical differentiation strategy, thereby improving the prediction accuracy of key roads in large-scale urban road networks while ensuring the robustness and practicality of the model. Attached Figure Description

[0039] Figure 1 This is a schematic diagram of the overall architecture of RHA-GWNet provided in an embodiment of the present invention.

[0040] Figure 2 This is a schematic diagram of the data preprocessing process provided in an embodiment of the present invention.

[0041] Figure 3 This is a schematic diagram of the road classification embedding layer provided in an embodiment of the present invention.

[0042] Figure 4 This is a hierarchical global context module structure diagram provided for embodiments of the present invention.

[0043] Figure 5 This is a schematic diagram of a hierarchical differentiation strategy provided in an embodiment of the present invention.

[0044] Figure 6 This is a structural diagram of the dynamic cross-level attention module provided in an embodiment of the present invention.

[0045] Figure 7 This is a schematic diagram of the composition of an electronic device provided in an embodiment of the present invention.

[0046] Figure 8 This is a schematic diagram illustrating the composition of a storage medium provided in an embodiment of the present invention. Detailed Implementation

[0047] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0048] Furthermore, in this invention, an element referred to as fixed to or disposed on another element may be directly disposed on the other element, or there may be an intermediate element. When an element is considered to be connected to another element, it may be directly connected to the other element, or there may be an intermediate element present simultaneously. The terms vertical, horizontal, left, right, and similar expressions used herein are for illustrative purposes only and do not represent the only possible implementation.

[0049] As attached Figure 1 As shown, the complete process of the method of this invention begins with the input of raw data, which then undergoes data preprocessing and feature engineering, and is finally input into the core spatiotemporal graph neural network model for training and prediction. This model takes preprocessed graph-structured data, dynamic spatiotemporal features, and static road attributes as input, and performs feature extraction and fusion through a stacked spatiotemporal convolutional backbone network. The core innovation of the network lies in the embedding of three dedicated hierarchical perception components, which enhance and modulate the features sequentially or in parallel, ultimately outputting predictions of traffic conditions at multiple future time steps.

[0050] Appendix Figure 2 The process is detailed, showcasing the corresponding data processing steps. Starting with the raw road network data and floating car trajectory data, the first step is to simplify the road network topology, merging consecutive road segments with the same attributes. Next, based on the simplified topology, a directed adjacency matrix is ​​constructed, including adjacency relationship determination, Gaussian kernel weighting, and normalization. Simultaneously, the time-series data is cleaned, aggregated, and repaired, and static node features and temporal features are extracted. Finally, all dynamic features are normalized, and the dataset is partitioned to prepare for model training.

[0051] Appendix Figure 3 This demonstrates how discrete road level labels (e.g., 00, 01, ...) are used as indices to look up nodes in a learnable embedding matrix, assigning a dense embedding vector to each node. This embedding vector is then concatenated with the node's original spatiotemporal features, injecting semantic hierarchical information into the model to form an enhanced node feature representation, laying the foundation for subsequent hierarchical perception modeling.

[0052] Appendix Figure 4 With appendix Figure 5 The following content was jointly explained: (see attached document) Figure 4 As shown, the HGC module first uses a level mask matrix to group all node features by level, aggregating them to generate context vectors representing the global state of each level. Subsequently, this vector is passed through a gating network to generate a modulated signal. (See attached diagram.) Figure 5As shown, a hierarchical differentiation strategy is adopted when applying the modulation signal: for the preset critical road level, the calculated gate value is used for feature modulation; for non-critical levels, a gate signal with a value of 1 is forced to be used, thereby effectively shielding the interference of low-level road noise and achieving accurate global context awareness.

[0053] like Figure 6 As shown, firstly, summary representations of each level are extracted from the node features, and then multi-head attention is calculated among these level representations. The attention mechanism can dynamically learn the mutual influence weights between roads of different levels, generating features containing cross-level interaction information. Finally, through a learnable gating network, this cross-level information is fused back into the features of each node in a residual manner, thereby modeling and utilizing dynamic, hierarchical traffic dependencies.

[0054] The technical solution of this application will be further described in detail below with reference to the accompanying drawings:

[0055] This application provides a method for predicting traffic conditions in large-scale urban road networks based on graph neural networks, including the following steps S1-S6:

[0056] S1. Obtain the topology data and traffic time-series data of the target city's road network;

[0057] S2. Based on the topology data, extract the road grade information of each road segment and construct graph data to represent the spatial structure of the road network;

[0058] S3. Preprocess the traffic time series data to obtain a normalized dynamic traffic feature sequence;

[0059] S4. Construct a spatiotemporal graph neural network model, which takes the graph data, the dynamic traffic feature sequence, and the road grade information as input;

[0060] The spatiotemporal graph neural network model includes a dedicated component for fusing the road grade information. This component is used at least for: semantically enhancing node features based on the road grade information, and modeling the global and dynamic relationships between roads of different grades.

[0061] S5. Train the model using historical data to optimize the model parameters;

[0062] S6. Use the trained model to predict future traffic conditions.

[0063] In this embodiment, the method first performs the steps described above for obtaining the topological data and traffic time-series data of the target city's road network, specifically as follows:

[0064] Obtain raw road network geographic information data and traffic time-series data such as floating car GPS trajectories for the target city, such as Jinan; then, parse the road classification of each road segment from the topology data. The attributes directly characterize the road level, thereby completing the step of extracting the road level information of each road segment, and constructing graph structure data such as directed adjacency matrices based on topological connection relationships, thus constructing graph data to represent the spatial structure of the road network.

[0065] Next, the traffic time series data is cleaned, aggregated, repaired, and normalized to obtain a standardized speed and flow characteristic sequence. This step corresponds to preprocessing the traffic time series data to obtain a normalized dynamic traffic characteristic sequence.

[0066] The core lies in constructing a novel spatiotemporal graph neural network model, namely:

[0067] RHA-GWNet (Road-HierarchyAwareGraphWaveNet) is a model that takes preprocessed graph data, dynamic feature sequences, and road hierarchy information as input. It integrates three dedicated components: a road hierarchy embedding layer, a hierarchical global context module, and a dynamic cross-level attention module. This enables the construction of a spatiotemporal graph neural network model. The model includes a dedicated component for fusing the road hierarchy information. This component is used at least to semantically enhance node features based on the road hierarchy information and to model the global and dynamic relationships between roads of different levels.

[0068] Finally, the model is trained using historical data to optimize parameters, and the trained model is ultimately used to predict future traffic conditions.

[0069] In one specific implementation, the dedicated component in constructing the spatiotemporal graph neural network model specifically includes: a road level embedding layer, used to map discrete road level labels into continuous learnable embedding vectors, and concatenate them with initial node features to form a level-aware enhanced feature representation.

[0070] In this embodiment, the specific implementation method of the road level embedding layer includes: first, defining a learnable embedding matrix E with a dimension of L multiplied by d, where L represents the number of levels, which is 6 in this embodiment, and d represents the embedding dimension, with a default value of 8.

[0071] For each node n, based on its road grade identifier The corresponding d-dimensional continuous embedding vector is obtained through a table lookup operation. .

[0072] The embedding vector is compared with the node's original spatiotemporal feature vector. The features are concatenated to obtain the enhanced node feature representation. This allows discrete hierarchical semantic information to be integrated into the model's feature space, achieving hierarchical awareness-based feature enhancement.

[0073] In one specific implementation, the dedicated component in constructing the spatiotemporal graph neural network model specifically includes: a hierarchical global context module, used to aggregate node features by road level, generate global context representations for each level, and fuse the global context representations with local node features through a gating mechanism.

[0074] In this embodiment, the implementation method of the hierarchical global context module, i.e., the HGC module, specifically includes: firstly, constructing a level mask matrix M, the dimension of which is the total number of nodes N multiplied by the number of levels L, and matrix elements... The value is 1 if node n belongs to level l, and 0 otherwise.

[0075] Using this mask matrix, the node feature matrix H is aggregated into a global feature matrix G at each level through a specific formula.

[0076] The aggregation here uses element-wise division and introduces a vector of all 1s. Participate in the calculation.

[0077] Next, G is transformed using an MLP consisting of two fully connected layers. This MLP includes a bottleneck layer structure that compresses the feature dimension to 1 / r of the original dimension (r is the compression factor, with a default value of 4) to reduce computation and enhance generalization ability. Subsequently, a gating signal is generated using the Sigmoid activation function. Finally, the gating signal is broadcast back to each node through a mask matrix and multiplied element-wise with the original features of the node to achieve the fusion of global context information.

[0078] In one specific implementation, the hierarchical global context module further includes a hierarchical differentiation strategy: a set of active road levels are preset; for nodes belonging to the active road levels, their fusion process is controlled by the gating mechanism; for nodes not belonging to the active road levels, their fusion process performs an identity mapping, so that the features of low-level roads are not affected by global context modulation, thereby avoiding noise information from polluting the global aggregation results and interfering with the feature learning of high-level roads.

[0079] In this embodiment, the hierarchical differentiation strategy is part of the HGC module, and its implementation method specifically includes: generating a gating signal. However, this is not applied to all levels; this embodiment pre-defines a set of active road levels, for example... It includes 0, 1, and 2, which correspond to highways, urban expressways, and national highways, respectively.

[0080] For level l belonging to these activity levels, its gating value The values ​​are calculated using the MLP; for inactive levels, such as provincial roads, county roads, and town / village roads, the gate value is forcibly set to 1.0. This ensures that in subsequent feature modulation steps, the gate signal corresponding to inactive level nodes is an all-1 vector, equivalent to performing an identity mapping, meaning that the features of these nodes remain unchanged and are not affected by global context modulation. The core function of this strategy is to ensure that global context aggregation and modulation only occur between active levels (highways, urban expressways, national highways), avoiding the pollution of global aggregation results by low-level road information that is sparse and noisy, thereby improving the prediction accuracy of high-level critical roads.

[0081] In one specific implementation, the dedicated component in the construction of the spatiotemporal graph neural network model specifically includes: a dynamic cross-level attention module, which is used to apply a multi-head self-attention mechanism on the sequence composed of global features of each level to dynamically model the interactive dependencies between different road levels, and to fuse the modeling results back to the node features through residual gating.

[0082] In this embodiment, the implementation method of the Dynamic Cross-Level Attention (DCLA) module includes: First, reusing the aggregation mechanism of HGC to obtain the level feature representation Z. Then, applying a standard multi-head self-attention mechanism (the number of attention heads h is 2 by default) across L levels: Z is respectively compared with the learnable weight matrix. , , Multiply to obtain query Q, key K, and value V. Calculate the scaled dot product attention, where... is the dimension of the key vector.

[0083] The resulting attention output Attn contains dynamic cross-level dependencies. Finally, a learnable gating network is used to generate a fusion weight gate, and cross-level information is injected into the node features in a residual manner to complete the modeling and fusion of dynamic interactive dependencies.

[0084] In one specific implementation, the preprocessing of traffic time-series data includes: cleaning the original floating car data and filtering out invalid and abnormal records; aggregating the cleaned data at fixed time intervals and calculating the average speed and cumulative flow of each road segment at each time step; and repairing time steps with missing values ​​using periodic replication or linear interpolation strategies.

[0085] In this embodiment, the specific steps of the preprocessing include: the cleaning process includes filtering records in the original data where the road length is 0 or 65535 and the travel time is less than or equal to 0.

[0086] Instantaneous speed v is calculated based on road segment length roadLen and travel time travelTime, and outliers with speeds below 1 km / h or above 120 km / h are removed.

[0087] The spatiotemporal aggregation process aggregates data into time steps at fixed time intervals Δt, with a default interval of 20 minutes. For each road segment n, the average speed is calculated within each time step t. and cumulative traffic The calculation involves the set of valid records for road segments within that time period. The missing value repair strategy is as follows: for time steps with data coverage below 0.1%, historical data from the same period last week is copied and used to fill the gaps; for sporadic missing values, linear interpolation between the preceding and following time steps is used for repair.

[0088] In one specific implementation, the construction of graph data to represent the spatial structure of the road network specifically includes: topological simplification of the original road network, merging continuous road segments with the same attributes; based on the simplified road network, constructing a directed adjacency matrix using the endpoint matching method, and further calculating spatial weights by combining road segment distances with a Gaussian kernel function; adding self-loops to the directed adjacency matrix and performing normalization processing.

[0089] In this embodiment, topology simplification is performed based on a directed graph, merging continuous roads of different levels. Adjacent road segments with the same direction are considered adjacent. The adjacency matrix is ​​constructed using an exact endpoint matching method; if the simplified endpoint coordinates of road segment i are equal to the starting coordinates of road segment j, then the two are considered adjacent. The weighting and normalization process includes calculations based on the distance between road segments. Calculating the Gaussian kernel weights involves the Gaussian kernel standard deviation. ; and in the adjacency matrix Add a self-loop on top and perform symmetric normalization, where For degree matrix, It is an identity matrix.

[0090] In one specific implementation, the method further includes the step of extracting static node features from the topology data, the static node features including at least coded road class, number of lanes, and normalized road length.

[0091] In this embodiment, the specific steps of extraction include: first, classifying the road level... Encoded as a 6-dimensional one-hot vector The lane width is divided into three intervals according to a preset threshold and encoded as a 3D one-hot vector. The road length `len` is transformed, where `len` is in kilometers. During the transformation, it is multiplied by 1000 to convert it to meters, then logarithmically incremented and normalized to its maximum and minimum values. `min` and `max` are the minimum and maximum values ​​of the transformed values ​​for all road segments, respectively. Finally, the encoded and transformed features are concatenated to obtain a 10-dimensional static feature vector. .

[0092] In one specific implementation, the loss function of the spatiotemporal graph neural network model is a split weighted loss function, which calculates the speed prediction loss and the flow prediction loss separately, and assigns a higher weight to the flow prediction loss, while applying a lower loss weight to data points with a true value of zero.

[0093] In this embodiment, the specific implementation method of the loss function is as follows:

[0094] Total loss Loss Prediction Based on Speed and traffic prediction loss The weighted sum is obtained, where the speed loss weight is... The weight for traffic loss is 1.0. It is version 3.0. and These represent the mean absolute error between the predicted and actual values; weights are also introduced for each data point when calculating the loss. If the true value If the value is greater than 0, the weight is 1.0; if the true value is... If the value is 0, the weight is 0.15, thereby reducing the dominant influence of a large number of zero values ​​on the loss calculation.

[0095] Example 2

[0096] This embodiment uses road network data from Jinan City, China as an example for illustration.

[0097] This method first acquires raw road network geographic information data and floating car GPS trajectory traffic time-series data for a target city, such as Jinan. This step completes the acquisition of topological data and traffic time-series data for the target city's road network. Subsequently, the `kind_x` attribute of each road segment is parsed from the topological data. This attribute directly represents the road level, thus extracting the road level information for each road segment. Based on the topological connectivity of the road network, a directed adjacency matrix and other graph structure data are constructed to represent the spatial structure of the road network. Next, the acquired traffic time-series data is cleaned, aggregated, repaired, and normalized to obtain standardized speed and flow characteristic sequences, thus completing the preprocessing of the traffic time-series data and obtaining a normalized dynamic traffic feature sequence. The core of this method lies in constructing a novel spatiotemporal graph neural network model called RHA-GWNet. This model takes the preprocessed graph data, dynamic feature sequences, and road level information as input. The model specifically integrates three dedicated components: a road level embedding layer, a hierarchical global context module, and a dynamic cross-level attention module. These components together constitute a dedicated component for fusing the road level information. This component can semantically enhance node features based on road classification information and model the global associations and dynamic interactions between roads of different classifications. Historical data is used to train the model to optimize its parameters, and the trained model is ultimately used to predict future road network traffic conditions.

[0098] The specific implementation method of the road hierarchy embedding layer includes:

[0099] Define a learnable embedding matrix In this embodiment, the level quantity parameter L is set to 6, and the embedding dimension parameter d defaults to 8. For each node n, based on its road level identifier... Through table lookup operation Obtain the corresponding d-dimensional continuous embedding vector. Finally, concatenate this embedding vector with the original spatiotemporal feature vector X_n of the node to obtain the enhanced node feature representation. This allows discrete hierarchical semantic information to be integrated into the feature space of the model.

[0100] The implementation methods of the hierarchical global context module, i.e., the HGC module, include:

[0101] First, construct a level mask matrix. Its matrix elements At the node The value is 1 if it belongs to level l, and 0 otherwise. This represents the total number of nodes. Using this mask matrix, the formula is: Node feature matrix Aggregates into global feature matrices at each level. The division here is element-wise. for A dimensional vector of all 1s For feature dimensions.

[0102] Next, a multilayer perceptron consisting of two fully connected layers is used to... The transformation involves a bottleneck layer structure, with the intermediate hidden layer dimension being 1 / r of the input dimension (r is the compression factor, with a default value of 8), and a sigmoid activation function is used to generate the gated signal. Finally, the gating signal is broadcast back to each node via a mask matrix and multiplied element-wise with the node's original features. This enables the fusion of global context information.

[0103] The hierarchical differentiation strategy is part of the HGC module, and its implementation includes: generating gating signals. However, this signal is not applied to all levels.

[0104] This embodiment predefines a set of active road levels, for example... These correspond to highways, urban expressways, and national highways, respectively; for level l belonging to these activity levels, the threshold value is... The threshold value is calculated by the aforementioned multilayer perceptron; for inactive levels such as provincial roads, county roads, and town / village roads, the threshold value is forcibly set to 1.0, i.e. This makes it possible in subsequent feature modulation steps In this design, the gating signal corresponding to inactive level nodes is an all-1 vector, which is equivalent to performing an identity mapping, meaning that the features of these nodes remain unchanged. This design ensures that the aggregation and gating modulation of the global context only apply to high-level critical roads, avoiding interference from sparse noise data from low-level roads on the global feature representation.

[0105] The implementation method of the dynamic cross-level attention module, i.e., the DCLA module, includes: first, reusing the aggregation mechanism of the HGC module to obtain the level feature representation. Then, a standard multi-head self-attention mechanism (using h=2 parallel attention heads) is applied across the L levels: Z is respectively compared with the learnable weight matrix. , , Multiply to get the query ,key Sum Next, the scaled dot product attention is calculated. ,in The dimension of the key vector; the resulting attention output It implies dynamic cross-level dependencies; finally, it uses a learnable gating network. Generate fusion weights and inject cross-level information into node features using residual connections: .

[0106] The preprocessing specifically includes the following steps.

[0107] The cleaning step requires filtering records in the original data where the road length is 0 or 65535 and the travel time is less than or equal to 0. Instantaneous speed is then calculated based on the road length (roadLen) and travel time (travelTime). And eliminate speed or Outliers.

[0108] The spatiotemporal aggregation step is performed at fixed time intervals. The default time interval is 20 minutes, and the data is aggregated into time steps. For each road segment n, the average speed is calculated within each time step t:

[0109] ;

[0110] Cumulative traffic ,in For the road section within this time period The valid set of records.

[0111] The missing value repair steps are as follows: For time steps with data coverage below 0.1%, historical data from the same period last week is copied and used to fill the missing value gap. The period =504 steps; for sporadic missing data, linear interpolation between preceding and following time steps is used for repair, that is:

[0112] .

[0113] The construction process specifically includes the following steps.

[0114] Topology simplification is based on directed graphs and requires merging continuous graphs that satisfy road class requirements. And directionality Adjacent road sections and .

[0115] The adjacency matrix is ​​constructed using the exact endpoint matching method. If the simplified road segments... The endpoint coordinates are equal to the road segment If the starting coordinates are the same, then the two are considered adjacent. Let .

[0116] The weighting and normalization process includes: based on the distance between road segments Calculate Gaussian kernel weights ,in The standard deviation of the Gaussian kernel; in the adjacency matrix Add a self-loop I to the top and perform symmetric normalization: ,in It is a degree matrix.

[0117] The extraction specifically includes: classifying roads by grade Encoded as a 6-dimensional one-hot vector The number of lanes Divided into three intervals according to a preset threshold, and encoded as 3D one-hot vectors. Regarding road length Perform the transformation: ,in The unit is kilometers, multiply by 1000 to convert to meters. and These represent the minimum and maximum values ​​of all transformed road segments, respectively. Finally, they are concatenated to obtain the static feature vector:

[0118] .

[0119] The loss function implementation method includes:

[0120] Total loss is ;in, and These are the mean absolute errors between the predicted speed and predicted flow rates and the actual values, respectively; the weights are set to... , This is done to balance the difference in magnitude between the two objectives after normalization. Additionally, a weight is introduced for each data point when calculating the loss. If the true value ,but ;like ,but This reduces the dominant influence of a large number of zero values ​​on loss calculation.

[0121] Example 3

[0122] In an exemplary embodiment of this disclosure, an electronic device capable of implementing the above-described method is also provided.

[0123] Those skilled in the art will understand that various aspects of the present invention can be implemented as systems, methods, or program products. Therefore, various aspects of the present invention can be specifically implemented in the following forms: entirely hardware implementations, entirely software implementations (including firmware, microcode, etc.), or implementations combining hardware and software aspects, collectively referred to herein as “circuits,” “modules,” or “systems.”

[0124] The following reference Figure 7 To describe an electronic device 700 according to this embodiment of the present invention. Figure 7 The electronic device 700 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0125] like Figure 7 As shown, the electronic device 700 is manifested in the form of a general-purpose computing device. The components of the electronic device 700 may include, but are not limited to: at least one processing unit 710, at least one storage unit 720, and a bus 730 connecting different system components (including storage unit 720 and processing unit 710).

[0126] The storage unit stores program code that can be executed by the processing unit 710, causing the processing unit 710 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 710 can perform the following method: S1. Acquire topological data and traffic time-series data of the target city road network; S2. Based on the topological data, extract road grade information of each road segment and construct graph data to represent the spatial structure of the road network; S3. Preprocess the traffic time-series data to obtain a normalized dynamic traffic feature sequence; S4. Construct a spatiotemporal graph neural network model, which takes the graph data, the dynamic traffic feature sequence, and the road grade information as input; wherein the spatiotemporal graph neural network model includes a dedicated component for fusing the road grade information, which is at least used for: semantically enhancing node features based on the road grade information, and modeling the global and dynamic relationships between roads of different grades; S5. Training the model using historical data to optimize model parameters; S6. Using the trained model to predict future traffic conditions.

[0127] Storage unit 720 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 7201 and / or cache memory 7202, and may further include a read-only memory (ROM) 7203.

[0128] The storage unit 720 may also include a program / utility 7204 having a set (at least one) program module 7205, such program module 7205 including but 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.

[0129] Bus 430 can represent one or more of several types of bus structures, including memory cell bus or memory cell controller, peripheral bus, graphics acceleration port, processing unit, or local bus using any of the multiple bus structures.

[0130] Electronic device 700 can also communicate with one or more external devices 600 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 700, and / or any device that enables electronic device 700 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 750. Furthermore, electronic device 700 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 760. As shown, network adapter 760 communicates with other modules of electronic device 700 via bus 730. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0131] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0132] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the methods described above is stored. In some possible embodiments, various aspects of the invention may also be implemented as a program product comprising program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps of the various exemplary embodiments of the invention described in the "Exemplary Methods" section of this specification.

[0133] refer to Figure 8As shown, a program product 800 for implementing the above-described method according to an embodiment of the present invention is described. This product may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0134] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0135] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.

[0136] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0137] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Python and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0138] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.

[0139] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.

Claims

1. A method for predicting traffic conditions in large-scale urban road networks based on graph neural networks, characterized in that, Includes the following steps: Obtain topology data and traffic time-series data of the target city's road network; Based on the topology data, road grade information for each road segment is extracted, and graph data is constructed to represent the spatial structure of the road network. The traffic time series data is preprocessed to obtain a normalized dynamic traffic feature sequence; A spatiotemporal graph neural network model is constructed, which takes the graph data, the dynamic traffic feature sequence, and the road grade information as input. The spatiotemporal graph neural network model includes a dedicated component for fusing the road grade information. This component is used at least for: semantically enhancing node features based on the road grade information, and modeling the global and dynamic relationships between roads of different grades. The model is trained using historical data to optimize its parameters; Use the trained model to predict future traffic conditions.

2. The method according to claim 1, characterized in that, The specific components used in constructing the spatiotemporal graph neural network model include: The road grading embedding layer is used to map discrete road grading labels into continuous learnable embedding vectors, which are then concatenated with the initial node features to form a grade-aware enhanced feature representation.

3. The method according to claim 1, characterized in that, The specific components used in constructing the spatiotemporal graph neural network model include: The hierarchical global context module is used to group and aggregate node features according to road level, generate global context representations for each level, and fuse the global context representations with local node features through a gating mechanism.

4. The method according to claim 3, characterized in that, The hierarchical global context module also includes a hierarchical differentiation strategy: Preset a set of active road levels; For nodes belonging to the active road level, their fusion process is regulated by the gating mechanism; For nodes that do not belong to the active road level, the fusion process performs an identity mapping to ensure that the features of low-level roads are not affected by global context modulation, thereby avoiding noise information from polluting the global aggregation results and interfering with the feature learning of high-level roads.

5. The method according to claim 1, characterized in that, The specific components used in constructing the spatiotemporal graph neural network model include: The dynamic cross-level attention module is used to apply a multi-head self-attention mechanism to a sequence composed of global features of each level, so as to dynamically model the interaction dependencies between different road levels, and fuse the modeling results back to the node features through residual gating.

6. The method according to claim 1, characterized in that, The preprocessing of traffic time-series data specifically includes: Clean the raw floating car data, filtering out invalid and abnormal records; The cleaned data is aggregated at fixed time intervals to calculate the average speed and cumulative flow of each road segment at each time step; For time steps with missing values, periodic replication or linear interpolation strategies are used to repair them.

7. The method according to claim 1, characterized in that, The construction of graph data for representing the spatial structure of the road network specifically includes: The original road network is topologically simplified by merging continuous road segments with the same attributes; Based on the simplified road network, an endpoint matching method is used to construct a directed adjacency matrix, and spatial weights are further calculated by combining road segment distances using a Gaussian kernel function. Add self-loops to the directed adjacency matrix and perform normalization.

8. The method according to claim 1, characterized in that, The method further includes the step of extracting static node features from the topology data, wherein the static node features include at least the encoded road class, number of lanes, and normalized road length.

9. The method according to claim 1, characterized in that, The loss function of the spatiotemporal graph neural network model is a split weighted loss function, which calculates the speed prediction loss and the flow prediction loss separately, and assigns a higher weight to the flow prediction loss, while applying a lower loss weight to data points with a true value of zero.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 9.