Traffic prediction method and device based on dynamic heterogeneous graph

By constructing a dynamic heterogeneous map and distinguishing between ordinary and important areas, combined with the space-time-dependent feature learning layer, the accuracy and response speed of traffic flow prediction are improved, and the problem of insufficient distinction between node importance in complex traffic networks is solved, and the needs of refined traffic management are met.

CN120496312APending Publication Date: 2025-08-15WUHAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510526196.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The existing traffic flow prediction technology has shortcomings in dealing with the spatiotemporal dependence, regional differences and node importance distinction of complex traffic networks, resulting in the prediction error of special areas being significantly higher than that of ordinary road sections, making it difficult to meet the needs of refined traffic management.

Method used

The traffic prediction method based on dynamic heterogeneous map is adopted to distinguish ordinary regions and important regions by constructing dynamic heterogeneous maps. The ordinary regional aggregation layer, important regional aggregation layer and full-region fusion layer are used to capture the spatiotemporal dependence of nodes, and comprehensive node features are generated through the spatiotemporal dependence feature learning layer for prediction.

Benefits of technology

It significantly improves the prediction accuracy of traffic flow under complex traffic networks, especially in sudden congestion and holiday traffic sudden changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120496312A_ABST
    Figure CN120496312A_ABST
Patent Text Reader

Abstract

The invention relates to a traffic prediction method and device based on a dynamic heterogeneous graph, belongs to the technical field of intelligent traffic, and is used for predicting traffic flow based on a constructed traffic prediction model, and the traffic prediction model comprises a common region aggregation layer, an important region aggregation layer, a full-region fusion layer and a space-time dependency feature learning layer. The traffic prediction method based on the dynamic heterogeneous graph comprises the following steps: constructing the dynamic heterogeneous graph, determining common region nodes and important region nodes, performing feature aggregation on first multi-order neighbors of the common region nodes based on a common region aggregation layer, performing feature aggregation on second multi-order neighbors of the important region nodes based on an important region aggregation layer, and performing feature aggregation on the second multi-order neighbors of the important region nodes. Fusing the node features based on a full-region fusion layer to obtain full-region node features; the time sequence feature extraction is performed based on the space-time dependence feature learning layer, the comprehensive node feature is generated, the traffic flow is predicted based on the comprehensive node feature, and the prediction precision of the traffic flow under the complex traffic network is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent transportation technology, and in particular to a traffic prediction method and device based on a dynamic heterogeneous graph. Background Art

[0002] Traffic flow prediction is a key technology for intelligent transportation systems to achieve efficient road network management. Its core lies in accurately modeling the spatiotemporal dependencies and complex network characteristics of traffic flow. With the expansion of urban transportation network scale and the enhancement of dynamics, the limitations of traditional methods in dealing with nonlinear relationships, differences in node interaction patterns and multi-source data fusion are becoming increasingly prominent. There is an urgent need to improve the prediction accuracy and robustness in complex scenarios through technological innovation.

[0003] Graph Neural Networks (GNNs) have attracted much attention in the field of traffic flow prediction because they can capture the spatial correlation between nodes in traffic networks. GNN-based traffic flow prediction models, such as Graph Convolutional Networks (GCNs) and Graph Attention Networks (GATs), improve prediction accuracy by modeling traffic networks as graph structures to transmit information. Some studies also combine multimodal data to enhance model expressiveness. However, most of these models do not fully consider the importance differences between different nodes and do not distinguish the significant differences in traffic flow characteristics between ordinary intersections and important intersections. Researchers have proposed many improved GNN architectures. The improved GNN architectures are not accurate enough in depicting the dynamic interactions between different types of nodes, lack flexibility and accuracy in modeling important nodes, and are not sufficient in modeling the time dependence of traffic flow, which limits the performance of the models in practical applications.

[0004] Therefore, existing traffic flow prediction technology has shortcomings in dealing with the spatiotemporal dependencies, regional differences, and node importance distinctions of complex traffic networks, resulting in prediction errors in special areas (such as commercial centers) that are significantly higher than those in ordinary sections, making it difficult to meet the needs of refined traffic management. Summary of the Invention

[0005] In view of this, it is necessary to provide a traffic prediction method and device based on dynamic heterogeneous graphs to solve the technical problem of low prediction accuracy of traffic flow in complex traffic networks.

[0006] In order to solve the above problems, in a first aspect, the present invention provides a traffic prediction method based on a dynamic heterogeneous graph, which is used to predict traffic flow based on a constructed traffic prediction model, wherein the traffic prediction model includes a general area aggregation layer, an important area aggregation layer, a full area fusion layer, and a spatiotemporal dependency feature learning layer; The traffic prediction method based on dynamic heterogeneous graph includes: Constructing a dynamic heterogeneous graph based on the acquired traffic network dataset, determining common area nodes and important area nodes based on the dynamic heterogeneous graph, and performing feature aggregation on first multi-order neighbors of the common area nodes based on the common area aggregation layer to obtain node features of the common area; Performing feature aggregation on second-order neighbors of the important region node based on the important region aggregation layer to obtain node features of the important region, wherein the order of the second-order neighbors is greater than the order of the first-order neighbors; Based on the full-area fusion layer, the node features of the important area and the common area are fused to obtain the full-area node features; Based on the spatiotemporal dependent feature learning layer, time series features are extracted from the node features of the entire region to generate comprehensive node features, and traffic flow of the transportation network is predicted based on the comprehensive node features.

[0007] In a possible implementation, determining common regional nodes and important regional nodes based on the dynamic heterogeneous graph includes: Based on the dynamic heterogeneous graph, the types of nodes and edges in the transportation network are determined, and based on the types of nodes and edges, ordinary area nodes and important area nodes are determined, wherein the nodes are the elements of the transportation network and the edges are the connection relationships between the elements.

[0008] In one possible implementation, the first multi-order neighbors include first-order neighbors and second-order neighbors; and performing feature aggregation on the first multi-order neighbors of the common area node based on the common area aggregation layer to obtain node features of the common area includes: Acquire the characteristics of the target node in the common area node, the characteristics of the first-order neighbor nodes of the target node, and the characteristics of the second-order neighbor nodes of the target node; Performing weighted aggregation updates on the features of the target node, the first-order neighbor nodes, and the second-order neighbor nodes, respectively, to obtain dynamic feature increments of the target node, the first-order neighbor nodes, and the second-order neighbor nodes; The features of the target node and the dynamic feature increments of the target node, the first-order neighbor nodes, and the second-order neighbor nodes are normalized to obtain the node features of the common area.

[0009] In a possible implementation, the node characteristics of the common area are: , , in, is the first The characteristics of the nodes, is the first The characteristics of the nodes, For the The dynamic feature increment of each node, is the degree of the node, For the nodes, is the smoothing term, is the neighbor order, is the activation function ReLU, For the The dynamic feature increment of each node, For the The dynamic feature increment of the first-order neighbor nodes of a node, For the The dynamic feature increment of the second-order neighbor nodes of a node.

[0010] In one possible implementation, the second multi-order neighbors include first-order neighbors, second-order neighbors, and third-order neighbors; and performing feature aggregation on the second multi-order neighbors of the important area node based on the important area aggregation layer to obtain node features of the important area includes: Obtaining features of a target node and first-order neighbor nodes, second-order neighbor nodes, and third-order neighbor nodes of the target node in the important area nodes; Performing weighted aggregation updates on the features of the target node, the first-order neighbor nodes, the second-order neighbor nodes, and the third-order neighbor nodes, respectively, to obtain dynamic feature increments of the target node, the first-order neighbor nodes, the second-order neighbor nodes, and the third-order neighbor nodes; The features of the target node and the dynamic feature increments of the target node, first-order neighbor nodes, second-order neighbor nodes, and third-order neighbor nodes are normalized to obtain node features of important areas.

[0011] In a possible implementation, fusing the node features of the important area and the common area based on the full-area fusion layer to obtain the full-area node features includes: After performing linear transformation on the node features of the important area and the common area respectively, the similarity between the node features of the important area and the node features of the common area is calculated; Normalizing the similarity using an attention mechanism to obtain an attention weight; Based on the attention weight, the node features of the important area and the node features of the common area are weightedly summed to obtain the node features of the entire area.

[0012] In one possible implementation, the attention weight is: , in, is the attention weight, is the dimension of node features, is the linear transformation matrix of the query space, is the linear transformation matrix of the key space, is the node feature of the general area, It is the node feature of important areas; The characteristics of the global node are: , in, It is the node feature of the entire region.

[0013] In one possible implementation, the spatiotemporal dependency feature learning layer includes an LSTM network; performing temporal feature extraction on the node features of the entire region based on the spatiotemporal dependency feature learning layer to generate comprehensive node features; including: Construct the historical feature sequence of each node based on the node features of the entire region; The historical feature sequence is input into the LSTM network, and the time series features of the historical feature sequence are extracted by the LSTM network. The extracted time series features are averaged and pooled to generate comprehensive node features.

[0014] In a possible implementation, the integrated node features are: , , in, is the comprehensive node feature, For nodes From time step 1 to time step historical characteristics, For nodes At time step The average pooled features, For nodes The set of neighbor nodes of For nodes and nodes The nodes in the neighbor set of Node information, For nodes and nodes The nodes in the neighbor set of .

[0015] In a second aspect, the present invention further provides a traffic prediction device based on a dynamic heterogeneous graph, which is used to predict traffic flow based on a constructed traffic prediction model, wherein the traffic prediction model includes a general area aggregation layer, an important area aggregation layer, a full area fusion layer, and a spatiotemporal dependency feature learning layer; The traffic prediction device based on dynamic heterogeneous graph includes: A common area aggregation module is used to construct a dynamic heterogeneous graph based on the acquired traffic network dataset, determine common area nodes and important area nodes based on the dynamic heterogeneous graph, and perform feature aggregation on the first multi-order neighbors of the common area nodes based on the common area aggregation layer to obtain node features of the common area; An important area aggregation module, configured to perform feature aggregation on second-order neighbors of the important area node based on the important area aggregation layer to obtain node features of the important area, wherein the order of the second-order neighbors is greater than the order of the first-order neighbors; A full-area fusion module, configured to fuse the node features of the important areas and the common areas based on the full-area fusion layer to obtain full-area node features; The comprehensive node feature generation module is used to extract the time series features of the node features of the entire area based on the spatiotemporal dependency feature learning layer, generate comprehensive node features, and predict the traffic flow of the transportation network based on the comprehensive node features.

[0016] The beneficial effects of the present invention are as follows: the traffic prediction model includes an ordinary area aggregation layer, an important area aggregation layer, a full area fusion layer and a spatiotemporal dependency feature learning layer; based on the ordinary area aggregation layer, the first multi-order neighbors of the ordinary area nodes are feature aggregated to obtain the node features of the ordinary area; the spatiotemporal dependency between the nodes and the neighbors is captured through the ordinary area aggregation layer; based on the important area aggregation layer, the second multi-order neighbors of the important area nodes are feature aggregated to obtain the node features of the important area; by expanding the neighbor aggregation range of the nodes in the important area, a wider spatiotemporal dependency is captured, and the traffic flow information at a longer distance is obtained, thereby enhancing the ability to capture traffic flow information between distant nodes; based on the full area fusion layer, the node features of the important area and the ordinary area are fused to obtain the full area node features. Features, the full-area fusion layer integrates the spatiotemporal information of ordinary areas and important areas through weighted aggregation and attention mechanism to realize differentiated processing of traffic network nodes, and uses attention mechanism to distinguish the flow characteristics of key intersections and ordinary sections in the spatial dimension. At the feature aggregation level, a gradient feature fusion strategy is designed for special areas to effectively reduce the prediction error of complex scenarios. Based on the spatiotemporal dependency feature learning layer, the time series features of the node features in the full area are extracted to generate comprehensive node features. The traffic flow of the traffic network is predicted based on the comprehensive node features. The spatiotemporal dependency feature learning layer uses LSTM and average pooling operations to capture the spatiotemporal dependency of nodes and generates a more refined node feature representation, which significantly improves the prediction response speed of sudden congestion scenarios and the prediction accuracy of mutation scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For the technical personnel of the present invention, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 A schematic structural diagram of an embodiment of a traffic prediction model of a traffic prediction method based on a dynamic heterogeneous graph provided by the present invention; Figure 2 A flow chart of an embodiment of a traffic prediction method based on a dynamic heterogeneous graph provided by the present invention; Figure 3 This is a structural diagram of an embodiment of a traffic prediction device based on a dynamic heterogeneous graph provided by the present invention. DETAILED DESCRIPTION

[0019] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, and are not used to limit the scope of the present invention.

[0020] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute a separate or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0021] Before presenting the embodiments, the following terms are explained first.

[0022] First-order neighbors: direct neighbors of a node in a transportation network; Second-order neighbors: neighbors of the direct neighbors of a node in a transportation network; Third-order neighbors: The neighbors of the second-order neighbors of a node in the transportation network, that is, all nodes reachable via a shortest path of length 3, the set of nodes that can only be reached from a node in the transportation network through three consecutive edges, and these nodes are not included in the first-order or second-order neighbors.

[0023] Region: In a transportation network, a region is a specific geographical area consisting of several adjacent transportation nodes and the roads connecting them. The region boundary is usually defined by the multi-order neighbors of different types of nodes.

[0024] The present invention discloses a traffic prediction method and device based on dynamic heterogeneous graph. Figure 1As shown, the traffic prediction model 100 includes a general area aggregation layer 110, an important area aggregation layer 120, a full area fusion layer 130 and a spatiotemporal dependency feature learning layer 140. The traffic flow is predicted based on the constructed traffic prediction model, as shown in FIG. Figure 2 As shown in Figure 2, traffic prediction methods based on dynamic heterogeneous graphs include: S201: construct a dynamic heterogeneous graph based on the acquired traffic network dataset, determine common area nodes and important area nodes based on the dynamic heterogeneous graph, perform feature aggregation on the first multi-order neighbors of the common area nodes based on the common area aggregation layer 110, and obtain node features of the common area; It should be noted that a dynamic heterogeneous graph refers to a graph structure in which the types of nodes and edges not only change in different time steps, but also change within each time step. In a dynamic heterogeneous graph, the topology of the graph and the attributes and types of nodes and edges evolve dynamically over time. Given a dynamic heterogeneous graph ,in It's time The node set of It's time The edge set of each node and the edge They have different types and attributes, and nodes and edges evolve dynamically over time; they fully consider the importance differences of different nodes, distinguish the significant differences in traffic flow characteristics between ordinary intersections and important intersections, and capture the spatiotemporal dependencies between nodes in ordinary areas through the ordinary area aggregation layer.

[0025] S202: performing feature aggregation on the second multi-order neighbors of the nodes in the important region based on the important region aggregation layer 120 to obtain node features of the important region, where the order of the second multi-order neighbors is greater than the order of the first multi-order neighbors; It should be noted that the important area aggregation layer captures the spatiotemporal dependencies between nodes in important areas, takes into account the traffic flow characteristics of complex transportation networks, and meets the needs of refined traffic management.

[0026] S203, based on the full-region fusion layer 130, the node features of the important region and the common region are fused to obtain the full-region node features; It should be noted that the node features of different regions are fused through the full-region fusion layer, and the node features of important regions and ordinary regions are integrated to ensure that the influence of important regions is strengthened.

[0027] S204, extracting time series features from node features of the entire region based on the spatiotemporal dependency feature learning layer 140, generating comprehensive node features, and predicting traffic flow of the transportation network based on the comprehensive node features; It should be noted that the spatiotemporal dependency feature learning layer uses LSTM and average pooling operations to capture the spatiotemporal dependencies of nodes, significantly improving the prediction response speed of sudden congestion scenarios and the prediction accuracy of holiday traffic mutation scenarios.

[0028] In some embodiments, in step S201, a dynamic heterogeneous graph is constructed based on the acquired traffic network dataset, data of the traffic network is collected through sensors to generate a traffic network dataset, a dynamic heterogeneous graph is constructed based on the traffic network dataset, ordinary area nodes and important area nodes are determined based on the dynamic heterogeneous graph, the types of nodes and edges in the traffic network are determined based on the dynamic heterogeneous graph, and ordinary area nodes and important area nodes are determined based on the types of nodes and edges, wherein nodes are elements of the traffic network and edges are connection relationships between elements; a dynamic heterogeneous graph containing multiple time steps is constructed based on the traffic network dataset, in which nodes represent elements in the traffic network (such as traffic stations, intersections, etc.), and edges represent connection relationships between these elements (such as roads), and each node and edge has different types and attributes, which will change dynamically over time, from the dynamic heterogeneous graph. The features of nodes and edges are extracted. These features may include the traffic flow, congestion level, and type of nodes, as well as the road type and traffic flow of edges. After extracting the features, the nodes are clustered according to the extracted features. The clustering results will form different areas. Each area is composed of several adjacent traffic nodes and the roads connected to them. The regional boundaries are usually defined by multi-order neighbors of different types of nodes to ensure the rationality and accuracy of the areas. After clustering, ordinary areas and important areas are determined. Ordinary area nodes and important area nodes are further determined according to the type of nodes and the type of edges. This is achieved by analyzing indicators such as node degree, betweenness centrality, and eigenvector centrality. These indicators can reflect the importance and influence of nodes in the transportation network. Nodes with higher indicators are selected as important area nodes. These nodes have important transportation functions in the region and may be the main channels for traffic flow or the main nodes for congestion.

[0029] Based on the common area aggregation layer, the first-order neighbors of the common area nodes are aggregated to obtain the node features of the common area. The first-order neighbors include first-order neighbors and second-order neighbors. The features of the target node in the common area node, the features of the first-order neighbor nodes of the target node, and the features of the second-order neighbor nodes of the target node are obtained. The features of the target node, the first-order neighbor nodes of the target node, and the second-order neighbor nodes of the target node are weightedly aggregated and updated respectively to obtain the dynamic feature increments of the target node, the first-order neighbor nodes, and the second-order neighbor nodes. Specifically, in the common area aggregation layer, the features of the common area nodes in the traffic network are aggregated by the graph convolution operation to capture the spatiotemporal dependencies between nodes. In the common area, the features of the target node are mainly affected by the direct neighbors (first-order neighbors) of the target node and the neighbors of the neighbors of the target node (second-order neighbors). For the target node in the common area, the node feature update is not only completed by the aggregation of the first-order and second-order neighbor information, but also reflects the dynamic changes of the node features through dynamic feature increments. First, the preliminary feature update is performed through the first-order neighbor aggregation, that is, the feature of the target node in the common area at the time step is initially updated as follows: , in, For the target node in the next time step The characteristics of time, For the target node at time step The characteristics of time, is the feature increment of the target node. The dynamic feature increment of the target node is obtained by feature propagation from the first-order neighbors and the second-order neighbors. The dynamic feature increment of the target node is: , in, is the dynamic feature increment of the target node, is the first-order neighbor node, is the second-order neighbor node, For the target node The set of directly connected nodes (the set of first-order neighbor nodes), The neighbor set of the first-order neighbor nodes of the target node (the second-order neighbor node set); 、 To learn the weight matrix, its first-order neighbor node set and second-order neighbor node set are: , , For the first-order neighbor nodes of the target node, the features of the target node are first weighted summed with the features of the first-order neighbor nodes to capture the spatiotemporal dependency between the target node and its direct neighbors. The dynamic feature increment of the first-order neighbor nodes between the target node and its direct neighbors is: , in, is the dynamic feature increment of the first-order neighbor node, is the activation function ReLU, is the first-order neighbor at time step The characteristics of time, is the weight matrix, which is used to learn the weighting of the first-order neighbor node features; Since the fluctuation of traffic flow in ordinary areas is usually small and has little impact on the global network, a simpler neighbor aggregation method can effectively capture the spatiotemporal characteristics of ordinary areas. It is necessary to perform feature aggregation through the dynamic feature increment of the second-order neighbor nodes. The dynamic feature increment of the second-order neighbor nodes is: , in, is the dynamic feature increment of the second-order neighbor node, is the second-order neighbor node At time step Features, is the weight matrix used to learn the weighting of second-order neighbor features; The features of the target node and the dynamic feature increments of the target node, first-order neighbor nodes, and second-order neighbor nodes are normalized to obtain the node features of the common area. In order to prevent excessive feature expansion, the traffic prediction model normalizes the aggregated node features to ensure that the features after each graph convolution operation have a consistent scale and avoid excessive information accumulation. That is, the features of the target node and the dynamic feature increments of the target node, first-order neighbor nodes, and second-order neighbor nodes in the common area are normalized to obtain the node features of the common area. The node features of the common area are: , , , in, is the normalized dynamic feature increment of the target node, first-order neighbor node, and second-order neighbor node. is the first The characteristics of the nodes, that is, the node characteristics of the general area, is the current time step In the general area The characteristics of the nodes, For the The dynamic feature increment of each node, is the degree of the node, For the nodes, is a smoothing term used to avoid division by zero errors, is the neighbor order, is the activation function ReLU, For the The dynamic feature increment of each node, For the The dynamic feature increment of the first-order neighbor nodes of a node, For the The dynamic feature increment of the second-order neighbor nodes of a node.

[0030] In some embodiments, in step S202, feature aggregation is performed on the second-order neighbors of the important area nodes based on the important area aggregation layer to obtain the node features of the important area. The order of the second-order neighbors is greater than the order of the first-order neighbors. The second-order neighbors include first-order neighbors, second-order neighbors and third-order neighbors. The features of the target node and the first-order neighbor nodes, second-order neighbor nodes and third-order neighbor nodes of the target node in the important area are obtained, and the features of the target node, the first-order neighbor nodes, second-order neighbor nodes and third-order neighbor nodes of the target node are weightedly aggregated and updated respectively to obtain the dynamic feature increments of the target node, the first-order neighbor nodes, the second-order neighbor nodes and the third-order neighbor nodes; traffic flow fluctuations have a significant impact on the entire traffic flow (for example, intersections near commercial areas). The traffic flow changes in these areas are more significant, and more complex aggregation operations are required to accurately capture their spatiotemporal dependencies. In the important area aggregation layer, traffic nodes near the commercial area are first identified, and their local neighborhood information is propagated together with deeper neighborhood diffusion to perform feature aggregation. Then, a graph convolution operation is used to perform feature aggregation at time steps. Update node features to capture the multi-layer dependencies between the target node and its neighbors, especially the influence from distant nodes. Finally, in time The points generate richer node feature representations, highlighting the key contribution of important regional nodes to traffic flow prediction; in the important regional aggregation layer, the traffic prediction model mainly performs feature aggregation on nodes in important areas of the traffic network, especially by expanding the aggregation range of neighbors to capture a wider range of spatiotemporal dependencies. Important areas (such as intersections near schools and commercial areas) have a greater impact on traffic flow, so a wider range of neighbor expansion (up to third-order neighbors) is used to obtain traffic flow information at a longer distance. For nodes in important areas, nodes Feature update is not only completed by the aggregation of higher neighbor information, but also reflects the dynamic changes of node features through dynamic feature increments. First, the traffic prediction model updates node features through first-order neighbor aggregation. In the traffic network, the target node Represents an important traffic intersection (such as an intersection near a school or a store), and the target node is at the time step The update is: , in, Target node At time step To the next time step The dynamic feature increment between is the time step Node features at the time, dynamic feature increment of the target node It is expressed as the feature change obtained by information propagation of first-order, second-order, and third-order neighbors. The dynamic feature increment of the target node is: , in, 、 、 They are the first-order neighbor node set, the second-order neighbor node set, and the third-order neighbor node set, 、 、 To learn the weight matrix, 、 、 They are first-order neighbor nodes, second-order neighbor nodes, and third-order neighbor nodes at time step Features, 、 、 They are first-order neighbor nodes, second-order neighbor nodes, and third-order neighbor nodes respectively. The set of third-order neighbor nodes is: , In important areas, by expanding to third-order neighbors, the traffic prediction model can capture more long-range spatiotemporal dependencies; In the important area aggregation layer, due to the large fluctuations in traffic flow at traffic nodes in important areas, more complex aggregation operations are required to accurately capture the spatiotemporal dependencies of important areas. Therefore, information aggregation is performed through the first-order neighbors, second-order neighbors, and third-order neighbors of the target node in the important area. First, the first-order neighbors of the target node are aggregated and updated to obtain the dynamic feature increment of the first-order neighbor nodes. The dynamic feature increment of the first-order neighbor nodes is: , in, is the dynamic feature increment of the first-order neighbor node, is the activation function ReLU, is the weight matrix, which is used to learn the weighting of the first-order neighbor node features; Aggregate and update the second-order neighbors of the target node, and obtain the dynamic feature increment of the second-order neighbor nodes: , in, is the dynamic feature increment of the second-order neighbor node, is the weight matrix, which is used to learn the weighting of the second-order neighbor node features; Aggregate and update the third-order neighbors of the target node to further capture more long-range spatiotemporal dependencies, and obtain the dynamic feature increment of the third-order neighbor nodes: , in, is the dynamic feature increment of the third-order neighbor node, is the weight matrix, which is used to learn the weighting of the third-order neighbor node features; In order to ensure that the features after each aggregation will not be over-expanded, the target features and the first-order, second-order, and third-order dynamic feature increments of the target features are normalized, that is, the final target node The features of are updated based on the aggregation of first-order, second-order and third-order neighbors to obtain the node features of important areas, which are calculated as follows: , , , in, is the node feature of the important area, For nodes degree (with node number of connected neighbor nodes).

[0031] In some embodiments, in step S203, the node features of the important area and the ordinary area are fused based on the full-area fusion layer to obtain the node features of the full area. In order to effectively integrate the node features of the ordinary area and the node features of the important area and ensure that the influence of the important area is enhanced, the full-area fusion layer fuses the two types of features obtained by the ordinary area aggregation layer and the important area aggregation layer, and uses the attention mechanism to weight the aggregation results of different areas. First, after linear transformation of the node features of the important area and the ordinary area, the similarity between the node features of the important area and the node features of the ordinary area is calculated, that is, for each node feature of the ordinary area and the important area, the node feature is mapped to the query and key space through a linear transformation, and the similarity between the ordinary area and the important area is calculated, and the similarity is the attention score; then, the attention mechanism is used to normalize the similarity to obtain the attention weight, that is, the softmax operation in the attention mechanism is used to normalize the similarity to obtain the attention weight to represent the relative importance between different areas, and the attention weight is: , in, is the attention weight, is the dimension of node features, is the linear transformation matrix of the query space, is the linear transformation matrix of the key space, is the node feature of the general area, It is the node feature of important areas; Finally, based on the attention weight, the node features of the important area and the node features of the common area are weighted and summed to obtain the node features of the entire area. The node features of the entire area are: , in, The full-area node feature integrates the spatiotemporal information of ordinary areas and important areas. The full-area node feature can better reflect the role of nodes in traffic flow prediction, especially their behavior at traffic intersections or important areas.

[0032] In some implementations, in step S204, the spatiotemporal dependency feature learning layer is used to extract the time series features of the node features of the entire region to generate comprehensive node features, and the traffic flow of the traffic network is predicted based on the comprehensive node features. The spatiotemporal dependency feature learning layer includes an LSTM network. In order to capture the pattern of node features changing over time, the LSTM network is used to process the historical feature sequence of each node. The LSTM network can effectively extract the dependency relationship of the nodes in the time dimension and generate the time series features of the nodes. First, the historical feature sequence of each node is constructed based on the node features of the entire region, that is, for each node , construct the historical feature sequence of each node, and its historical feature sequence is: , Then we get the hidden state sequence of each time step, which is: , in, Contains nodes From time step 1 to time step historical information; The historical feature sequence is input into the LSTM network, and the time series features of the historical feature sequence are extracted by the LSTM network. After the extracted time series features are averaged and pooled, the comprehensive node features are generated. After the time series features are extracted, in order to ensure that each time step contributes equally to the node features, thereby avoiding excessive amplification or neglect of information, the average pooling method is used to average pool the extracted time series features and calculate each node. The average value of the time series features of the node's neighbor nodes at each time step, that is, the average value of the LSTM hidden state, the average pooled feature is: , in, For nodes The set of neighbor nodes of For nodes and nodes The nodes in the neighbor set of Node information, For nodes and nodes Nodes in the neighbor set of For nodes At time step After LSTM time series feature extraction and average pooling, the traffic prediction model combines the generated time series features with spatial features to generate the final comprehensive node features. The comprehensive node features are: , in, It is a comprehensive node feature.

[0033] The spatiotemporal dependency feature learning layer uses LSTM and average pooling operations to capture the spatiotemporal dependencies of nodes and generate more refined node features. It can dynamically adjust the graph structure to ensure that node features can reflect the latest spatiotemporal changes. The comprehensive node features provide rich input for subsequent traffic flow predictions of the traffic network, greatly improving the model's ability to process spatiotemporal information.

[0034] In summary, the traffic prediction method based on dynamic heterogeneous graph provided by the present invention is used to predict traffic flow based on a constructed traffic prediction model, which includes an ordinary area aggregation layer, an important area aggregation layer, a full area fusion layer and a spatiotemporal dependency feature learning layer. A dynamic heterogeneous graph is constructed based on the acquired traffic network data set, and ordinary area nodes and important area nodes are determined based on the dynamic heterogeneous graph. The first multi-order neighbors of the ordinary area nodes are feature aggregated based on the ordinary area aggregation layer to obtain the node features of the ordinary area; the second multi-order neighbors of the important area nodes are feature aggregated based on the important area aggregation layer to obtain the node features of the important area, and the order of the second multi-order neighbors is greater than the order of the first multi-order neighbors; the node features of the important area and the ordinary area are fused based on the full area fusion layer to obtain the node features of the full area; the time series features of the full area node features are extracted based on the spatiotemporal dependency feature learning layer to generate comprehensive node features, and the traffic flow of the traffic network is predicted based on the comprehensive node features, thereby improving the prediction accuracy of traffic flow in complex traffic networks.

[0035] In order to better implement the traffic prediction method based on dynamic heterogeneous graph in the embodiment of the present invention, based on the traffic prediction method based on dynamic heterogeneous graph, correspondingly, Figure 3 As shown, an embodiment of the present invention further provides a traffic prediction device based on a dynamic heterogeneous graph, which is used to predict traffic flow based on a constructed traffic prediction model. The traffic prediction model includes a general area aggregation layer, an important area aggregation layer, a full area fusion layer, and a spatiotemporal dependency feature learning layer. The traffic prediction device 300 based on a dynamic heterogeneous graph includes: The common area aggregation module 301 is used to construct a dynamic heterogeneous graph based on the acquired traffic network dataset, determine common area nodes and important area nodes based on the dynamic heterogeneous graph, and perform feature aggregation on the first multi-order neighbors of the common area nodes based on the common area aggregation layer to obtain node features of the common area; An important region aggregation module 302 is configured to perform feature aggregation on second-order neighbors of nodes in the important region based on the important region aggregation layer to obtain node features of the important region, wherein the order of the second-order neighbors is greater than the order of the first-order neighbors; The full-region fusion module 303 is used to fuse the node features of the important region and the common region based on the full-region fusion layer to obtain the full-region node features; The comprehensive node feature generation module 304 is used to extract time series features of the node features of the entire region based on the spatiotemporal dependency feature learning layer, generate comprehensive node features, and predict the traffic flow of the transportation network based on the comprehensive node features.

[0036] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or replacements that can be easily conceived by any technician familiar with the technical neighbors within the technical scope disclosed by the present invention should be covered by the scope of protection of the present invention.

Claims

1. A traffic prediction method based on dynamic heterogeneous graph, characterized in that: Used to predict traffic flow based on the constructed traffic prediction model, wherein the traffic prediction model includes a general area aggregation layer, an important area aggregation layer, a full area fusion layer and a spatiotemporal dependency feature learning layer; The traffic prediction method based on dynamic heterogeneous graph includes: Constructing a dynamic heterogeneous graph based on the acquired traffic network dataset, determining common area nodes and important area nodes based on the dynamic heterogeneous graph, and performing feature aggregation on first multi-order neighbors of the common area nodes based on the common area aggregation layer to obtain node features of the common area; Performing feature aggregation on second-order neighbors of the important region node based on the important region aggregation layer to obtain node features of the important region, wherein the order of the second-order neighbors is greater than the order of the first-order neighbors; Based on the full-area fusion layer, the node features of the important area and the common area are fused to obtain the full-area node features; Based on the spatiotemporal dependent feature learning layer, time series features are extracted from the node features of the entire region to generate comprehensive node features, and traffic flow of the transportation network is predicted based on the comprehensive node features.

2. The traffic prediction method based on dynamic heterogeneous graph according to claim 1 is characterized in that: The determining of common regional nodes and important regional nodes based on the dynamic heterogeneous graph includes: Based on the dynamic heterogeneous graph, the types of nodes and edges in the transportation network are determined, and based on the types of nodes and edges, ordinary area nodes and important area nodes are determined, wherein the nodes are the elements of the transportation network and the edges are the connection relationships between the elements.

3. The traffic prediction method based on dynamic heterogeneous graph according to claim 2 is characterized in that: The first multi-order neighbors include first-order neighbors and second-order neighbors; performing feature aggregation on the first multi-order neighbors of the common area node based on the common area aggregation layer to obtain node features of the common area includes: Acquire the characteristics of the target node in the common area node, the characteristics of the first-order neighbor nodes of the target node, and the characteristics of the second-order neighbor nodes of the target node; Performing weighted aggregation updates on the features of the target node, the first-order neighbor nodes, and the second-order neighbor nodes, respectively, to obtain dynamic feature increments of the target node, the first-order neighbor nodes, and the second-order neighbor nodes; The features of the target node and the dynamic feature increments of the target node, the first-order neighbor nodes, and the second-order neighbor nodes are normalized to obtain the node features of the common area.

4. The traffic prediction method based on dynamic heterogeneous graph according to claim 3 is characterized in that: The node characteristics of the general area are: , , in, is the first The characteristics of the nodes, is the first The characteristics of the nodes, For the The dynamic feature increment of each node, is the degree of the node, For the nodes, is the smoothing term, is the neighbor order, is the activation function ReLU, For the The dynamic feature increment of each node, For the The dynamic feature increment of the first-order neighbor nodes of a node, For the The dynamic feature increment of the second-order neighbor nodes of a node.

5. The traffic prediction method based on dynamic heterogeneous graph according to claim 3 is characterized in that: The second multi-order neighbors include first-order neighbors, second-order neighbors, and third-order neighbors. Based on the important area aggregation layer, feature aggregation is performed on the second multi-order neighbors of the important area node to obtain node features of the important area, including: Obtaining features of a target node and first-order neighbor nodes, second-order neighbor nodes, and third-order neighbor nodes of the target node in the important area nodes; Performing weighted aggregation updates on the features of the target node, the first-order neighbor nodes, the second-order neighbor nodes, and the third-order neighbor nodes, respectively, to obtain dynamic feature increments of the target node, the first-order neighbor nodes, the second-order neighbor nodes, and the third-order neighbor nodes; The features of the target node and the dynamic feature increments of the target node, first-order neighbor nodes, second-order neighbor nodes, and third-order neighbor nodes are normalized to obtain node features of important areas.

6. The traffic prediction method based on dynamic heterogeneous graph according to claim 5 is characterized in that: The step of fusing the node features of the important area and the common area based on the full-area fusion layer to obtain full-area node features includes: After performing linear transformation on the node features of the important area and the common area respectively, the similarity between the node features of the important area and the node features of the common area is calculated; Normalizing the similarity using an attention mechanism to obtain an attention weight; Based on the attention weight, the node features of the important area and the node features of the common area are weightedly summed to obtain the node features of the entire area.

7. The traffic prediction method based on dynamic heterogeneous graph according to claim 6, characterized in that: The attention weight is: , in, is the attention weight, is the dimension of node features, is the linear transformation matrix of the query space, is the linear transformation matrix of the key space, is the node feature of the general area, It is the node feature of important areas; The characteristics of the global node are: , in, It is the node feature of the entire region.

8. The traffic prediction method based on dynamic heterogeneous graph according to claim 6 is characterized in that: The spatiotemporal dependency feature learning layer includes an LSTM network; based on the spatiotemporal dependency feature learning layer, time series feature extraction is performed on the node features of the entire region to generate comprehensive node features; including: Construct the historical feature sequence of each node based on the node features of the entire region; The historical feature sequence is input into the LSTM network, and the time series features of the historical feature sequence are extracted by the LSTM network. The extracted time series features are averaged and pooled to generate comprehensive node features.

9. The traffic prediction method based on dynamic heterogeneous graph according to claim 6, characterized in that: The comprehensive node features are: , , in, is the comprehensive node feature, For nodes From time step 1 to time step historical characteristics, For nodes At time step The average pooled features, For nodes The set of neighbor nodes of For nodes and nodes The nodes in the neighbor set of Node information, For nodes and nodes The nodes in the neighbor set of .

10. A traffic prediction device based on dynamic heterogeneous graph, characterized in that: Used to predict traffic flow based on the constructed traffic prediction model, wherein the traffic prediction model includes a general area aggregation layer, an important area aggregation layer, a full area fusion layer and a spatiotemporal dependency feature learning layer; The traffic prediction device based on dynamic heterogeneous graph includes: A common area aggregation module is used to construct a dynamic heterogeneous graph based on the acquired traffic network dataset, determine common area nodes and important area nodes based on the dynamic heterogeneous graph, and perform feature aggregation on the first multi-order neighbors of the common area nodes based on the common area aggregation layer to obtain node features of the common area; an important area aggregation module, configured to perform feature aggregation on second-order neighbors of the important area node based on the important area aggregation layer to obtain node features of the important area, wherein the order of the second-order neighbors is greater than the order of the first-order neighbors; A full-area fusion module, configured to fuse the node features of the important areas and the common areas based on the full-area fusion layer to obtain full-area node features; The comprehensive node feature generation module is used to extract the time series features of the node features of the entire area based on the spatiotemporal dependency feature learning layer, generate comprehensive node features, and predict the traffic flow of the transportation network based on the comprehensive node features.