Rail transit passenger flow OD prediction method and system
By combining the improved iTransformer model with multivariate attention and temporal convolutional networks to extract the spatial and temporal relationships of rail transit passenger flow, the problems of low accuracy and stability of existing prediction methods are solved, achieving more accurate passenger flow prediction and resource optimization, and improving the operational efficiency and service level of rail transit.
Patent Information
- Application Number
- CN202411256460.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-09-09
AI Technical Summary
Existing methods for predicting rail transit passenger flow have low accuracy when dealing with large or abnormal passenger flows, and traditional models are prone to gradient vanishing and exploding problems, leading to an imbalance in the allocation of rail transit network resources and an inability to meet transportation demands.
An improved iTransformer model is adopted, which combines a variable embedding layer, a multivariate attention mechanism layer, a temporal convolutional network layer, and a fully connected layer. Spatial relationships are extracted through a self-attention mechanism, and temporal relationships are extracted using causal convolution and dilated convolution. An OD matrix is constructed for passenger flow prediction, and the model parameters are optimized through cross-validation.
It improves the accuracy of OD passenger flow forecasting in rail transit, helps transportation departments to scientifically plan capacity, avoid operational bottlenecks, improve the quality of public services and passenger experience, and achieve more efficient operation of urban infrastructure.
Smart Images

Figure CN119180372B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of rail transit control technology, and in particular to a method and system for predicting the origin-destination (OD) of rail transit passenger flow. Background Technology
[0002] Urban rail transit, as a mode of transportation in cities, is characterized by large passenger capacity, safety, punctuality, and sustainability, playing a vital role in urban development. However, with the acceleration of urbanization, the rail transit network faces immense passenger pressure, leading to problems such as low punctuality rates and insufficient train frequency to meet peak hour demands. The root cause lies in the lack of accurate analysis of passenger flow patterns, resulting in an imbalance in the allocation of rail transit network resources and a situation where the supply of rail lines cannot meet transportation demand. Therefore, how to accurately predict passenger flow has become an urgent problem to solve.
[0003] Early methods for accurate origin-destination (OD) passenger flow forecasting primarily relied on various classical linear forecasting models based on statistical theory. Examples include the Autoregressive Integrated Moving Average (ARMIA) model, the Kalman filter model, and nonparametric models. A key assumption of these models is that passenger flow exhibits linear and stationary characteristics. While computationally simple and efficient, these statistically based linear forecasting models are static and highly susceptible to large and abnormal passenger flows, resulting in lower prediction accuracy. In reality, OD volume is significantly influenced by its internal temporal variability and spatial correlation. With the development of big data technology, research has gradually shifted to methods such as neural networks. These networks train on large amounts of OD data to attempt to uncover spatiotemporal relationships and accurately grasp passenger flow patterns. However, this approach is prone to gradient vanishing and exploding problems and is difficult to train. Summary of the Invention
[0004] To overcome the aforementioned technical deficiencies and improve the accuracy of OD (Original Departure) passenger flow prediction in urban rail transit, this application provides a method and system for predicting OD passenger flow in rail transit, the specific scheme of which is as follows:
[0005] In a first aspect, according to an embodiment of the present invention, a method for predicting the origin-destination (OD) flow of rail transit passengers is characterized by the following steps: S1, constructing an OD passenger flow dataset: matching the cleaned passenger flow data with entry and exit information to form an OD passenger flow dataset for a certain time step, wherein the passenger flow data is extracted from an automatic fare collection (AFC) system; S2, generating an OD matrix: for each station in the rail transit system, taking that station as the starting station and other stations as different destination stations, extracting the corresponding passenger flow from the OD passenger flow dataset to generate a corresponding OD matrix; wherein the OD matrix includes spatial and temporal relationships, and the time series from the same starting station to different destination stations corresponds to the spatial relationships in the OD matrix of each station. Spatial variables represent spatial relationships. In the OD matrix corresponding to each station, the time variables corresponding to the same timestamp from the same starting station to different destination stations represent temporal relationships. S3, OD passenger flow prediction: The OD matrix is input into the trained OD prediction model to predict the OD passenger flow results. The OD prediction model is an improvement on the iTransformer model, which includes a variable embedding layer, a multivariate attention mechanism layer, a temporal convolutional network layer, a feature fusion layer, and a fully connected layer. The self-attention mechanism in the multivariate attention mechanism layer is used to extract features of spatial relationships in the OD matrix. The temporal convolutional network layer includes causal convolution and dilated convolution, which are used to extract features of temporal relationships in the OD matrix.
[0006] Optionally, in one implementation of the present invention, the specific steps of data cleaning include deleting duplicate values and using a smoothing correction method to correct outliers.
[0007] The OD passenger flow dataset is denoted as D. T=t Its expression is:
[0008]
[0009] In the formula, T = t represents different times, and D T=t For OD datasets at different times, d 1i (t) represents the passenger flow from the i-th starting station to the 1-th station, where the passenger flow from the 1-th station to the 1-th station is zero, which is the value in the first row and first column of the formula; d j1 (t) represents the passenger flow from the first starting station to the jth destination station; the diagonal elements in the formula represent the passenger flow from the nth station to the nth station and are all 0; d 12 (t), ...d 1n (t) represents the passenger flow from the 2nd to the nth starting station to the 1st station; d 21 (t)…d n1(t) represents the passenger flow from the first starting station to the second to the nth destination stations.
[0010] Optionally, in one implementation of this invention, the daily operating hours of the rail transit system are divided into b time periods. This represents the number of passengers traveling from origin i to destination j in the p-th time period on day D (1≤D≤s). For destination n with origin i, the passenger volume of the n OD pairs forms an n-dimensional OD vector. Represented as:
[0011]
[0012] At this point, the OD matrix is denoted as Its expression is:
[0013]
[0014] In the formula, the spatial variable is The vector corresponding to each column in the vector is denoted as Mc, and the time variable is... The vector corresponding to each row in the vector is denoted as M. k .
[0015] Optionally, in one implementation of this invention, the specific steps of OD passenger flow prediction include:
[0016] S3.1, OD matrix After inputting the OD prediction model, its spatial variable Mc is input into the variable embedding layer, and its temporal variable M k Input is fed into a temporal convolutional network layer;
[0017] S3.2. Vector embedding is performed on the variable embedding layer, and then input into the multivariate attention mechanism layer. The multivariate attention mechanism layer uses a self-attention mechanism to extract features from the spatial variable Mc. The extracted results are then processed by residual connection and layer normalization to obtain the spatial variable features, denoted as H. c And output it to the feature fusion layer;
[0018] S3.3, In the temporal convolutional network layer, first convert the time variable M... k After transposition, a temporal convolutional network consisting of causal convolution and dilated convolution is used to extract features, denoted as H. M And output it to the feature fusion layer;
[0019] S3.4, In the feature fusion layer, the spatial variable feature H c and time variable H M Feature fusion yields feature W, which is expressed as: Output to the fully connected layer;
[0020] S3.5. After extracting features from the input features W in the fully connected layer, output the OD passenger flow prediction result;
[0021] The fully connected layer consists of 3 hidden layers, 1 input layer, and 1 output layer, with 256 neurons. The activation function is softmax. The input layer receives features W, and the output layer is processed by inverse normalization.
[0022] Optionally, in one implementation of this invention, the time variable features obtained by using a temporal convolutional network composed of causal convolution and dilated convolution for feature extraction are denoted as H. M The specific steps include:
[0023] S3.3.1. Use the following calculation formula to calculate the time variable M. k The calculation is performed to obtain the result, and the calculation formula is as follows:
[0024]
[0025] In the formula, d is the dilation coefficient, g is the kernel size, and f(e) is the e-th element in the kernel.
[0026] S3.3.2. The calculation results are first activated by the ReLU function, then normalized by the layer, and finally output using residual connection. The output F(M) is expressed as:
[0027] F(M)=F(t)+M k ;
[0028] S3.3.3. Perform layer normalization again on the output of the residual connection to obtain the time variable feature H. M .
[0029] Optionally, in one implementation of this invention, cross-validation is used to update and optimize parameters during the training of the OD prediction model. The loss function of the OD prediction model is MSE, and minimizing MAPE and RMSE is used as evaluation metrics to complete model training.
[0030] Secondly, this invention provides a rail transit passenger flow OD prediction system, comprising:
[0031] Data acquisition unit, data processing unit, training unit, and prediction unit;
[0032] The data acquisition unit is used to construct the OD passenger flow dataset, which specifically includes: matching the cleaned passenger flow data with the entry and exit information to form an OD passenger flow dataset for a certain time step, wherein the passenger flow data is extracted from the automatic fare collection (AFC) system;
[0033] The data processing unit is used to generate the OD matrix, specifically including: for each station in the rail transit system, taking that station as the starting station and other stations as different destination stations, extracting the corresponding passenger flow from the OD passenger flow dataset to generate the corresponding OD matrix; wherein the OD matrix includes spatial and temporal relationships, in the OD matrix corresponding to each station, the spatial variables corresponding to the time series from the same starting station to different destination stations represent its spatial relationship, and in the OD matrix corresponding to each station, the temporal variables corresponding to the same timestamp from the same starting station to different destination stations represent its temporal relationship;
[0034] The training unit is used to update and optimize parameters using cross-validation during the training of the OD prediction model. The loss function of the OD prediction model is MSE, and the minimization of MAPE and RMSE is used as evaluation metrics to complete the model training.
[0035] The prediction unit is used for OD passenger flow prediction, specifically including: inputting the OD matrix into the trained OD prediction model to predict the OD passenger flow result; wherein the OD prediction model is an improvement based on the iTransformer model, including a variable embedding layer, a multivariate attention mechanism layer, a temporal convolutional network layer, a feature fusion layer, and a fully connected layer. The self-attention mechanism in the multivariate attention mechanism layer is used to extract features of spatial relationships in the OD matrix, and the temporal convolutional network layer includes causal convolution and dilated convolution, which are used to extract features of temporal relationships in the OD matrix.
[0036] The technical effects achieved by employing the above-described technical solution in the embodiments of this application are as follows:
[0037] This scheme uses temporal variable embedding and self-attention mechanism in iTransformer to obtain the spatial distribution of OD passenger flow in urban rail transit. At the same time, it uses temporal convolutional network to extract features for the mining of temporal relationships, and fuses spatial and temporal relationship features. The fully connected layer performs further internal feature learning and makes predictions. Inverse normalization is used to obtain an easy-to-understand expression, thereby improving the accuracy of OD passenger flow prediction in urban rail transit. Attached Figure Description
[0038] The accompanying drawings exemplify embodiments and form part of the specification, serving together with the textual description to explain exemplary implementations of the embodiments. The illustrated embodiments are for illustrative purposes only and do not limit the scope of the claims. Throughout the drawings, the same reference numerals refer to similar but not necessarily identical elements.
[0039] Figure 1 This is a flowchart illustrating the rail transit passenger flow OD prediction method in an embodiment of the present invention;
[0040] Figure 2 This is a schematic diagram of time and space variables in an embodiment of the present invention;
[0041] Figure 3 This is a flowchart illustrating the specific steps of OD passenger flow prediction in an embodiment of the present invention;
[0042] Figure 4 This is a schematic diagram of the model structure of the OD prediction model in an embodiment of the present invention;
[0043] Figure 5 This is a computational schematic diagram of the self-attention mechanism in an embodiment of the present invention;
[0044] Figure 6 This is a schematic diagram illustrating the workflow of the temporal convolutional network in an embodiment of the present invention;
[0045] Figure 7 This is a schematic diagram of a feature extraction process using a temporal convolutional network in an embodiment of the present invention;
[0046] Figure 8 This is a schematic diagram of a system structure for a rail transit passenger flow OD prediction system in an embodiment of the present invention. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0048] It should be noted that the descriptions involving "first," "second," etc., in the embodiments of this application are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed in this application.
[0049] In the description of this application, it should be understood that the numerical labels before the steps do not indicate the order of the steps, but are only used to facilitate the description of this application and to distinguish each step, and therefore should not be construed as a limitation of this application.
[0050] To facilitate understanding of the technical solutions of the embodiments of this application, the technical solutions will be described in detail below with reference to the accompanying drawings, as follows:
[0051] Example 1
[0052] See Figure 1 The method for predicting the origin-destination (OD) of rail transit passenger flow in this embodiment of the invention will be described in detail, specifically including the following steps:
[0053] S1. Construct OD passenger flow dataset: Match the cleaned passenger flow data with the entry and exit information to form an OD passenger flow dataset with a certain time step.
[0054] Specifically, passenger flow data is extracted from the Automatic Fare Collection (AFC) system.
[0055] When constructing the critical foundational data structure of the OD (Original Departure Point) passenger flow dataset, data preprocessing is essential—a crucial step. This involves cleaning the raw AFC (Automatic Fare Collection) system data to ensure only high-quality and valid data is retained for subsequent analysis. Next, the data is integrated and matched based on each passenger's specific entry and exit records, forming a dataset reflecting the actual passenger flow between different departure points and destinations within a fixed period. For example, in constructing OD passenger flow data for a specific time span in the Beijing subway network, summarizing the data for the hour between 7:30 AM and 8:30 AM might yield the following: 2,000 passengers traveled from point A to point B.
[0056] S2. Generate OD matrix: For each station in the rail transit system, take that station as the starting station and other stations as different destination stations, extract the corresponding passenger flow from the OD passenger flow dataset to generate the corresponding OD matrix.
[0057] Specifically, the OD matrix includes spatial and temporal relationships. In the OD matrix corresponding to each station, the spatial variables corresponding to the time series from the same starting station to different destination stations represent the spatial relationship, and the temporal variables corresponding to the same timestamp from the same starting station to different destination stations represent the temporal relationship.
[0058] In S2, the OD matrix reflects the data representation of the closeness of connections and the frequency of flow between different transportation network nodes. This process requires transforming the information extracted from the aforementioned OD passenger flow dataset into a form easily analyzed and interpreted by machine learning models. This clearly demonstrates the distribution characteristics of travel demand across the entire transportation network for each origin-destination station combination. Specifically, the station numbers are sequentially used as the horizontal axis coordinates, and the vertical axis indices are arranged in the same way for each route. With the above preparations complete, this information can be used to construct a rectangular array reflecting the total number of passengers traveling from a given origin to other destinations within a certain time period. This table not only shows the actual passenger volume distribution from a departure station to all possible destination stations at a specific time, but also reflects, in cross-sectional direction, the seasonal effects and intraday imbalances in overall travel patterns as time changes. In other words, this matrix shows fluctuations in passenger flow levels compared to the same time on weekends, such as passengers typically choosing the route from point A to point B to enjoy nightlife during Friday evening rush hour.
[0059] S3, OD Passenger Flow Prediction: Input the OD matrix into the trained OD prediction model to obtain the OD passenger flow prediction result.
[0060] To more accurately predict the OD value at the next moment, the relationship between time and space variables needs to be considered. Therefore, a pre-defined OD prediction model is used for description. This pre-defined OD prediction model is obtained by improving the iTransformer model, and its structure is as follows: Figure 3 As shown. Specifically, the OD prediction model is an improvement on the iTransformer model, which includes a variable embedding layer, a multivariate attention mechanism layer, a temporal convolutional network layer, a feature fusion layer, and a fully connected layer. The self-attention mechanism in the multivariate attention mechanism layer is used to extract features of spatial relationships in the OD matrix. The temporal convolutional network layer includes causal convolution and dilated convolution, which are used to extract features of temporal relationships in the OD matrix.
[0061] S3 is the final step in making accurate predictions of future travel flow. It involves using the previously processed passenger flow information between traffic sources and destinations as part of the input data received by the machine prediction system. This process uses an enhanced version of the iTransformer architecture for related calculations, which incorporates several different levels of deep understanding components to achieve better results. For example, when predicting passenger flow before the Spring Festival, given the massive influx of people returning home during the holiday, historical data analysis based on the steps outlined above shows that the number of passengers exiting major subway stations will increase by approximately 40% or more in the month leading up to the festival. This prediction helps transportation departments better allocate capacity to cope with the upcoming surge in passenger flow and avoid operational bottlenecks. Through the application of these steps and methods, we have successfully improved the accuracy of predicting the number of passengers arriving at any destination station from any point within the entire subway network. This provides a strong theoretical basis and reference standard for relevant units to scientifically plan and optimize operational plans, thereby improving the quality of public services and passenger experience, achieving a more efficient and intelligent urban infrastructure operation mode, alleviating congestion and improving service levels, and ultimately optimizing the public transportation environment to promote comprehensive economic and social development.
[0062] Furthermore, the above method employs cross-validation for parameter updates and optimization during the training process of the OD model prediction. The loss function of the OD prediction model is MSE, and the minimization of MAPE and RMSE is used as evaluation metrics to complete model training.
[0063] Specifically, cross-validation is a commonly used model evaluation method. It involves dividing the dataset into multiple parts, using one part for training and another part for validation or testing, to evaluate the model's performance. This method helps the present invention understand the model's performance on unseen data, thereby allowing for better adjustment of the model's parameters and structure to improve its accuracy and stability. The model's loss function is MSE, and minimizing MAPE and RMSE are used as evaluation metrics. The formulas for each evaluation metric are as follows:
[0064]
[0065] Where l represents the number of data points. Represents the predicted value, y i This represents the actual value.
[0066] In the technical solution of this invention, for each station in the rail transit system, the corresponding passenger flow is extracted from the OD passenger flow dataset to generate a corresponding OD matrix, with the station as the starting station and other stations as different destination stations. In the OD matrix corresponding to each station, the spatial variables corresponding to the time series from the same starting station to different destination stations represent their spatial relationship, and the temporal variables corresponding to the same timestamp from the same starting station to different destination stations represent their temporal relationship. This allows the OD matrix to comprehensively cover relatively complete passenger flow information in urban rail transit. Furthermore, by adopting a self-attention mechanism, causal convolution, and dilated convolution to improve the iTransformer model, a new OD prediction model is obtained that can accurately extract the spatial and temporal relationships in the OD matrix, thereby effectively improving the accuracy of OD passenger flow prediction in urban rail transit.
[0067] Example 2
[0068] Next, the data cleaning method of this invention embodiment will be described:
[0069] Optionally, in S1, the specific steps of the above data cleaning include deleting duplicate values and using a smoothing correction method to correct outliers;
[0070] The OD passenger flow dataset is denoted as D. T=t Its expression is:
[0071]
[0072] In the formula, T = t represents different times, and D T=t For OD datasets at different times, d 1i (t) represents the passenger flow from the i-th starting station to the 1-th station, where the passenger flow from the 1-th station to the 1-th station is zero, which is the value in the first row and first column of the formula; d j1 (t) represents the passenger flow from the first starting station to the jth destination station; the diagonal elements in the formula represent the passenger flow from the nth station to the nth station and are all 0; d 12 (t), ...d 1n (t) represents the passenger flow from the 2nd to the nth starting station to the 1st station; d 21 (t)…d n1 (t) represents the passenger flow from the first starting station to the second to the nth destination stations.
[0073] Before starting data cleaning, an OD dataset was defined, which contains passenger flow data for all origin-destination combinations within different time periods. Assuming a transportation network consisting of 128 routes, and passenger data collected in 15-minute time slices, there will be data for different OD (Origin-Destination) pairs. If a certain time is time t, it represents the statistical summary of all OD passengers within the entire public transportation system during that time period.
[0074] The first step is to remove any duplicates in the dataset. Duplicate records may be due to various reasons that lead to the repeated saving of input data. In this step, algorithms are used to identify and remove these redundant information to avoid bias in subsequent analysis.
[0075] After deduplication of the data, the next step is to correct outliers using smoothing techniques. Outliers are usually unreasonable numerical records, such as data from extreme cases like unreasonably large or negative numbers caused by system errors, equipment problems, or operational mistakes. Smoothing methods typically replace these extreme values by averaging adjacent values, thereby reducing their adverse effects on the model and making subsequent trend predictions based on the cleaned data more accurate and reliable.
[0076] As an example, suppose there are three stations A, B, and C within a given time period. Between time intervals T1 and T3, the actual passenger flow from station A to the other two stations B and C, or from any other station to any other destination station, is recorded as follows: T1(A, B) = 30, T1(A, C) = 40; T2(A, B) = 50, T2(B, C) = 70. However, the data for a certain time period, T3(A, A) = -10, is clearly incorrect. This is corrected using smoothing techniques. For example, the average flow between the same origin and destination within the previous two time slices T1 and T2 is used as a substitute value to replace the original value, and duplicate records like (A, C, T1) that might have been entered more than once due to error are deleted. This process ensures the accuracy and reasonableness of the basic data used for calculating passenger flow trends and traffic distribution. Please note that the data in this example is merely hypothetical data values for illustrative purposes.
[0077] Example 3
[0078] Next, see Figure 2 The spatial and temporal relationships of the OD matrix are explained, using the following format for clarity: Figure 2 To represent and define:
[0079] Definition 1: Spatial variable: If each column in the OD matrix is a time series from the originating station to the same destination station, then that column is regarded as a variable in a spatial relationship. The relationship between variables can be reflected as the spatial dependency between two stations.
[0080] Definition 2: Time variable: Each row in the OD matrix is a time stamp from the same originating station to different destination stations. This row is regarded as a time variable in a time relationship. The relationship between time variables can be reflected as the time dependency between different timestamps.
[0081] Specifically, in a rail transit system, the daily operating hours are divided into b time periods. This represents the number of passengers traveling from origin i to destination j in the p-th time period on day D (1≤D≤s). For destination n with origin i, the number of passengers on the n OD pairs forms an n-dimensional OD vector F. i (p,D) , is represented as:
[0082]
[0083] At this point, the OD matrix is denoted as Its expression is:
[0084]
[0085] In the formula, the spatial variable is The vector corresponding to each column in the vector is denoted as Mc, and the time variable is... The vector corresponding to each row in the vector is denoted as M. k .
[0086] First, in the analysis of the rail transit system, the daily operating hours are defined as being divided into m smaller time periods (e.g., morning peak, evening peak, off-peak). This allows for more granular management and control of passenger flow during each specific time period. For example, rail transit can be divided into three time periods—morning peak, evening peak, and off-peak—for operation scheduling and data analysis.
[0087] Then, using This represents the number of passengers traveling from a specific originating station to another fixed station during time period j' on a specific day. Next, a set of combinations of originating and ending stations (OD pairs) with different destinations are defined. This set of data forms an n-dimensional passenger flow or traffic behavior model. For example, during the morning rush hour, the number of passengers departing from a fixed originating subway station and heading to different locations can be represented as a vector.
[0088] Simultaneously, a complete OD (origin-destination pair) matrix M is created to comprehensively display passenger flow distribution across all possible travel modes within any given day. Its structure is built from multiple such vector combinations; the matrix captures the connections between all potential origins and destinations. Taking the morning rush hour as an example, the OD matrix records the total number of passengers traveling from each origin station to each destination station, such as M = [m 11 ,m 12 ,...,m kn ].
[0089] The set of vertically arranged entries in the matrix is then defined as Mc (spatial factor or travel volume between source and destination). In the example scenario above, the column vector of this matrix would be an integrated representation of all passenger data for a specific station or at different times of a day.
[0090] Next, the clusters of row elements in matrix M are defined as variables T (or time series), i.e., M. k This indicates the total number of rides for each specified time interval of the day, such as or between all origin and destination pairs; for example, between 7:30 a.m. and 9:30 a.m., the matrix rows represent the number of passengers arriving at any other location from any origin.
[0091] Example 4
[0092] Next, see Figure 3 , 4 Sections 5 and 6 explain the specific scheme for the above-mentioned OD passenger flow forecasting. The specific steps for the above-mentioned OD passenger flow forecasting include:
[0093] S3.1, OD matrix After inputting the OD prediction model, its spatial variable Mc is input into the variable embedding layer, and its temporal variable M k Input to the temporal convolutional network layer.
[0094] First, the OD matrix is input into the OD prediction model. The spatial variable here is labeled Mc and fed into a variable embedding layer for further processing. Simultaneously, the model also processes the temporal information related to Mc. These temporal variables are then fed into a temporal convolutional network layer to analyze their internal sequence dependency patterns and characteristic changes. For example, in predicting passenger boarding and alighting on a subway line, we consider the number of passengers boarding at different stations at different times of the day as our spatial variable, and the different times of the day as corresponding temporal variables. Through data input, both are used to construct the initial prediction basis.
[0095] S3.2. Vector embedding is performed on the variable embedding layer, and then input into the multivariate attention mechanism layer. The multivariate attention mechanism layer uses a self-attention mechanism to extract features from the spatial variable Mc. The extracted results are then processed by residual connection and layer normalization to obtain the spatial variable features, denoted as H. c The result is then output to the feature fusion layer.
[0096] The previously obtained spatial variable Mc is used for feature extraction and mapping using a mechanism called variable embedding layer, forming an embedded vector representation. This vector representation is then fed into a layer called multivariate attention mechanism. In this stage, the model uses self-attention to refine the feature details in the vector and performs a series of operations on the processed information (such as residual connection and normalization). In our case, the system captures the temporal patterns and behavioral preferences of subway passengers through the above steps and outputs the processed spatial characteristics for subsequent processing.
[0097] S3.3, In the temporal convolutional network layer, first convert the time variable M... k After transposition, a temporal convolutional network consisting of causal convolution and dilated convolution is used to extract features, denoted as H. M The result is then output to the feature fusion layer.
[0098] S3.3 focuses on the stage of handling time-dimensional variables. The time variables are preprocessed, including denoising, before being fed into a Temporal Convolutional Network (TCN). The characteristic of this type of convolutional network is its ability to effectively capture temporal sequence information. Through TCN operations (including causal convolution and dilated or expanded convolution), the final result is a set of features closely related to the time factor. For example, the time element in subway passenger flow data, after transposition, undergoes a specific convolution process to obtain more refined time-dimensional features.
[0099] S3.4, In the feature fusion layer, the spatial variable feature H c and time variable H M Feature fusion yields feature W, which is expressed as: The output is sent to the fully connected layer.
[0100] In S3.4, we move on to the crucial feature integration step. The main purpose of this step is to effectively combine spatial and temporal characteristics based on the previous three stages. This integration involves merging the different types of information extracted above into a composite, integrated feature, and outputting the integrated result to prepare for the next stage of data processing. Taking the subway passenger flow data as an example, this step involves integrating temporal and spatial characteristics and passing the result to subsequent processing stages.
[0101] S3.5. After extracting features from the input features W in the fully connected layer, output the OD passenger flow prediction result.
[0102] The fully connected layer consists of 3 hidden layers, 1 input layer, and 1 output layer, with 256 neurons. The activation function is softmax. The input layer receives features W, and the output layer is processed by inverse normalization.
[0103] In S3.5, a deeper exploratory analysis and processing of the data is performed based on the previously integrated information W. Under the action of these fully connected layers (FC-Layers), the previously integrated information features are further mined to refine their connotations, resulting in more accurate results. At this stage, the fully connected layer structure is a 1+4 layer structure (one input layer + three hidden layers) with 256 nodes and neurons. An activation algorithm (softmax is chosen here) is applied to ensure that the calculated result outputs the expected target, namely the OD traffic flow forecast value. In our example, this is analogous to obtaining the predicted passenger volume for each subway line at different time periods based on all the previously integrated spatial and temporal data, after multiple complex calculations, so that subway operators can make reasonable arrangements in advance to cope with different peak and off-peak conditions and optimize the overall service effect.
[0104] Example 4
[0105] Next, see Figure 6 and 7 The specific steps for extracting time variable features using a temporal convolutional network composed of causal convolution and dilated convolution in this invention are described below:
[0106] Further, optionally, in one embodiment of the present invention, the time variable features obtained by the temporal convolutional network composed of causal convolution and dilated convolution are denoted as H. M The specific steps include:
[0107] S3.3.1. Use the following calculation formula to calculate the time variable M. k The calculation is performed to obtain the result, and the calculation formula is as follows:
[0108]
[0109] In the formula, d is the dilation coefficient, g is the kernel size, and f(e) is the e-th element in the kernel. Widely used in deep learning for audio processing or signal analysis tasks requiring temporal information, the above formula ensures the network can capture dependencies within a specific range. d, the dilation coefficient, determines the sparsity of the parsing window, while g represents the kernel size, which directly affects the length of the captured temporal segments; f(e) is the e-th element in the kernel.
[0110] S3.3.2. The calculation results are first activated by the ReLU function, then normalized by the layer, and finally output using residual connection. The output F(M) is expressed as:
[0111] F(M)=F(t)+M k .
[0112] The ReLU activation function introduces non-linearity, thereby enhancing the expressiveness of the neural network model. Then, layer normalization is performed on the data; subtracting the mean and dividing by the standard deviation ensures that the numerical distribution of the inputs to each layer is roughly stable, which accelerates the training process and improves convergence efficiency. Finally, residual connections are applied to output the results of this part. This connection allows deep models to learn better and solves the gradient vanishing problem, making it possible to train deeper networks. The direct paths within the residual blocks allow gradients propagated forward and backward to traverse several layers, thus improving learning performance and making training more efficient and stable.
[0113] S3.3.3. Perform layer normalization again on the output of the residual connection to obtain the time variable feature H. M .
[0114] After further processing the residual connection output F(M) mentioned earlier, we perform another layer normalization to obtain more standardized time-varying features. This step, by readjusting the normalization, ensures the uniformity of features flowing between different layers of the network, reduces interference caused by variations in numerical scale, facilitates more efficient information propagation, and improves the neural network's ability to understand features.
[0115] Example 5
[0116] Next, see Figure 8 The rail transit passenger flow OD prediction system in this embodiment of the invention will be described in detail below:
[0117] like Figure 8 As shown, the rail transit passenger flow OD prediction system 80 includes a data acquisition unit 801, a data processing unit 802, a training unit 803, and a prediction unit 804.
[0118] Data acquisition unit 801 is connected to the AFC system via a network or transmission line. At fixed intervals, the data acquisition unit collects data from the AFC system at each station and sends the data to data processing unit 802. Data processing unit 802 is equipped with multiple storage devices and a processor. It stores the data collected by data acquisition unit 801 into the storage devices. Simultaneously, the processor extracts all information from the storage devices, using the ID card number as the primary key and the payment amount as the determining factor. Stations with a payment amount of 0 are designated as starting stations, and stations with a non-zero payment amount are designated as arrival stations, thus forming a complete travel chain. Furthermore, by statistically analyzing the number of people and time at the starting and arrival stations, a complete OD matrix is formed and stored in another storage medium.
[0119] Furthermore, the OD matrix stored in the storage medium of the data processing unit 802 is sent to the training unit 803 via a means including but not limited to network transmission. The training unit 803 trains a preset OD passenger flow prediction model and transmits the trained model and the organized data to the prediction unit 804. Optionally, the training unit 804 can be trained using a cloud-based training method.
[0120] Furthermore, the prediction unit 804 contains at least one or more storage media and processors capable of handling large data volumes, as well as input and output devices. Specifically, the processor must have a GPU unit, and the GPU unit version must be at least 12.0 or higher. The storage media stores the trained model, the processor receives the processed data from the processing unit, including sufficient historical passenger flow data, performs rail transit passenger flow OD prediction in the prediction unit, and visualizes the results. The input and output devices enable user interaction with the system.
[0121] First, the data acquisition unit 801 is primarily used to construct the OD (Original Departure Point) passenger flow dataset. This means that the system must first process the raw passenger flow data obtained from the Automatic Fare Collection (AFC) system. Data processing includes comprehensive cleaning of the data source, removing invalid data, and handling missing or outlier values. This cleaned data is then combined with its associated detailed entry and exit records to form OD passenger flow information with clear origin and destination locations over a specific time span. For example, if a station handles 100,000 passengers daily, the AFC system logs can be used to obtain the specific entry and exit data for these 100,000 passengers. Based on this, a passenger count table (OD passenger flow dataset) for each journey during a specific time period of a day can be compiled, thus preparing the groundwork for building a predictive model.
[0122] Secondly, the data processing unit 802 is mainly used to create a more intuitive data table reflecting the passenger flow distribution—the OD matrix—based on the aforementioned collected and organized passenger flow dataset. It not only records the departure and arrival information for each passenger, but also focuses on revealing the structural characteristics of the interconnections between stations and the dynamic changes in passenger flow at different times. For example, during peak periods of a holiday, the passenger flow from station A to station B on a certain route may increase compared to usual, reflecting the overall mobility of the transportation network. By observing the OD matrix, analysts can see the actual number of passengers from an initial station to each destination station within the entire network, the changing trends at different travel times, and spatial correlation patterns—a comprehensive dynamic characteristic.
[0123] Secondly, the training unit 803 aims to perform deep learning training on the existing OD (Original Demand) passenger flow model. This stage employs a technique called iTransformer to train the prediction algorithm model, using cross-validation to continuously adjust and optimize various parameter settings. The loss function defines the deviation between predicted and actual values; the goal during training is to minimize this deviation metric, MSE (mean squared error), so that the final optimal algorithm can accurately predict future OD demand. During this process, the algorithm uses a large amount of known past and present passenger flow patterns for simulation calculations. Through repeated training, the model's predictive accuracy is continuously improved until a relatively ideal fit is achieved before entering the formal prediction stage.
[0124] Finally, the task of prediction unit 804 is as follows: After a series of preparatory activities, the OD passenger flow data has been transformed into a standardized input form (i.e., a matrix) to facilitate rapid analysis by the AI module, which has finished training and is in a standby state. The core of this module is a deeply modified iTransformer framework design. When receiving new OD flow patterns from the external world as its operating parameters, it sequentially processes the data through a recursive process: variable feature embedding layer, multi-head self-attention encoding block, time-dimensional convolution operation, feature combination integrator, and linear regressor. The output at the end of this chain is the final product of a scientific and reasonable prediction of various passenger flow distributions that may occur within the urban rail transit system under any given conditions over a period of time. This helps management departments better understand and timely allocate service resources, respond to potential crowd gatherings or other emergencies, accurately estimate passenger flow changes on various subway lines and stations, and assist transportation operators in developing effective scheduling plans to ensure smooth travel for citizens.
[0125] It should be noted that the above are merely preferred embodiments of this application and do not limit the scope of patent protection of this application. Any equivalent structural or procedural changes made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of this application.
Claims
1. A method for predicting the origin-destination (OD) of passenger flow in rail transit, characterized in that, Includes the following steps: S1. Constructing the OD passenger flow dataset: Match the cleaned passenger flow data with the entry and exit information to form an OD passenger flow dataset for a certain time step, wherein the passenger flow data is extracted from the automatic ticketing and inspection (AFC) system. S2. Generate OD matrix: For each station in the rail transit system, take that station as the starting station and other stations as different destination stations, extract the corresponding passenger flow from the OD passenger flow dataset to generate the corresponding OD matrix; The OD matrix includes spatial and temporal relationships. In the OD matrix corresponding to each station, the spatial variables corresponding to the time series from the same starting station to different destination stations represent the spatial relationship. In the OD matrix corresponding to each station, the temporal variables corresponding to the same timestamp from the same starting station to different destination stations represent the temporal relationship. In a rail transit system, the daily operating hours are divided into b time periods. This represents the number of passengers traveling from origin i to destination j in the p-th time period on day D, where 1 ≤ D ≤ s days. For n destinations originating from i, the passenger volume of the n OD pairs forms an n-dimensional OD vector. Represented as: At this point, the OD matrix is denoted as Its expression is: In the formula, the spatial variable is The vector corresponding to each column in the vector is denoted as Mc, and the time variable is... The vector corresponding to each row in the vector is denoted as M. k ; S3, OD Passenger Flow Forecast: Input the OD matrix into the trained OD forecast model to obtain the OD passenger flow forecast result; The OD prediction model is an improvement on the iTransformer model, which includes a variable embedding layer, a multivariate attention mechanism layer, a temporal convolutional network layer, a feature fusion layer, and a fully connected layer. The self-attention mechanism in the multivariate attention mechanism layer is used to extract features of spatial relationships in the OD matrix. The temporal convolutional network layer includes causal convolution and dilated convolution, which are used to extract features of temporal relationships in the OD matrix. The specific steps for OD (Original Demand) passenger flow prediction include: S3.1, OD matrix After inputting the OD prediction model, its spatial variable Mc is input into the variable embedding layer, and its temporal variable M k Input is fed into a temporal convolutional network layer; S3.
2. Vector embedding is performed on the variable embedding layer, and then input into the multivariate attention mechanism layer. The multivariate attention mechanism layer uses a self-attention mechanism to extract features from the spatial variable Mc. The extracted results are then subjected to residual connection and layer normalization to obtain the spatial variable features, denoted as H. c And output it to the feature fusion layer; S3.3, In the temporal convolutional network layer, first convert the time variable M... k After transposition, a temporal convolutional network consisting of causal convolution and dilated convolution is used to extract features, denoted as H. M And output it to the feature fusion layer; S3.4, In the feature fusion layer, the spatial variable feature H c and time variable H M Feature fusion is performed to obtain feature W. Its feature fusion expression is as follows: Output to the fully connected layer; S3.
5. After extracting features from the input features W in the fully connected layer, output the OD passenger flow prediction result; The fully connected layer consists of 3 hidden layers, 1 input layer, and 1 output layer, with 256 neurons. The activation function is softmax. The input layer receives features W, and the output layer is processed by inverse normalization.
2. The method according to claim 1, characterized in that, The specific steps of the data cleaning include deleting duplicate values and using a smoothing correction method to correct outliers; The OD passenger flow dataset is denoted as D. T=t ; Its expression is: In the formula, T = t represents different times, and D T=t For OD datasets at different times, d 1i (t) represents the passenger flow from the i-th starting station to the 1-th station, where the passenger flow from the 1-th station to the 1-th station is zero, which is the value in the first row and first column of the formula; d j1 (t) represents the passenger flow from the first starting station to the jth destination station; the diagonal elements in the formula represent the passenger flow from the nth station to the nth station and are all 0.
3. The method according to claim 1, characterized in that, The temporal variable features obtained by using a temporal convolutional network composed of causal convolution and dilated convolution are denoted as H. M The specific steps include: S3.3.
1. Use the following calculation formula to calculate the time variable M. k The calculation is performed to obtain the result, and the calculation formula is as follows: In the formula, d is the dilation coefficient, g is the kernel size, and f(e) is the e-th element in the kernel. S3.3.2 The calculation results are first activated by the ReLU function, then normalized by the layer, and finally output using residual connection. The output F(M) is expressed as: F(M) = F(t) + M k ; S3.3.
3. Perform layer normalization again on the output of the residual connection to obtain the time variable feature H. M .
4. The method according to claim 1, characterized in that, In the training process of the OD prediction model, cross-validation is used to update and optimize parameters. The loss function of the OD prediction model is MSE, and the minimization of MAPE and RMSE is used as evaluation indicators to complete the model training.
5. A rail transit passenger flow OD prediction system, characterized in that, The system is used to implement the prediction method according to claim 1, and the system includes: Data acquisition unit, data processing unit, training unit, and prediction unit; The data acquisition unit is used to construct the OD passenger flow dataset, which specifically includes: matching the cleaned passenger flow data with the entry and exit information to form an OD passenger flow dataset for a certain time step, wherein the passenger flow data is extracted from the automatic fare collection (AFC) system; The data processing unit is used to generate the OD matrix, specifically including: for each station in the rail transit system, taking that station as the starting station and other stations as different destination stations, extracting the corresponding passenger flow from the OD passenger flow dataset to generate the corresponding OD matrix; wherein the OD matrix includes spatial and temporal relationships, in the OD matrix corresponding to each station, the spatial variables corresponding to the time series from the same starting station to different destination stations represent its spatial relationship, and in the OD matrix corresponding to each station, the temporal variables corresponding to the same timestamp from the same starting station to different destination stations represent its temporal relationship; The training unit is used to update and optimize parameters using cross-validation during the training of the OD prediction model. The loss function of the OD prediction model is MSE, and the minimization of MAPE and RMSE is used as evaluation metrics to complete the model training. The prediction unit is used for OD passenger flow prediction, specifically including: inputting the OD matrix into the trained OD prediction model to predict the OD passenger flow result; wherein the OD prediction model is an improvement based on the iTransformer model, including a variable embedding layer, a multivariate attention mechanism layer, a temporal convolutional network layer, a feature fusion layer, and a fully connected layer. The self-attention mechanism in the multivariate attention mechanism layer is used to extract features of spatial relationships in the OD matrix, and the temporal convolutional network layer includes causal convolution and dilated convolution, which are used to extract features of temporal relationships in the OD matrix.
Citation Information
Patent Citations
Urban rail transit multi-step short-time passenger flow prediction method based on attention mechanism
CN116227668A
Urban rail passenger flow prediction method based on dynamic multi-graph and multi-dimensional attention space-time neural network
CN117454119A