Subway passenger flow prediction method and equipment based on multi-scale space-time diagram attention network

By building an OD-level urban rail transit knowledge graph and a multi-scale spatio-temporal map attention network, the problems of strong data spativity and spatio-temporal dynamics in subway passenger flow prediction are solved, and higher-precision passenger flow prediction and operational scheduling optimization are achieved.

CN119494442AActive Publication Date: 2025-02-21SHANGHAI UNIV OF ENG SCI

Patent Information

Application Number
CN202411543931.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-02-21
Estimated Expiration
2044-10-31

AI Technical Summary

Technical Problem

The existing technology is difficult to effectively predict subway passenger flow, especially in OD-level predictions, which face the problems of data sparsity and strong spatial and temporal dynamics, resulting in low prediction accuracy.

Method used

By adopting the subway passenger flow prediction method based on multi-scale spatiotemporal graph attention network, the complex spatiotemporal relationship between OD pairs is captured and the long-term and short-term passenger flow dynamics are modeled. .

Benefits of technology

It significantly improves the accuracy of subway passenger flow prediction, can more accurately identify passengers' travel routes and flow trends between stations, provides more targeted scheduling optimization solutions, and improves the operation efficiency of the subway system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119494442A_ABST
    Figure CN119494442A_ABST
Patent Text Reader

Abstract

The invention relates to a subway passenger flow prediction method and device based on a multi-scale space-time diagram attention network. The method comprises the steps of collecting passenger flow data of subway OD pairs, subway line network structure data and land use type data; constructing an OD-level urban rail transit knowledge graph based on the collected data, and calculating node features of the knowledge graph, including calculating historical passenger flow features, calculating land use information, calculating accessibility of OD pairs and calculating correlation of the OD pairs; inputting node features of the knowledge graph into a multi-scale space-time diagram attention network, performing diagram filtering on the node features, and updating the node features of the knowledge graph in combination with a result of a space-time attention mechanism; and inputting the updated node features into the multi-scale LSTM model, and outputting a multi-scale prediction result of the subway passenger flow. Compared with the prior art, the method has the advantages of being more accurate in prediction, beneficial to intelligent scheduling and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of urban subway passenger flow prediction and management, and in particular to a subway passenger flow prediction method and device based on a multi-scale spatiotemporal graph attention network. Background Art

[0002] With the rapid advancement of urbanization, the subway system has become one of the indispensable public transportation modes in modern metropolises. The subway system has played a key role in alleviating urban traffic congestion, improving travel efficiency, and reducing carbon emissions. However, the subway system faces a series of complex challenges in operation and management. Especially in the context of a substantial increase in passenger flow, how to accurately predict subway passenger flow, optimize resource scheduling, and improve passenger experience has become a problem that needs to be solved urgently. At present, the passenger flow prediction methods of subway systems mainly rely on traditional time series models (such as the autoregressive integrated moving average model ARIMA) and regression analysis models. These models are based on historical passenger flow data and can capture short-term fluctuations and trends in passenger flow. However, the main limitation of these traditional models is that they are difficult to handle the inherent nonlinearity and complex spatiotemporal dependencies in subway passenger flow data. There is a significant spatial correlation between passenger flow at different subway stations, and it is also affected by many external factors, such as weather, holidays, and emergencies, which makes passenger flow prediction in subway systems a highly dynamic and complex problem. In particular, for the travel OD (Origin-Destination) data between stations, the accuracy of its prediction is crucial to the scheduling optimization of the subway system.

[0003] With the development of deep learning technology, especially the application of graph neural network (GNN), researchers have gradually introduced these technologies into the field of subway passenger flow prediction. Deep learning models, such as long short-term memory network (LSTM) and graph convolutional network (GCN), have shown strong capabilities in modeling complex spatiotemporal dependencies. Graph neural network can effectively capture the spatial associations between different stations in the subway network, while recursive neural networks such as LSTM can better handle the long-term dependency problems in time series data. Although these models have achieved good results in station-level passenger flow prediction, most existing studies focus on station-level flow prediction and ignore the fine-grained analysis of OD pairs. In contrast, OD-level prediction can not only provide more sophisticated travel mode analysis, but also more accurately identify passengers' travel routes and flow trends between stations, thereby providing operators with more targeted scheduling optimization solutions.

[0004] However, passenger flow prediction at the OD level faces more complex challenges. First, the number of OD pairs increases exponentially with the increase in the number of subway stations, resulting in a huge amount of data and a significant increase in computational complexity. Second, the passenger flow data of OD pairs is highly sparse, and many OD pairs have almost no passenger flow during non-peak hours, which makes it difficult for the model to effectively learn the flow pattern under sparse data. In addition, the temporal volatility of OD passenger flow data is extremely strong, especially between weekdays and weekends, holidays, and different time periods, the passenger flow change trend is more significant. This dynamic and unpredictable fluctuation increases the requirements for passenger flow prediction models. In response to these problems, existing traditional methods such as multivariate regression models or simple time series models have been unable to cope with the complexity of subway passenger flow. Therefore, there is an urgent need for a new method that can handle large-scale, high-dimensional sparse data and effectively capture spatiotemporal dynamic changes to improve the accuracy of subway passenger flow prediction and optimize subway operation scheduling.

[0005] After searching, China Invention Patent Publication No. CN117592602A discloses a subway passenger flow prediction method and system based on spatiotemporal graph ordinary differential equations, the method includes the following steps: collecting and processing original subway AFC historical data, using geographic topology information and original historical passenger flow data to construct a set of subway network spatiotemporal relationship graphs; using the processed historical passenger flow and graph group as model input; establishing a new subway passenger flow prediction network, in each spatiotemporal layer, using two temporal self-attention modules and temporal convolution modules to obtain dynamic multi-scale time dependencies between nodes, using tensor-based ordinary differential equations to capture spatial dependencies, and feeding the hidden state obtained in each spatiotemporal layer to the output layer through jump connections to predict subway passenger flow at future moments. This existing patent has the problem of insufficient prediction accuracy.

[0006] How to improve the accuracy of subway passenger flow prediction by integrating knowledge graph and multi-scale spatiotemporal graph attention network model has become a technical problem that needs to be solved. Summary of the invention

[0007] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and to provide a subway passenger flow prediction method and device based on a multi-scale spatiotemporal graph attention network.

[0008] The purpose of the present invention can be achieved by the following technical solutions:

[0009] According to one aspect of the present invention, a subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network is provided, the method comprising the following steps:

[0010] Step S1, collecting the passenger flow data of subway OD pairs, subway network structure data and land use type data;

[0011] Step S2, constructing an OD-level urban rail transit knowledge graph based on the data in step S1, and calculating node features of the knowledge graph, including calculating historical passenger flow features, calculating land use information, calculating the accessibility of OD pairs, and calculating the correlation of OD pairs;

[0012] Step S3, inputting the node features of the knowledge graph in step S2 into a multi-scale spatiotemporal graph attention network, first performing graph filtering on the node features, and then updating the node features of the knowledge graph in combination with the results output by the spatiotemporal graph attention mechanism model, wherein the network includes a graph filtering model, a spatiotemporal graph attention mechanism model, and a multi-scale LSTM model connected in sequence;

[0013] Step S4, input the updated node features into the multi-scale LSTM model, and output the multi-scale prediction results of subway passenger flow.

[0014] Preferably, the calculating of historical passenger flow characteristics comprises calculating historical statistical indicators of each OD pair, wherein the historical statistical indicators comprise passenger flow mean and standard deviation in a specific time period, and passenger flow in peak and non-peak periods, wherein the specific time period comprises weekday peak, weekday non-peak, weekend peak and weekend non-peak;

[0015] The calculation of land use information is to calculate the ratio of different types of points of interest around the starting station and the terminal station for each OD;

[0016] The calculation of the reachability of the OD pair includes: calculating the shortest path distance and the number of feasible paths for each OD pair;

[0017] The calculation of OD pair correlation includes: calculating the nonlinear correlation of historical passenger flow sequences through a kernel canonical correlation analysis method, constructing relationship edges of OD pairs based on a correlation threshold, and then constructing edge features of a knowledge graph.

[0018] Preferably, the graph filtering model is used to extract knowledge graph features, and the spatiotemporal graph attention mechanism model is used to capture the passenger flow correlation between OD pairs and model the long-term and short-term passenger flow dynamics.

[0019] Preferably, the graph filtering process includes:

[0020] First, calculate the degree matrix D t , the degree matrix is ​​the sum of the weights of the edges connected to the node, and is calculated as:

[0021]

[0022] Among them, the degree matrix D t is a diagonal matrix, each diagonal element D t(p,p) represents the degree of OD for node p and its neighbor node q, A t (p,q) is the corresponding adjacency matrix, and the graph Laplacian operator L at time point t t Defined as:

[0023]

[0024] The graph filtering process is expressed by the following formula:

[0025]

[0026] Among them, W L is the trainable parameter matrix in the graph filtering model, σ represents the activation function, γ is the hyperparameter, and x p,t is the feature vector of node p at time t, x' p,t is the result after graph filtering, N is the node set, and T is the timestamp set.

[0027] Preferably, the spatiotemporal graph attention mechanism model learns node features through spatial attention, temporal attention, and spatiotemporal attention respectively, and then combines the learning results of the three attention mechanisms to obtain the final node feature representation of each node at timestamp t, specifically:

[0028]

[0029] Among them, σ is the activation function, N is the node set, T is the timestamp set, and are the node features learned by spatial attention, temporal attention, and spatiotemporal attention at timestamp t, respectively.

[0030] More preferably, the learning process of the node features by the spatial attention includes: calculating the spatial attention coefficient for the node p and its neighboring node q; normalizing the spatial attention coefficient to obtain the weight of the timestamp, and weighting the node features according to the neighborhood information and the spatial attention coefficient;

[0031] The learning process of the node features by temporal attention includes: calculating the temporal attention coefficient for the node p and its neighbor node q; normalizing the temporal attention coefficient to obtain the weight of the timestamp, and weighting the node features according to the neighborhood information and the temporal attention coefficient;

[0032] The learning process of the spatiotemporal attention on node features includes: for node p and its neighbor node q, calculating the spatiotemporal attention coefficients at different times; normalizing the spatiotemporal attention coefficients to obtain the weight of the timestamp, and weighting the node features according to the neighborhood information and the spatiotemporal attention coefficients.

[0033] Preferably, the multi-scale LSTM model includes a day-level LSTM model and a minute-level LSTM model, which are used to capture long-term passenger flow models and short-term passenger flow trends, respectively;

[0034] The input of the day-level LSTM model is the day-level spatiotemporal attention weighted feature vector, and the output is the long-term hidden state;

[0035] The input of the minute LSTM model is the minute-level spatiotemporal attention weighted feature vector, and the output is the short-term hidden state.

[0036] More preferably, the multi-scale prediction result of subway passenger flow output in step S4 is specifically: predicting subway passenger flow according to the output results of minute-level and day-level LSTM, the formula is:

[0037]

[0038] Among them, z M and z D is a nonlinear function that maps hidden states to OD passenger flow, and are the long-term hidden state and the short-term hidden state, respectively. and They are the subway passenger flow prediction values ​​at the day and minute levels respectively.

[0039] Preferably, the training of the multi-scale LSTM model uses a joint loss function that considers both minute-level and day-level prediction losses, and its formula is:

[0040]

[0041] Among them, λ M and λ D They are respectively the minute-level prediction loss and day-level prediction loss The weight of and are the corresponding real value passenger flow at the day level and minute level, T D and T M The time sets are day level and minute level respectively.

[0042] According to another aspect of the present invention, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the method described above is implemented when the processor executes the program.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] 1) The present invention integrates multi-source heterogeneous data such as historical passenger flow, land use information and OD accessibility, introduces knowledge graph to construct node features, effectively enhances the adaptability of the model to sparse data, and enriches the feature representation of the OD level; and accurately captures the complex spatiotemporal correlations between OD pairs through a multi-scale spatiotemporal graph attention network. The multi-scale LSTM model can simultaneously model long-term trends and short-term fluctuations, solving the problems of data sparsity and strong spatiotemporal dynamics, so the predicted subway passenger flow is more accurate.

[0045] 2) The present invention combines three attention mechanisms to learn node features, which improves the prediction ability of the model at different time scales. Compared with other algorithms, this method has high adaptability and flexibility, can adjust the model according to different spatiotemporal characteristics, and is suitable for all-weather operation needs in complex subway operation environments.

[0046] 3) The method of the present invention models long-term and short-term passenger flow dynamics and outputs accurate passenger flow forecasts at the day and minute levels, providing strong data support for the intelligent scheduling of the subway system, helping operators to better formulate resource allocation and emergency management plans, and improving the overall operating efficiency of the system.

[0047] 4) The present invention outputs accurate passenger flow predictions, which helps reduce the energy consumption and operating costs of the subway system in intelligent scheduling, and promotes the green, intelligent and sustainable development of the urban transportation system. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 It is a schematic diagram of the flow chart of the subway passenger flow prediction method in the present invention;

[0049] Figure 2 It is a schematic diagram of using the knowledge graph to identify the correlation between OD pairs in the present invention;

[0050] Figure 3 Schematic diagram of the structure of the multi-scale spatiotemporal graph attention network in the present invention;

[0051] Figure 4 A schematic diagram showing the comparison of the calculation effect MAPE between the method in the present invention and other deep learning model methods;

[0052] Figure 5 This is a schematic diagram comparing the calculation effect MAPE of the method in the present invention and other deep learning model methods over time. DETAILED DESCRIPTION

[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0054] In order to solve the above challenges, the present invention proposes a subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network that integrates a knowledge graph and an MSP-GATNet (multi-scale spatiotemporal graph attention network) deep learning model. The method first integrates prior knowledge such as historical passenger flow patterns, land use information around stations, and accessibility of OD pairs into a unified graph structure by constructing a knowledge graph based on OD pairs. The introduction of the knowledge graph not only enriches the representation ability of sparse data, but also enhances the modeling of spatial dependencies, so that the model can learn effective features from similar OD pairs, alleviating the problem of data sparsity. On this basis, the present invention designs a multi-scale spatiotemporal graph attention network (MSP-GATNet), whose core modules include: a graph filtering module, a graph attention module, and a multi-scale LSTM model. The graph filtering module is used to extract the key features of the OD-level knowledge graph, the graph attention module captures the passenger flow correlation between stations by dynamically adjusting the information propagation between OD pairs, and the multi-scale LSTM model simultaneously models the long-term and short-term dynamic changes of passenger flow. This model can not only effectively process large-scale data of OD pairs, but also capture the changing patterns of subway passenger flow at different time periods and spatial scales. Finally, the experimental results show that this method is significantly better than the existing benchmark model in terms of passenger flow prediction accuracy at the OD level, improving the prediction accuracy by about 4.34%. This innovative method not only improves the operating efficiency of the subway system, but also lays a solid foundation for the construction of future intelligent urban transportation systems.

[0055] Example 1

[0056] This embodiment relates to a subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network. Figure 1 , the method comprising:

[0057] Step 1: Collect the passenger flow data, subway network structure data and land use type data (i.e. POI data) of subway OD pairs over a period of time.

[0058] Step 2, constructing the urban rail transit knowledge graph at the OD level, integrating historical passenger flow patterns, land use information, and the accessibility of OD pairs, constructing the node features of the knowledge graph, and solving the problems of large OD data volume, high sparsity, and strong temporal dynamics.

[0059] In step 3, a multi-scale spatiotemporal graph attention network (MSP-GATNet) is proposed, which contains a graph filtering model and a spatiotemporal graph attention mechanism model, which are used to extract knowledge graph features, capture passenger flow correlations between OD pairs, and model long-term and short-term passenger flow dynamics.

[0060] In step 4, a multi-scale spatiotemporal graph attention network will be constructed and used to predict subway passenger flow.

[0061] The process for step 2 includes:

[0062] 1) Calculate historical passenger flow characteristics. Based on the historical passenger flow data of OD pairs, extract the average and standard deviation of passenger flow, as well as passenger flow statistics during weekdays and weekends, morning and evening peak and non-peak hours, to capture the long-term passenger flow pattern and short-term fluctuation trend between OD pairs. And the historical passenger flow data of each timestamp in the previous time window, which records the actual passenger flow at a specific time interval within the defined historical time period, provides the short-term time trend of recent passenger flow dynamics.

[0063] Calculate the historical statistical indicators of each OD pair, which include the mean and standard deviation of passenger flow in a specific time period (such as weekday peak, weekday off-peak, weekend peak, weekend off-peak), as well as passenger flow during peak and off-peak hours. It represents the average number of passengers between OD pairs in a specific time period (such as weekday peak, weekday non-peak, weekend peak, weekend non-peak), and its calculation rule is:

[0064]

[0065] Among them, T t represents the set of all time intervals belonging to a specific time period type t, |T t | is the number of time intervals in the set. The standard deviation of passenger flow is expressed as It measures the volatility and dispersion of passenger flow around the mean in a specified time period type t.

[0066] Standard deviation of passenger flow Reveals the fluctuation of passenger travel demand in the subway network, calculated by the formula:

[0067]

[0068] Calculate the historical passenger flow data for each timestamp within the previous time window length: To capture the short-term pattern of OD-level subway passenger flow, the historical passenger flow data for each timestamp within the previous time window length w is defined as:

[0069]

[0070] in, is the historical passenger flow data corresponding to timestamp i.

[0071] In this way, historical data captures both long-term statistical patterns and short-term dynamic trends, providing multi-level information for OD-level passenger flow forecasting.

[0072] 2) Calculate land use information. By combining the land use type data (including work, residence, education, medical care, commerce, etc.) within 1 km around the OD starting point and terminal stations, add socioeconomic attributes to the node characteristics of the OD pair and enrich the information expression in the spatial dimension.

[0073] Based on the land use information of subway OD pairs, the proportions of different types of points of interest (POI) around the starting and ending stations of each OD pair are considered and calculated as follows:

[0074]

[0075] Among them, POI l is the set of POIs belonging to land use type l, d(s,poi) represents the relationship between site s and POI point poi i The distance between o and d They are the starting and ending stations of the OD pair respectively.

[0076] 3) Calculate the accessibility of OD pairs. Based on the accessibility of subway lines between OD pairs, calculate the shortest path distance and the number of feasible paths. Combined with the connectivity between subway stations, characterize the spatial accessibility and accessibility of different OD pairs to strengthen the spatiotemporal correlation modeling between OD pairs.

[0077] The travel distance of each OD pair is defined as the sum of the distances between its stations along the shortest path in the subway network, calculated using the Dijkstra algorithm, expressed as:

[0078]

[0079] Among them, d(s i ,s j ) is the OD pair of adjacent sites on the shortest path i and j The distance between them, SP(od) represents the set of adjacent sites on the shortest path of the OD pair.

[0080] Reachability is defined as the number of feasible paths for each OD pair, provided that the total number of stations on these paths does not exceed the shortest path length plus a threshold, expressed as

[0081]

[0082] Among them, P(od) is the set of feasible paths of OD pairs, L(p) is the length of path p, and L sp (od) is the shortest path length of the OD pair, ΔL is the reachability threshold, A true function that satisfies a condition.

[0083] Among them, the specific steps of Dijkstra algorithm are as follows:

[0084] Step a: Initialization. For the starting node s, set its distance to itself to 0, that is, d(s) = 0, indicating that the distance from the starting point to the starting point is 0. For all other nodes v, set their initial distance to infinity d(v) = ∞, indicating that the distance from the starting point to these nodes has not yet been determined. Use a priority queue to store the nodes and their current shortest distances. Initially, add the starting point s to the priority queue, and the queue is sorted according to the shortest distance of the nodes.

[0085] Step b: Select the node with the shortest distance. Take out the node u closest to the starting point (i.e. the node with the shortest distance in the queue) from the priority queue. Because the shortest path to this node has been determined, the paths of other nodes will not be updated. If the current shortest distance is infinite, it means that the remaining nodes are unreachable and the algorithm terminates.

[0086] Step c: Relaxation operation. For all neighbor nodes v of the current node u, check whether the path to v through u is shorter than the currently known path. If so, update the distance of v:

[0087] d(v)=min(d(v),d(u)+w(u,v))

[0088] Among them, w(u,v) represents the edge weight between node u and v. If the distance of v is updated, v and its new distance are reinserted into the priority queue.

[0089] Step d: Repeat steps b and c. Keep taking out the node with the smallest distance from the priority queue and performing the relaxation operation until all nodes are processed or the queue is empty.

[0090] Step e: End. When all nodes have been processed, the shortest path from the starting point to all other nodes has been found, and the algorithm terminates.

[0091] 4) Calculate the correlation of OD pairs: The nonlinear correlation of historical passenger flow sequences is calculated by the kernel canonical correlation analysis (KCCA) method, and the relationship edges of OD pairs are constructed based on the correlation threshold to represent the node association in the knowledge graph. The edge features of the knowledge graph are constructed based on the correlation of OD pairs.

[0092] The key to identifying the correlation between different OD pairs to build an accurate OD knowledge graph is to use Kernel Canonical Correlation Analysis (KCCA) to explore the correlation between the historical passenger flow sequences of two OD pairs in a high-dimensional feature space. KCCA captures more complex nonlinear relationships by mapping the original input to a high-dimensional feature space.

[0093] The historical passenger flow sequences of two OD pairs are defined as and Where t represents the time step.

[0094] First, the kernel function φ is used to map the two sequences into a high-dimensional feature space, and we get and Where φ is the mapping function. Commonly used kernel functions include Gaussian kernel and polynomial kernel, which ensure that sufficient nonlinear features are captured in high-dimensional space.

[0095] Next, KCCA aims to find the linear combination of these mapping vectors to maximize their correlation in the high-dimensional feature space. Its mathematical expression is:

[0096]

[0097] Among them, K 11 and K 12 are the self-core matrices of the two OD pairs, is the kernel matrix between the two OD pairs, w1 and w2 are the corresponding learnable parameter matrices. By maximizing ρ, the correlation between the two OD pairs in high-dimensional space can be quantified.

[0098] If the calculated correlation exceeds the preset threshold, it indicates that there is a significant association between the two OD pairs. When constructing the adjacency matrix of the OD knowledge graph, this association determines whether to establish an edge between the two OD pairs. Specifically, if ρ>δ (where v is the correlation threshold), the corresponding element in the adjacency matrix A is set to 1, indicating that there is a direct relationship between the two OD pairs in the knowledge graph. The process is as follows Figure 2 shown.

[0099] In step 3, a multi-scale spatiotemporal graph attention network (MSP-GATNet) is constructed, which includes a graph filtering model, a spatiotemporal graph attention mechanism model, and a multi-scale LSTM model.

[0100] Step 3-1: Build a graph filtering model to filter graph features x p,t Perform graph filtering operations, the process includes:

[0101] First, calculate the degree matrix Dt , which is the sum of the weights of the edges connected to the node, is calculated as:

[0102]

[0103] Among them, the degree matrix D t is a diagonal matrix, each diagonal element D t (p,p) represents the degree of OD for node p and node q. Based on this, A t (p,q) is the corresponding adjacency matrix, and the graph Laplacian operator L at time point t t Defined as:

[0104]

[0105] The graph Laplacian is a key part of the graph filtering process and is used to aggregate the features of neighboring nodes.

[0106] The graph filtering process can be expressed by the following formula:

[0107]

[0108] Among them, W L is the trainable parameter matrix in the graph filtering model, σ represents the activation function, γ is the hyperparameter, and x p,t is the feature vector of node p at time t, x' p,t This is the result after filtering.

[0109] Step 3-2, construct the spatiotemporal graph attention mechanism model of the Multi-Scale Spatiotemporal Graph Attention Network (MSP-GATNet) model. Assign weights to neighbor features to capture the collaborative or competitive relationship between OD pairs.

[0110] For node p and its neighbor node q, the spatial attention coefficient can be calculated using the following formula:

[0111]

[0112] in, is a learnable vector of spatial attention, tr represents the matrix transpose operation; W S is a learnable parameter matrix to transform features, || represents vector concatenation operation, x p,t With x q,t are the feature vectors of nodes p and q at time t respectively.

[0113] Then, the spatial attention coefficient is normalized by the SoftMax function to obtain the weight of timestamp t:

[0114]

[0115] in, It indicates that the neighboring nodes of the target OD node p at timestamp t constitute a set of OD pairs. Then the graph features are weighted according to the neighborhood information and the spatial attention coefficient, which can be calculated as follows:

[0116]

[0117] For OD node p at different timestamps t and t', based on the feature vector x p,t With x m,t′ , the time attention coefficient is calculated as follows:

[0118]

[0119] in, is a learnable vector of temporal attention; W T The learnable time parameter matrix is ​​used to transform the features, and || represents the vector concatenation operation.

[0120] Then, the temporal attention coefficient is normalized by the SoftMax function to obtain the weight of timestamp t:

[0121]

[0122] The node features are learned through historical node features and time attention coefficients, and the calculation formula is as follows:

[0123]

[0124] In order to further incorporate historical neighborhood knowledge, the spatiotemporal attention coefficients of each node p and its historical neighboring node q at different times are calculated:

[0125]

[0126] The spatiotemporal attention coefficient is then normalized as follows:

[0127]

[0128] The node features are dependent on the historical neighborhood features and the spatiotemporal attention coefficient, and their mathematical expression is:

[0129]

[0130] Finally, combining the results of spatial, temporal and spatiotemporal attention mechanisms, we obtain the final node feature representation of each node at timestamp t:

[0131]

[0132] Among them, σ is the activation function, N is the node set, and T is the timestamp set.

[0133] Step S4, construct a multi-scale LSTM model of the Multi-Scale Spatio-Temporal Graph Attention Network (MSP-GATNet) model, and use the Long Short-Term Memory (LSTM) network to process complex continuous predictions and output the subway passenger flow prediction value.

[0134] The LSTM model is able to manage long-term dependencies using a gating mechanism (input gate, forget gate, and output gate). The LSTM model uses a cell state C t To store important information, this information is passed across time steps and updated at each step based on new input data. The forget gate is the first mechanism to decide whether to retain the state information of the previous unit. Its calculation expression is:

[0135] f t =σ(W f ·[h t-1 ,x t ]+b f )

[0136] Among them, W f is the weight matrix of the learnable forget gate; b f is the bias term; σ is the activation function; h t-1 is the previous hidden state, x t is the input feature at the current timestamp.

[0137] The input gate determines what new information is incorporated into the cell state. Through this step, the model can adjust its prediction results based on the influence of real-time data. The calculation formula of the input gate is:

[0138] i t =σ(W i ·[h t-1 ,x t ]+b i )

[0139] The state of the candidate unit can be calculated as follows:

[0140]

[0141] Among them, W i , W C is the learnable parameter weight matrix, b i , b C are the bias vectors; x t is the eigenvector at time t.

[0142] The state of the new unit is C tIt can be updated as follows:

[0143]

[0144] Through this process, LSTM can dynamically adjust its memory to reflect the new trend of passenger flow. The output gate determines the hidden state h of the current time step. t , which depends on the current cell state C t And output gate. The calculation formula of output gate is:

[0145] o t =σ(W o ·[h t-1 ,x t ]+b o )

[0146] Among them, W o is the learnable parameter weight matrix, b o is the bias vector;

[0147] Then the hidden state h at the current time step is t Based on this calculation:

[0148] h t =o t ⊙tanh(C t )

[0149] In the subway OD passenger flow prediction task, the hidden state h t It can be used to comprehensively utilize the information at the current time point to predict the passenger flow at the next time step.

[0150] Specifically, in order to effectively capture the long-term passenger flow pattern (day level) and short-term subway passenger flow trend (minute level) in subway OD data, a multi-scale LSTM model is constructed. The input of the day-level LSTM is the spatiotemporal attention weighted feature vector of the day The output is the long-term hidden state It is calculated as follows:

[0151]

[0152] Among them, T D Represents a set of days. Similarly, the input of the minute-level LSTM is the spatiotemporal attention weighted feature vector for each minute m. The output is the short-term hidden state It is calculated as follows:

[0153]

[0154] Among them, T M Represents a collection of minutes.

[0155] To update the hidden state at the minute level At the beginning of each day d, use the hidden state of the previous day To initialize the minute-level hidden state It is calculated as follows:

[0156]

[0157] Among them, T D Denotes the set d for the first minute of the day.

[0158] The constructed multi-scale spatiotemporal graph attention network is used to predict subway passenger flow.

[0159] Make predictions based on the output of minute-level and day-level LSTM:

[0160]

[0161] Among them, z M and z D It is a nonlinear function that maps the hidden state to the OD passenger flow.

[0162] To ensure that both models are optimized during training, a joint loss function is constructed that takes into account both minute-level and day-level prediction losses. It can be expressed as follows:

[0163]

[0164] Among them, λ M and λ D They are respectively the minute-level prediction loss and day-level prediction loss The weight of and are the corresponding daily d and minute m level real value passenger flow, T D and T M The time sets are day level and minute level respectively.

[0165] Based on the proposed evaluation index system, a subway passenger flow prediction model designed by integrating knowledge graph and MSP-GATNet deep learning model is evaluated.

[0166] The mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE) are calculated respectively. Among them, MAE is used to measure the average size of the error between the predicted value and the actual value, providing an intuitive explanation of the prediction accuracy. Its mathematical expression is:

[0167]

[0168] Among them, z p,t is the actual passenger flow value of OD node p at timestamp t; is the predicted value; N is the total number of samples of OD pairs; T start and T end are the start and end timestamps.

[0169] Calculate RMSE as follows:

[0170]

[0171] Calculate MAPE as follows:

[0172]

[0173] Example 2

[0174] This embodiment also involves a verification test of a subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network. In this embodiment, OD-level passenger flow data from a subway system was used, and the data covered a three-week period from September 1, 2023 to September 21, 2023, excluding holidays and other special dates. The study period covered the standard subway operating hours, that is, from 6:00 to 22:00 every day, with a time granularity of 10 minutes. In this study, a total of 409 stations in a subway system were selected as research objects, and the passenger flow patterns at the subway OD level were analyzed. The entire study period was divided into 14 days of training data and 7 days of verification and test data.

[0175] The intensity of OD passenger flow on weekdays is generally higher than that on weekends, and shows obvious directional characteristics at different times of the day. During the morning period of 6:00 to 10:00, passenger flow mainly flows from the suburbs to the city center; between 10:00 and 17:00, the inflow and outflow of the city center is relatively balanced; between 18:00 and 22:00, passenger flow begins to flow outward from the city center. The morning and evening peak hours on weekdays occur at 8:00 to 9:00 and 18:00 to 19:00, respectively, while the morning peak on weekends is postponed to 9:00 to 10:00 and the evening peak is postponed to 19:00 to 20:00. POI data are divided into five types: work area, residential area, education area, medical area, and commercial area. In order to quantify the number of POIs within 1 km of each subway station, a distance threshold of 1 km was set. In this POI analysis, commercial POIs are the largest, accounting for 64.70%, followed by work areas, accounting for 18.91%; while the number of POIs in residential, educational and medical areas is relatively small, accounting for 8.34%, 5.17% and 2.89% respectively.

[0176] In this study, a variety of benchmark models, including Historical Average (HA), Support Vector Regression (SVR), Long Short-Term Memory Network (LSTM), and Temporal Convolutional Network (TCN), were used to predict subway OD level passenger flow, and the results are shown in Table 1. Taking the MAPE of 10-minute prediction as an example, the performance of the HA model is significantly worse than that of the SVR, and the SVR is not as good as the deep learning method LSTM. Specifically, the MAPE of the HA model is 64.765%, which is significantly higher than the 60.307% of the SVR. These results show that although statistical regression and machine learning methods perform well in capturing simple historical trends, they have limited ability to model spatiotemporal dynamics in OD passenger flow prediction. In contrast, deep learning methods significantly improve prediction accuracy because of their strong ability to learn from temporal data. The MAPE of LSTM is 52.244%, which is significantly better than HA and SVR. The MAPE of TCN is 55.818%, which is inferior to LSTM. This shows that step-by-step learning is more effective than learning the entire sequence at once in OD passenger flow prediction. Although TCN can capture long-term dependencies through convolution operations, its prediction ability is not as good as LSTM.

[0177] Table 1

[0178] Evaluation indicators Time interval HA SVR LSTM TCN MAE 10min 2.885 2.693 2.31 2.49 20min 5.425 5.097 4.346 4.743 30min 8.001 7.468 6.423 6.97 60min 15.465 14.402 12.399 13.44 MAPE 10min 64.765 60.307 52.244 55.818 20min 69.357 64.553 55.389 60.416 30min 73.976 68.958 60.242 64.65 60min 77.81 74.226 62.228 66.587 RMSE 10min 3.615 3.376 2.898 3.12 20min 6.799 6.382 5.445 5.951 30min 10.032 9.344 8.051 8.718 60min 19.446 18.108 15.586 16.886

[0179] In addition, a deep learning hybrid model is used for comparison. PSAM-CNN (Position-Sensitive Attention Mechanism with Convolutional Neural Network) is a model that combines the position-sensitive attention mechanism with the convolutional neural network (CNN). ST-VGCN (Spatiotemporal Virtual Graph Convolutional Network) ST-VGCN is a spatiotemporal virtual graph convolutional network model. AFFN (Adaptive Fusion Factor Network) is an adaptive fusion factor network. Table 2 shows the hybrid models (PSAM-CNN, ST-VGCN, AFFN, MSP-GATNet (network structure as shown in Figure 3Compared with the baseline models, the four hybrid models have significantly improved in accuracy. Taking the MAPE of 10-minute prediction as an example, PSAM-CNN has a MAPE of 47.342%, ST-VGCN has a MAPE of 43.083%, and AFFN has a MAPE of 38.791%, all of which are better than the best performance of the aforementioned baseline models. MSP-GATNet has a MAPE of 34.449%, which is the most outstanding performance, demonstrating its effectiveness in integrating spatial, temporal and external factors.

[0180] Table 2

[0181] Evaluation indicators Time interval PSAM-CNN ST-VGCN AFFN MSP-GATNet MAE 10min 2.113 1.917 1.729 1.539 20min 3.999 3.628 3.252 2.904 30min 5.875 5.342 4.77 4.254 60min 11.304 10.326 9.312 8.243 MAPE 10min 47.342 43.083 38.791 34.449 20min 51.184 46.301 41.569 36.775 30min 53.358 49.096 43.879 38.442 60min 57.26 51.802 46.45 41.192 RMSE 10min 2.645 2.403 2.169 1.926 20min 5.009 4.55 4.081 3.636 30min 7.361 6.692 5.971 5.328 60min 14.185 12.931 11.675 10.321

[0182] By analyzing the spatial and temporal dimensions, we further explored the performance of PSAM-CNN, ST-VGCN, AFFN, and MSP-GATNet in different time periods and on different dates (see Appendix Figure 4 ). The MAPE analysis results from Monday to Sunday show that MSP-GATNet outperforms the other three hybrid models on all days of the week. The prediction error on weekdays is generally lower than that on weekends, especially on the transition days between weekdays and weekends (Saturday and Monday), the prediction error increases significantly, mainly due to the shift of passenger flow from commuting to entertainment travel mode, which increases data complexity. In addition, the attached Figure 5 The changes in MAPE in different time periods (6:00 to 22:00) are shown, and the results show that the errors of all models increase significantly during peak hours, while MSP-GATNet shows the best performance in all time periods.

[0183] To verify the effectiveness of each component in MSP-GATNet, we conducted an ablation experiment, and the results are shown in Table 3. The experiment designed four groups, combining historical passenger flow information (K1), land use information (K2), OD distance and accessibility information (K3). Taking the MAPE of 10-minute prediction as an example, when only historical passenger flow information is used, the MAPE is 64.946%; after adding land use information, the MAPE is significantly reduced to 41.506%; and after adding OD distance and accessibility information, the MAPE increases to 57.394%. When all knowledge is combined, the model performs best, and the MAPE drops to 34.449%.

[0184] Table 3

[0185]

[0186] Finally, Table 4 shows the impact of different attention mechanism combinations on prediction accuracy. A0 represents no attention, As represents spatial attention, Ap represents temporal attention, and Asp represents MSP-GATNet. The results show that when the attention mechanism is not used, the MAPE of the 10-minute prediction is 58.247%; when only spatial attention is used, the error is reduced to 42.112%; when only temporal attention is used, the error is 54.148%; and the MAPE of the MSP-GATNet model combining spatial and temporal attention is 34.449%, which verifies the effectiveness of the spatiotemporal attention mechanism in improving the accuracy of OD passenger flow prediction.

[0187] Table 4

[0188]

[0189] It can be seen from the results that the method of the present invention can not only accurately predict the passenger flow at the subway OD level, significantly improving the accuracy of the prediction, but also solves the problems of data sparsity and strong spatiotemporal dynamics by integrating the knowledge graph and the multi-scale spatiotemporal graph attention network. The method also has high adaptability and flexibility, can adjust the model according to different spatiotemporal characteristics, and is suitable for complex subway operation environments, thereby optimizing the scheduling and resource allocation of the subway system.

[0190] Example 3

[0191] The electronic device of the present invention includes a central processing unit (CPU), which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) or loaded from a storage unit into a random access memory (RAM). In the RAM, various programs and data required for device operation can also be stored. The CPU, ROM and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.

[0192] Multiple components in the device are connected to the I / O interface, including: input units, such as keyboards, mice, etc.; output units, such as various types of displays, speakers, etc.; storage units, such as disks, optical disks, etc.; and communication units, such as network cards, modems, wireless communication transceivers, etc. The communication unit allows the device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunication networks.

[0193] The processing unit performs the various methods and processes described above, such as methods S1 to S4. For example, in some embodiments, methods S1 to S4 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program may be loaded and / or installed on the device via a ROM and / or a communication unit. When the computer program is loaded into the RAM and executed by the CPU, one or more steps of methods S1 to S4 described above may be performed. Alternatively, in other embodiments, the CPU may be configured to execute methods S1 to S4 in any other appropriate manner (e.g., by means of firmware).

[0194] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0195] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0196] In the context of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0197] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network, characterized in that: The method comprises the following steps: Step S1, collecting the passenger flow data of subway OD pairs, subway network structure data and land use type data; Step S2, constructing an OD-level urban rail transit knowledge graph based on the data in step S1, and calculating node features of the knowledge graph, including calculating historical passenger flow features, calculating land use information, calculating the accessibility of OD pairs, and calculating the correlation of OD pairs; Step S3, inputting the node features of the knowledge graph in step S2 into a multi-scale spatiotemporal graph attention network, first performing graph filtering on the node features, and then updating the node features of the knowledge graph in combination with the results output by the spatiotemporal graph attention mechanism model, wherein the network includes a graph filtering model, a spatiotemporal graph attention mechanism model, and a multi-scale LSTM model connected in sequence; Step S4, input the updated node features into the multi-scale LSTM model, and output the multi-scale prediction results of subway passenger flow.

2. According to claim 1, a subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network is characterized in that: The calculating of the historical passenger flow characteristics includes calculating the historical statistical indicators of each OD pair, wherein the historical statistical indicators include the passenger flow mean and standard deviation in a specific time period, and the passenger flow in peak and non-peak periods, wherein the specific time period includes weekday peak, weekday non-peak, weekend peak and weekend non-peak; The calculation of land use information is to calculate the ratio of different types of points of interest around the starting station and the terminal station for each OD; The calculation of the reachability of the OD pair includes: calculating the shortest path distance and the number of feasible paths for each OD pair; The calculation of OD pair correlation includes: calculating the nonlinear correlation of historical passenger flow sequences through a kernel canonical correlation analysis method, constructing relationship edges of OD pairs based on a correlation threshold, and then constructing edge features of a knowledge graph.

3. According to claim 1, a subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network is characterized in that: The graph filtering model is used to extract knowledge graph features, and the spatiotemporal graph attention mechanism model is used to capture the passenger flow correlation between OD pairs and model the long-term and short-term passenger flow dynamics.

4. According to claim 1, a subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network is characterized in that: The graph filtering process includes: First, calculate the degree matrix D t , the degree matrix is ​​the sum of the weights of the edges connected to the node, and is calculated as: Among them, the degree matrix D t is a diagonal matrix, each diagonal element D t (p,p) represents the degree of OD for node p and its neighbor node q, A t (p,q) is the corresponding adjacency matrix, and the graph Laplacian operator L at time point t t Defined as: The graph filtering process is expressed by the following formula: Among them, W L is the trainable parameter matrix in the graph filtering model, σ represents the activation function, γ is the hyperparameter, and x p,t is the feature vector of node p at time t, x' p,t is the result after graph filtering, N is the node set, and T is the timestamp set.

5. According to claim 1, a subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network is characterized in that: The spatiotemporal graph attention mechanism model learns node features through spatial attention, temporal attention, and spatiotemporal attention respectively, and then combines the learning results of the three attention mechanisms to obtain the final node feature representation of each node at timestamp t, specifically: Among them, σ is the activation function, N is the node set, T is the timestamp set, and are the node features learned by spatial attention, temporal attention, and spatiotemporal attention at timestamp t, respectively.

6. The subway passenger flow prediction method based on multi-scale spatiotemporal graph attention network according to claim 5 is characterized in that: The learning process of the spatial attention on the node features includes: calculating the spatial attention coefficient for the node p and its neighbor node q; normalizing the spatial attention coefficient to obtain the weight of the timestamp, and weighting the node features according to the neighborhood information and the spatial attention coefficient; The learning process of the node features by temporal attention includes: calculating the temporal attention coefficient for the node p and its neighbor node q; normalizing the temporal attention coefficient to obtain the weight of the timestamp, and weighting the node features according to the neighborhood information and the temporal attention coefficient; The learning process of the spatiotemporal attention on node features includes: for node p and its neighbor node q, calculating the spatiotemporal attention coefficients at different times; normalizing the spatiotemporal attention coefficients to obtain the weight of the timestamp, and weighting the node features according to the neighborhood information and the spatiotemporal attention coefficients.

7. The subway passenger flow prediction method based on multi-scale spatiotemporal graph attention network according to claim 1 is characterized in that: The multi-scale LSTM model includes a day-level LSTM model and a minute-level LSTM model, which are used to capture long-term passenger flow models and short-term passenger flow trends respectively; The input of the day-level LSTM model is the day-level spatiotemporal attention weighted feature vector, and the output is the long-term hidden state; The input of the minute LSTM model is the minute-level spatiotemporal attention weighted feature vector, and the output is the short-term hidden state.

8. The subway passenger flow prediction method based on multi-scale spatiotemporal graph attention network according to claim 7 is characterized in that: The multi-scale prediction result of subway passenger flow output in step S4 is specifically: predicting subway passenger flow according to the output results of minute-level and day-level LSTM, the formula is: Among them, z M and z D is a nonlinear function that maps hidden states to OD passenger flow, and are the long-term hidden state and the short-term hidden state, respectively. and They are the subway passenger flow prediction values ​​at the day and minute levels respectively.

9. The subway passenger flow prediction method based on multi-scale spatiotemporal graph attention network according to claim 1 is characterized in that: The multi-scale LSTM model is trained using a joint loss function that considers both minute-level and day-level prediction losses, and its formula is: Among them, λ M and λ D They are respectively the minute-level prediction loss and day-level prediction loss The weight of and are the corresponding real value passenger flow at the day level and minute level, T D and T M The time sets are day level and minute level respectively.

10. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the program, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Passenger flow prediction method based on LSTM

    CN113221472A

  • Urban rail passenger flow prediction method based on dynamic multi-graph and multi-dimensional attention space-time neural network

    CN117454119A

  • Subway passenger flow volume prediction method and system based on space-time diagram ordinary differential equation

    CN117592602A

  • Urban rail transit station short-time passenger flow prediction model and prediction method

    CN118298632A

Cited By

  • Elderly health condition prediction method based on wearable device

    CN120432168A