Regional passenger flow prediction method, device and equipment based on dynamic and static mixed space constraint and emergency response
By constructing a hybrid dynamic and static spatial constraint matrix and introducing dynamic weighting parameters, combined with a multi-layer Transformer encoder, the problems of missing spatial constraint modeling and weak response to emergencies in regional passenger flow forecasting are solved, achieving more accurate passenger flow forecasting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU INTELLIGENCE COMM TECH CO LTD
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-14
AI Technical Summary
Existing regional passenger flow forecasting methods suffer from low accuracy due to a lack of spatial constraint modeling and weak response to emergencies.
By constructing a hybrid dynamic and static spatial constraint matrix, and combining the results of sudden event detection with dynamic weighting parameters and dynamic attention mask matrix, a multi-layer Transformer encoder is used for feature extraction to predict regional passenger flow.
It improves the accuracy of regional passenger flow forecasting, effectively integrates physical constraints and dynamic characteristics, and enhances the ability to respond to emergencies.
Smart Images

Figure CN121860133A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of regional passenger flow forecasting technology, and in particular to a method, apparatus and equipment for regional passenger flow forecasting based on dynamic and static mixed spatial constraints and emergency response. Background Technology
[0002] Regional passenger flow forecasting refers to predicting the passenger flow in a specified area over a certain period of time. It is a core topic in intelligent transportation and smart city management. In the field of artificial intelligence, this topic can be categorized as "multivariate time series forecasting," a branch of the field.
[0003] Traditional methods for regional passenger flow forecasting are mainly based on statistical models (such as ARIMA) and shallow machine learning (such as SVM). However, these traditional methods rely on linear assumptions and cannot handle nonlinear spatiotemporal relationships. Furthermore, feature engineering for the latter requires expert experience and human intervention. With the development of artificial intelligence and deep learning, hybrid deep learning models, such as Graph Neural Networks (CNNs) and Long Short-Term Memory Networks (LSTMs), have gradually become the mainstream method for time series forecasting. These models extract spatial features through convolutional layers and capture temporal dependencies using Recurrent Neural Networks (RNNs) or LSTMs. However, these RNN-based sequence models have several drawbacks: first, the serial nature of the model process prevents parallel processing of time-series data, resulting in low training efficiency; second, they are prone to numerical problems such as vanishing or exploding gradients when processing long sequences; and third, they are limited by regular spatial convolutional kernels and cannot adapt to the complex and varied road network topologies in real-world scenarios.
[0004] To address the aforementioned issues, existing technologies employ the Transformer architecture to construct models that enable parallel processing of time-series data. By using time series data as variable features as input, they achieve optimal performance in multivariate time series prediction tasks. However, the original model design has significant shortcomings: First, it lacks spatial constraint modeling. The model only implicitly learns the relationships between variables through a self-attention mechanism, failing to explicitly utilize geographical constraints such as road network distances. Second, it is weak in responding to sudden events. The model uses a standard attention mechanism, which cannot dynamically adjust the spatiotemporal correlation weights under sudden events. Other improved solutions, such as the Spatiotemporal Graph Neural Network (STGNN) (Yu et al., KDD 2020), although introducing graph neural networks, still do not solve the problem of modeling dynamic events. Therefore, there is currently a lack of a regional passenger flow prediction technology that considers both spatial constraints such as road network connectivity and the global impact of sudden events. Summary of the Invention
[0005] This application provides a method, apparatus, and equipment for predicting regional passenger flow based on a combination of dynamic and static spatial constraints and emergency response, which addresses the technical problem of low accuracy in existing regional passenger flow prediction methods due to factors such as the lack of spatial constraint modeling and weak emergency response.
[0006] To achieve the above objectives, this application provides the following technical solution:
[0007] On the one hand, a regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response is provided, including the following steps:
[0008] The system acquires the passenger flow prediction area and the emergency event detection results of the passenger flow prediction area, divides the passenger flow prediction area into grids, and obtains each grid and the number of grids; it acquires the road network GIS data of each grid, as well as the time steps and historical passenger flow data of each grid.
[0009] A matrix is constructed based on the time steps, the historical passenger flow data of each grid, and the number of grids to obtain the grid historical passenger flow input matrix; the road network GIS data of each grid is processed to obtain the road network distance matrix.
[0010] The historical passenger flow input matrix of the grid is processed by time feature encoding to obtain a spatiotemporal feature encoding matrix; the road network distance matrix is processed by spatial topology constraint to obtain a static adjacency matrix between each grid; the spatiotemporal feature encoding matrix is processed by dynamic adaptive constraint to obtain a dynamic adjacency matrix.
[0011] Based on the results of the sudden event detection, dynamic weighting parameters and dynamic attention mask matrix are determined; dynamic and static weighted fusion calculations are performed based on the dynamic weighting parameters, the static adjacency matrix, and the dynamic adjacency matrix to obtain a dynamic-static hybrid spatial constraint matrix;
[0012] The spatiotemporal feature encoding matrix is subjected to column vector extraction to obtain a first matrix and a second matrix; the attention weight matrix is calculated based on the dynamic-static hybrid spatial constraint matrix, the dynamic attention mask matrix, the first matrix, and the second matrix.
[0013] Based on the dynamic attention mask matrix and the attention weight matrix, a multi-layer Transformer encoder is used to extract features from the spatiotemporal feature encoding matrix to obtain a passenger flow feature matrix corresponding to the passenger flow feature representation vector of each grid.
[0014] Based on the passenger flow feature matrix, a feedforward neural network is used to predict the passenger flow in the next time interval of each grid, thereby obtaining a predicted passenger flow matrix corresponding to the area to be predicted.
[0015] Preferably, the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response further includes: obtaining passenger flow thresholds at different levels for each of the grids, and comparing the predicted passenger flow matrix with the passenger flow thresholds at different levels for the corresponding grids to obtain a predicted passenger flow risk matrix corresponding to the area to be predicted.
[0016] Preferably, determining the dynamic weighting parameters and dynamic attention mask matrix based on the incident detection results includes:
[0017] If the detection result of the sudden event indicates that there is a sudden event in the passenger flow prediction area, then the first value is used as the value of the dynamic weighting parameter, and the characteristic information of the sudden event is obtained. Based on the characteristic information and each of the grids, a dynamic attention mask matrix that changes over time is generated.
[0018] If the emergency event detection result indicates that there is no emergency event in the passenger flow prediction area, then the second value is used as the value of the dynamic weighting parameter, and the dynamic attention mask matrix is set to an identity matrix.
[0019] The second value is greater than the first value.
[0020] Preferably, the spatial topology constraint processing of the road network distance matrix to obtain the static adjacency matrix between each grid includes:
[0021] The connectivity between the grids is determined based on the road network GIS data of each grid, and the road network distance matrix is processed based on the connectivity between the grids to obtain a topology matrix;
[0022] The topological matrix is symmetricized to obtain a symmetric matrix; a self-loop matrix is calculated based on the symmetric matrix and the identity matrix; the self-loop matrix is processed using the diag function to obtain a metric matrix.
[0023] The self-loop matrix is normalized based on the metric matrix to obtain the static adjacency matrix.
[0024] Preferably, the spatiotemporal feature encoding matrix is subjected to dynamic adaptive constraint processing to obtain a dynamic adjacency matrix, including:
[0025] The spatiotemporal feature encoding matrix is subjected to joint feature processing to obtain a joint feature matrix;
[0026] A multilayer perceptron is used to reduce the dimensionality of the joint feature matrix to obtain a joint feature dimensionality-reduced matrix.
[0027] The joint feature dimensionality reduction matrix is subjected to Top-k sparsification and Softmax normalization in sequence to obtain the dynamic adjacency matrix.
[0028] Preferably, the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response further includes: calculating an attention weight matrix using an attention weight formula based on the dynamic and static hybrid spatial constraint matrix, the dynamic attention mask matrix, the first matrix, and the second matrix; the attention weight formula is:
[0029]
[0030] In the formula, Q is the first matrix, K is the second matrix, dK is the 0th dimension of the second matrix, and M... mask W is a dynamic attention mask matrix. hybrid Let A be the dynamic-static hybrid space constraint matrix. cons (t) is the attention weight matrix with time-dependent dynamic and static mixed spatial constraints, and T is the transpose of the matrix.
[0031] On the other hand, a regional passenger flow prediction device based on dynamic and static hybrid spatial constraints and emergency response is provided, including a data acquisition module, a matrix construction module, a matrix processing module, a matrix weighted fusion module, a matrix calculation module, a matrix feature extraction module, and a prediction module;
[0032] The data acquisition module is used to acquire the passenger flow prediction area and the emergency event detection results of the passenger flow prediction area, divide the passenger flow prediction area into grids to obtain each grid and the number of grids; acquire the road network GIS data of each grid, as well as acquire the time steps and the historical passenger flow data of each grid.
[0033] The matrix construction module is used to construct a matrix based on the time steps, the historical passenger flow data of each grid, and the number of grids to obtain a grid historical passenger flow input matrix; and to process the road network GIS data of each grid to obtain a road network distance matrix.
[0034] The matrix processing module is used to perform time feature encoding processing on the grid historical passenger flow input matrix to obtain a spatiotemporal feature encoding matrix; to perform spatial topology constraint processing on the road network distance matrix to obtain a static adjacency matrix between each grid; and to perform dynamic adaptive constraint processing on the spatiotemporal feature encoding matrix to obtain a dynamic adjacency matrix.
[0035] The matrix weighted fusion module is used to determine dynamic weighting parameters and dynamic attention mask matrix based on the sudden event detection results; and to perform dynamic and static weighted fusion calculation based on the dynamic weighting parameters, the static adjacency matrix, and the dynamic adjacency matrix to obtain a dynamic and static hybrid spatial constraint matrix.
[0036] The matrix calculation module is used to extract column vectors from the spatiotemporal feature encoding matrix to obtain a first matrix and a second matrix; and to calculate an attention weight matrix based on the dynamic-static hybrid spatial constraint matrix, the dynamic attention mask matrix, the first matrix, and the second matrix.
[0037] The matrix feature extraction module is used to extract features from the spatiotemporal feature encoding matrix using a multi-layer Transformer encoder based on the dynamic attention mask matrix and the attention weight matrix, to obtain a passenger flow feature matrix corresponding to the passenger flow feature representation vector of each grid.
[0038] The prediction module is used to predict the passenger flow in the next time interval of each grid using a feedforward neural network based on the passenger flow feature matrix, so as to obtain a predicted passenger flow matrix corresponding to the passenger flow prediction area.
[0039] Preferably, the matrix feature extraction module includes a first mask submodule and a second mask submodule;
[0040] The first mask submodule is used to take the first value as the value of the dynamic weighting parameter if a sudden event is detected in the waiting flow prediction area based on the sudden event detection result, and to obtain the characteristic information of the sudden event, and to generate a dynamic attention mask matrix that changes over time based on the characteristic information and each of the grids.
[0041] The second mask submodule is used to set the second value as the value of the dynamic weighting parameter if the emergency event detection result indicates that there is no emergency event in the passenger flow prediction area. The dynamic attention mask matrix is set as an identity matrix.
[0042] The second value is greater than the first value.
[0043] Preferably, the matrix processing module includes a static adjacency submodule and a dynamic adjacency submodule;
[0044] The static adjacency submodule is used to determine the connectivity between the grids based on the road network GIS data of each grid; process the road network distance matrix based on the connectivity between the grids to obtain a topology matrix; perform symmetry processing on the topology matrix to obtain a symmetric matrix; calculate a self-loop matrix based on the symmetric matrix and the identity matrix; process the self-loop matrix using the diag function to obtain a metric matrix; and normalize the self-loop matrix based on the metric matrix to obtain a static adjacency matrix.
[0045] The dynamic adjacency submodule is used to perform joint feature processing on the spatiotemporal feature encoding matrix to obtain a joint feature matrix; to perform dimensionality reduction processing on the joint feature matrix using a multilayer perceptron to obtain a joint feature dimensionality reduction matrix; and to perform Top-k sparsification and Softmax normalization processing on the joint feature dimensionality reduction matrix in sequence to obtain a dynamic adjacency matrix.
[0046] On the other hand, a terminal device is provided, including a processor and a memory;
[0047] The memory is used to store program code and transmit the program code to the processor;
[0048] The processor is used to execute the aforementioned regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response, according to the instructions in the program code.
[0049] This method, device, and equipment for predicting regional passenger flow based on dynamic and static hybrid spatial constraints and emergency response are applied to a micro-island microgrid combining pumped storage and photovoltaics. The island microgrid includes a DC bus and photovoltaic modules, pumped storage modules, DC output modules, and AC output modules connected to the DC bus. Both the DC and AC output modules are connected to the load. The method includes acquiring the passenger flow prediction area and the emergency detection results for that area; dividing the passenger flow prediction area into grids to obtain the individual grids and their number; acquiring road network GIS data for each grid, as well as the time steps and historical passenger flow data for each grid; constructing a matrix based on the time steps, historical passenger flow data, and grid number to obtain a grid historical passenger flow input matrix; processing the road network GIS data for each grid to obtain a road network distance matrix; performing time feature encoding on the grid historical passenger flow input matrix to obtain a spatiotemporal feature encoding matrix; and then performing time feature encoding on the road network GIS data for each grid. The distance matrix is processed with spatial topological constraints to obtain the static adjacency matrix between each grid. The spatiotemporal feature encoding matrix is processed with dynamic adaptive constraints to obtain the dynamic adjacency matrix. Dynamic weighting parameters and dynamic attention mask matrix are determined based on the results of sudden event detection. The dynamic and static weighted fusion calculation is performed based on the dynamic weighting parameters, static adjacency matrix, and dynamic adjacency matrix to obtain the dynamic and static hybrid spatial constraint matrix. Column vector extraction is performed on the spatiotemporal feature encoding matrix to obtain the first matrix and the second matrix. The attention weight matrix is calculated based on the dynamic and static hybrid spatial constraint matrix, dynamic attention mask matrix, first matrix, and second matrix. Based on the dynamic attention mask matrix and attention weight matrix, a multi-layer Transformer encoder is used to extract features from the spatiotemporal feature encoding matrix to obtain the passenger flow feature matrix corresponding to the passenger flow feature representation vector of each grid. Based on the passenger flow feature matrix, a feedforward neural network is used to predict the passenger flow of each grid in the next time interval to obtain the predicted passenger flow matrix corresponding to the area to be predicted.
[0050] As can be seen from the above technical solutions, this application has the following advantages: The regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response constructs a static adjacency matrix using road network GIS data, enabling the passenger flow feature matrix for predicting passenger flow to integrate physical constraints; based on the emergency detection results of the area to be predicted, dynamic weighting parameters and dynamic attention mask matrices are introduced. The dynamic weighting parameters balance the weighting between the static adjacency matrix and the dynamic adjacency matrix, allowing the passenger flow feature matrix for predicting passenger flow to retain the adaptability of dynamic features; by adopting a dynamic attention mask matrix, the passenger flow feature matrix for predicting passenger flow adds a response mechanism to emergency events. Through this passenger flow feature matrix, not only is passenger flow prediction for the area to be predicted achieved, but the accuracy of passenger flow prediction is also improved. This solves the technical problem of low passenger flow prediction accuracy caused by the lack of spatial constraint modeling and weak emergency response in existing regional passenger flow prediction methods.
[0051] This regional passenger flow prediction device, based on a hybrid dynamic and static spatial constraint and emergency response, constructs a static adjacency matrix through a data acquisition module, a matrix construction module, a matrix processing module, a matrix weighted fusion module, a matrix calculation module, a matrix feature extraction module, and a prediction module. This allows the passenger flow feature matrix for predicting passenger flow to incorporate physical constraints. Based on the emergency detection results of the area to be predicted, dynamic weighting parameters and a dynamic attention mask matrix are introduced. The dynamic weighting parameters balance the weighting between the static and dynamic adjacency matrices, ensuring that the passenger flow feature matrix for predicting passenger flow retains the adaptability of dynamic features. The use of a dynamic attention mask matrix adds a response mechanism to emergencies to the passenger flow feature matrix for predicting passenger flow. This passenger flow feature matrix not only enables passenger flow prediction for the area to be predicted but also improves the accuracy of passenger flow prediction. Attached Figure Description
[0052] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0053] Figure 1 This is a flowchart illustrating the steps of the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response described in the embodiments of this application.
[0054] Figure 2 This is a transformation diagram from the grid historical passenger flow input matrix to the spatiotemporal feature encoding matrix in the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response described in the embodiments of this application;
[0055] Figure 3 This is a diagram illustrating the overall architecture of the multi-layer Transformer coding model in the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response described in the embodiments of this application.
[0056] Figure 4 This is a diagram of the grid passenger flow prediction and risk level classification architecture of the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response as described in the embodiments of this application.
[0057] Figure 5 This is a diagram of the joint feature processing architecture of the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response described in the embodiments of this application;
[0058] Figure 6 This is a schematic diagram of the framework of the regional passenger flow prediction device based on dynamic and static hybrid spatial constraints and emergency response as described in the embodiments of this application;
[0059] Figure 7 This is a schematic diagram of the terminal device described in an embodiment of this application. Detailed Implementation
[0060] To make the inventive objectives, features, and advantages of this application more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0061] In the description of the embodiments of this application, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0062] In the embodiments of this application, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in the embodiments of this application according to the specific circumstances.
[0063] Patent terminology used in this application:
[0064] Time series forecasting / Multivariate time series forecasting: Time series forecasting is an important branch of artificial intelligence, divided into "univariate" and "multivariate" approaches. Univariate time series forecasting refers to the task of predicting the value of a single variable at one or more future time steps using historical observation data of a single variable (such as the number of visitors to an amusement park each day over the past year), employing statistical or machine learning methods. Multivariate time series forecasting refers to the task of jointly modeling multiple interrelated time series variables and predicting their future values. Unlike univariate time series forecasting, multivariate time series forecasting not only considers the historical changes of individual variables but also utilizes the dynamic correlations between variables to improve forecast accuracy.
[0065] Self-attention / multi-head attention mechanism is a mechanism that dynamically aggregates contextual information by calculating the relevance weights between all elements in a sequence. It can directly calculate the relevance between two elements regardless of their position in the sequence. Multi-head attention mechanism is an extension of self-attention mechanism, capturing features of the input data in different subspaces by running multiple attention head models in parallel.
[0066] The Transformer model is a deep learning model based on a self-attention mechanism. It abandons the convolutional or recursive operations of traditional CNNs or RNNs and captures the global (long-range) dependencies of the input sequence data through parallel computation. The core components of the Transformer model include input embedding, positional encoding, multi-head attention layer, feed-forward network, and residual connection.
[0067] Positional encoding refers to a technique used in the Transformer architecture to inject relative or absolute positional information of sequence elements (within the entire sequence) into the model.
[0068] Residual connections are a technique in deep learning used to mitigate the vanishing gradient problem and network degradation (where node weights become close to zero). The core idea of residual connections is to directly pass the input to subsequent layers, allowing the network to learn the difference between the input and output, rather than directly learning the output. This design significantly alleviates the vanishing gradient problem during the training of deep networks. This technique was first proposed by Kaiming He, a professor at MIT, and used for training the ResNet network; it has since been widely applied in various deep learning models.
[0069] Graph Neural Networks (GNNs) are deep learning models used to process graph-structured data. The core idea of GNNs is to iteratively aggregate the features of neighboring nodes to update the representation of the target node through a message-passing mechanism (aggregation functions, typically involving operations such as summing, averaging, and maximizing node features), thereby enabling the modeling and analysis of non-Euclidean spatial data. Graph-structured data is widely found in various real-world scenarios, including social network relationships, chemical molecular structures, and knowledge graphs. Common GNN model classifications include Graph Convolutional Networks (GCNs), Graph Attention Networks (GATs), Graph Sampling Networks (GraphSAGE), and Graph Isomorphic Networks (GINs).
[0070] Static spatial topology constraints refer to constraints that maintain a fixed relationship between spatial nodes (in graph-structured data). These constraints are usually defined by prior knowledge, such as physical connections and connectivity relationships in road networks.
[0071] Dynamic spatial topological constraints refer to constraints (in graph-structured data) that cause spatial node relationships to change over time or with data distribution, such as changes in temporary road weights due to traffic congestion.
[0072] Hybrid Spatial Topological Constraint refers to a spatial topological constraint obtained by fusing static and dynamic spatial topological constraints in a certain way.
[0073] Masked attention is a variant of the attention mechanism that introduces a mask matrix M. mask This is used to adjust the calculation of the attention weight matrix, thereby forcing the model to consider or ignore certain sequence elements (variables) at specific positions.
[0074] A Recurrent Neural Network (RNN) is a type of neural network specifically designed for processing time-series data (such as text and speech). A key characteristic of RNNs is their recurrent connections, which allow the network to retain historical information.
[0075] Long Short-Term Memory (LSTM) networks are a special type of Recurrent Neural Network (RNN). LSTMs control the flow and retention of information by introducing three gate structures (forget gate, input gate, and output gate). Compared to RNNs, they are better able to capture the dependencies between elements in long-term sequences, mitigating the vanishing or exploding gradient problems of RNNs. Like RNNs, LSTM networks operate sequentially (the output at time t depends on the output at time t-1).
[0076] A feedforward neural network (FNN) is one of the most basic artificial neural network structures. It consists of multiple layers of nodes, with each layer's nodes being fully connected, meaning that every node is connected to all nodes in the layer below it. A key characteristic of feedforward neural networks is that information can only flow in one direction: from the input layer to the hidden layer, and then to the output layer; it cannot flow in the reverse direction.
[0077] This application provides a method, apparatus, and device for predicting regional passenger flow based on a combination of dynamic and static spatial constraints and emergency response, which solves the technical problem that existing regional passenger flow prediction methods suffer from low accuracy due to factors such as the lack of spatial constraint modeling and weak emergency response.
[0078] Example 1:
[0079] Figure 1 This is a flowchart illustrating the steps of the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response described in the embodiments of this application.
[0080] like Figure 1 As shown in the figure, this application provides a regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response, including the following steps:
[0081] S1. Obtain the passenger flow prediction area and the emergency event detection results of the passenger flow prediction area, divide the passenger flow prediction area into grids, and obtain each grid and the number of grids; obtain the road network GIS data of each grid, as well as the time steps and historical passenger flow data of each grid.
[0082] It should be noted that step S1 involves three steps: first, the passenger flow prediction area and the detection results of sudden events in the passenger flow prediction area; second, dividing the passenger flow prediction area into grids to obtain each grid and the number of grids N; and third, obtaining the corresponding road network GIS data based on each grid, as well as obtaining the time steps and historical passenger flow data of each grid at time intervals, to provide data for subsequent steps. In this embodiment, sudden events generally refer to non-periodic events with a short duration (generally within 3-4 days), such as a celebrity concert, a fireworks display or other celebration during a holiday, or a peak in inbound and outbound traffic before or after a short holiday in the passenger flow prediction area. Road network GIS data refers to road network data in a Geographic Information System (GIS) used to describe the spatial distribution of road networks and the geometric shape of roads described by elements such as coordinate points, lines, and polygons. The time interval can be 10 minutes.
[0083] In this embodiment of the application, dividing the area to be predicted passenger flow into grids to obtain each grid and the number of grids N includes: dividing the area to be predicted passenger flow into a Geohash 6-level grid to obtain each grid and the number of grids N.
[0084] In this embodiment of the application, obtaining historical passenger flow data of each grid at time intervals includes: taking 10 minutes as the time interval (time slice), statistically analyzing the passenger flow data of each grid over a period of time (such as one year) at 10-minute intervals to obtain the historical passenger flow data of each grid.
[0085] S2. Construct a matrix based on the number of time steps, historical passenger flow data of each grid, and the number of grids to obtain the grid historical passenger flow input matrix; process the road network GIS data of each grid to obtain the road network distance matrix.
[0086] It should be noted that in step S2, the first step is to construct the grid historical passenger flow input matrix X∈R based on the time step T, the historical passenger flow data C of each grid, and the number of grids N obtained in step S1. N×T×C This provides data for subsequent steps. Secondly, based on the road network GIS data of each grid, the Haversine distances between N grids (e.g., between centers) are calculated, resulting in an N×N road network distance matrix D∈R. N×N In this embodiment, the Haversine distance between any two grid centers is calculated based on the road network GIS data of each grid as an approximation of the road network distance between grids. A total of N×N Haversine distances are calculated, resulting in a road network distance matrix D of shape N×N.
[0087] S3. Perform time feature encoding on the grid historical passenger flow input matrix to obtain the spatiotemporal feature encoding matrix; perform spatial topological constraint processing on the road network distance matrix to obtain the static adjacency matrix between each grid; perform dynamic adaptive constraint processing on the spatiotemporal feature encoding matrix to obtain the dynamic adjacency matrix.
[0088] It should be noted that in step S3, one aspect is to process the grid historical passenger flow input matrix X∈R obtained in step S2. N×T×C Perform temporal feature encoding processing to obtain the spatiotemporal feature encoding matrix E∈R N×D Secondly, the road network distance matrix D∈R obtained in step S2 is... N×N Spatial topology constraints are applied to obtain the static adjacency matrix W between each grid. static ∈R N×N Third, the spatiotemporal feature encoding matrix E∈R obtained in step S3 is then processed. N×D Dynamic adaptive constraint processing is performed to obtain the dynamic adjacency matrix W. dynamic ∈R N×N This provides data for subsequent steps. In this embodiment, the static adjacency matrix W static The computation actually uses a modified graph convolutional network (GCN), and the dynamic adjacency matrix W... dynamic The computation utilizes a modified graph neural network with a structure similar to the Graph Attention Network (GAT). Spatial topological constraints are embodied in the static adjacency matrix W. static ∈R N×N N is the number of nodes / number of variables. Dynamic adaptive constraints are embodied in the dynamic adjacency matrix W. dynamic ∈R N×N Dynamic adjacency matrix W dynamic It describes the implicit changes in inter-grid connectivity over time (e.g., the "implicit" (non-prior) changes in road weights due to congestion, temporary traffic control, or road construction).
[0089] Figure 2 This is a transformation diagram from the grid historical passenger flow input matrix to the spatiotemporal feature encoding matrix in the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response described in the embodiments of this application.
[0090] like Figure 2As shown in this embodiment, in the process of obtaining the spatiotemporal feature encoding matrix by performing time feature encoding on the grid historical passenger flow input matrix, in the prediction task of the passenger flow prediction area, the passenger flow size of each grid within a past period (e.g., one year) at each time interval (e.g., 10 minutes) is used as the unique feature of the grid. Therefore, the time step T = 6 * 24 * 365 = 52560, and C = 1 (one feature, i.e., grid passenger flow). Each grid is a variable, and then the time series of each grid is independently mapped to a token, i.e., the grid historical passenger flow input matrix X (e.g., N×T×C) is formed. Figure 2 The matrix on the left is transformed into a spatiotemporal feature encoding matrix E∈R with shape N×D (where D=T×C)2D. N×D (like Figure 2 (The matrix on the right).
[0091] It's important to note that a token refers to the basic unit of data processed by the model. A token is a time series of passenger flow data within a grid, collected at 10-minute intervals over the past 365 days (e.g.,...). Figure 2 (column vectors in the text)
[0092] S4. Determine the dynamic weighting parameters and dynamic attention mask matrix based on the results of the sudden event detection; perform dynamic and static weighted fusion calculation based on the dynamic weighting parameters, static adjacency matrix and dynamic adjacency matrix to obtain the dynamic and static hybrid spatial constraint matrix.
[0093] It should be noted that in step S4, the dynamic weighting parameters and dynamic attention mask matrix are first determined based on the sudden event detection results obtained in step S1, providing data for subsequent steps; then, based on the dynamic weighting parameters λ and the static adjacency matrix W... static ∈R N×N and the dynamic adjacency matrix W dynamic ∈R N×N The dynamic and static hybrid space constraint matrix W is obtained by performing a weighted fusion calculation using a weighted fusion formula. hybrid ∈R N×N The weighted fusion formula is: W hybrid =W static +λ×W dynamic .
[0094] S5. Extract column vectors from the spatiotemporal feature encoding matrix to obtain the first matrix and the second matrix; calculate the attention weight matrix based on the dynamic-static hybrid spatial constraint matrix, the dynamic attention mask matrix, the first matrix, and the second matrix.
[0095] It should be noted that in step S5, column vectors are first extracted from the spatiotemporal feature encoding matrix E obtained in step S3 to obtain the first matrix Q and the second matrix K. Then, the attention weight matrix is calculated using the attention weight formula based on the dynamic-static hybrid spatial constraint matrix, the dynamic attention mask matrix, the first matrix, and the second matrix. The attention weight formula is as follows:
[0096]
[0097] In the formula, Q is the first matrix, K is the second matrix, dK is the 0th dimension of the second matrix, and M... mask W is a dynamic attention mask matrix. hybrid Let A be the dynamic-static hybrid space constraint matrix. cons (t) is the attention weight matrix with time-dependent dynamic and static mixed spatial constraints, and T is the transpose of the matrix. This is the Hadamard product (i.e., the product of matrix elements). Where M is the dynamic attention mask matrix. mask ∈R N×1 It needs to be expanded to M first. mask ∈R N×N .
[0098] In this embodiment of the application, in the dynamic-static hybrid space constraint matrix W hybrid Instead of logarithmic addition, this regional passenger flow prediction method based on dynamic-static hybrid spatial constraints and emergency response, used as a bias term, also calculates the attention weight matrix using an updated attention weight formula based on the dynamic-static hybrid spatial constraint matrix, the dynamic attention mask matrix, the first matrix, and the second matrix. The updated attention weight formula is as follows:
[0099]
[0100] or
[0101]
[0102] In the formula, α is a hyperparameter that controls the strength of the topological constraints in the hybrid space.
[0103] Figure 3 This is a diagram illustrating the overall architecture of the multi-layer Transformer coding model in the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response described in this application embodiment.
[0104] In this embodiment of the application, the spatiotemporal coding feature matrix E is obtained through... Figure 3 The input embedding module (obtained after passing through a linear layer) yields the feature map matrix H∈R. N×D Then extract the column vector H of the feature map matrix H. i ∈R D×1(Where i = 0, 1, 2, ..., N-1, N), these column vectors are respectively used as the first matrix Q and the second matrix K.
[0105] S6. Based on the dynamic attention mask matrix and attention weight matrix, a multi-layer Transformer encoder is used to extract features from the spatiotemporal feature encoding matrix to obtain the passenger flow feature matrix corresponding to the passenger flow feature representation vector of each grid.
[0106] It should be noted that in step S6, an n-layer (default n=8) Transformer encoder is used, combined with a dynamic attention mask matrix M∈R N×1 Attention weight matrix A cons (t)∈R N×N The spatiotemporal feature encoding matrix E∈R of the input N×D Feature extraction is performed to generate a passenger flow feature matrix H, which is a passenger flow feature representation vector for each grid. out ∈R N×D In this embodiment, as Figure 3 As shown, the spatiotemporal feature encoding matrix E is based on N grids and T time points, and then passes through an input embedding module (such as...). Figure 3 Positional encoding is not mandatory and can be replaced by an all-zero matrix to obtain the feature matrix (embedding matrix) H∈R. N×D The feature matrix H is then transformed through a linear layer and input into an n-layer Transformer encoder. Finally, the output matrices of each attention head are concatenated to obtain a matrix of dimension R. N×D The feature matrix is then obtained. Next, the output matrix of the multi-head attention module is added to the feature matrix H through a residual connection to obtain a new feature matrix. This new feature matrix is then normalized and input into the feedforward neural network. Finally, the output matrix is added to the feature matrix H through a residual connection to obtain the final passenger flow feature matrix H. out The multi-head attention layer performs correlation analysis on the column vectors of the feature matrix from different dimensions. The feedforward neural network further integrates and refines information after the multi-head attention layer, enhancing the model's ability to capture more complex changing patterns of passenger flow in different grids. Residual connections are widely used in deep learning and multi-layer neural networks to avoid gradient vanishing and the loss of original input information. The feature matrix after the concatenation module in the Transformer encoder is shown. Each attention head is responsible for calculating the attention weights between column vectors of the input feature matrix H in a specific dimension. Finally, the concatenation yields an output matrix with the same dimensions as the original input feature matrix.
[0107] Figure 4 This is a diagram illustrating the grid-based passenger flow prediction and risk level classification architecture of the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response, as described in the embodiments of this application.
[0108] S7. Based on the passenger flow feature matrix, a feedforward neural network is used to predict the passenger flow in the next time interval of each grid, so as to obtain the predicted passenger flow matrix corresponding to the area to be predicted.
[0109] It should be noted that, as Figure 4 As shown, in step S7, the passenger flow feature matrix H of each input grid is processed based on the feedforward neural network FFN. out ∈R N×D The prediction is performed to obtain the predicted passenger flow matrix F∈R for each grid at the next time step. N×1 For example, based on the passenger flow size of each grid in each time interval over a past period, the passenger flow of each grid in the next time interval is predicted. Then, the passenger flow of each grid in the next time interval is used as the passenger flow size of each time interval over a past period and input into the feedforward neural network FFN (the time windows of all grids are shifted forward by a time interval), and so on. In other embodiments, this regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and sudden event response may also include predicting the passenger flow of each grid in the next time interval using any Transformer-based encoder that includes dynamic and static hybrid spatial constraints and a time-dependent attention mask sudden event response mechanism, based on the passenger flow feature matrix, to obtain a predicted passenger flow matrix corresponding to the area to be predicted.
[0110] In this embodiment, the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response achieves synergy between the static adjacency matrix and the dynamic adjacency matrix through the Hadamard product. Furthermore, it calculates the attention weight matrix by combining logarithmic addition with a dynamic attention mask matrix whose temporal and spatial influences both exhibit Gaussian decay. This attention weight matrix effectively coordinates and integrates the three constraints: static physical constraints, dynamic adaptive constraints, and emergency response based on time-dependent attention masks. The dynamic attention mask matrix containing dynamic and static hybrid spatial constraints enables this regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response to simultaneously adapt to regional passenger flow prediction and passenger flow risk level classification tasks under both "normal" and "emergency" scenarios: In the "normal" scenario, the dynamic adjacency matrix W... dynamic The dynamic attention mask matrix M, which replaces the time-dependent Gaussian decay, will be replaced. mask This provides a certain degree of dynamic adaptive constraint "fine-tuning" for passenger flow propagation between grids. In the scenario of "emergency events", by adjusting the dynamic weighting parameter λ of the mixed weight factor of dynamic and static constraints, the weight of the influence of dynamic graph adaptive constraints is reduced, and instead, mask-based attention calculation is adopted to achieve an efficient response to emergencies.
[0111] This application provides a regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response. The method includes acquiring the passenger flow prediction area and the emergency detection results of the prediction area; dividing the passenger flow prediction area into grids to obtain each grid and the number of grids; acquiring road network GIS data for each grid, as well as the time steps and historical passenger flow data for each grid; constructing a matrix based on the time steps, historical passenger flow data for each grid, and the number of grids to obtain a grid historical passenger flow input matrix; processing the road network GIS data for each grid to obtain a road network distance matrix; performing time feature encoding on the grid historical passenger flow input matrix to obtain a spatiotemporal feature encoding matrix; performing spatial topological constraint processing on the road network distance matrix to obtain a static adjacency matrix between each grid; and performing dynamic adaptive constraint processing on the spatiotemporal feature encoding matrix to obtain a dynamic adjacency matrix. The process involves: determining dynamic weighting parameters and a dynamic attention mask matrix based on the results of emergency event detection; performing dynamic and static weighted fusion calculations based on the dynamic weighting parameters, static adjacency matrix, and dynamic adjacency matrix to obtain a dynamic-static hybrid spatial constraint matrix; extracting column vectors from the spatiotemporal feature encoding matrix to obtain a first matrix and a second matrix; calculating the attention weight matrix based on the dynamic-static hybrid spatial constraint matrix, dynamic attention mask matrix, first matrix, and second matrix; extracting features from the spatiotemporal feature encoding matrix using a multi-layer Transformer encoder based on the dynamic attention mask matrix and attention weight matrix to obtain a passenger flow feature matrix corresponding to the passenger flow feature representation vectors of each grid; and using a feedforward neural network to predict the passenger flow of each grid in the next time interval based on the passenger flow feature matrix to obtain a predicted passenger flow matrix corresponding to the area to be predicted. This regional passenger flow prediction method, based on a hybrid dynamic and static spatial constraint and emergency response, constructs a static adjacency matrix using road network GIS data, enabling the passenger flow feature matrix for prediction to incorporate physical constraints. It introduces dynamic weighting parameters and a dynamic attention mask matrix based on emergency detection results in the area to be predicted. The dynamic weighting parameters balance the weighting between the static and dynamic adjacency matrices, allowing the passenger flow feature matrix to retain the adaptability of dynamic features. The use of a dynamic attention mask matrix adds a response mechanism to emergencies to the passenger flow feature matrix. This passenger flow feature matrix not only achieves passenger flow prediction for the area to be predicted but also improves the accuracy of passenger flow prediction. It solves the technical problem of low passenger flow prediction accuracy in existing regional passenger flow prediction methods due to factors such as the lack of spatial constraint modeling and weak emergency response.
[0112] It should be noted that this regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response improves data processing efficiency by performing parallel temporal processing during feature extraction of the spatiotemporal feature encoding matrix using a multi-layer Transformer encoder. Furthermore, this method constructs a dynamic adjacency matrix of dynamically adaptive constraints using the spatiotemporal feature encoding matrices of grid nodes, enabling global information interaction and adaptive modeling of spatial constraints.
[0113] In one embodiment of this application, the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response further includes: S8. obtaining passenger flow thresholds at different levels for each grid, and obtaining a predicted passenger flow risk matrix corresponding to the passenger flow prediction area by comparing the predicted passenger flow matrix with the passenger flow thresholds at different levels for the corresponding grid.
[0114] It should be noted that, as Figure 4 As shown, in step S8, the passenger flow feature matrix H of each input grid is processed based on the feedforward neural network FFN. out ∈R N×D Predictions are made to obtain the probability that the passenger flow in each grid is at the "high, medium, or low" risk level. The resulting passenger flow risk matrix is P∈R. N×3 (N is the number of grid cells), each row of the predicted passenger flow risk matrix P contains p elements. i =[p 高 p 中 p 低 ], where i = 0, 1, 2, ..., N-1, “p 高 p 中 p 低 The values (between 0 and 1) represent the probabilities (high, medium, and low) of passenger flow in each grid. The daily and annual passenger flow of each grid is different, therefore the passenger flow size corresponding to the "high, medium, and low" risk levels also varies. For example, a railway station in a first-tier city, as the grid for passenger flow prediction, can see a daily passenger flow of hundreds of thousands during peak periods, meaning even the "low-risk" level could correspond to tens or hundreds of thousands of passengers. However, a suburban bus station in a third- or fourth-tier city might only have a few hundred or tens of passengers per day, with the "high-risk" level potentially only having a few thousand. Therefore, the daily and annual passenger flow of each grid are combined to calculate the passenger flow threshold corresponding to different risk levels, and then the passenger flow size of each grid is labeled with the corresponding risk level. During the inference phase, the system can automatically predict the passenger flow size of each grid in the next time interval based on the passenger flow size of each grid in the past period, and then... Figure 4The feedforward neural network outputs the probability of passenger flow in each grid being at a "high," "medium," or "low" risk level (the label with the highest probability is the predicted passenger flow risk level label for that grid). In other embodiments, this regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response may further include using any Transformer-based encoder containing dynamic and static hybrid spatial constraints and a time-dependent attention mask emergency response mechanism to predict the passenger flow risk of each grid in the next time interval based on the passenger flow feature matrix, obtaining a predicted passenger flow risk matrix P∈R corresponding to the area to be predicted. N×3 .
[0115] In one embodiment of this application, determining the dynamic weighting parameters and dynamic attention mask matrix based on the sudden event detection results includes:
[0116] If the emergency event detection result indicates that there is an emergency event in the passenger flow prediction area, the first value is used as the value of the dynamic weighting parameter, and the characteristic information of the emergency event is obtained. Based on the characteristic information and each grid, a dynamic attention mask matrix that changes over time is generated.
[0117] If the emergency detection result indicates that there are no emergency events in the passenger flow prediction area, then the second value will be used as the value of the dynamic weighting parameter, and the dynamic attention mask matrix will be set to the identity matrix.
[0118] The second value is greater than the first value.
[0119] It should be noted that the second value can be 1, and the first value can be 0.3. When the detection result of a sudden event indicates that a sudden event exists, the weight of the dynamic graph adaptive constraint needs to be reduced during the calculation of the attention weight matrix, and instead, mask-based attention calculation is adopted. The characteristic information includes event type (event_type), event location (loc=[x,y]), influence radius (radius) (unit: km), event time (begintime, such as timestamp), and duration (max_duration), etc. The characteristic information can be represented by the vector event_fea, event_fe=[event_type, loc, radius, begintime, max_duration].
[0120] In the embodiments of this application, a dynamic attention mask matrix M that varies over time is generated based on characteristic information and each grid using a dynamic mask generation formula. mask The formula for generating a dynamic mask is:
[0121]
[0122] In the formula, D e 2(i) represents the distance (in km) from the i-th grid to the grid where the emergency occurs, R is the radius of influence of the emergency, and t start For the time of the incident, T duration The duration of the emergency is denoted as t, and the time t is the time at which passenger flow forecasting is performed.
[0123] In one embodiment of this application, spatial topological constraint processing is performed on the road network distance matrix to obtain the static adjacency matrix between each grid, including:
[0124] The connectivity between grids is determined based on the road network GIS data of each grid. The road network distance matrix is then processed based on the connectivity between grids to obtain the topology matrix.
[0125] The topological matrix is symmetricized to obtain a symmetric matrix; the self-loop matrix is calculated based on the symmetric matrix and the identity matrix; the self-loop matrix is processed using the diag function to obtain the metric matrix.
[0126] The static adjacency matrix is obtained by normalizing the self-loop matrix based on the metric matrix.
[0127] It should be noted that, in obtaining the topological matrix W enhanced In the process, first, based on the topological connectivity matrix W connect The value of W is determined by judging the connectivity between N grid roads based on the open-source road network GIS data from OpenStreetMap. W is defined as follows: W is defined as the value of W when there is at least one road connecting grid i to grid j. connect [i, j] = 1; otherwise W connect [i, j] = 0, at which point the road network distance matrix D[i, j] = 1.0E + 19). Based on the topological connectivity matrix W... connect The topological matrix W is obtained by using the first calculation formula. enhanced The matrix elements D[i, j] of the road network distance matrix D represent the Haversine distance (in km) between grid i and grid j, where i and j take values of 1, 2, ..., N. The Haversine distance is the shortest distance between two grids (e.g., between two points on the surface of a sphere). If all elements on the diagonal of the road network distance matrix D are "0" (representing that the grid is connected to itself), the first calculation formula is:
[0128]
[0129] In the formula, D[i,j] is the Haversine distance between grid i and grid j, σ is the distance decay coefficient (default value is 1.0, unit is km). exp(x) represents the natural exponential function.
[0130] In this embodiment, the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response further includes: calculating a symmetric matrix using a symmetric formula based on the topological matrix; calculating a self-loop matrix using a self-loop formula based on the symmetric matrix and the identity matrix; and calculating a static adjacency matrix using a matrix normalization formula based on the metric matrix. The symmetric formula is:
[0131]
[0132] The self-loop formula is: W self =W sys +I N×N ;
[0133] The expression for the diag function is:
[0134]
[0135] The matrix normalization formula is:
[0136]
[0137] In the formula, W sys W is a symmetric matrix. enhanced Let I be a topological matrix. N×N W is an N×N identity matrix. self It is a self-loop matrix. W is the metric matrix. static This is a static adjacency matrix. In this embodiment, when the road network connectivity is not symmetric (i.e., grid A is connected to grid B through one-way road L, but this does not mean that grid B is connected to grid A, because road L is a one-way road), the symmetry processing in the symmetry formula needs to be ignored.
[0138] In this embodiment, the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response can also be constructed based on a static neighbor matrix of regional functional similarity or complementarity. For example, based on regional functional semantic POI information, forced or similar connections are made between functionally complementary regions, such as the smaller "D[residential area, subway station]" from a residential area to a subway station compared to other areas. Based on statistical connections and static neighbor matrix generation using historical passenger flow patterns, the transfer probability between regions or grids in historical passenger flow is used as a weight D[i,j]). The topology generation method based on administrative planning refers to hard-coding connections based on urban planning documents such as maps, bus hub connections, etc., to generate a static neighbor matrix W. staticIn a GIS (Geographic Information System), a Point of Interest (POI) is a data unit used to mark specific locations, representing entities such as buildings, shops, and bus stops. It is one of the basic geospatial data types. Each POI contains basic data such as name, category, coordinates, address, opening hours, and contact information. Its classification system adopts a first-level and second-level category structure.
[0139] Figure 5 This is a diagram of the joint feature processing architecture of the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response described in the embodiments of this application.
[0140] In one embodiment of this application, the spatiotemporal feature encoding matrix is subjected to dynamic adaptive constraint processing to obtain a dynamic adjacency matrix, including:
[0141] Joint feature processing is performed on the spatiotemporal feature coding matrix to obtain the joint feature matrix;
[0142] A multilayer perceptron is used to reduce the dimensionality of the joint feature matrix, resulting in a dimensionality-reduced joint feature matrix.
[0143] The joint feature dimensionality reduction matrix is subjected to Top-k sparsification and Softmax normalization in sequence to obtain the dynamic adjacency matrix.
[0144] It should be noted that, as Figure 5 As shown, for a given node (e.g., a node represents a grid), the embedding matrix H∈R N×D (e.g., spatiotemporal coding feature matrix E∈R) N×D ), calculate the joint feature matrix pair features ∈ R of shape N×N×2D for all node pairs. N×N×2D This can be understood as concatenating the array vectors of the spatiotemporal encoded feature matrix E to obtain the joint feature matrix pair features∈R. N×N×2D Then, it is dimensionality reduced to R using a multilayer perceptron (MLP). N×N Next, the joint feature matrix (pair features) after dimensionality reduction by the multilayer perceptron (MLP) model is subjected to Top-k sparsification (i.e., all elements of the matrix are sorted from largest to smallest, the first k elements are retained, the value of the kth element is set as the threshold, and all subsequent elements less than the threshold are set to 0). Then, the elements of the sparsified matrix are subjected to Softmax normalization, finally obtaining the dynamic adjacency matrix W used to represent the dynamic adaptive constraints. dynamic ∈R N×N In this embodiment, the perceptron includes: a 2D→D linear layer, a ReLU layer, a D→ (reducing from D dimensions to 1 dimension) linear layer, and finally a softmax layer for output.
[0145] In the embodiments of this application, the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response further includes node feature clustering based on clustering algorithms such as K-Means in machine learning. Nodes within the same cluster are replaced by dynamically generated edges using fully connected connections instead of the dynamic adjacency matrix W based on node similarity calculation in graph neural networks. dynamic Construct; or generate a dynamic adjacency matrix W based on a dynamic graph of random walks. dynamic Or any automatically generated dynamic adjacency matrix W based on node feature similarity. dynamic .
[0146] In one embodiment of this application, the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response uses a multi-layer Transformer encoder as the model architecture. On the basis of the original attention, it introduces the synergy of static physical constraints and data-driven dynamic graph adaptive constraints and the time-dependent response mechanism for emergencies, resulting in a Transformer bi-branch model with dual attention correction represented by a passenger flow feature matrix. This model can efficiently and accurately predict passenger flow in each grid of the area to be predicted.
[0147] Example 2:
[0148] Figure 6 This is a schematic diagram of the framework of the regional passenger flow prediction device based on dynamic and static hybrid spatial constraints and emergency response as described in the embodiments of this application.
[0149] like Figure 6 As shown, this application embodiment provides a regional passenger flow prediction device based on dynamic and static hybrid spatial constraints and emergency response, including a data acquisition module 10, a matrix construction module 20, a matrix processing module 30, a matrix weighted fusion module 40, a matrix calculation module 50, a matrix feature extraction module 60, and a prediction module 70;
[0150] The data acquisition module 10 is used to acquire the passenger flow prediction area and the detection results of sudden events in the passenger flow prediction area, divide the passenger flow prediction area into grids to obtain each grid and the number of grids; acquire the road network GIS data of each grid, as well as the time steps and historical passenger flow data of each grid.
[0151] The matrix construction module 20 is used to construct a matrix based on the time step, the historical passenger flow data of each grid, and the number of grids to obtain the grid historical passenger flow input matrix; and to process the road network GIS data of each grid to obtain the road network distance matrix.
[0152] The matrix processing module 30 is used to perform time feature encoding processing on the grid historical passenger flow input matrix to obtain a spatiotemporal feature encoding matrix; to perform spatial topological constraint processing on the road network distance matrix to obtain a static adjacency matrix between each grid; and to perform dynamic adaptive constraint processing on the spatiotemporal feature encoding matrix to obtain a dynamic adjacency matrix.
[0153] The matrix weighted fusion module 40 is used to determine the dynamic weighting parameters and dynamic attention mask matrix based on the sudden event detection results; and to perform dynamic and static weighted fusion calculation based on the dynamic weighting parameters, static adjacency matrix and dynamic adjacency matrix to obtain the dynamic and static hybrid space constraint matrix.
[0154] The matrix calculation module 50 is used to extract column vectors from the spatiotemporal feature encoding matrix to obtain the first matrix and the second matrix; and to calculate the attention weight matrix based on the dynamic-static hybrid spatial constraint matrix, the dynamic attention mask matrix, the first matrix and the second matrix.
[0155] The matrix feature extraction module 60 is used to extract features from the spatiotemporal feature encoding matrix using a multi-layer Transformer encoder based on the dynamic attention mask matrix and attention weight matrix, so as to obtain the passenger flow feature matrix corresponding to the passenger flow feature representation vector of each grid.
[0156] The prediction module 70 is used to predict the passenger flow of each grid in the next time interval based on the passenger flow feature matrix using a feedforward neural network, so as to obtain the predicted passenger flow matrix corresponding to the area to be predicted.
[0157] It should be noted that the content of the modules in the device of Embodiment 2 has been described in the steps of the method of Embodiment 1. Therefore, the content of the regional passenger flow prediction device module based on dynamic and static hybrid spatial constraints and emergency response will not be repeated in this embodiment. In this embodiment, the regional passenger flow prediction device based on dynamic and static hybrid spatial constraints and emergency response constructs a static adjacency matrix through a data acquisition module, a matrix construction module, a matrix processing module, a matrix weighted fusion module, a matrix calculation module, a matrix feature extraction module, and a prediction module. This allows the passenger flow feature matrix for predicting passenger flow to incorporate physical constraints. Based on the emergency event detection results of the area to be predicted, dynamic weighting parameters and a dynamic attention mask matrix are introduced. The dynamic weighting parameters balance the weighting between the static adjacency matrix and the dynamic adjacency matrix, allowing the passenger flow feature matrix for predicting passenger flow to retain the adaptability of dynamic features. The use of a dynamic attention mask matrix adds a response mechanism to emergency events to the passenger flow feature matrix for predicting passenger flow. This passenger flow feature matrix not only achieves passenger flow prediction for the area to be predicted but also improves the accuracy of passenger flow prediction.
[0158] In this embodiment of the application, the matrix weighted fusion module 40 includes a first mask submodule and a second mask submodule;
[0159] The first mask submodule is used to determine if there is a sudden event in the passenger flow prediction area based on the sudden event detection results. If so, the first value is used as the value of the dynamic weighting parameter, and the characteristic information of the sudden event is obtained. Based on the characteristic information and each grid, a dynamic attention mask matrix that changes over time is generated.
[0160] The second mask submodule is used to set the second value as the value of the dynamic weighting parameter if the emergency event detection result indicates that there is no emergency event in the passenger flow prediction area, and the dynamic attention mask matrix is set to the identity matrix.
[0161] The second value is greater than the first value.
[0162] In this embodiment, the matrix processing module 30 includes a static adjacency submodule and a dynamic adjacency submodule;
[0163] The static adjacency submodule is used to determine the connectivity between grids based on the road network GIS data of each grid, process the road network distance matrix based on the connectivity between grids to obtain the topology matrix, perform symmetry processing on the topology matrix to obtain the symmetric matrix, calculate the self-loop matrix based on the symmetric matrix and the identity matrix, process the self-loop matrix using the diag function to obtain the metric matrix, and normalize the self-loop matrix based on the metric matrix to obtain the static adjacency matrix.
[0164] The dynamic adjacency submodule is used to perform joint feature processing on the spatiotemporal feature encoding matrix to obtain a joint feature matrix; a multilayer perceptron is used to perform dimensionality reduction processing on the joint feature matrix to obtain a joint feature dimensionality reduction matrix; the joint feature dimensionality reduction matrix is then subjected to Top-k sparsification and Softmax normalization processing to obtain a dynamic adjacency matrix.
[0165] Example 3:
[0166] Figure 7 This is a schematic diagram of the terminal device described in an embodiment of this application.
[0167] like Figure 7 As shown, this application provides a terminal device, including a processor and a memory;
[0168] Memory is used to store program code and transfer the program code to the processor;
[0169] The processor is used to execute the aforementioned regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response, according to the instructions in the program code.
[0170] It should be noted that the processor is used to execute the steps in the above-described embodiment of a regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency event response, according to the instructions in the program code. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the above-described system / device embodiments.
[0171] For example, a computer program can be divided into one or more modules / units, one or more of which are stored in memory and executed by a processor to complete this application. One or more modules / units can be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in a terminal device.
[0172] Terminal devices can be computing devices such as desktop computers, laptops, handheld computers, and cloud servers. Terminal devices may include, but are not limited to, processors and memory. Those skilled in the art will understand that this does not constitute a limitation on the terminal device, which may include more or fewer components than illustrated, or combinations of certain components, or different components. For example, a terminal device may also include input / output devices, network access devices, buses, etc.
[0173] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0174] Memory can be an internal storage unit of a terminal device, such as a hard drive or RAM. Memory can also be an external storage device, such as a plug-in hard drive, SmartMedia Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, memory can include both internal and external storage units. Memory is used to store computer programs and other programs and data required by the terminal device. Memory can also be used to temporarily store data that has been output or will be output.
[0175] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0176] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0177] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0178] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0179] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0180] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A regional passenger flow forecasting method based on dynamic and static hybrid spatial constraints and emergency event response, characterized in that, Includes the following steps: The system acquires the passenger flow prediction area and the emergency event detection results of the passenger flow prediction area, divides the passenger flow prediction area into grids, and obtains each grid and the number of grids; it acquires the road network GIS data of each grid, as well as the time steps and historical passenger flow data of each grid. A matrix is constructed based on the time steps, the historical passenger flow data of each grid, and the number of grids to obtain the grid historical passenger flow input matrix; the road network GIS data of each grid is processed to obtain the road network distance matrix. The historical passenger flow input matrix of the grid is subjected to time feature encoding processing to obtain a spatiotemporal feature encoding matrix; Spatial topology constraints are applied to the road network distance matrix to obtain the static adjacency matrix between each grid. The spatiotemporal feature encoding matrix is subjected to dynamic adaptive constraint processing to obtain a dynamic adjacency matrix; Based on the results of the emergency event detection, determine the dynamic weighting parameters and the dynamic attention mask matrix; Based on the dynamic weighting parameters, the static adjacency matrix, and the dynamic adjacency matrix, a dynamic-static weighted fusion calculation is performed to obtain a dynamic-static hybrid spatial constraint matrix; Column vectors are extracted from the spatiotemporal feature encoding matrix to obtain a first matrix and a second matrix; The attention weight matrix is calculated based on the dynamic-static hybrid space constraint matrix, the dynamic attention mask matrix, the first matrix, and the second matrix. Based on the dynamic attention mask matrix and the attention weight matrix, a multi-layer Transformer encoder is used to extract features from the spatiotemporal feature encoding matrix to obtain a passenger flow feature matrix corresponding to the passenger flow feature representation vector of each grid. Based on the passenger flow feature matrix, a feedforward neural network is used to predict the passenger flow in the next time interval of each grid, thereby obtaining a predicted passenger flow matrix corresponding to the area to be predicted.
2. The regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response as described in claim 1, characterized in that, Also includes: Obtain the passenger flow thresholds for different levels of each grid, and compare the predicted passenger flow matrix with the passenger flow thresholds for different levels of the corresponding grid to obtain the predicted passenger flow risk matrix corresponding to the passenger flow prediction area.
3. The regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response as described in claim 1 or 2, characterized in that, Determining the dynamic weighting parameters and dynamic attention mask matrix based on the incident detection results includes: If the detection result of the sudden event indicates that there is a sudden event in the passenger flow prediction area, then the first value is used as the value of the dynamic weighting parameter, and the characteristic information of the sudden event is obtained. Based on the characteristic information and each of the grids, a dynamic attention mask matrix that changes over time is generated. If the emergency event detection result indicates that there is no emergency event in the passenger flow prediction area, then the second value is used as the value of the dynamic weighting parameter, and the dynamic attention mask matrix is set to an identity matrix. The second value is greater than the first value.
4. The regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response as described in claim 1 or 2, characterized in that, Spatial topology constraints are applied to the road network distance matrix to obtain the static adjacency matrix between each grid, including: The connectivity between the grids is determined based on the road network GIS data of each grid, and the road network distance matrix is processed based on the connectivity between the grids to obtain a topology matrix; The topological matrix is symmetricized to obtain a symmetric matrix; a self-loop matrix is calculated based on the symmetric matrix and the identity matrix; the self-loop matrix is processed using the diag function to obtain a metric matrix. The self-loop matrix is normalized based on the metric matrix to obtain the static adjacency matrix.
5. The regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response as described in claim 1 or 2, characterized in that, The spatiotemporal feature encoding matrix is subjected to dynamic adaptive constraint processing to obtain a dynamic adjacency matrix, which includes: The spatiotemporal feature encoding matrix is subjected to joint feature processing to obtain a joint feature matrix; A multilayer perceptron is used to reduce the dimensionality of the joint feature matrix to obtain a joint feature dimensionality-reduced matrix. The joint feature dimensionality reduction matrix is subjected to Top-k sparsification and Softmax normalization in sequence to obtain the dynamic adjacency matrix.
6. The regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response as described in claim 1 or 2, characterized in that, Also includes: The attention weight matrix is obtained by using the attention weight formula based on the dynamic-static hybrid space constraint matrix, the dynamic attention mask matrix, the first matrix, and the second matrix. The attention weight formula is as follows: In the formula, Q is the first matrix, K is the second matrix, dK is the 0th dimension of the second matrix, and M... mask W is a dynamic attention mask matrix. hybrid Let A be the dynamic-static hybrid space constraint matrix. cons (t) is the attention weight matrix with time-dependent dynamic and static mixed spatial constraints, and T is the transpose of the matrix.
7. A regional passenger flow prediction device based on dynamic and static hybrid spatial constraints and emergency response, characterized in that, include: The system includes a data acquisition module, a matrix construction module, a matrix processing module, a matrix weighted fusion module, a matrix calculation module, a matrix feature extraction module, and a prediction module. The data acquisition module is used to acquire the passenger flow prediction area and the emergency event detection results of the passenger flow prediction area, divide the passenger flow prediction area into grids to obtain each grid and the number of grids; acquire the road network GIS data of each grid, as well as acquire the time steps and the historical passenger flow data of each grid. The matrix construction module is used to construct a matrix based on the time steps, the historical passenger flow data of each grid, and the number of grids to obtain a grid historical passenger flow input matrix; and to process the road network GIS data of each grid to obtain a road network distance matrix. The matrix processing module is used to perform time feature encoding processing on the grid historical passenger flow input matrix to obtain a spatiotemporal feature encoding matrix; Spatial topology constraints are applied to the road network distance matrix to obtain the static adjacency matrix between each grid. The spatiotemporal feature encoding matrix is subjected to dynamic adaptive constraint processing to obtain a dynamic adjacency matrix; The matrix weighted fusion module is used to determine dynamic weighting parameters and dynamic attention mask matrix based on the sudden event detection results; Based on the dynamic weighting parameters, the static adjacency matrix, and the dynamic adjacency matrix, a dynamic-static weighted fusion calculation is performed to obtain a dynamic-static hybrid spatial constraint matrix; The matrix calculation module is used to extract column vectors from the spatiotemporal feature encoding matrix to obtain a first matrix and a second matrix; The attention weight matrix is calculated based on the dynamic-static hybrid space constraint matrix, the dynamic attention mask matrix, the first matrix, and the second matrix. The matrix feature extraction module is used to extract features from the spatiotemporal feature encoding matrix using a multi-layer Transformer encoder based on the dynamic attention mask matrix and the attention weight matrix, to obtain a passenger flow feature matrix corresponding to the passenger flow feature representation vector of each grid. The prediction module is used to predict the passenger flow in the next time interval of each grid using a feedforward neural network based on the passenger flow feature matrix, so as to obtain a predicted passenger flow matrix corresponding to the passenger flow prediction area.
8. The regional passenger flow prediction device based on dynamic and static hybrid spatial constraints and emergency response as described in claim 7, characterized in that, The matrix weighted fusion module includes a first mask submodule and a second mask submodule; The first mask submodule is used to take the first value as the value of the dynamic weighting parameter if a sudden event is detected in the waiting flow prediction area based on the sudden event detection result, and to obtain the characteristic information of the sudden event, and to generate a dynamic attention mask matrix that changes over time based on the characteristic information and each of the grids. The second mask submodule is used to set the second value as the value of the dynamic weighting parameter if the emergency event detection result indicates that there is no emergency event in the passenger flow prediction area. The dynamic attention mask matrix is set as an identity matrix. The second value is greater than the first value.
9. The regional passenger flow prediction device based on dynamic and static hybrid spatial constraints and emergency response as described in claim 7, characterized in that, The matrix processing module includes a static adjacency submodule and a dynamic adjacency submodule; The static adjacency submodule is used to determine the connectivity between each grid based on the road network GIS data of each grid, and to process the road network distance matrix based on the connectivity between each grid to obtain a topology matrix; The topological matrix is symmetricized to obtain a symmetric matrix; The self-loop matrix is calculated based on the symmetric matrix and the identity matrix. The self-loop matrix is processed using the diag function to obtain the metric matrix; The self-loop matrix is normalized according to the metric matrix to obtain the static adjacency matrix; The dynamic adjacency submodule is used to perform joint feature processing on the spatiotemporal feature encoding matrix to obtain a joint feature matrix; A multilayer perceptron is used to reduce the dimensionality of the joint feature matrix to obtain a joint feature dimensionality-reduced matrix; the joint feature dimensionality-reduced matrix is then subjected to Top-k sparsification and Softmax normalization to obtain a dynamic adjacency matrix.
10. A terminal device, characterized in that, Including the processor and memory; The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the regional passenger flow prediction method based on dynamic and static hybrid spatial constraints and emergency response as described in any one of claims 1-6, according to the instructions in the program code.