Traffic Flow Speed ​​Prediction Method and System Based on Directed Hypergraph and Attention Mechanism

By constructing a traffic flow speed prediction method based on directed hypergraphs and attention mechanisms, a directed hypergraph of road traffic is built. By utilizing spatiotemporal attention modules and dense connection structures, the problems of insufficient spatiotemporal relationship representation and gradient vanishing in traditional methods are solved, and high-accuracy traffic flow speed prediction is achieved.

CN117131979BActive Publication Date: 2026-05-26BEIJING JIAOTONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING JIAOTONG UNIV
Filing Date
2023-08-14
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing traffic flow speed prediction methods struggle to accurately characterize the spatiotemporal relationships within complex road traffic networks, and traditional neural network methods suffer from the gradient vanishing problem, limiting their prediction performance.

Method used

A traffic flow speed prediction method based on directed hypergraphs and attention mechanisms is adopted. By constructing a directed hypergraph of road traffic to obtain traffic flow data, a spatiotemporal attention module is used for feature extraction and fusion, and end-to-end training is achieved by combining a dense connection structure and residual network optimization.

Benefits of technology

It effectively represents complex spatial information, improves the accuracy of traffic flow speed prediction, overcomes the gradient vanishing problem, solves the error accumulation problem in multi-step prediction, and improves prediction accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117131979B_ABST
    Figure CN117131979B_ABST
Patent Text Reader

Abstract

This invention provides a traffic flow speed prediction method and system based on directed hypergraphs and attention mechanisms, belonging to the field of traffic state prediction technology. Based on directed hypergraphs, it constructs the relationships between nodes in a road network; aggregates directed hyperedge information to characterize the complex spatiotemporal features of the road network; builds an encoder and decoder architecture; integrates an attention mechanism, constructs an attention module, and introduces an improved dense connection structure to enhance the method's accuracy. This invention effectively overcomes the shortcomings of methods based on traditional graph structures, achieves the extraction and fusion of temporal and spatial features, and solves problems such as gradient vanishing in deep neural networks. It is applicable to multi-step traffic flow prediction in real road networks and achieves good prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of traffic condition prediction technology, specifically to a method and system for predicting traffic flow speed based on directed hypergraphs and attention mechanisms. Background Technology

[0002] Traffic flow velocity is the most direct parameter reflecting traffic conditions. Accurately predicting traffic flow velocity is fundamental to traffic situation simulation and is of great significance for urban traffic management and normal operation. For example, traffic management departments can implement traffic control measures in advance based on traffic condition predictions to alleviate congestion and reduce safety hazards. However, early traffic flow velocity prediction methods mainly relied on statistical models to model traffic flow, such as historical mean methods and integrated moving average autoregressive methods. Obviously, these methods are difficult to use for large-scale predictions and can only predict the state of a single sensing node, which has significant limitations. This is because the spatiotemporal relationships in the road traffic system are extremely complex; the state of one node simultaneously affects the future states of itself and its neighboring nodes.

[0003] Therefore, in recent years, with the development of computing resources and data scale, the mainstream methods have shifted to machine learning and neural network methods. Among them, graph-based neural network models have achieved significant advantages in prediction performance and have shown certain potential. However, traditional graphs are difficult to represent the complex topological relationships in real road networks. For example, a complex overpass may connect multiple layers of roads simultaneously, and the same road node may be connected to multiple other road nodes. Traditional graphs cannot accurately and comprehensively model such complex spatiotemporal relationships of traffic networks, which greatly limits the performance of traffic flow speed prediction methods based on traditional graphs. Hypergraphs, on the other hand, have significant advantages in modeling and representing the complex spatial relationships between multiple road nodes and are in line with future development trends. Due to the inherent defects of traditional graph structures, they are difficult to represent complex spatiotemporal relationships of traffic networks, and the performance of traffic flow speed prediction methods based on traditional graph neural networks is currently greatly limited. Traditional traffic flow speed prediction methods have not achieved the fusion of temporal and spatial dependencies and cannot characterize the intrinsic correlation of spatiotemporal dynamics. Traditional neural network methods suffer from the problem that continuously increasing the number of network layers makes the network difficult to train and leads to phenomena such as gradient vanishing. Summary of the Invention

[0004] The purpose of this invention is to provide a traffic flow speed prediction method and system based on directed hypergraphs and attention mechanisms, in order to characterize the complex spatial relationships in real roads and more completely extract and integrate the temporal and spatial information in traffic data, thereby achieving accurate and rapid road traffic flow speed prediction to solve at least one of the technical problems existing in the background art.

[0005] To achieve the above objectives, the present invention adopts the following technical solution:

[0006] On the one hand, this invention provides a traffic flow speed prediction method based on directed hypergraphs and attention mechanisms, including:

[0007] Acquire traffic flow data, including sensor location, detection time, pulse count, vehicle direction of travel, and cross-sectional traffic flow speed information;

[0008] The acquired traffic flow data is processed using a pre-trained traffic flow speed prediction model to obtain traffic flow speed prediction results. The training of the pre-trained traffic flow speed prediction model includes: constructing a directed hypergraph of road traffic; acquiring the traffic flow speed of road nodes in the directed hypergraph within a historical time step; performing weighted summation on the road node speed data at a certain moment within the historical time step, extracting the traffic flow speed feature vectors of the head and tail of the directed hypergraph, performing gating fusion to obtain the traffic flow speed feature vectors of the corresponding directed hyperedges, extracting new feature vectors for each road node, and outputting a matrix composed of vectors. The input consists of an encoder composed of L spatiotemporal attention modules connected in series, adaptively acquiring the spatial and temporal dependencies of each traffic node at different time steps; the input consists of a decoder composed of L spatiotemporal attention modules connected in series, and an output module is constructed using fully connected layers, generating prediction results for multiple prediction steps; defining a loss function for optimization, minimizing the mean absolute error between the predicted and true values, and training the directed hypergraph network end-to-end based on the error backpropagation mechanism to obtain the traffic flow speed prediction model.

[0009] Optionally, the road network data is obtained to form a directed hypergraph of road traffic G = {V, ε, A}, where V represents the set of road nodes, V = {v1, v2, ..., v q ,…,v Q}, q=1,2,…,Q, where Q is the total number of road nodes, V q Let represent the q-th node in the road; ε represents the set of directed hyperedges E = (D, T), ε = {E1, E2, ..., E...} k ,…,E K}, k = 1, 2, ..., K, where K is the total number of directed hyperedges, E k Let D represent the k-th directed hyperedge in the road network, T represent the head of the directed hyperedge, and A represent the tail of the directed hyperedge. Each hyperedge corresponds to a directed relationship between two node sets (D, T). element a ij If it is 1, it indicates that the head D of the i-th directed superedge is... i Including the j-th node, if -1 indicates the tail T of the i-th directed superedge. iIt contains the j-th node. If it is 0, it means that the i-th directed superedge is not related to the j-th node.

[0010] Optionally, aggregate directed hyperedge information; including:

[0011] Based on the road node speed data X∈X at a certain moment within the historical step length U time period, a weighted sum is performed to extract the traffic flow speed feature vectors at the head and tail of the directed hyperedge respectively.

[0012] The traffic flow velocity feature vectors at the head and tail of the extracted directed hyperedge are gated and fused to obtain the traffic flow velocity feature vector of the corresponding directed hyperedge.

[0013] Extract new feature vectors for each road node based on the traffic flow velocity feature vector of the directed hyperedge. ω represents the matrix composed of the output vectors of all road nodes after the aggregation process.

[0014] Optionally, an encoder is defined consisting of L spatiotemporal attention modules connected in series. Each spatiotemporal attention module includes a spatial attention module, a temporal attention module, and a gating fusion mechanism.

[0015] The matrix H composed of output vectors (0) H is obtained after passing through l-1 spatiotemporal attention modules in the encoder. (l-1) Where l∈{1,2,...,L}, H (l-1) The output of the spatial attention module after the l-th spatiotemporal attention module is obtained The output of the time attention module after the l-th spatiotemporal attention module is obtained

[0016] Will and Gated fusion of spatial and temporal features is performed to obtain the output of the l-th spatiotemporal attention module. To adaptively acquire the spatial and temporal dependencies of each traffic node at different time steps;

[0017] Through the fully connected layer, the encoder output is

[0018] Optionally, a decoder is defined by concatenating L spatiotemporal attention modules. Each spatiotemporal attention module contains a spatial attention module, a temporal attention module, and a gating fusion mechanism.

[0019] The input H of the decoder is obtained by adaptively selecting relevant features. (L+1) H (L+1) H is obtained after passing through l-1 spatiotemporal attention modules in the decoder. (L+l)Where l∈{1,2,...,L}, H (L+l) The output obtained after the spatial attention mechanism of the l-th spatiotemporal attention module is... The output obtained after the time attention mechanism of the l-th spatiotemporal attention module is

[0020] Will and Gated fusion of temporal and spatial features is performed to obtain the output of the l-th spatiotemporal attention module.

[0021] Through the fully connected layer, the decoder output is

[0022] Optionally, the output of the directed hypergraph network incorporating the attention mechanism can be optimized using the following loss function:

[0023]

[0024] In the formula, Y t For the true value, The predicted value is obtained by minimizing the mean absolute error between the predicted value and the true value.

[0025] Secondly, the present invention provides a traffic flow speed prediction system based on directed hypergraphs and attention mechanisms, comprising:

[0026] The acquisition module is used to acquire traffic flow data, including sensor location, detection time, pulse count, vehicle direction of travel, and cross-sectional traffic flow speed information;

[0027] The prediction module processes the acquired traffic flow data using a pre-trained traffic flow speed prediction model to obtain traffic flow speed prediction results. The training of the pre-trained traffic flow speed prediction model includes: constructing a directed hypergraph of road traffic; acquiring the traffic flow speed of road nodes in the directed hypergraph within a historical time step; performing weighted summation on the road node speed data at a certain moment within the historical time step, extracting the traffic flow speed feature vectors of the head and tail of the directed hypergraph, performing gating fusion to obtain the traffic flow speed feature vectors of the corresponding directed hyperedges, extracting new feature vectors for each road node, and outputting a matrix composed of vectors. The input consists of an encoder composed of L spatiotemporal attention modules connected in series, adaptively acquiring the spatial and temporal dependencies of each traffic node at different time steps; the input consists of a decoder composed of L spatiotemporal attention modules connected in series, and an output module is constructed using fully connected layers, generating prediction results for multiple prediction steps; defining a loss function for optimization, minimizing the mean absolute error between the predicted and true values, and training the directed hypergraph network end-to-end based on an error backpropagation mechanism to obtain the traffic flow speed prediction model.

[0028] Thirdly, the present invention provides a non-transitory computer-readable storage medium for storing computer instructions, which, when executed by a processor, implement the traffic flow speed prediction method based on directed hypergraphs and attention mechanisms as described above.

[0029] Fourthly, the present invention provides a computer device including a memory and a processor, wherein the processor and the memory communicate with each other, the memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the traffic flow speed prediction method based on directed hypergraph and attention mechanism as described above.

[0030] Fifthly, the present invention provides an electronic device, comprising: a processor, a memory, and a computer program; wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory to cause the electronic device to execute instructions for implementing the traffic flow speed prediction method based on directed hypergraph and attention mechanism as described above.

[0031] Beneficial effects of this invention:

[0032] (1) It can effectively represent the complex spatial information in the actual road network. The directed hypergraph used can not only contain all the spatial information in the traditional graph structure, but also more effectively model the directed relationships between multiple nodes to capture the complex spatiotemporal features in the traffic network, and ultimately improve the accuracy.

[0033] (2) It can effectively establish connections between spatiotemporal information in the road network. Based on the directed hypergraph and the historical traffic flow data of each node, a deep encoder and decoder architecture, as well as spatiotemporal attention mechanism and transformation attention mechanism, are adopted to enhance the learning of spatiotemporal dependencies, realize the extraction and fusion of temporal and spatial features, and finally accurately predict the traffic flow speed of multiple road nodes in multiple time steps.

[0034] (3) It overcomes the gradient vanishing problem in deep networks. A dense connection structure is introduced, and the idea of ​​residual networks is used to optimize it to solve the gradient vanishing problem in deep networks and avoid parameter redundancy. This effectively solves the problem of error accumulation in multi-step prediction and improves the prediction accuracy of the method.

[0035] The advantages of additional aspects of the invention will be set forth more clearly in the following description or will be learned by practice of the invention. Attached Figure Description

[0036] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0037] Figure 1 This is a flowchart illustrating the overall process framework of the traffic flow speed prediction method based on directed hypergraphs and attention mechanisms as described in this embodiment of the invention.

[0038] Figure 2 This refers to the directed hypergraph constructed based on a real road network as described in the embodiments of the present invention.

[0039] Figure 3 This refers to the directed hypergraph after the aggregation of directed hyperedge information as described in the embodiments of the present invention.

[0040] Figure 4 This is a schematic diagram illustrating the process of aggregating directed hyperedge information according to an embodiment of the present invention.

[0041] Figure 5 This is a schematic diagram of the fully connected layer described in an embodiment of the present invention.

[0042] Figure 6 This is a schematic diagram of the spatiotemporal attention module according to an embodiment of the present invention.

[0043] Figure 7 This is a schematic diagram of a densely connected network according to an embodiment of the present invention.

[0044] Figure 8 This is a schematic diagram of the attention conversion module according to an embodiment of the present invention. Detailed Implementation

[0045] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0046] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0047] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this specification means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, and / or groups thereof.

[0048] To facilitate understanding of the present invention, the present invention will be further explained and described below with reference to the accompanying drawings and specific embodiments. However, the specific embodiments do not constitute a limitation on the embodiments of the present invention.

[0049] Those skilled in the art should understand that the accompanying drawings are merely schematic diagrams of embodiments, and the components in the drawings are not necessarily essential for implementing the present invention.

[0050] Example 1

[0051] In this embodiment 1, a traffic flow speed prediction system based on a directed hypergraph and attention mechanism is first provided, including: an acquisition module for acquiring traffic flow data, including sensor location, detection time, pulse count, vehicle travel direction, and cross-sectional traffic flow speed information; and a prediction module for processing the acquired traffic flow data using a pre-trained traffic flow speed prediction model to obtain traffic flow speed prediction results. The training of the pre-trained traffic flow speed prediction model includes: constructing a directed hypergraph of road traffic; acquiring the traffic flow speed of road nodes in the directed hypergraph within a historical time step; and performing a weighted summation based on the road node speed data at a certain moment within the historical time step to extract the traffic flow speed. The traffic flow velocity feature vectors at the head and tail of the directed hypergraph are gated and fused to obtain the corresponding traffic flow velocity feature vectors of the directed hyperedges. New feature vectors are extracted from each road node, and the output vector matrix is ​​formed. The input consists of an encoder composed of L spatiotemporal attention modules connected in series, which adaptively obtains the spatial and temporal dependencies of each traffic node at different time steps. The input consists of a decoder composed of L spatiotemporal attention modules connected in series, and the output module is constructed using fully connected layers. The output module generates prediction results with multiple prediction steps. A loss function is defined for optimization. By minimizing the mean absolute error between the predicted and the true values, the directed hypergraph network is trained end-to-end based on the error backpropagation mechanism to obtain the traffic flow velocity prediction model.

[0052] In this embodiment, the above-described system is used to implement a traffic flow speed prediction method based on directed hypergraphs and attention mechanisms. The method includes: acquiring traffic flow data, including sensor location, detection time, pulse count, vehicle travel direction, and cross-sectional traffic flow speed information; processing the acquired traffic flow data using a pre-trained traffic flow speed prediction model to obtain traffic flow speed prediction results; wherein, the training of the pre-trained traffic flow speed prediction model includes: constructing a directed hypergraph of road traffic; acquiring the traffic flow speed of road nodes in the directed hypergraph within a historical time frame; performing a weighted summation based on the road node speed data at a certain moment within the historical time frame, and extracting the traffic flow speed from the directed hypergraph. The traffic flow velocity feature vectors at the head and tail are gated and fused to obtain the corresponding traffic flow velocity feature vectors of the directed hyperedges. New feature vectors for each road node are extracted, and the output vector matrix is ​​formed. The input consists of an encoder composed of L spatiotemporal attention modules connected in series, which adaptively obtains the spatial and temporal dependencies of each traffic node at different time steps. The input consists of a decoder composed of L spatiotemporal attention modules connected in series, and the output module is constructed using fully connected layers. The output module generates prediction results with multiple prediction steps. A loss function is defined for optimization. By minimizing the mean absolute error between the predicted and true values, the directed hypergraph network is trained end-to-end based on the error backpropagation mechanism to obtain the traffic flow velocity prediction model.

[0053] Specifically, the road network data is obtained to form a directed hypergraph of road traffic G = {V, ε, A}, where V represents the set of road nodes, V = {v1, v2, ..., v...}. q ,…,v Q}, q=1,2,…,Q, where Q is the total number of road nodes, V q Let represent the q-th node in the road; ε represents the set of directed hyperedges E = (D, T), ε = {E1, E2, ..., E...} k ,…,E K}, k = 1, 2, ..., K, where K is the total number of directed hyperedges, E k Let D represent the k-th directed hyperedge in the road network, T represent the head of the directed hyperedge, and A represent the tail of the directed hyperedge. Each hyperedge corresponds to a directed relationship between two node sets (D, T). element a ij If it is 1, it indicates that the head D of the i-th directed superedge is... i Including the j-th node, if -1 indicates the tail T of the i-th directed superedge. i It contains the j-th node. If it is 0, it means that the i-th directed superedge is not related to the j-th node.

[0054] Aggregate directed hyperedge information; including:

[0055] Based on the road node speed data X∈X at a certain moment within the historical step length U time period, a weighted sum is performed to extract the traffic flow speed feature vectors at the head and tail of the directed hyperedge respectively.

[0056] The traffic flow velocity feature vectors at the head and tail of the extracted directed hyperedge are gated and fused to obtain the traffic flow velocity feature vector of the corresponding directed hyperedge.

[0057] Extract new feature vectors for each road node based on the traffic flow velocity feature vector of the directed hyperedge. ω represents the matrix composed of the output vectors of all road nodes after the aggregation process.

[0058] The encoder is defined as consisting of L spatiotemporal attention modules connected in series. Each spatiotemporal attention module includes a spatial attention module, a temporal attention module, and a gating fusion mechanism.

[0059] The matrix H composed of output vectors (0) H is obtained after passing through l-1 spatiotemporal attention modules in the encoder. (l-1) Where l∈{1,2,...,L}, H (l-1) The output of the spatial attention module after the l-th spatiotemporal attention module is obtained The output of the time attention module after the l-th spatiotemporal attention module is obtained

[0060] Will and Gated fusion of spatial and temporal features is performed to obtain the output of the l-th spatiotemporal attention module. To adaptively acquire the spatial and temporal dependencies of each traffic node at different time steps;

[0061] Through the fully connected layer, the encoder output is

[0062] The decoder is defined as consisting of L spatiotemporal attention modules connected in series. Each spatiotemporal attention module contains a spatial attention module, a temporal attention module, and a gating fusion mechanism.

[0063] The input H of the decoder is obtained by adaptively selecting relevant features. (L+1) H (L+1) H is obtained after passing through l-1 spatiotemporal attention modules in the decoder. (L+l) Where l∈{1,2,...,L}, H (L+l) The output obtained after the spatial attention mechanism of the l-th spatiotemporal attention module is... The output obtained after the time attention mechanism of the l-th spatiotemporal attention module is

[0064] Will and Gated fusion of temporal and spatial features is performed to obtain the output of the l-th spatiotemporal attention module.

[0065] Through the fully connected layer, the decoder output is

[0066] The output of the directed hypergraph network incorporating the attention mechanism is optimized using the following loss function:

[0067]

[0068] In the formula, Y t For the true value, The predicted value is obtained by minimizing the mean absolute error between the predicted value and the true value.

[0069] Example 2

[0070] With increasing urbanization, urban roads and highways are becoming increasingly complex, resulting in a road network structure with high spatiotemporal complexity. A single road node may have directed traffic relationships with multiple other nodes. If such spatial information can be extracted comprehensively and efficiently during traffic flow velocity feature mining, the accuracy of traffic flow velocity prediction will be improved. Therefore, in this embodiment 2, a traffic flow velocity prediction method based on directed hypergraphs and attention mechanisms is provided, in which a traffic flow velocity prediction model is trained.

[0071] like Figure 1 As shown. First, the road network and sensor layout of a certain area are obtained. The traffic flow data collected by the sensors mainly includes information such as sensor location, detection time, pulse count, vehicle travel direction, and cross-sectional traffic flow speed. Based on this, a directed hypergraph of road traffic is constructed, i.e., step 1.

[0072] Step 1: Construct a directed hypergraph of road traffic;

[0073] like Figure 2 As shown, the directed hypergraph G={V,ε,A} obtained from the road network data represents the set of road nodes, V={v1,v2,…,v…}. q ,…,v Q}, q=1,2,…,Q, where Q is the total number of road nodes, and in this embodiment Q is 74, V q Let represent the q-th node in the road, corresponding to a sensor on the actual road; ε represents the set of directed hyperedges E = (D, T), ε = {E1, E2, ..., E...} k ,…,E K}, k = 1, 2, ..., K, where K is the total number of directed hyperedges. In this embodiment, K is 81, E k Let D represent the k-th directed superedge in the road, and T represent the head and tail of the directed superedge. Each superedge corresponds to a directed relationship between two node sets (D, T), such as... Figure 3 As shown, combined with Figure 2 Road nodes v8, v 23 ,v 25 ,v 26 A visual illustration of the concept of a directed hyperedge;

[0074] A represents the correlation matrix of the road traffic network. It can represent the relationship between the head D and tail T of a directed hyperedge and the road nodes, element a ij If it is 1, it indicates that the head D of the i-th directed superedge is... i Including the j-th node, if -1 indicates the tail T of the i-th directed superedge. iIt contains the j-th node; if it is 0, it means that the i-th directed superedge is not related to the j-th node.

[0075] Step 2: Based on the collected data, obtain the traffic flow velocity of Q road nodes in the directed hypergraph G of road traffic within the historical time interval U. Then the q-th road node at time t u The following traffic flow speed data is In this embodiment, U is set to 30;

[0076] Define the future traffic flow velocity of all Q nodes in the directed hypergraph G of road traffic within a prediction step size P as: In this embodiment, P is set to 12;

[0077] Step 3: As Figure 4 The diagram shown illustrates the process of aggregating directed hyperedge information.

[0078] Step 3.1: Based on the road node speed data X∈X at a certain moment within the historical step time U, perform weighted summation according to equations (1) and (2) to extract the traffic flow speed feature vectors at the head and tail of the directed hyperedge, respectively. and

[0079]

[0080]

[0081] In the formula and All of these are learnable parameters. ⊙ represents the Hadamarda accumulation;

[0082] Step 3.2: ω D and ω T By performing gating fusion using equations (3) and (4), the traffic flow velocity feature vector of the corresponding directed hyperedge is obtained.

[0083] ω DT =(1-z1)⊙ω D +z1⊙ω T (3)

[0084]

[0085] In the formula, z1 is the gate control. All of these are learnable parameters, and σ(·) represents the sigmoid activation function;

[0086] Step 3.3: Based on the traffic flow velocity feature vector ω of the directed hyperedge DTExtracting new feature vectors from each road node ω represents the matrix composed of the output vectors of all road nodes after the aggregation process in steps 3.1 and 3.2, and the calculation method is shown in equation (5);

[0087]

[0088] Step 4: The traffic flow speed data for the historical time interval U of the Q road nodes are processed in step 3 to obtain... Then the q-th road node at time t u The new traffic flow velocity feature vector is

[0089] Step 5: Input w into the fully connected layer to change the matrix dimension and transform it to obtain... Where D indicates that the dimension of the matrix is ​​D-dimensional, and a common diagram of a fully connected layer is shown below. Figure 5 As shown;

[0090] Step 6: Define the encoder;

[0091] Step 6.1: Define an encoder consisting of L spatiotemporal attention modules connected in series. Each spatiotemporal attention module includes a spatial attention module, a temporal attention module, and a gating fusion mechanism. The specific structure of the spatiotemporal attention module is as follows: Figure 6 As shown;

[0092] To verify the impact of L on the performance of the prediction method proposed in this invention, this embodiment uses the controlled variable method to discuss four different values ​​of L under the same training configuration, resulting in four prediction models representing MD1, MD2, MD3, and MD4 respectively. By comparing the results of the ablation experiment of the four models, L is set as the L value corresponding to the best-performing model.

[0093] Step 6.2: H (0) H is obtained after passing through l-1 spatiotemporal attention modules in the encoder. (l-1) Where l∈{1,2,...,L}, H (l-1) The output of the spatial attention module after the l-th spatiotemporal attention module is obtained The output of the time attention module after the l-th spatiotemporal attention module is obtained

[0094] Step 6.3: [The text appears to be incomplete and contains several grammatical errors. A more accurate translation would require the full context.] and By performing gating fusion of spatial and temporal features using equations (6) and (7), the output of the l-th spatiotemporal attention module is obtained. To adaptively acquire the spatial and temporal dependencies of each traffic node at different time steps;

[0095]

[0096]

[0097] In the formula All parameters are learnable, with z2 being the gated parameter;

[0098] Step 6.4: Through the fully connected layer, the encoder output is

[0099] Step 7: Introduce a densely connected structure in the encoder, such as... Figure 7 The diagram shown is a schematic of a densely connected structure.

[0100] Step 7.1: Add a direct connection structure between the L cascaded spatiotemporal attention modules, so that the input of each spatiotemporal attention module comes from the output of all the preceding spatiotemporal attention modules, thereby realizing information transfer and reuse between the parts;

[0101] Step 7.2: Based on the idea of ​​dimension addition in residual networks, the concatenate operation in the dense connection structure is optimized into an add operation to avoid parameter explosion and achieve a balance between performance and parameter quantity;

[0102] Step 8: Define a transformation attention module to model the direct relationship between each future time step and historical time step, such as... Figure 8 The diagram shown is a schematic of the attention switching module.

[0103] Step 8.1: Calculate arbitrary road node v based on equations (8) and (9) q Prediction time step t m ={t U+1 ,t U+2 ,…,t U+P} and historical time step t u ={t1,t2,…,t U The correlation of};

[0104]

[0105]

[0106] In the formula and Let n represent different nonlinear mapping functions in the nth attention mechanism ∈ {1,2,…,N}, as shown in Equation (10);

[0107] f(x)=ReLU(xW+b) (10)

[0108] In the formula, W and b are learnable parameters, and ReLU(·) is the activation function;

[0109] Step 8.2: Based on the transition attention score obtained in Step 8.1, H (L) Relevant features are adaptively selected across U historical time steps and then transformed into the input of the decoder via a transformation attention module.

[0110] Step 9: Define the decoder;

[0111] Step 9.1: Define a decoder consisting of L spatiotemporal attention modules connected in series. Each spatiotemporal attention module contains a spatial attention module, a temporal attention module, and a gating fusion mechanism.

[0112] Step 9.2: H (L+1) H is obtained after passing through l-1 spatiotemporal attention modules in the decoder. (L+l) Where l∈{1,2,...,L}, H (L+l) The output obtained after the spatial attention mechanism of the l-th spatiotemporal attention module is... The output obtained after the time attention mechanism of the l-th spatiotemporal attention module is

[0113] Step 9.3: [The text appears to be incomplete and contains several grammatical errors. A more accurate translation would require the full context.] and The output of the l-th spatiotemporal attention module is obtained by gating and fusing temporal and spatial features using equations (8) and (9).

[0114]

[0115]

[0116] In the formula All are learnable parameters, with z3 being a gating parameter;

[0117] Step 9.4: After passing through the fully connected layer, the decoder output is...

[0118] Step 10: Same as step 7, introduce a dense connection structure in the decoder as well;

[0119] Step 10: Define the output module;

[0120] The output module is constructed using a fully connected layer. The output module generates prediction results with P prediction steps.

[0121] Step 11: Define the loss function for optimization;

[0122] The output of the directed hypergraph network with fused attention mechanism is optimized using the following loss function;

[0123]

[0124] In the formula, Y t For the true value, For the predicted values, the directed hypergraph network is trained end-to-end based on the error backpropagation mechanism by minimizing the mean absolute error between the predicted and the true values.

[0125] Step 12: Train the model using the Adam optimizer with an initial learning rate of 0.001, 200 training epochs, and a batch size of 16. For the actual dataset, the training set, validation set, and test set can be divided in a 7:1:2 ratio. The mean squared error (MAE), mean absolute percentage error (MAPE), and root mean square error (RMSE) are used as evaluation metrics to quantify the accuracy of the model training in this embodiment.

[0126] Example 3

[0127] This embodiment 3 provides a non-transitory computer-readable storage medium for storing computer instructions. When executed by a processor, the computer instructions implement the traffic flow speed prediction method based on directed hypergraphs and attention mechanisms as described above. The method includes:

[0128] Acquire traffic flow data, including sensor location, detection time, pulse count, vehicle direction of travel, and cross-sectional traffic flow speed information;

[0129] The acquired traffic flow data is processed using a pre-trained traffic flow speed prediction model to obtain traffic flow speed prediction results. The training of the pre-trained traffic flow speed prediction model includes: constructing a directed hypergraph of road traffic; acquiring the traffic flow speed of road nodes in the directed hypergraph within a historical time step; performing weighted summation on the road node speed data at a certain moment within the historical time step, extracting the traffic flow speed feature vectors of the head and tail of the directed hypergraph, performing gating fusion to obtain the traffic flow speed feature vectors of the corresponding directed hyperedges, extracting new feature vectors for each road node, and outputting a matrix composed of vectors. The input consists of an encoder composed of L spatiotemporal attention modules connected in series, adaptively acquiring the spatial and temporal dependencies of each traffic node at different time steps; the input consists of a decoder composed of L spatiotemporal attention modules connected in series, and an output module is constructed using fully connected layers, generating prediction results for multiple prediction steps; defining a loss function for optimization, minimizing the mean absolute error between the predicted and true values, and training the directed hypergraph network end-to-end based on the error backpropagation mechanism to obtain the traffic flow speed prediction model.

[0130] Example 4

[0131] This embodiment 4 provides a computer device, including a memory and a processor, wherein the processor and the memory communicate with each other, and the memory stores program instructions that can be executed by the processor. The processor calls the program instructions to execute the traffic flow speed prediction method based on directed hypergraph and attention mechanism as described above, the method including:

[0132] Acquire traffic flow data, including sensor location, detection time, pulse count, vehicle direction of travel, and cross-sectional traffic flow speed information;

[0133] The acquired traffic flow data is processed using a pre-trained traffic flow speed prediction model to obtain traffic flow speed prediction results. The training of the pre-trained traffic flow speed prediction model includes: constructing a directed hypergraph of road traffic; acquiring the traffic flow speed of road nodes in the directed hypergraph within a historical time step; performing weighted summation on the road node speed data at a certain moment within the historical time step, extracting the traffic flow speed feature vectors of the head and tail of the directed hypergraph, performing gating fusion to obtain the traffic flow speed feature vectors of the corresponding directed hyperedges, extracting new feature vectors for each road node, and outputting a matrix composed of vectors. The input consists of an encoder composed of L spatiotemporal attention modules connected in series, adaptively acquiring the spatial and temporal dependencies of each traffic node at different time steps; the input consists of a decoder composed of L spatiotemporal attention modules connected in series, and an output module is constructed using fully connected layers, generating prediction results for multiple prediction steps; defining a loss function for optimization, minimizing the mean absolute error between the predicted and true values, and training the directed hypergraph network end-to-end based on the error backpropagation mechanism to obtain the traffic flow speed prediction model.

[0134] Example 5

[0135] This embodiment 5 provides an electronic device, including: a processor, a memory, and a computer program; wherein, the processor is connected to the memory, and the computer program is stored in the memory. When the electronic device is running, the processor executes the computer program stored in the memory to cause the electronic device to execute instructions to implement the traffic flow speed prediction method based on directed hypergraphs and attention mechanisms as described above. The method includes:

[0136] Acquire traffic flow data, including sensor location, detection time, pulse count, vehicle direction of travel, and cross-sectional traffic flow speed information;

[0137] The acquired traffic flow data is processed using a pre-trained traffic flow speed prediction model to obtain traffic flow speed prediction results. The training of the pre-trained traffic flow speed prediction model includes: constructing a directed hypergraph of road traffic; acquiring the traffic flow speed of road nodes in the directed hypergraph within a historical time step; performing weighted summation on the road node speed data at a certain moment within the historical time step, extracting the traffic flow speed feature vectors of the head and tail of the directed hypergraph, performing gating fusion to obtain the traffic flow speed feature vectors of the corresponding directed hyperedges, extracting new feature vectors for each road node, and outputting a matrix composed of vectors. The input consists of an encoder composed of L spatiotemporal attention modules connected in series, adaptively acquiring the spatial and temporal dependencies of each traffic node at different time steps; the input consists of a decoder composed of L spatiotemporal attention modules connected in series, and an output module is constructed using fully connected layers, generating prediction results for multiple prediction steps; defining a loss function for optimization, minimizing the mean absolute error between the predicted and true values, and training the directed hypergraph network end-to-end based on the error backpropagation mechanism to obtain the traffic flow speed prediction model.

[0138] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0139] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0140] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0141] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment, whereby a series of operational steps are performed to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0142] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that, based on the technical solutions disclosed in the present invention, various modifications or variations that can be made by those skilled in the art without creative effort should be included within the scope of protection of the present invention.

Claims

1. A traffic flow speed prediction method based on directed hypergraphs and attention mechanisms, characterized in that, include: Acquire traffic flow data, including sensor location, detection time, pulse count, vehicle direction of travel, and cross-sectional traffic flow speed information; The acquired traffic flow data is processed using a pre-trained traffic flow speed prediction model to obtain traffic flow speed prediction results. The training of the pre-trained traffic flow speed prediction model includes: constructing a directed hypergraph of road traffic; acquiring the traffic flow speed of road nodes in the directed hypergraph within a historical time step; performing weighted summation on the road node speed data at a certain moment within the historical time step, extracting the traffic flow speed feature vectors of the head and tail of the directed hypergraph, performing gating fusion to obtain the traffic flow speed feature vectors of the corresponding directed hyperedges, extracting new feature vectors for each road node, and outputting a matrix composed of vectors. The input consists of an encoder composed of L spatiotemporal attention modules connected in series, adaptively acquiring the spatial and temporal dependencies of each traffic node at different time steps; the input consists of a decoder composed of L spatiotemporal attention modules connected in series, and an output module is constructed using fully connected layers, generating prediction results for multiple prediction steps; defining a loss function for optimization, minimizing the mean absolute error between the predicted and true values, and training the directed hypergraph network end-to-end based on the error backpropagation mechanism to obtain the traffic flow speed prediction model.

2. The traffic flow speed prediction method based on directed hypergraph and attention mechanism according to claim 1, characterized in that, Obtaining road network data yields a directed hypergraph of road traffic G = {V, ε, A}, where V represents the set of road nodes, V = {v1, v2, ..., v...} q ,…,v Q }, q=1,2,…,Q, where Q is the total number of road nodes, v q Let represent the q-th node in the road; ε represents the set of directed hyperedges E = (D, T), ε = {E1, E2, ..., E...} k ,…,E K }, k = 1, 2, ..., K, where K is the total number of directed hyperedges, E k Let D represent the k-th directed hyperedge in the road network, T represent the head of the directed hyperedge, and A represent the tail of the directed hyperedge. Each hyperedge corresponds to a directed relationship between two node sets (D, T). element a ij If it is 1, it indicates that the head D of the i-th directed superedge is... i Including the j-th node, if -1 indicates the tail T of the i-th directed superedge. i It contains the j-th node. If it is 0, it means that the i-th directed superedge is not related to the j-th node.

3. The traffic flow speed prediction method based on directed hypergraph and attention mechanism according to claim 2, characterized in that, Aggregate directed hyperedge information; including: Based on the road node speed data X∈X at a certain moment within the historical step length U time period, a weighted sum is performed to extract the traffic flow speed feature vectors at the head and tail of the directed hyperedge respectively. The traffic flow velocity feature vectors at the head and tail of the extracted directed hyperedge are gated and fused to obtain the traffic flow velocity feature vector of the corresponding directed hyperedge. Extract new feature vectors for each road node based on the traffic flow velocity feature vector of the directed hyperedge. ω represents the matrix composed of the output vectors of all road nodes after the aggregation process.

4. The traffic flow speed prediction method based on directed hypergraph and attention mechanism according to claim 2, characterized in that, The encoder is defined as consisting of L spatiotemporal attention modules connected in series. Each spatiotemporal attention module includes a spatial attention module, a temporal attention module, and a gating fusion mechanism. The matrix H composed of output vectors (0) H is obtained after passing through l-1 spatiotemporal attention modules in the encoder. (l-1) Where l∈{1,2,...,L}, H (l-1) The output of the spatial attention module after the l-th spatiotemporal attention module is obtained The output of the time attention module after the l-th spatiotemporal attention module is obtained Will and Gated fusion of spatial and temporal features is performed to obtain the output of the l-th spatiotemporal attention module. To adaptively acquire the spatial and temporal dependencies of each traffic node at different time steps; Through the fully connected layer, the encoder output is 5. The traffic flow speed prediction method based on directed hypergraph and attention mechanism according to claim 4, characterized in that, The decoder is defined as consisting of L spatiotemporal attention modules connected in series. Each spatiotemporal attention module contains a spatial attention module, a temporal attention module, and a gating fusion mechanism. The input H of the decoder is obtained by adaptively selecting relevant features. (L+1) H (L+1) H is obtained after passing through l-1 spatiotemporal attention modules in the decoder. (L+l) Where l∈{1,2,...,L}, H (L+l) The output obtained after the spatial attention mechanism of the l-th spatiotemporal attention module is... The output obtained after the time attention mechanism of the l-th spatiotemporal attention module is Will and Gated fusion of temporal and spatial features is performed to obtain the output of the l-th spatiotemporal attention module. Through the fully connected layer, the decoder output is 6. The traffic flow speed prediction method based on directed hypergraph and attention mechanism according to claim 4, characterized in that, The output of the directed hypergraph network incorporating the attention mechanism is optimized using the following loss function: In the formula, Y t For the true value, The predicted value is obtained by minimizing the mean absolute error between the predicted value and the true value.

7. A traffic flow speed prediction system based on directed hypergraphs and attention mechanisms, characterized in that, include: The acquisition module is used to acquire traffic flow data, including sensor location, detection time, pulse count, vehicle direction of travel, and cross-sectional traffic flow speed information; The prediction module processes the acquired traffic flow data using a pre-trained traffic flow speed prediction model to obtain traffic flow speed prediction results. The training of the pre-trained traffic flow speed prediction model includes: constructing a directed hypergraph of road traffic; acquiring the traffic flow speed of road nodes in the directed hypergraph within a historical time step; performing weighted summation on the road node speed data at a certain moment within the historical time step, extracting the traffic flow speed feature vectors of the head and tail of the directed hypergraph, performing gating fusion to obtain the traffic flow speed feature vectors of the corresponding directed hyperedges, extracting new feature vectors for each road node, and outputting a matrix composed of vectors. The input consists of an encoder composed of L spatiotemporal attention modules connected in series, adaptively acquiring the spatial and temporal dependencies of each traffic node at different time steps; the input consists of a decoder composed of L spatiotemporal attention modules connected in series, and an output module is constructed using fully connected layers, generating prediction results for multiple prediction steps; defining a loss function for optimization, minimizing the mean absolute error between the predicted and true values, and training the directed hypergraph network end-to-end based on an error backpropagation mechanism to obtain the traffic flow speed prediction model.

8. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium is used to store computer instructions, which, when executed by a processor, implement the traffic flow speed prediction method based on directed hypergraphs and attention mechanisms as described in any one of claims 1-6.

9. A computer device, characterized in that, The system includes a memory and a processor, which communicate with each other. The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the traffic flow speed prediction method based on directed hypergraph and attention mechanism as described in any one of claims 1-6.

10. An electronic device, characterized in that, include: The electronic device includes a processor, a memory, and a computer program; wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory to cause the electronic device to execute instructions to implement the traffic flow speed prediction method based on directed hypergraphs and attention mechanisms as described in any one of claims 1-6.