A method for traffic flow prediction at origin and destination points based on adaptive two-dimensional graph convolution
By performing adaptive two-dimensional graph convolution on the origin and destination dimensions, and combining it with the temporal convolution network, the problem of insufficient spatial and temporal dependency capture in the prediction of origin and destination traffic flow in the existing technology is solved, and the prediction is improved. accuracy and simplifies the model training process.
Patent Information
- Application Number
- CN202310205025.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-06
- Publication Date
- 2024-09-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing traffic flow prediction methods at origin and destination points have shortcomings in capturing the spatial and temporal dependencies between nodes. In particular, the graph convolution method relies on prior conditions, and the complex gating mechanism increases the time overhead of model training. .
A method based on adaptive two-dimensional graph convolution is used to establish an adaptive adjacency matrix in the two dimensions of the start and end points, and stack it with multiple layers of the temporal convolution network to construct a spatiotemporal convolution block through residual connections to capture the traffic at the start and end points. Spatiotemporal dependencies of traffic data.
It improves the accuracy of traffic flow prediction at origin and destination points, enhances the ability to represent node spatial dependencies, and reduces the time overhead of model training.
Smart Images

Figure CN116129659B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of traffic flow prediction, and in particular to a method for predicting traffic flow at an origin and destination point based on adaptive two-dimensional graph convolution. Background Art
[0002] With the acceleration of urbanization, a large number of people gather in cities, and the flow of passengers and goods between cities has become more frequent. By the end of 2020, the total mileage of expressways in China reached 152,900 kilometers. Expressways make travel between cities fast and convenient. More and more people choose expressways as a means of travel, and the large-scale flow of passengers and goods between cities has put tremendous pressure on the transportation system. Origin-destination traffic flow prediction refers to extracting internal laws from a large amount of historical traffic data to predict the traffic flow from one area to another area within the research scope in the future, that is, the traffic flow between regions. The origin-destination traffic flow prediction based on highway toll data has great practical significance in highway traffic management and regional economic development indicators. On the one hand, the origin-destination traffic flow between regions can reflect the scale of goods and passengers between the two, and can be used as an important indicator to reflect the economic connection between the two places. On the other hand, the origin-destination traffic flow prediction between regions can provide decision-making support for traffic management departments in congestion evacuation and route planning.
[0003] Domestic and foreign scholars have used many methods to conduct in-depth exploration in the field of origin-destination traffic flow prediction. According to the time development context, they can be roughly divided into statistical analysis methods, machine learning methods and deep learning methods. Among them, deep learning methods are frequently used in recent studies. This type of method focuses on capturing spatial dependencies and temporal dependencies in the problem of traffic flow prediction. YuB et al. proposed STGCN for traffic flow prediction. This model uses graph convolution after Chebyshev first-order approximation to capture spatial dependencies and uses gated linear units to capture temporal dependencies. WuZ et al. proposed MTGNN. This model uses node embedding matrix to generate adaptive adjacency matrix, and uses adaptive graph convolution to capture spatial dependencies. In terms of capturing temporal dependencies, multi-scale one-dimensional dilated convolution is used to achieve good prediction results.
[0004] However, the above method has the following problems: the construction of the graph adjacency matrix depends on prior conditions such as node distance, and this type of adjacency matrix has a weak ability to represent node connections. Although there are models that use adaptive adjacency matrices to capture deep spatial dependencies between nodes, the origin-destination traffic flow prediction problem has its own characteristics, that is, the origin-destination traffic flow data has two dimensions, the starting point and the end point, and the graph convolution of a single dimension cannot fully capture the different spatial dependencies of the nodes when they are the starting point and the end point; in addition, many articles use LSTM or GRU to capture the time dependency of traffic flow data. This type of method designs multiple gates in order to obtain long-term and short-term time dependencies, but the complex gating mechanism makes the time cost of model training large. Therefore, the present invention proposes a method for predicting origin-destination traffic flow based on adaptive two-dimensional graph convolution, which uses adaptive two-dimensional graph convolution to capture spatial dependencies, and on this basis, it is stacked with a multi-layer temporal convolution network to comprehensively capture the spatiotemporal dependencies between the origin-destination traffic flow data. Summary of the invention
[0005] In response to the above technical problems, the technical problem that the present invention intends to solve is to propose a method for predicting origin-destination traffic flow based on adaptive two-dimensional graph convolution. This method establishes adaptive adjacency matrices in the starting point dimension and the end point dimension respectively, and performs graph convolution on the origin-destination traffic flow data from two perspectives, so as to fully capture the different spatial dependencies of the nodes when they are the starting point and the end point; and uses a temporal convolutional network to capture the temporal dependencies between data in different time slices, so as to fully capture the spatiotemporal dependencies of the origin-destination traffic flow data, thereby improving the prediction accuracy.
[0006] There are two core innovations in this application: First, an adaptive two-dimensional graph convolution is proposed to capture spatial dependencies. The specific approach is to establish a node embedding matrix in the two dimensions of the starting point and the end point; use the node embedding matrix in the two dimensions of the starting point and the end point to construct an adaptive adjacency matrix in the two dimensions of the starting point and the end point; and perform adaptive two-dimensional graph convolution on the traffic flow data of the starting and ending points from two perspectives. Second, the adaptive two-dimensional graph convolution and the temporal convolution network are stacked in multiple layers, and residual connections are used to prevent overfitting. On this basis, a spatiotemporal convolution block is constructed to capture both spatial and temporal dependencies.
[0007] The technical solution adopted by the present invention to solve the technical problem is:
[0008] A method for predicting traffic flow at origin and destination points based on adaptive two-dimensional graph convolution, the prediction method comprising the following contents:
[0009] S1. According to the county-level administrative divisions in the actual scenario, the entire research scope is divided into N areas. According to the entrance toll station number and exit toll station number in the original data table collected by the monitoring points in the area, as well as the basic information table of the toll station, the starting area number and the end area number of each trip are determined, and the time slice number is determined according to the time of entering the entrance toll station; initialized as a three-dimensional tensor of all zeros, traverse each record in the original data table, determine the starting area number, end area number and time slice number corresponding to each record, and add one to the element value of the corresponding position in the three-dimensional tensor until all records in the entire original data table are traversed. The final three-dimensional tensor is the constructed start-end point traffic flow dataset;
[0010] S2. Construct an origin-destination traffic flow prediction model based on adaptive two-dimensional graph convolution:
[0011] The origin-destination traffic flow prediction model based on adaptive two-dimensional graph convolution includes multiple layers of stacked spatiotemporal convolution blocks and two-dimensional convolution layers, wherein the multiple layers of stacked spatiotemporal convolution blocks are sequentially connected in series, and the output of the last spatiotemporal convolution block is connected to the two-dimensional convolution layer; the convolution kernel size of the two-dimensional convolution layer is set to (T-τ+1)×F, wherein τ represents the number of time slices output by the model, and T represents the number of time slices input by the model; F represents the feature dimension of the hidden layer node, and the hidden layer is a layered structure in the model except for the input and output, which includes the layered structure composed of the adaptive two-dimensional graph convolution module and the time convolution module introduced below;
[0012] All spatiotemporal convolution blocks have the same structure. Each spatiotemporal convolution block includes a series structure consisting of T adaptive two-dimensional graph convolution modules 2D-AGCN and a temporal convolution module TCN connected in series. The traffic flow data of the starting and ending points of each time slice is connected to the input of the temporal convolution module TCN through an adaptive two-dimensional graph convolution module 2D-AGCN, and the input of the temporal convolution module TCN is T. The number of the series structures is M, where M is an integer not less than 1. The outputs of all series structures are subjected to matrix addition operation with the input of the first series structure to form a residual connection. The result after the residual connection is the output of the spatiotemporal convolution block.
[0013] The adaptive two-dimensional graph convolution module performs graph convolution operations in two dimensions, the starting point and the end point;
[0014] S3. Model training: Divide the origin-destination traffic flow data set into training set, validation set and test set in proportion. Update the model parameters on the training set and validation set. The model with the minimum loss is the optimal model, which is used for origin-destination traffic flow prediction.
[0015] The construction process of the origin-destination traffic flow dataset is as follows:
[0016] S1.1. Based on the county-level administrative divisions in the actual scenario, the entire research scope is divided into N areas. A certain number of sensors are arranged at the entrance toll station and the exit toll station in each area to collect the original data table of the corresponding location. The key fields of the original data table are the trip number pass_id. The vehicle is called a trip from entering the entrance toll station to exiting the exit toll station. pass_id is the unique identifier of the trip; the entrance toll station number start_sta_id; the exit toll station number end_sta_id; the start time start_time, which indicates the time when the vehicle enters the entrance toll station;
[0017] S1.2. Obtain the basic information table of the toll station, and construct a mapping from the toll station number to the area number based on the basic information table of the toll station, recorded as dict_l. The specific method is: the key fields in the basic information table of the toll station are the toll station number sta_id, the longitude lng of the toll station, and the latitude lat of the toll station. Use ArcGIS software to perform spatial analysis, and project the toll station location into the corresponding county-level administrative division area based on the longitude and latitude of the toll station. Then, add the area number of the area to which the toll station belongs as a field value to the basic information table of the toll station, thereby completing the establishment of the mapping;
[0018] S1.3. Construct a mapping from the start time to the time slice number, recorded as dict_2. The specific method is: take the earliest time in the original data table as the time starting point, set the time slice length to s minutes, and each s minutes as a time slice, and divide it into A time slice is defined, and the time slice number corresponding to the start time is determined by defining the time range of the time slice in which the start time falls, thereby completing the establishment of the mapping;
[0019] S1.4. By traversing the original data table and using the two mappings established in the first two steps, construct the origin and destination traffic flow dataset, specifically:
[0020] Initialize the three-dimensional tensor χ to all zeros, where the three-dimensional tensor The first dimension represents the starting point dimension, the second dimension represents the end point dimension, and the third dimension represents the time dimension. Indicates the number of time slices divided according to the time span of the original data table;
[0021] Then, we traverse each record in the original data table, and get the start area number start_area_id corresponding to the record according to start_sta_id and dict_1, get the end area number end_area_id corresponding to the record according to end_sta_id and dict_1, and get the time slice number time_id corresponding to the record according to start_time and dict_2. Then the element x in the tensor χ is start_area_idend_areaid,time_id The value of is increased by one; repeat this step until all records in the original data table are traversed, and the final three-dimensional tensor is the constructed origin and destination traffic flow dataset;
[0022] The traffic flow data of the starting and ending points in time slices constitute the traffic flow data set of the starting and ending points. The data of T time slices are selected from the data set as a sample as the input of the model, and the data of each time slice are input into the 2D-AGCN.
[0023] The acquisition process of the adaptive two-dimensional graph convolution module is: abstracting the areas in the actual scene into nodes in the graph structure, abstracting the traffic network composed of all areas in the entire research scope, and expressing it as a graph structure. Then, the areas in the actual scene correspond to the nodes in the graph structure one by one, and the following formula is used to express the traffic network composed of the areas divided in the scene:
[0024]
[0025] Where V represents the node set, that is, the divided area set; v∈V represents the node, that is, a certain area; |V|=N represents the number of nodes, that is, the number of areas, the number of nodes is the same as the number of areas; ε represents the edge set in the transportation network; Represents the adjacency matrix in the traffic network. The element a in the i-th row and j-th column of the adjacency matrix is ij Represents node v i With node v j Degree of association;
[0026] Use the softmax function and ReLU function for normalization and build an adaptive adjacency matrix from the starting point
[0027]
[0028] in, represents the embedding matrix of N nodes in the graph, and d represents the dimension of node embedding; Indicates E O The transposed matrix of
[0029] Use the softmax function and ReLU function for normalization and build an adaptive adjacency matrix from the end point perspective
[0030]
[0031] in, Represents the embedding matrix of N nodes in the graph, and d is the dimension of node embedding; Indicates E D The transposed matrix of
[0032] At the same time, an adaptive two-dimensional graph convolution operation is performed on the input origin and destination traffic flow data, which is expressed by formula (6):
[0033]
[0034] in, Represent the input and output of the adaptive 2D graph convolution module respectively; represents the parameter matrix; represents the bias matrix; σ(·) represents the sigmoid function; × O Represents graph convolution at the starting dimension; × D Represents graph convolution at the end dimension; × c Represents convolution in the feature dimension; denote the adaptive adjacency matrices of the starting point and the end point respectively; d denotes the dimension of node embedding; Represent the embedding matrices of the starting point and the end point respectively.
[0035] The number of the series structures is 2, and the spatiotemporal convolution block uses the traffic flow data of the starting and ending points of T time slices in history {X1, X2, ..., X T} is the input, and a copy of the input is made. The two copies of the input have different data flows:
[0036] One of the inputs first captures the spatial dependency, and the data of each time slice is input into the adaptive two-dimensional graph convolution module for processing; then the output As the input of the temporal convolution module, perform temporal convolution to capture its temporal dependency; repeat the above steps once, that is, stack the adaptive 2D graph convolution module and the temporal convolution module twice;
[0037] The other input does not undergo convolution operation, but performs matrix addition operation with the result of two stacking operations to form a residual connection. Finally, the output of the spatiotemporal convolution block is
[0038] The present invention also protects a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the prediction method can be implemented.
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] The method for predicting the traffic flow at the origin and destination points based on adaptive two-dimensional graph convolution in the present invention generates the starting point embedding matrix and the end point embedding matrix in the starting point dimension and the end point dimension of the traffic flow data at the origin and destination point, respectively. On this basis, an adaptive adjacency matrix of the starting point and the end point dimension is established. By performing graph convolution in two dimensions, the different spatial dependencies of the nodes when they are respectively used as the starting point and the end point are fully captured. To verify the effectiveness of this method, relevant experiments were conducted on the traffic flow data set at the origin and destination points. The experiments showed that compared with other similar models, this model can achieve better prediction results. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a flow chart of the method for predicting the traffic flow at the origin and destination points based on adaptive two-dimensional graph convolution of the present invention;
[0042] Figure 2 Schematic diagram of the process of constructing a data set in the present invention;
[0043] Figure 3 Schematic diagram of the structure of the adaptive two-dimensional graph convolution module in the present invention;
[0044] Figure 4 Schematic diagram of the structure of the temporal convolutional network in the present invention;
[0045] Figure 5 It is a structural schematic diagram of the origin-destination traffic flow prediction model based on adaptive two-dimensional graph convolution in the present invention;
[0046] Figure 6 This is a graph showing the loss decrease during the model training process of the present invention. DETAILED DESCRIPTION
[0047] The specific implementation of the present invention will be described below in conjunction with the accompanying drawings.
[0048] The present invention provides a method for predicting traffic flow at origin and destination points based on adaptive two-dimensional graph convolution (see Figure 1 ), including the following steps:
[0049] S1. Constructing the start-end point traffic flow data set: Divide the area within the research scope, set up monitoring sensors in the traffic network within the area, collect vehicle trip information (for example: entrance toll station, exit toll station, time of entering the entrance toll station, time of leaving the exit toll station, trip number, etc.), pre-process the collected data, determine the start and end areas of the trip according to the entrance toll station and the exit toll station, determine the time slice according to the start time, and construct the start-end point traffic flow data set by accumulating the traffic flow from the start area to the end area in a certain time slice;
[0050] S2. Construct an adaptive two-dimensional graph convolution module: establish adaptive adjacency matrices at the starting point and the end point respectively, and perform graph convolution operations in the two dimensions of the starting point and the end point to capture the different spatial dependencies of the nodes when they are the starting point and the end point respectively;
[0051] S3. Construct a time convolution module: aggregate historical information of different time slices to capture the time dependency of the traffic data at the origin and destination points;
[0052] S4. Constructing a spatiotemporal convolution block: stacking the adaptive two-dimensional graph convolution module and the temporal convolution module in multiple layers, and capturing the temporal and spatial dependencies of the traffic flow data at the origin and destination points;
[0053] S5. Construct an origin-destination traffic flow prediction model based on adaptive two-dimensional graph convolution: stack multiple layers of spatiotemporal convolution blocks to fully capture the deep spatiotemporal dependency of the origin-destination traffic flow data; set a two-dimensional convolution layer to process the time dimension and node feature dimension into preset values;
[0054] S6. Model training optimization and evaluation: Divide the origin-destination traffic flow dataset into training set, validation set and test set in proportion. Update the model parameters on the training set and validation set. The model with the minimum loss is the optimal model.
[0055] Furthermore, step S1 specifically includes the following steps:
[0056] S1.1. Based on the county-level administrative divisions in the actual scenario, the entire research scope is divided into N areas, where N represents the number of areas divided according to the county-level administrative divisions. In this actual scenario, a province is selected as the entire research scope. The number of areas divided is the same as the number of county-level administrative divisions in the province, that is, N is obtained based on the division. A certain number of sensors are arranged at the entrance toll station and exit toll station in each area to collect the original data table at the corresponding location. The key fields include the trip number pass_id. A vehicle is called a trip from entering the entrance toll station to exiting the exit toll station, and pass_id is the unique identifier of the trip; the entrance toll station number start_sta_id; the exit toll station number end_sta_id; the starting time start_time, which represents the time when the vehicle enters the entrance toll station.
[0057] S1.2. Construct a mapping from toll station number to area number based on the toll station basic information table (recorded as dict_1). The specific method is: the key fields in the toll station basic information table are the toll station number sta_id, the toll station longitude lng and the toll station latitude lat. Use ArcGIS software for spatial analysis. According to the longitude and latitude of the toll station, project the toll station location into the corresponding county-level administrative division area, and then add the area number of the area to which the toll station belongs as a field value to the toll station basic information table to complete the establishment of the mapping.
[0058] S1.3. Construct a mapping from the start time to the time slice number (recorded as dict_2). The specific method is: take the earliest time 2021-01-01 00:00:00 in the original data table as the time starting point, and every 5 minutes as a time slice. For example, 2021-01-01 00:00:00 to 2021-01-01 00:00:05 is the first time slice, 2021-01-01 00:00:06 to 2021-01-01 00:00:10 is the second time slice, and so on. There are a total of The mapping is established by defining the time range of the time slice in which the start time is located to determine the time slice number corresponding to the start time.
[0059] S1.4. By traversing the original data table and using the two mappings established in the first two steps, construct the origin-destination traffic flow dataset. The specific method is:
[0060] First, initialize the dataset to a three-dimensional tensor χ of all zeros:
[0061]
[0062] Among them, the tensor The first dimension represents the starting point dimension, the second dimension represents the end point dimension, and the third dimension represents the time dimension. Indicates the number of time slices divided according to the time span of the original data table, X t Represents the data of the tth time slice, and its detailed expression is:
[0063]
[0064] Among them, x i,j,t It represents the traffic flow from the i-th area to the j-th area in the t-th time slice.
[0065] Then, we traverse each record in the original data table, and get the corresponding starting area number start_area_id according to start_sta_id and dict_1, get the corresponding end area number end_area_id according to end_sta_id and dict_1, and get the corresponding time slice number time_id according to start_time and dict_2. Then the element x in the tensor χ is start_area_id,end_area_id,time_id The value of is increased by 1. Repeat this step until all records in the original data table are traversed, and the final three-dimensional tensor is the constructed origin and destination traffic flow dataset.
[0066] Furthermore, step S2 specifically includes the following steps:
[0067] S2.1. This model abstracts the regions in the actual scene into nodes in the graph structure. The transportation network composed of all regions in the entire research scope is abstracted and represented as a graph structure. The regions in the actual scene correspond to the nodes in the graph structure one by one. The following formula is used to represent the abstract transportation network of the regions in the scene:
[0068]
[0069] Where V represents a node set, i.e., a region set; v∈V represents a node, i.e., a region; |V|=N represents the number of nodes, i.e., the number of regions; ε represents the edge set in the traffic network. If there is a road connection or a short distance between regions, there is an edge between two nodes. The existence of an edge indicates that there is a correlation between the two nodes. Represents the adjacency matrix in the traffic network. The element a in the i-th row and j-th column of the adjacency matrix is ij Represents node v i With node v j Degree of association;
[0070] S2.2. Use the following formula, use the softmax function and ReLU function for normalization, and establish an adaptive adjacency matrix from the starting point
[0071]
[0072] in, represents the embedding matrix of N nodes in the graph, and d represents the dimension of node embedding; Indicates E O The transposed matrix of
[0073] S2.3. Use the following formula, use the softmax function and ReLU function for normalization, and establish an adaptive adjacency matrix from the end point perspective:
[0074]
[0075] in, Represents the embedding matrix of N nodes in the graph, and d is the dimension of node embedding; Indicates E D The transposed matrix of .
[0076] S2.4. Use the following formula to perform adaptive two-dimensional graph convolution operation on the input origin and destination traffic flow data:
[0077]
[0078] in, Represent the input and output of the adaptive two-dimensional graph convolution respectively; represents the parameter matrix; represents the bias matrix; σ(·) represents the sigmoid function; × O Represents graph convolution at the starting dimension; × D Represents graph convolution at the end dimension; × C Represents convolution on the node feature dimension. F represents the node feature dimension of the hidden layer.
[0079] Furthermore, step S3 specifically includes the following steps:
[0080] S3.1. To keep the number of output time slices consistent with the number of input time slices, padding mode is used to fill the input;
[0081] S3.2. Use the following formula to perform convolution operation on historical multiple time slice data:
[0082]
[0083] in They represent the traffic flow data of the starting and ending points of the l-th layer and the l+1-th layer respectively; α kRepresents the weight parameter. K is the size of the convolution kernel, which indicates the number of time slices of historical data aggregated by the current time slice data.
[0084] Furthermore, step S4 specifically includes the following steps:
[0085] S4.1. Stack the adaptive 2D graph convolution module and the temporal convolution module;
[0086] S4.2. A residual connection is set at the outermost layer of the temporal convolution block, and the residual connection inside the spatiotemporal convolution block is expressed by the following formula:
[0087] H out =F(H in )+H in (8),
[0088] Among them, H in ,H out denote the input and output of the spatiotemporal convolutional block respectively; F(·) denotes a stacked multi-layer convolution operation.
[0089] Furthermore, step S5 specifically includes the following steps:
[0090] S5.1. Stack the spatiotemporal convolution blocks to fully explore the deep spatiotemporal dependency relationship within the origin-destination traffic flow data;
[0091] S5.2. Set a two-dimensional convolution layer at the end of the model to perform convolution operations on the data in the time dimension and the node feature dimension so that the output data reaches the expected amount in two dimensions.
[0092] Furthermore, step S6 specifically includes the following steps:
[0093] S6.1. Divide the dataset into training set, validation set and test set in a ratio of 6:2:2;
[0094] S6.2. Input the training set and validation set into the model for training;
[0095] S6.3. The loss is calculated based on the predicted value and the actual value using the following formula:
[0096]
[0097] Among them, Y, Represent the actual value and the predicted value of the model respectively; MAE represents the mean absolute error.
[0098] Furthermore, metrics that describe the prediction accuracy of the model include: mean absolute error (MAE) and root mean square error (RMSE).
[0099] Example
[0100] The specific implementation of the present invention uses 15 days of toll data of a certain province's expressway to construct a start-end point traffic flow data set, and uses an start-end point traffic flow prediction method based on adaptive two-dimensional graph convolution to predict the start-end point traffic flow. The specific implementation steps are as follows:
[0101] 1. According to the county-level administrative divisions in the actual scenario, the entire research scope is divided into N areas. N represents the number of areas divided according to the county-level administrative divisions. In this actual scenario, a province is selected as the entire research scope. The number of divided areas is the same as the number of county-level administrative divisions in the province, that is, N is obtained based on the division. The final number of divided areas is 160, that is, N = 160. A certain number of sensors are arranged at the entrance and exit toll stations in each area to collect the original data table of the corresponding location. The sample data of some fields are shown in Table 1:
[0102] Table 1. Raw data table example data
[0103]
[0104] Among them, pass_id is the trip number. A trip is from the time the vehicle enters the entrance toll station to the time it exits the exit toll station. pass_id is the unique identifier of the trip; start_sta_id indicates the entrance toll station number; end_sta_id indicates the exit toll station number; start_time is the starting time, indicating the time when the vehicle enters the entrance toll station.
[0105] On this basis, the process of constructing the data set is as follows: Figure 2 As shown, the key steps are described in turn below:
[0106] First, according to the basic information table of toll stations (the sample data of some fields are shown in Table 2), a mapping from toll station number to area number (denoted as dict_1) is constructed. The specific method is: use ArcGIS software for spatial analysis, and project the toll station location into the corresponding county-level administrative area according to the longitude and latitude (longitude lng, latitude lat) of the toll station. Then, add the area number of the area to which the toll station belongs as a field value to the basic information table of the toll station, thereby completing the establishment of the mapping.
[0107] Table 2 Example data of basic information table of toll station
[0108]
[0109] Then, a mapping from the start time to the time slice number is constructed (recorded as dict_2). The specific method is: take the earliest time 2021-01-01 00:00:00 in the original data table as the time starting point, and every 5 minutes as a time slice, for example, 2021-01-01 00:00:00 to 2021-01-01 00:00:05 is the first time slice, 2021-01-01 00:00:06 to 2021-01-01 00:00:10 is the second time slice, and so on. By defining the time range in which the start time is located, the time slice number corresponding to the start time is determined, thereby completing the establishment of the mapping.
[0110] Finally, we construct the dataset by traversing the original data table and using the two mappings established in the first two steps. The specific method is: initialize the dataset to a three-dimensional tensor χ of all zeros:
[0111]
[0112] Among them, the tensor The first dimension represents the starting point dimension, the second dimension represents the end point dimension, and the third dimension represents the time dimension. Indicates the number of time slices divided according to the time span of the original data table, X t Represents the data of the tth time slice, and its detailed expression is:
[0113]
[0114] Among them, x i,j,t It represents the traffic flow from the i-th area to the j-th area in the t-th time slice.
[0115] Traverse each record in the original data table, get the start area number start_area_id corresponding to the record according to start_sta_id and dict_1, get the end area number end_area_id corresponding to the record according to end_sta_id and dict_1, get the time slice number time_id corresponding to the record according to start_time and dict_2, add one to the element value at the corresponding position in the three-dimensional tensor, then the element x in the tensor x start_area_id,end_area_id,time_id The value of is increased by 1. Repeat this step until all records in the original data table are traversed, and the data set is constructed.
[0116] 2. Construct an adaptive two-dimensional graph convolution module:
[0117] This model abstracts the regions in the actual scene into nodes in the graph structure. The transportation network composed of all regions in the entire research scope is abstracted and represented as a graph structure. The regions in the actual scene correspond to the nodes in the graph structure one by one. The following formula is used to represent the abstract transportation network of the regions in the scene:
[0118]
[0119] Where V represents a node set, i.e., a region set; v∈V represents a node, i.e., a region; |V|=N represents the number of nodes, i.e., the number of regions; ε represents the edge set in the traffic network. If there is a road connection or a short distance between regions, there is an edge between two nodes. The existence of an edge indicates that there is a correlation between the two nodes. Represents the adjacency matrix in the traffic network. The element a in the i-th row and j-th column of the adjacency matrix is ij Represents node v i With node v j Degree of association;
[0120] As attached Figure 3 As shown in the figure, nodes are embedded in the starting point and end point dimensions respectively, and on this basis, an adaptive adjacency matrix of the starting point and end point dimensions is constructed, which is specifically expressed as:
[0121]
[0122]
[0123] in, They represent the embedding matrices of the starting point and the end point respectively. The two embedding matrices are similar to parameter matrices and are independent of the data set. They are initialized during model training and are continuously optimized through training. d represents the dimension of node embedding and takes a value of 16. Represent the adaptive adjacency matrices of the start and end points respectively.
[0124] On this basis, an adaptive two-dimensional graph convolution operation 2D-AGCN is performed on the input origin and destination traffic flow data:
[0125]
[0126] in, They represent the input and output of the adaptive 2D graph convolution, X in is the data of a certain time slice in the data set; represents the parameter matrix; F represents the feature dimension of the hidden layer node, and its value is 16; represents the bias matrix; σ(·) represents the activation function, using the sigmoid function; since X inIt has two dimensions, the starting point and the end point, and needs to perform graph convolution operations in two dimensions, × O Represents graph convolution at the starting dimension; × D Represents graph convolution at the end dimension; × c It represents convolution (matrix multiplication) in the feature dimension. It can be seen that the adaptive two-dimensional graph convolution module performs graph convolution operations in the two dimensions of the starting point and the end point, capturing the spatial dependency relationship of the traffic flow data at the starting and ending points from two perspectives, and enhancing the model's ability to represent the spatial connection between nodes.
[0127] 3. Construct the time convolution module TCN:
[0128] As attached Figure 4 As shown, a temporal convolutional network is used. The temporal convolutional network has been used in many related articles. However, the use of the temporal convolutional network requires setting the convolution kernel size K and the padding value. This embodiment conducts preliminary experiments on different values of the two parameters on a small amount of data. By comparing the results of the preliminary experiments, the method of taking K as 3 and padding as 2 is finally adopted to perform convolution operations on multiple historical time slice data in the time dimension:
[0129]
[0130] in, They represent the traffic flow data of the starting and ending points of the l-th layer and the l+1-th layer respectively; α k represents the weight coefficient; K represents the convolution kernel size and its value is 3.
[0131] Since each time slice of the temporal convolutional network is generated by convolution of the previous layer of historical data, the number of time slices will be reduced. Therefore, a padding mechanism is introduced to fill the data in the time dimension so that the number of input time slices is consistent with the number of output time slices. The padding value needs to correspond to the value of K, and the padding value is 2.
[0132] 4. Construct spatiotemporal convolution blocks:
[0133] In order to comprehensively capture the spatial and temporal dependencies of the traffic flow data at the origin and destination points, the adaptive two-dimensional graph convolution module and the temporal convolution module are stacked. Inside each spatiotemporal convolution block, the adaptive two-dimensional graph convolution module 2D-AGCN is stacked twice in the order of the temporal convolution module TCN. In order to prevent problems such as gradient disappearance or network degradation caused by stacking multiple layers of convolution blocks, residual connections are used in the outermost layer of the spatiotemporal convolution block to streamline the neural network, reduce the space overhead of model training, and reduce the number of parameters. The training time is also effectively shortened, which improves the efficiency of the entire model training. The residual connection is represented as follows:
[0134] H out =F(H in )+H in (8)
[0135] Among them, H in , H out They represent the input and output of the spatiotemporal convolutional block respectively; F(·) represents the operation of stacking multiple layers of convolutional blocks.
[0136] The overall structure of the spatiotemporal convolution block is shown in the attached figure. Figure 5 The spatiotemporal convolution block uses the traffic flow data of the starting and ending points of T time slices in history {X1, X2, ..., X T | is the input, and the input is copied. The two inputs have different data flows. One of the inputs first captures the spatial dependency and performs adaptive two-dimensional graph convolution operations on the data of each time slice; then the output As the input of the temporal convolution module, a temporal convolution is performed to capture its temporal dependency; this step is repeated once, that is, the adaptive two-dimensional graph convolution module and the temporal convolution module are stacked twice. The other input does not undergo convolution operation, but performs matrix addition operation with the result of the above operation to form a residual connection. The final output of the spatiotemporal convolution block is
[0137] 5. Construct an origin-destination traffic flow prediction model based on adaptive two-dimensional graph convolution:
[0138] As attached Figure 5 As shown in the figure, in order to fully explore the deep spatiotemporal dependency of the traffic flow data at the origin and destination points, the model stacks two layers of spatiotemporal convolution blocks, and the two spatiotemporal convolution blocks are connected in series. On this basis, a two-dimensional convolution layer is set at the end of the model, as shown in the figure. Figure 4 As shown, the input of this two-dimensional convolutional layer is:
[0139]
[0140] Where: N represents the number of nodes, T represents the number of time slices of the model input, and F represents the node feature dimension of the hidden layer;
[0141] The output of the convolutional layer is:
[0142]
[0143] Where N represents the number of nodes, T represents the number of time slices of model input, and τ represents the number of time slices of model output;
[0144] To obtain this output, the convolution kernel size of the two-dimensional convolution layer is set to (T-τ+1)×F, and convolution operations are performed on the data in the time dimension and the node feature dimension so that the output data reaches the expected amount in two dimensions.
[0145] 6. Model training:
[0146] First, the origin-destination traffic flow dataset is divided into training set, validation set and test set in a ratio of 6:2:2. The training set and validation set are input into the origin-destination traffic flow prediction model based on adaptive two-dimensional graph convolution, and normalization is used to reduce the impact of data dimension on the prediction results. MAE is used as the loss function during training:
[0147]
[0148] Among them, Y, Represent the actual value and the predicted value of the model respectively; MAE represents the mean absolute error.
[0149] The experimental parameter settings are shown in Table 3.
[0150] Table 3 Experimental parameter settings
[0151]
[0152]
[0153] The loss decrease during training is shown in the following figure. Figure 5 shown.
[0154] The present invention selects mean absolute error (MAE) and root mean square error (RMSE) as metrics to describe prediction accuracy:
[0155]
[0156]
[0157] in, Represents the predicted value, y i represents the actual value, n represents the number of data, and takes the value of N×N×τ. The smaller the value of the evaluation index, the better the performance of the model.
[0158] In order to explore the advantages of the model proposed in this invention in the task of predicting the traffic flow at the origin and destination, the following methods are selected for comparison:
[0159] (1) ARIMA (Autoregression Integrated Moving Average): A classic time series prediction model that has high requirements for the stability of input data.
[0160] (2) GRU (Gated Recurrent Unit): A variant of recurrent neural network used for time series prediction. It does not consider the spatial dependency between nodes and uses two GRU layers to capture the temporal dependency.
[0161] (3) STGCN: A traffic prediction model that uses a sandwich-like spatiotemporal convolutional block with two gated time series convolutional blocks and one graph convolutional block;
[0162] (4) AGCRN: A prediction model that uses adaptive graph convolution for traffic prediction.
[0163] The performance comparison of the model proposed in the present invention and the above four models is shown in Table 4:
[0164] Table 4 Model performance comparison
[0165]
[0166] It can be seen from the table that the origin-destination traffic flow prediction method based on adaptive two-dimensional graph convolution proposed in the present invention has achieved obvious advantages in the metrics MAE and RMSE compared with ARIMA, GRU, STGCN, and AGCRN. The experimental comparative analysis shows the scientificity and effectiveness of the origin-destination traffic flow prediction method based on adaptive two-dimensional graph convolution proposed in the present invention.
[0167] This specification describes the technical solution of the present invention in detail, and further explains the core idea and effectiveness of the present invention by using specific implementation methods. The above description of the implementation methods is only used to help understand the principle of the present invention. For researchers in any related field, modifications and replacements in design solutions and application scenarios are all within the scope of protection of the present invention. In short, the contents of this specification are not intended to limit the present invention.
[0168] Any matters not described in the present invention are applicable to the prior art.
Claims
1. A method for predicting traffic flow at origin and destination points based on adaptive two-dimensional graph convolution. It is characterized in that The prediction method includes the following contents: S1. According to the county-level administrative divisions in the actual scenario, the entire research scope is divided into N areas. According to the entrance toll station number and exit toll station number in the original data table collected by the monitoring points in the area, as well as the basic information table of the toll station, the starting area number and the end area number of each trip are determined, and the time slice number is determined according to the time of entering the entrance toll station; initialized as a three-dimensional tensor of all zeros, traverse each record in the original data table, determine the starting area number, end area number and time slice number corresponding to each record, and add one to the element value of the corresponding position in the three-dimensional tensor until all records in the entire original data table are traversed. The final three-dimensional tensor is the constructed start-end point traffic flow dataset; S2. Construct an origin-destination traffic flow prediction model based on adaptive two-dimensional graph convolution: The origin-destination traffic flow prediction model based on adaptive two-dimensional graph convolution includes multiple layers of stacked spatiotemporal convolution blocks and two-dimensional convolution layers, wherein the multiple layers of stacked spatiotemporal convolution blocks are sequentially connected in series, and the output of the last spatiotemporal convolution block is connected to the two-dimensional convolution layer; the convolution kernel size of the two-dimensional convolution layer is set to (T-τ+1)×F, wherein τ represents the number of time slices output by the model, and T represents the number of time slices input by the model; F represents the feature dimension of the hidden layer node, and the hidden layer is a layered structure in the model except for the input and output; All spatiotemporal convolution blocks have the same structure. Each spatiotemporal convolution block includes a series structure consisting of T adaptive two-dimensional graph convolution modules 2D-AGCN and a temporal convolution module TCN connected in series. The traffic flow data of the starting and ending points of each time slice is connected to the input of the temporal convolution module TCN through an adaptive two-dimensional graph convolution module 2D-AGCN, and the input of the temporal convolution module TCN is T. The number of the series structures is M, where M is an integer not less than 1. The outputs of all series structures are subjected to matrix addition operation with the input of the first series structure to form a residual connection. The result after the residual connection is the output of the spatiotemporal convolution block. The adaptive two-dimensional graph convolution module performs graph convolution operations in two dimensions, the starting point and the end point; S3. Model training: Divide the origin-destination traffic flow dataset into training set, validation set, and test set in proportion. Update the model parameters on the training set and validation set. The model with the minimum loss is the optimal model, which is used for origin-destination traffic flow prediction.
2. According to claim 1, the method for predicting the traffic flow at the origin and destination points based on adaptive two-dimensional graph convolution, It is characterized in that The construction process of the origin-destination traffic flow dataset is as follows: S1.
1. Based on the county-level administrative divisions in the actual scenario, the entire research scope is divided into N areas. A certain number of sensors are arranged at the entrance toll station and the exit toll station in each area to collect the original data table of the corresponding location. The key fields of the original data table are the trip number pass_id. The vehicle is called a trip from entering the entrance toll station to exiting the exit toll station. pass_id is the unique identifier of the trip; the entrance toll station number start_sta_id; the exit toll station number end_sta_id; the start time start_time, which indicates the time when the vehicle enters the entrance toll station; S1.
2. Obtain the basic information table of the toll station, and construct a mapping from the toll station number to the area number based on the basic information table of the toll station, recorded as dict_1. The specific method is: the key fields in the basic information table of the toll station are the toll station number sta_id, the longitude lng of the toll station, and the latitude lat of the toll station. Use ArcGIS software to perform spatial analysis, and project the toll station location into the corresponding county-level administrative division area based on the longitude and latitude of the toll station. Then, add the area number of the area to which the toll station belongs as a field value to the basic information table of the toll station, thereby completing the establishment of the mapping; S1.
3. Construct a mapping from the start time to the time slice number, recorded as dict_2. The specific method is: take the earliest time in the original data table as the time starting point, set the time slice length to s minutes, and each s minutes as a time slice, and divide it into A time slice is defined, and the time slice number corresponding to the start time is determined by defining the time range of the time slice in which the start time falls, thereby completing the establishment of the mapping; S1.
4. By traversing the original data table and using the two mappings established in the first two steps, construct the origin and destination traffic flow dataset, specifically: Initialize a 3D tensor of all zeros Among them, the three-dimensional tensor The first dimension represents the starting point dimension, the second dimension represents the end point dimension, and the third dimension represents the time dimension. Indicates the number of time slices divided according to the time span of the original data table; Then, traverse each record in the original data table, get the starting area number start_area_id corresponding to the record according to start_sta_id and dict_1, get the end area number end_area_id corresponding to the record according to end_sta_id and dict_1, get the time slice number time_id corresponding to the record according to start_time and dict_2, then the tensor The element x in start_area_id,end_area_id,time_id The value of is increased by one; repeat this step until all records in the original data table are traversed, and the final three-dimensional tensor is the constructed origin and destination traffic flow dataset; The traffic flow data of the starting and ending points in time slices constitute the traffic flow data set of the starting and ending points. The data of T time slices are selected from the data set as a sample as the input of the model, and the data of each time slice are input into the 2D-AGCN respectively.
3. According to claim 1, the method for predicting traffic flow at the origin and destination points based on adaptive two-dimensional graph convolution, It is characterized in that The acquisition process of the adaptive two-dimensional graph convolution module is: abstracting the areas in the actual scene into nodes in the graph structure, abstracting the traffic network composed of all areas in the entire research scope, and expressing it as a graph structure. Then, the areas in the actual scene correspond to the nodes in the graph structure one by one, and the following formula is used to express the traffic network composed of the areas divided in the scene: Where V represents the node set, that is, the divided area set; v∈V represents the node, that is, a certain area; ε represents the edge set in the transportation network; Represents the adjacency matrix in the traffic network. The element a in the i-th row and j-th column of the adjacency matrix is ij Represents node v i With node v j Degree of association, N represents the number of nodes, and the number of nodes is the same as the number of regions; Use the softmax function and ReLU function for normalization and build an adaptive adjacency matrix from the starting point in, represents the embedding matrix of N nodes in the graph, and d represents the dimension of node embedding; Indicates E O The transposed matrix of Use the softmax function and ReLU function for normalization and build an adaptive adjacency matrix from the end point perspective in, Represents the embedding matrix of N nodes in the graph, and d is the dimension of node embedding; Indicates E D The transposed matrix of At the same time, an adaptive two-dimensional graph convolution operation is performed on the input origin and destination traffic flow data, which is expressed by formula (6): in, Represent the input and output of the adaptive 2D graph convolution module respectively; represents the parameter matrix; represents the bias matrix; σ(·) represents the sigmoid function; × O Represents graph convolution at the starting dimension; × D Represents graph convolution at the end dimension; × c Represents convolution in the feature dimension; denote the adaptive adjacency matrices of the starting point and the end point respectively; d denotes the dimension of node embedding; Represent the embedding matrices of the starting point and the end point respectively.
4. The method for predicting traffic flow at origin and destination points based on adaptive two-dimensional graph convolution according to claim 3, It is characterized in that The temporal convolution module TCN adopts a padding mode to fill the input and keep the number of output time slices consistent with the number of input time slices; the convolution operation is performed on multiple historical time slice data using formula (7): in They represent the traffic flow data of the starting and ending points of the l-th layer and the l+1-th layer respectively; α k represents the weight parameter; K is the size of the time convolution kernel, which represents the number of time slices of historical data aggregated by the current time slice data.
5. The method for predicting traffic flow at origin and destination points based on adaptive two-dimensional graph convolution according to claim 4, It is characterized in that The parameters in the origin-destination traffic flow prediction model based on adaptive two-dimensional graph convolution are set as follows: Model parameter settings 6. The method for predicting origin-destination traffic flow based on adaptive two-dimensional graph convolution according to claim 1, It is characterized in that S6.
1. Divide the dataset into training set, validation set and test set in a ratio of 6:2:2; S6.
2. Input the training set and validation set into the model for training; S6.
3. Use the following formula to calculate the loss based on the predicted value and the actual value calculate: Among them, Y, Represent the actual value and the predicted value of the model respectively; MAE represents the mean absolute error; The prediction accuracy metrics of the model include mean absolute error (MAE) and root mean square error (RMSE).
7. The method for predicting origin-destination traffic flow based on adaptive two-dimensional graph convolution according to claim 1, It is characterized in that The number of the series structures is 2, and the spatiotemporal convolution block uses the traffic flow data of the starting and ending points of T time slices in history {X 1 ,X 2 ,…,X T } is the input, and a copy of the input is made. The two copies of the input have different data flows: One of the inputs first captures the spatial dependency, and the data of each time slice is input into the adaptive two-dimensional graph convolution module for processing; then the output As the input of the temporal convolution module, perform temporal convolution to capture its temporal dependency; repeat the above steps once, that is, stack the adaptive 2D graph convolution module and the temporal convolution module twice; The other input does not undergo convolution operation, but performs matrix addition operation with the result of two stacking operations to form a residual connection. Finally, the output of the spatiotemporal convolution block is 8. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the steps of the prediction method described in any one of claims 1 to 7 can be implemented.
