Traffic flow prediction method based on state space model and graph attention network
By using a traffic flow prediction method based on a state-space model and graph attention network, we have solved the dual bottlenecks of traditional methods in terms of spatiotemporal interaction and spatial perception. This method achieves accurate prediction in complex traffic scenarios, improves prediction accuracy and efficiency, and can effectively capture long-term and cross-regional dependencies in traffic flow.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- UNIV OF ELECTRONICS SCI & TECH OF CHINA
- Filing Date
- 2026-03-11
- Publication Date
- 2026-06-09
Smart Images

Figure CN122176922A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent transportation technology, specifically to a traffic flow prediction method based on a state-space model and a graph attention network. Background Technology
[0002] With the accelerating pace of urbanization and the rapid development of Intelligent Transportation Systems (ITS), traffic flow prediction has become a key technology for improving urban traffic management efficiency, alleviating traffic congestion, and optimizing the travel experience. Traffic flow data, as a typical spatiotemporal series data, exhibits strong nonlinearity, periodicity, and randomness in the time dimension, and multi-scale, multi-level dependencies in the spatial dimension. It is not only affected by local adjacent road segments but may also involve long-distance interaction effects across regions. Therefore, how to accurately model the complex spatiotemporal dependencies in traffic flow has become a core scientific problem that urgently needs to be solved in the field of intelligent transportation.
[0003] Traditional traffic forecasting methods often separate temporal and spatial modeling, making it difficult to depict the true mechanisms of their interaction and co-driving effects, thus limiting the improvement of forecast accuracy. Furthermore, existing graph neural network-based methods are mostly limited to message passing within local neighborhoods, lacking sufficient ability to model long-range spatial dependencies, resulting in limited performance in predicting long-term traffic conditions and cross-regional congestion propagation. In recent years, although deep learning methods, such as recurrent neural networks, graph convolutional networks, and Transformers, have made some progress in traffic forecasting, they still face significant bottlenecks in computational efficiency, long-sequence modeling, and global spatial awareness. Summary of the Invention
[0004] This invention addresses the dual constraints of traditional traffic prediction methods, namely the lack of spatiotemporal interaction and limitations in spatial perception. It provides a traffic flow prediction method, device, and storage medium based on a state-space model and graph attention network, enabling accurate traffic flow prediction in complex traffic scenarios.
[0005] The present invention is achieved through the following technical solution.
[0006] Firstly, a traffic flow prediction method based on a state-space model and a graph attention network is provided, the method comprising:
[0007] Historical traffic flow data of multiple traffic nodes in the road network is obtained, and the historical traffic flow data is represented by a weighted graph structure, which includes: a set of nodes, a set of edges between nodes, and a weighted adjacency matrix;
[0008] Based on the historical traffic flow data and the road network, a traffic flow prediction model is constructed using a state-space model and a graph attention network.
[0009] Historical traffic flow data to be predicted is obtained and input into the traffic flow prediction model to obtain traffic flow prediction results within the target future time range.
[0010] In some embodiments, based on the historical traffic flow data and the road network, a traffic flow prediction model is constructed using a state-space model and a graph attention network, including:
[0011] The historical traffic flow data is standardized and feature-enhanced.
[0012] A static adjacency matrix is generated based on the actual connection relationship of the road network, and a learnable adjacency matrix is constructed through a learnable node embedding matrix. An adjacency matrix is then generated based on the static adjacency matrix and the learnable adjacency matrix.
[0013] From the historical traffic flow data after standardization and feature enhancement, temporal features are extracted through the state space model, spatial features are extracted through the graph attention network, and based on the adjacency matrix, multiple rounds of interaction between temporal and spatial features are performed to obtain the final temporal and spatial features.
[0014] The final temporal features and the final spatial features are integrated, and based on the integrated features, a multilayer perceptron is used to construct the traffic flow prediction model.
[0015] In some embodiments, the historical traffic flow data is subjected to standardization and feature enhancement processing, including:
[0016] The historical traffic flow data is standardized using the Z-score function.
[0017] The standardized historical traffic flow data is then subjected to feature enhancement processing, which includes: extracting basic temporal features from the standardized sequence using a one-way gated cyclic unit, adding Laplace map location encoding to traffic nodes in the historical traffic flow data, and embedding the historical traffic flow data into time.
[0018] In some embodiments, a static adjacency matrix is generated based on the actual connection relationships of the road network, and a learnable adjacency matrix is constructed through a learnable node embedding matrix. Based on the static adjacency matrix and the learnable adjacency matrix, an adjacency matrix is generated, including:
[0019] Based on the actual connection relationship of the road network, a distance matrix is constructed, and the distance matrix is subjected to Gaussian kernel normalization, sparsification, self-connection and symmetry processing to generate the static adjacency matrix.
[0020] A dynamic adjacency matrix is constructed using a learnable node embedding matrix, and the dynamic adjacency matrix is normalized to generate the learnable adjacency matrix.
[0021] The static adjacency matrix and the learnable adjacency matrix are weighted, fused, and symmetricized to obtain the adjacency matrix, wherein the adjacency matrix is represented as follows:
[0022] ;
[0023] in, It is a static adjacency matrix; It is a learnable adjacency matrix; These are learnable fusion weight parameters; This indicates standardized processing.
[0024] In some embodiments, from the standardized and feature-enhanced historical traffic flow data, temporal features are extracted using the state-space model, spatial features are extracted using the graph attention network, and multiple rounds of interaction between temporal and spatial features are performed based on the adjacency matrix to obtain the final temporal and spatial features, including:
[0025] The standardized and feature-enhanced historical traffic flow data is used as the initial input.
[0026] Temporal features are extracted from the historical traffic flow data using the state-space model.
[0027] The learnable node embedding matrix is extended to align with the data batch to determine the adjacency matrix;
[0028] Spatial features are extracted from the historical traffic flow data using the graph attention network and the determined adjacency matrix and temporal features.
[0029] The initial input is fused with the extracted spatial features and used as the new input.
[0030] Based on the new round of input, the temporal features are updated using the state-space model.
[0031] Using the graph attention network, the spatial features are updated by utilizing the determined adjacency matrix and the updated temporal features. The process then returns to the step of fusing the initial input with the extracted spatial features as the input for the next round, until the final temporal features and the final spatial features are obtained.
[0032] In some embodiments, the final iteration of the multi-round interaction between temporal and spatial features further includes: performing global enhancement and adaptive fusion of the local spatial features output by the graph attention network using a traffic node serialization method, wherein performing global enhancement and adaptive fusion of the local spatial features output by the graph attention network using a traffic node serialization method includes:
[0033] In the final round of the interaction between the multi-round temporal features and spatial features, the local spatial features output by the graph attention network are mapped to a low-dimensional feature space suitable for processing by the state space model.
[0034] The local spatial features mapped to the low-dimensional feature space suitable for processing by the state space model are converted into a long sequence format suitable for processing by the state space model to obtain serialized features;
[0035] The state-space mechanism of the state-space model is used to capture the global spatial dependencies in the serialized features, thereby achieving global enhancement and information integration of local spatial features;
[0036] The serialized features processed by the state-space model are restored to the original weighted graph structure of traffic node features to obtain enhanced global features.
[0037] By using a gating mechanism, the enhanced global features are adaptively fused with the original local spatial features to balance local details and global context.
[0038] In some embodiments, the final temporal features and the final spatial features are integrated, and based on the integrated features, a multilayer perceptron is used to construct the traffic flow prediction model, including:
[0039] The final temporal features and the final spatial features are concatenated along the feature dimensions to obtain the concatenated features;
[0040] The spliced features are projected onto a unified semantic space for fusion and dimensionality reduction.
[0041] A multilayer perceptron is used to map the fused and dimensionality-reduced spliced features into traffic flow prediction values at a standardized scale;
[0042] The traffic flow prediction values under the standardized scale are destandardized, and the loss function of the model is calculated based on the destandardized prediction values until the loss function meets the preset training termination condition, thus determining the traffic flow prediction model.
[0043] Secondly, a traffic flow prediction device based on a state-space model and a graph attention network is provided, the device comprising:
[0044] The data acquisition module is used to: acquire historical traffic flow data of multiple traffic nodes in the road network, and represent the historical traffic flow data in a weighted graph structure, wherein the weighted graph structure includes: a set of nodes, a set of edges between nodes, and a weighted adjacency matrix;
[0045] The traffic flow prediction model construction module is used to: construct a traffic flow prediction model based on the historical traffic flow data and the road network, using a state-space model and a graph attention network;
[0046] The traffic flow prediction module is used to: acquire historical traffic flow data to be predicted and input it into the traffic flow prediction model to obtain the traffic flow prediction results within a future target time range.
[0047] Thirdly, a traffic flow prediction device based on a state-space model and a graph attention network is provided, the device comprising:
[0048] At least one processor;
[0049] At least one memory coupled to the at least one processor and storing instructions for execution by the at least one processor, the instructions implementing the method described in any of the above when executed by the at least one processor.
[0050] Fourthly, a computer-readable storage medium is provided, the computer-readable storage medium storing instructions that, when executed by a computer, cause the computer to perform the method described in any of the preceding embodiments.
[0051] Compared with existing technologies, this invention has the following advantages and beneficial effects: it realizes the coupled representation of spatiotemporal features through an iterative bidirectional interaction mechanism; at the same time, it introduces a dual-branch collaboration between a local spatial graph attention network and a global spatial selective state space model in the spatial path to simultaneously capture local fine associations and global long-range dependencies, breaking through the dual bottlenecks of existing methods in terms of missing spatiotemporal interaction and limited spatial perception, and providing a new solution for accurate prediction in complex traffic scenarios. Attached Figure Description
[0052] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0053] Figure 1This is a flowchart of a traffic flow prediction method based on a state-space model and graph attention network according to an embodiment of the present invention.
[0054] Figure 2 A schematic diagram of the overall architecture of a traffic flow prediction model according to an embodiment of the present invention is shown.
[0055] Figure 3 A schematic diagram of the structure of a GRU model according to an embodiment of the present invention is shown.
[0056] Figure 4 This is a schematic diagram illustrating the working principle of Mamba according to an embodiment of the present invention.
[0057] Figure 5 This is a schematic diagram of the core algorithm of GAT according to an embodiment of the present invention.
[0058] Figure 6 This is a structural block diagram of a traffic flow prediction device based on a state-space model and graph attention network according to an embodiment of the present invention.
[0059] Figure 7 This is a schematic diagram of a traffic flow prediction device based on a state-space model and graph attention network according to an embodiment of the present invention. Detailed Implementation
[0060] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.
[0061] This invention proposes a traffic flow prediction model based on a state-space model and a graph attention network (DualMamba-GAT). The core of DualMamba-GAT lies in designing a deeply integrated interactive architecture, which achieves coupled representation of spatiotemporal features through an iterative bidirectional interaction mechanism. At the same time, it introduces a dual-branch collaboration between a local spatial graph attention network and a global spatial selective state-space model in the spatial path to simultaneously capture local fine-grained associations and global long-range dependencies. This aims to overcome the dual bottlenecks of existing methods in terms of missing spatiotemporal interaction and limited spatial perception, and provide a new solution for accurate prediction in complex traffic scenarios.
[0062] On the one hand, the present invention provides a traffic flow prediction method based on a state-space model and a graph attention network. Figure 1 This is a flowchart illustrating a traffic flow prediction method based on a state-space model and graph attention network according to an embodiment of the present invention. (Reference) Figure 1The traffic flow prediction method based on state-space model and graph attention network includes: S10 to S30.
[0063] Figure 2 A schematic diagram of the overall architecture of a traffic flow prediction model according to an embodiment of the present invention is shown. Figure 3 A schematic diagram of the structure of a GRU model according to an embodiment of the present invention is shown. Figure 4 This is a schematic diagram illustrating the working principle of Mamba according to an embodiment of the present invention. Figure 5 This is a schematic diagram of the core algorithm of GAT according to an embodiment of the present invention.
[0064] The present invention, S10 to S30, will be described in detail below with reference to the accompanying drawings.
[0065] In S10, historical traffic flow data of multiple traffic nodes in the road network is obtained and the historical traffic flow data is represented by a weighted graph structure, which includes: a set of nodes, a set of edges between nodes, and a weighted adjacency matrix.
[0066] Traffic flow data includes at least one traffic state feature. Traffic state features are quantitative indicators used to describe the operation of traffic flow at specific times and spatial locations, involving macro-traffic flow features (flow rate, speed, density, etc.), extended macro-features, micro-vehicle features, spatiotemporal features, traffic state labels, etc.
[0067] Traffic flow prediction is a typical spatiotemporal series prediction problem, the core of which lies in simultaneously modeling the spatial dependencies between nodes in the road network and the temporal dynamics of each node. In this invention, the target road network is modeled as a weighted graph structure. ,in, This represents the set of sensor nodes in the road network. The total number of nodes; This represents the set of edges between nodes, reflecting road connectivity; The elements of the weighted adjacency matrix Represents a node and The spatial correlation strength between them is constructed by distance cost, Gaussian similarity and learnable parameters.
[0068] The diagram The traffic flow observed above is represented as a graphical signal. Each node at time Traffic conditions are represented by multidimensional features, among which, This refers to the number of features (such as speed and traffic flow) for each node. In this invention, the number of features can be set as follows: Let the historical time step be... The predicted step size is Then the traffic flow prediction problem can be formally expressed as:
[0069] (1)
[0070] in, For historical observation sequence, For the predicted sequence, This invention presents a traffic flow prediction model based on a state-space model and a graph attention network.
[0071] In S20, a traffic flow prediction model is constructed based on historical traffic flow data and road network, using a state-space model and graph attention network.
[0072] Traffic flow is characterized by dynamic evolution, spatial coupling, and multi-scale properties. Based on this, this invention proposes a traffic flow representation model (Dual Mamba-GAT) that can couple complex spatiotemporal dependencies to achieve a deep fusion of temporal dynamics and spatial structural information. Figure 2 A schematic diagram of the overall architecture of a traffic flow prediction model according to an embodiment of the present invention is shown, which mainly includes the following five modules:
[0073] ① Data preprocessing and feature enhancement module (Inputs): Standardizes the raw traffic flow data, performs preliminary temporal feature extraction, location coding, and time embedding;
[0074] ②Adjacency Matrix Fusion Module: Combines static road network structure with learnable node embedding to generate a dynamically fused adjacency matrix;
[0075] ③ Multi-round iterative spatiotemporal interaction module (GAT-Mamba): Through the alternating iteration of Mamba and GAT, deep coupling of temporal and spatial features is achieved;
[0076] ④ Selective spatial augmentation module (spatial-Mamba): It uses spatial Mamba to capture global spatial dependencies and fuses them with local features through a gating mechanism;
[0077] ⑤ Feature Fusion and Prediction Output Module (Outputs): This module concatenates and maps the final spatiotemporal features, and outputs the prediction results through a multilayer perceptron.
[0078] The following describes S20 in detail, taking into account the five modules mentioned above. In some embodiments, S20 includes S21 to S25.
[0079] In S21, historical traffic flow data undergoes standardization and feature enhancement processing.
[0080] refer to Figure 2For the original historical traffic flow (time series) data Standardization is performed to eliminate dimensional differences and improve training stability. In this invention, the Z-score function is used to standardize the flow rate, speed, and occupancy characteristics of historical traffic flow data. The Z-score calculation process is shown in the following formula:
[0081] (2)
[0082] in, , represents the mean and standard deviation of the corresponding features in the training data.
[0083] From the training dataset The statistics for each feature are calculated, and the formulas for calculating the mean and standard deviation are shown below:
[0084] (3)
[0085] (4)
[0086] In the formula, These are training samples.
[0087] Feature enhancement processing includes three steps: a one-way gated recurrent unit (GRU) extracts basic temporal features from the normalized sequence, position encoding, and temporal embedding.
[0088] The first step in feature enhancement is to use a one-way gated recurrent unit (GRU) to extract basic time-series features from the standardized sequence in order to capture short-term fluctuations and periodic patterns in the sequence. Figure 3 A schematic diagram of the structure of a GRU model according to an embodiment of the present invention is shown. (Reference) Figure 3 The update equation for GRU is as follows:
[0089] (5)
[0090] (6)
[0091] (7)
[0092] (8)
[0093] in, For the current moment, Let the input vector be the input vector at the current time. This represents the hidden state from the previous time step (hidden layer output). It is the Sigmoid activation function. The hyperbolic tangent activation function is used. This indicates element-wise multiplication. This is the weight matrix (corresponding to the update gate, reset gate, and candidate state, respectively). , , For bias vectors, It refers to concatenating two vectors. To update the activation vector of the gate, To reset the activation vector of the gate, In the candidate hidden state, This represents the hidden state at the current moment. The final extracted GRU hidden state is denoted as... .
[0094] The second step of feature enhancement involves adding Laplace's mapping location codes to traffic nodes in historical traffic flow data. To compensate for the Mamba model's deficiency in spatial structure perception when processing temporal features, this invention introduces Laplace's mapping location codes after the initial extraction of temporal features by the GRU, generating a unique spatial coordinate representation for each traffic node. This Laplace's mapping location code is constructed based on the eigenvectors of the graph Laplace matrix, effectively capturing the spatial topological relationships of the road network. The specific steps for adding Laplace's mapping location codes to traffic nodes in historical traffic flow data are as follows:
[0095] ① Construction of direct distance weighted adjacency matrix
[0096] Based on distance data from actual road networks, a spatial relationship matrix reflecting the cost of direct connections between nodes is constructed, providing a structural foundation for subsequent Laplace calculations, using the physical distance between nodes as the basis. As connection weights, construct a weighted adjacency matrix. :
[0097] (9)
[0098] At the same time, set up self-connection This underscores the importance of ensuring that each node retains its own characteristics within the structure.
[0099] ②Calculation of the Laplace matrix
[0100] Based on the weighted adjacency matrix, the degree matrix and Laplacian matrix are calculated, laying the mathematical foundation for eigenvalue decomposition and positional encoding extraction.
[0101] Calculate the degree matrix The formula is shown below:
[0102] (10)
[0103] To ensure numerical stability, the degree matrix is subjected to safety processing:
[0104] (11)
[0105] in, It is a very small positive number used for numerical stability and to avoid division by zero errors.
[0106] ③ Calculation of normalized Laplace matrix
[0107] By normalizing the graph, the influence of node degree differences on the structural representation is eliminated. Standardized graph structure operators are extracted, and the symmetric normalized Laplacian matrix is calculated. The calculation formula is shown in the following equation:
[0108] (12)
[0109] in, It is the identity matrix, which is positive semidefinite, and its spectral properties reflect the structural characteristics of the graph.
[0110] ④ Eigenvalue decomposition and positional encoding extraction:
[0111] By performing eigenvalue decomposition on the Laplacian matrix, low-dimensional embedding vectors that characterize the spatial location of nodes are extracted and used as positional encodings. The specific process is as follows: Solving the eigenvalue problem. Sort by eigenvalues from smallest to largest; select the eigenvectors excluding the eigenvalue corresponding to the smallest eigenvalue. The eigenvectors constitute the position encoding matrix:
[0112] (13)
[0113] This encoding maps each node to A 3D space vector preserves the relative positions and structural relationships of nodes in the graph, where... The first of the Laplace matrix 1 eigenvalue, For the corresponding eigenvalues eigenvectors, The dimension for location encoding. This represents the number of nodes.
[0114] The Laplace map location encoding module transforms the spatial topology of the traffic network into a learnable low-dimensional vector representation using graph theory. This encoding not only supplements the temporal features with spatial location information, enhancing the model's ability to perceive the spatial distribution of nodes, but also provides geometrically interpretable structural priors for subsequent spatiotemporal interaction modules, thereby improving the model's spatial modeling accuracy and generalization performance in traffic flow prediction tasks.
[0115] The third step of feature enhancement involves temporal embedding of historical traffic flow data. To fully model the temporal periodic patterns inherent in traffic flow data, such as morning and evening rush hours, and weekday and holiday patterns, this invention introduces temporal embedding on top of the original flow, speed, and occupancy features. By constructing learnable time-period embeddings and weekday embeddings, the model can explicitly capture and utilize the intraday and weekly periodic characteristics of traffic data, thereby enhancing the semantic richness and predictive accuracy of time-series modeling. The specific implementation method of temporal embedding is as follows:
[0116] ① Construction of intraday time cycle characteristics
[0117] Each time step is mapped to its relative intraday location, providing the model with standardized intraday time coordinates. Let the data sampling interval be... Minutes, then the number of time slices per day is:
[0118] (14)
[0119] For the The normalized intraday time characteristics of each time step are calculated as follows:
[0120] (15)
[0121] when At minute, This feature maps the day evenly to The intervals enable the model to identify differences in traffic patterns at different times.
[0122] ② Calculation of Weekly Cycle Characteristics
[0123] Encoding weekday information as numerical features enables the model to distinguish between weekday and weekend traffic patterns. The day of the week information is extracted from timestamps and mapped to integers.
[0124] (16)
[0125] After normalization, the weekday characteristics are as follows:
[0126] (17)
[0127] This feature uniformly normalizes the weekdays from Monday to Sunday, preserving the weekday sequence information and making it easier for the model to learn the weekly cycle changes.
[0128] ③ Extension of time features
[0129] The temporal features are replicated and extended along the node dimension to align with the spatial dimension of the traffic flow data, facilitating subsequent feature fusion. This forms the basic temporal feature matrix. Expanded to:
[0130] (18)
[0131] in, For batch size, For the number of nodes, The time step is defined as such, and after expansion, each node has the same temporal feature representation.
[0132] ④ Temporal Embedded Network Structure
[0133] By using nonlinear mapping, the original time features are transformed into high-dimensional, learnable embedded representations, enhancing the expressive and interactive capabilities of time information. A two-layer fully connected network is used to encode the time features: the first layer is a nonlinear transformation, and the second layer is a linear mapping.
[0134] The first-level nonlinear transformation formula is shown below:
[0135] (19)
[0136] The second-level linear mapping formula is shown below:
[0137] (20)
[0138] To further simplify the representation and enhance stability, average pooling is performed on the time dimension to obtain node-level temporal embeddings:
[0139] (twenty one)
[0140] in, This is the original time feature vector. This is the first layer weight matrix. This is the first layer bias vector. This is the hidden representation after the first layer is activated. For activation function, This is the weight matrix for the second layer. This is the second layer bias vector. This is the final output temporal embedding vector. For batch size, For the number of nodes, For time step, Embed the dimension of time.
[0141] Temporal embedding transforms raw discrete-time information into semantically expressive continuous vector representations by extracting structured temporal features down to the node dimension and aligning them to a nonlinear embedding map. This design enables the model to explicitly model periodic patterns in traffic flow data, enhances the discriminative power and generalization ability of temporal features, and provides crucial contextual information support for subsequent spatiotemporal modeling modules, thereby significantly improving the model's predictive performance under complex temporal dynamics.
[0142] In summary, the preliminary temporal features extracted by GRU, the Laplace map location encoding, and the temporal embedding are concatenated along the feature dimension with the features (flow, speed, occupancy) of the original traffic flow data to form the model input:
[0143] (twenty two)
[0144] in, , The original traffic flow characteristics, For the original traffic flow feature dimensions, Preliminary temporal feature dimensions extracted for the gated recurrent unit. For location encoding dimension, Embed the dimension of time.
[0145] In S22, a static adjacency matrix is generated based on the actual connection relationship of the road network, and a learnable adjacency matrix is constructed through a learnable node embedding matrix. Based on the static adjacency matrix and the learnable adjacency matrix, an adjacency matrix is generated.
[0146] In this invention, the process of constructing the adjacency matrix comprehensively considers the physical structure and dynamic semantic relationships of the transportation system. By fusing static and learnable adjacency matrices, a comprehensive modeling of spatial dependencies is achieved. The specific steps for constructing the adjacency matrix based on graph attention networks are as follows:
[0147] 1. Static Adjacency Matrix Construction
[0148] ①Distance matrix construction
[0149] First, a distance matrix is constructed based on the actual connectivity of the transportation network. In this system, the physical distance between connected node pairs is recorded, while the distance between unconnected node pairs is set to infinity. This preserves the topological information of the road network, providing a physical basis for subsequent similarity calculations.
[0150] ② Gaussian kernel normalization
[0151] The physical distance is converted into the similarity between nodes using the Gaussian kernel function. The calculation formula is as follows:
[0152] (twenty three)
[0153] in, is the standard deviation of all effective distances. This allows the model to simulate the distance decay effect in traffic flow, making nodes that are closer together have higher similarity, which is consistent with the real-world law that traffic impact decreases with distance.
[0154] ③Sparsening treatment
[0155] Set threshold This process removes connections with low similarity, retaining only significant spatial dependencies. This reduces noisy connections, lowers computational complexity, and makes the adjacency matrix more physically interpretable. The sparsification formula is shown below:
[0156] (twenty four)
[0157] ④ Self-connection and symmetry handling
[0158] Set the diagonal of the matrix to 1 to ensure that each node can interact with its own features, and perform symmetry processing on the undirected graph:
[0159] (25)
[0160] This enhances the ability to preserve the characteristics of nodes themselves and ensures the structural consistency of the adjacency matrix, adapting to the characteristics of undirected traffic networks.
[0161] 2. Learnable adjacency matrix construction
[0162] Through a learnable node embedding matrix, Constructing a dynamic adjacency matrix:
[0163] (26)
[0164] in, An embedding matrix for learnable nodes. For the number of nodes, Embed dimensions for nodes.
[0165] right Normalization is performed:
[0166] (27)
[0167] In this way, the model can automatically learn the semantic relationships between nodes from the data, capture unstructured traffic pattern similarities (such as dynamic relationships like functional zone spacing and traffic state synchronization), and enhance the model's ability to model complex traffic dependencies.
[0168] 3. Generate the adjacency matrix
[0169] The static adjacency matrix and the learnable adjacency matrix are weighted and fused:
[0170] (28)
[0171] in, For learnable parameters, This is a normalization operation.
[0172] Symmetry treatment:
[0173] (29)
[0174] This achieves a dynamic balance between physical priors and data-driven approaches, enabling the model to utilize a fixed road network structure while adaptively learning the spatial dependencies implicit in traffic flow, thus improving the robustness and adaptability of spatial modeling.
[0175] In S23, temporal features are extracted from historical traffic flow data after standardization and feature enhancement through a state-space model, spatial features are extracted through a graph attention network, and multiple rounds of interaction between temporal and spatial features are performed based on the adjacency matrix to achieve deep coupling between temporal and spatial features.
[0176] The selective state-space model (Mamba) is used to extract temporal features. The Mamba structure has lower computational complexity when processing long sequences, which makes it valuable for tasks that require modeling long-term dependencies in traffic flow prediction. Figure 4 This illustrates how Mamba works.
[0177] Spatial features are extracted using a graph attention network (GAT). GAT assigns different weights to each neighbor node through an attention mechanism, and these weights are dynamically calculated based on the node features. Figure 5 The diagram illustrates the core algorithm principle of Graph Attention Network (GAT), which aggregates neighbor node information through a dynamic attention mechanism, significantly improving the expressive power of graph neural networks.
[0178] Based on the above, this invention designs a multi-round iterative spatiotemporal interaction module based on DualMamba-GAT. This module gradually enhances the interaction and expression of spatiotemporal features during the iteration process by alternately using the Selective State Space Model (Mamba) and the Graph Attention Network (GAT). This model achieves the enhancement of spatiotemporal feature interaction through the following mechanisms:
[0179] ① Multi-round iterative interaction mechanism: Let the number of iterations be... For each iteration ;
[0180] ② Temporal feature extraction: The Mamba module efficiently captures long sequence dependencies, which is suitable for temporal dynamic modeling of traffic flow;
[0181] ③ Temporal feature enhancement: Concatenate Mamba output features with learnable node embedding features;
[0182] ④ Spatial feature extraction: GAT dynamically aggregates neighbor node information through an attention mechanism to extract local spatial dependencies;
[0183] ⑤ Dynamic feedback: Spatial features from each round are fed back to the temporal input of the next round, realizing cross-round information transmission.
[0184] Among them, the Wheel and the first The input update relationship between rounds is as follows:
[0185] (30)
[0186] in, As the initial input, For the first The spatial characteristics of a wheel This is a dynamic projection function.
[0187] The specific implementation steps for deep coupling of temporal and spatial features are as follows:
[0188] Initial input: Features after preprocessing and feature enhancement as described in S21 As the initial input, where For batch size, For the number of nodes, For time step, For feature dimensions.
[0189] Round 1 Iteration: Temporal Feature Extraction
[0190] (31)
[0191] Mamba captures temporal dependencies through a selective state-space mechanism;
[0192] Node embedding extension: embedding learnable nodes Expand to align with batch:
[0193] (32)
[0194] Spatial feature extraction: Concatenate temporal features and node embeddings, input GAT to extract spatial dependencies:
[0195] (33)
[0196] (34)
[0197] Second iteration: Dynamic input update: The initial input is fused with the spatial features from the first iteration to form a new input.
[0198] (35)
[0199] Time-series feature update:
[0200] (36)
[0201] Spatial feature update:
[0202] (37)
[0203] (38)
[0204] Third iteration: Dynamic input update:
[0205] (39)
[0206] Final temporal feature extraction:
[0207] (40)
[0208] Final spatial feature extraction:
[0209] (41)
[0210] (42)
[0211] Through the above multiple spatiotemporal interactions, the model can simultaneously capture long-range temporal dependencies and complex spatial relationships in traffic flow, achieving bidirectional enhancement and deep fusion of temporal dynamics and spatial structure information, and providing highly expressive spatiotemporal feature representations for subsequent prediction tasks.
[0212] In S24, the selective spatial augmentation module in the DualMamba-GAT model is used to further enhance the global spatial dependency modeling capability. In the final iteration of the aforementioned multi-round iterative spatiotemporal interaction module, the selective spatial augmentation module is introduced. This module is built based on the state-space model (Mamba) and uses a node serialization method to perform global augmentation and adaptive fusion of local spatial features. The specific implementation steps of this selective spatial augmentation are as follows:
[0213] 1. Local spatial feature projection
[0214] The local spatial features output by the graph attention network in the last round of the multi-round iterative spatiotemporal interaction in S23 above. Mapping to a low-dimensional feature space suitable for Mamba processing achieves feature dimension alignment and information compression. This is achieved through a learnable weight matrix. With bias A linear transformation is performed, and the transformation formula is shown below:
[0215] (43)
[0216] In the formula, , Input dimensions for Mamba; this step preserves key local information while reducing computational overhead.
[0217] 2. Serialization processing:
[0218] The node features in the graph structure are converted into a long sequence format suitable for sequence models (Mamba), making it easier for the model to capture long-range dependencies across nodes globally. The 3D feature tensor is converted into sequence form through a reshaping operation, as shown in the following formula:
[0219] (44)
[0220] This transformation treats the node dimension as sequence length, enabling Mamba to model the relationships between nodes globally.
[0221] 3. Mamba space handling:
[0222] The state-space mechanism of Mamba is used to capture global spatial dependencies in serialized features, thereby achieving global enhancement and information integration of local features. The serialized features are input into the spatial Mamba module, and the mathematical formula is shown below:
[0223] (45)
[0224] Mamba efficiently models the dynamic interactions between long-distance nodes and extracts global spatial patterns through a structured state-space model (SSM) and a selective scanning mechanism.
[0225] 4. Feature Recovery
[0226] The serialized features processed by Mamba are restored to the original graph node feature format for fusion with local features. The feature shape is restored through a reshaping operation, as shown in the following formula:
[0227] (46)
[0228] 5. Gated Adaptive Fusion
[0229] The gating mechanism is designed to adaptively fuse the enhanced global features with the original local features, balancing local details with the global context.
[0230] Global Feature Projection: Projecting global features output by Mamba Mapping to the same dimension as the local features, the formula is as follows:
[0231] (47)
[0232] Feature stitching: combining original local features The concatenation with the projected global features is shown in the following formula:
[0233] (48)
[0234] Gating signal generation: Gating weights are generated through a fully connected layer and a sigmoid activation function to determine the fusion strength of global features, as shown in the following formula:
[0235] (49)
[0236] Residual fusion: The residual structure is used to weight and fuse global features into local features, as shown in the following formula:
[0237] (50)
[0238] In summary, the selective spatial augmentation module, through sequential modeling and gating fusion mechanisms, enables the model to effectively introduce global spatial context while preserving local graph structure information. This enhances the model's ability to model complex dependencies between distant nodes in the traffic network, thereby improving the overall performance and robustness of the prediction system.
[0239] In S25, the feature fusion and prediction output module of the DualMamba-GAT model is used to effectively integrate the temporal and spatial features extracted through multiple rounds of spatiotemporal modeling, and finally map them to traffic flow prediction values at a standard scale. The design of this module balances the effectiveness of information fusion with the interpretability of the prediction output. The specific implementation steps are as follows:
[0240] 1. Feature splicing
[0241] The final temporal features extracted through multiple rounds of spatiotemporal interaction Combined spatial features after selective spatial enhancement By concatenating along the feature dimension, explicit integration of spatiotemporal features is achieved. Through the concatenation operation, the two types of features are fused into a unified feature representation, as shown in the following formula:
[0242] (51)
[0243] This step preserves all information about temporal dynamics and spatial dependencies, providing a complete feature representation for subsequent mapping.
[0244] 2. Feature Fusion Projection
[0245] The concatenated high-dimensional features are projected onto a unified semantic space to achieve deep interaction and information compression between features, avoiding dimensionality redundancy. Learnable linear transformations are used to fuse and reduce the dimensionality of the concatenated features.
[0246] (52)
[0247] This step enhances the consistency of feature representation and provides structured input to the final prediction layer.
[0248] 3. Multilayer perceptron prediction
[0249] A two-layer MLP structure is adopted to map the fused features into traffic flow prediction values at a standardized scale, thereby achieving a nonlinear transformation from the feature space to the prediction space.
[0250] The first nonlinear mapping layer extracts high-level abstract features through a fully connected layer and the ReLU activation function, enhancing the model's expressive power. The mapping formula is shown below:
[0251] (53)
[0252] The second-layer linear output maps abstract features to the future values of each node. The predicted traffic value for each time step is given by the following formula:
[0253] (54)
[0254] Among them, the output To ensure that the prediction results are at a standardized scale, the scale of the input data remains consistent.
[0255] In summary, the feature fusion and prediction output module achieves end-to-end transformation from multi-source spatiotemporal features to the final predicted value through a progressive structure of feature concatenation and fusion projection onto the MLP mapping. This module not only effectively integrates multi-level information at the local and global, temporal and spatial levels, but also captures the complex dynamic relationships in traffic flow through a nonlinear mapping mechanism. The final output is a prediction result at a physically interpretable standardized scale, providing a stable and scalable output interface for subsequent de-standardization and model training.
[0256] 4. Perform destandardization on the traffic flow prediction values under the standardized scale, and calculate the loss function of the model based on the destandardized prediction values until the loss function meets the preset training termination condition. The model that meets the training termination condition is designated as the target model.
[0257] 1. Inverse standardization of prediction results
[0258] The output standardized scale prediction value Mapping back to the original data scale gives the prediction results interpretability in actual flow units, facilitating subsequent evaluation and application, and addressing the dimensions of flow prediction. Using the mean saved during the training phase with standard deviation Perform the inverse linear transformation, the transformation formula is as follows:
[0259] (55)
[0260] in, This represents the traffic flow forecast restored to its original scale. This operation eliminates the influence of the previous standardization process on the data distribution, ensuring that the output is on the same scale as the actual observations.
[0261] 2. Loss Function and Training Strategy
[0262] By defining reasonable optimization objectives and training control mechanisms, we ensure that the model can effectively learn traffic flow dynamics while avoiding overfitting. Mean Squared Error (MSE) is used as the training loss to measure the difference between predicted and true values. The formula for MSE is as follows:
[0263] (56)
[0264] This function is more sensitive to larger errors, which helps the model focus on correcting significant prediction biases and improve overall prediction accuracy.
[0265] Secondly, monitor the change in loss on the validation set; if it is continuous... One cycle (in this invention) If the verification loss does not decrease, training is terminated early. This mechanism effectively suppresses overfitting and improves the model's generalization ability.
[0266] The de-standardization and loss function design completes a closed loop from standardized prediction to physical value restoration, and from prediction output to model optimization. This invention not only ensures the practical usability of the prediction results, but also achieves stable control and efficient convergence of the model training process by combining the MSE loss function with the early stopping mechanism, providing a reliable learning paradigm for traffic flow prediction tasks.
[0267] In S30, historical traffic flow data to be predicted is acquired and input into the traffic flow prediction model to obtain traffic flow prediction results within the future target time range.
[0268] This invention proposes a traffic flow prediction model based on a state-space model and a graph attention network (DualMamba-GAT), the core of which lies in designing a deeply integrated interactive architecture. Through an iterative bidirectional interaction mechanism, it achieves coupled representation of spatiotemporal features. Simultaneously, it introduces a dual-branch collaboration between a local spatial graph attention network and a global spatial selective state-space model within the spatial path, capturing both local fine-grained associations and global long-range dependencies. This overcomes the dual bottlenecks of existing methods—lack of spatiotemporal interaction and limitations in spatial perception—and provides a new solution for accurate prediction in complex traffic scenarios.
[0269] On the other hand, a traffic flow prediction device based on a state-space model and a graph attention network is provided. Figure 6 This is a structural block diagram of a traffic flow prediction device based on a state-space model and graph attention network according to an embodiment of the present invention. (Reference) Figure 6 The device includes: a data acquisition module, a traffic flow prediction model construction module, and a traffic flow prediction module.
[0270] The data acquisition module is used to: acquire historical traffic flow data of multiple traffic nodes in the road network, and represent the historical traffic flow data in a weighted graph structure, wherein the weighted graph structure includes: a set of nodes, a set of edges between nodes, and a weighted adjacency matrix.
[0271] The traffic flow prediction model construction module is used to: construct a traffic flow prediction model based on historical traffic flow data and the road network, using a state-space model and a graph attention network.
[0272] The traffic flow prediction module is used to: acquire historical traffic flow data to be predicted and input it into the traffic flow prediction model to obtain the traffic flow prediction results within the target future time range.
[0273] For further details regarding the traffic flow prediction device based on state-space models and graph attention networks, please refer to the previous description of the traffic flow prediction method based on state-space models and graph attention networks, which will not be repeated here.
[0274] In implementing the functions of the integrated modules described above in hardware, this embodiment of the invention provides another structure for the traffic flow prediction device based on state-space model and graph attention network involved in the above embodiments. Figure 7 This is a schematic diagram of a traffic flow prediction device based on a state-space model and graph attention network according to an embodiment of the present invention. (Reference) Figure 7The traffic flow prediction device based on a state-space model and graph attention network includes: at least one processor; and at least one memory. The at least one memory is coupled to the at least one processor and stores instructions for execution by the at least one processor, which, when executed by the at least one processor, implement the method described above.
[0275] A processor can be a set of logic blocks, modules, and circuits that implement or execute the various exemplary logic blocks, modules, and circuits described in connection with embodiments of the present invention. The processor can be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in connection with embodiments of the present invention. A processor can also be a combination that implements computational functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, etc.
[0276] The memory may be read-only memory (ROM) or other types of static storage devices that can store static information and instructions, random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, electrically erasable programmable read-only memory (EEPROM), disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
[0277] In one implementation, the memory can exist independently of the processor. The memory can be connected to the processor via a bus and used to store instructions or program code. When the processor calls and executes the instructions or program code stored in the memory, it can implement the method provided in the embodiments of the present invention. In another implementation, the memory can also be integrated with the processor.
[0278] On the other hand, the present invention also provides a computer-readable storage medium (e.g., a non-transitory computer-readable storage medium) storing computer program instructions that, when executed on a computer, cause the computer to perform the method as described in any of the above embodiments.
[0279] Exemplary examples show that the aforementioned computer-readable storage media may include, but are not limited to: magnetic storage devices (e.g., hard disks, floppy disks, or magnetic tapes), optical discs (e.g., compact disks (CDs), digital versatile disks (DVDs), etc.), smart cards, and flash memory devices (e.g., erasable programmable read-only memory (EPROMs), cards, sticks, or key drives, etc.). The various computer-readable storage media described in this invention may represent one or more devices and / or other machine-readable storage media for storing information. The term "machine-readable storage medium" may include, but is not limited to, wireless channels and various other media capable of storing, containing, and / or carrying instructions and / or data.
[0280] This invention provides a computer program that, when run on a computer, causes the computer to perform the method of any of the above embodiments.
[0281] This invention provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the method of any of the above embodiments.
[0282] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A traffic flow prediction method based on a state-space model and a graph attention network, characterized in that, The method includes: Historical traffic flow data of multiple traffic nodes in the road network is obtained, and the historical traffic flow data is represented by a weighted graph structure, which includes: a set of nodes, a set of edges between nodes, and a weighted adjacency matrix; Based on the historical traffic flow data and the road network, a traffic flow prediction model is constructed using a state-space model and a graph attention network. Historical traffic flow data to be predicted is obtained and input into the traffic flow prediction model to obtain traffic flow prediction results within the target future time range.
2. The method according to claim 1, characterized in that, Based on the historical traffic flow data and the road network, a traffic flow prediction model is constructed using a state-space model and a graph attention network, including: The historical traffic flow data is standardized and feature-enhanced. A static adjacency matrix is generated based on the actual connection relationship of the road network, and a learnable adjacency matrix is constructed through a learnable node embedding matrix. An adjacency matrix is then generated based on the static adjacency matrix and the learnable adjacency matrix. From the historical traffic flow data after standardization and feature enhancement, temporal features are extracted through the state space model, spatial features are extracted through the graph attention network, and based on the adjacency matrix, multiple rounds of interaction between temporal and spatial features are performed to obtain the final temporal and spatial features. The final temporal features and the final spatial features are integrated, and based on the integrated features, a multilayer perceptron is used to construct the traffic flow prediction model.
3. The method according to claim 2, characterized in that, The historical traffic flow data undergoes standardization and feature enhancement processing, including: The historical traffic flow data is standardized using the Z-score function. The standardized historical traffic flow data is then subjected to feature enhancement processing, which includes: extracting basic temporal features from the standardized sequence using a one-way gated cyclic unit, adding Laplace map location encoding to traffic nodes in the historical traffic flow data, and embedding the historical traffic flow data into time.
4. The method according to claim 2, characterized in that, A static adjacency matrix is generated based on the actual connection relationships of the road network, and a learnable adjacency matrix is constructed through a learnable node embedding matrix. Based on the static adjacency matrix and the learnable adjacency matrix, an adjacency matrix is generated, including: Based on the actual connection relationship of the road network, a distance matrix is constructed, and the distance matrix is subjected to Gaussian kernel normalization, sparsification, self-connection and symmetry processing to generate the static adjacency matrix. A dynamic adjacency matrix is constructed using a learnable node embedding matrix, and the dynamic adjacency matrix is normalized to generate the learnable adjacency matrix. The static adjacency matrix and the learnable adjacency matrix are weighted, fused, and symmetricized to obtain the adjacency matrix, wherein the adjacency matrix is represented as follows: ; in, It is a static adjacency matrix; It is a learnable adjacency matrix; These are learnable fusion weight parameters; This indicates standardized processing.
5. The method according to claim 2, characterized in that, From the standardized and feature-enhanced historical traffic flow data, temporal features are extracted using the state-space model, and spatial features are extracted using the graph attention network. Based on the adjacency matrix, multiple rounds of interaction between temporal and spatial features are performed to obtain the final temporal and spatial features, including: The standardized and feature-enhanced historical traffic flow data is used as the initial input. Temporal features are extracted from the historical traffic flow data using the state-space model. The learnable node embedding matrix is extended to align with the data batch to determine the adjacency matrix; Spatial features are extracted from the historical traffic flow data using the graph attention network and the determined adjacency matrix and temporal features. The initial input is fused with the extracted spatial features and used as the new input. Based on the new round of input, the temporal features are updated using the state-space model. Using the graph attention network, the spatial features are updated by utilizing the determined adjacency matrix and the updated temporal features. The process then returns to the step of fusing the initial input with the extracted spatial features as the input for the next round, until the final temporal features and the final spatial features are obtained.
6. The method according to claim 5, characterized in that, In the final iteration of the multi-round interaction between temporal and spatial features, the method further includes: using a traffic node serialization approach to perform global enhancement and adaptive fusion of the local spatial features output by the graph attention network. This global enhancement and adaptive fusion of the local spatial features output by the graph attention network, using a traffic node serialization approach, includes: In the final round of the interaction between the multi-round temporal features and spatial features, the local spatial features output by the graph attention network are mapped to a low-dimensional feature space suitable for processing by the state space model. The local spatial features mapped to the low-dimensional feature space suitable for processing by the state space model are converted into a long sequence format suitable for processing by the state space model to obtain serialized features; The state-space mechanism of the state-space model is used to capture the global spatial dependencies in the serialized features, thereby achieving global enhancement and information integration of local spatial features; The serialized features processed by the state-space model are restored to the original weighted graph structure of traffic node features to obtain enhanced global features. By using a gating mechanism, the enhanced global features are adaptively fused with the original local spatial features to balance local details and global context.
7. The method according to claim 2, characterized in that, The final temporal features and the final spatial features are integrated, and based on the integrated features, a traffic flow prediction model is constructed using a multilayer perceptron, including: The final temporal features and the final spatial features are concatenated along the feature dimensions to obtain the concatenated features; The spliced features are projected onto a unified semantic space for fusion and dimensionality reduction. A multilayer perceptron is used to map the fused and dimensionality-reduced spliced features into traffic flow prediction values at a standardized scale; The traffic flow prediction values under the standardized scale are destandardized, and the loss function of the model is calculated based on the destandardized prediction values until the loss function meets the preset training termination condition, thus determining the traffic flow prediction model.
8. A traffic flow prediction device based on a state-space model and a graph attention network, characterized in that, The device includes: The data acquisition module is used to: acquire historical traffic flow data of multiple traffic nodes in the road network, and represent the historical traffic flow data in a weighted graph structure, wherein the weighted graph structure includes: a set of nodes, a set of edges between nodes, and a weighted adjacency matrix; The traffic flow prediction model construction module is used to: construct a traffic flow prediction model based on the historical traffic flow data and the road network, using a state-space model and a graph attention network; The traffic flow prediction module is used to: acquire historical traffic flow data to be predicted and input it into the traffic flow prediction model to obtain the traffic flow prediction results within a future target time range.
9. A traffic flow prediction device based on a state-space model and a graph attention network, characterized in that, The device includes: At least one processor; At least one memory coupled to the at least one processor and storing instructions for execution by the at least one processor, the instructions implementing the method of any one of claims 1 to 7 when executed by the at least one processor.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 7.