Urban traffic flow prediction method based on graph convolutional network and related equipment
Through the graph-convolution network-based method, the existing traffic flow prediction model is solved, and the problem of difficulty in capturing complex space-time dependence and traffic network structure is achieved, achieving higher prediction accuracy and generalization capabilities.
Patent Information
- Application Number
- CN202411937971.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-03-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing urban traffic flow prediction models are difficult to capture the complex graphical structure and space-time dependence of the transportation network, resulting in limited prediction accuracy and generalization capabilities.
Using a graph convolution network method, by obtaining traffic flow data for multiple historical time periods, the urban area is divided into multiple unit areas, the traffic flow time characteristics are calculated, and the feature calculation is performed using graph convolution network, and traffic flow prediction is finally performed based on these characteristics.
It improves the accuracy and generalization ability of traffic flow prediction, can more effectively capture complex space-time dependence and traffic network structure, and optimizes the prediction results.
Smart Images

Figure CN119723884A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of traffic flow prediction, and in particular to a method and related equipment for predicting urban traffic flow based on a graph convolutional network. Background Art
[0002] With the continuous acceleration of urbanization, urban traffic problems have become increasingly prominent, especially the rapid growth in the number of vehicles, which has brought severe challenges to traffic management. Traffic congestion not only reduces the efficiency of urban operations, but also leads to increased energy consumption and aggravated air pollution. It also has a profound impact on urban planning, public health, and emergency management. In this context, in-depth research on the changing laws of urban traffic flow and the development of efficient and accurate traffic flow prediction models have become the core tasks of smart city construction and traffic management optimization.
[0003] At present, research on urban traffic flow prediction mainly relies on traditional deep learning models. These methods usually divide urban areas into regular grids or standard segments, and try to extract the spatiotemporal characteristics between regions through convolutional neural networks (CNN) or recurrent neural networks (RNN). However, this division method fails to fully consider the non-Euclidean spatial characteristics of the traffic network and ignores the complex graphical structure existing in the real road network. In addition, traditional methods are highly dependent on external factors (such as weather, holidays, major events, etc.) and lack the ability to fully model the high nonlinearity and complexity of traffic flow, resulting in limited accuracy and generalization of prediction results.
[0004] The spatiotemporal characteristics of urban traffic flow have significant dynamic dependencies, that is, the traffic flow changes in a certain area are not only affected by its own historical data, but also closely related to the traffic interactions with other areas and time-periodic changes. This complex spatiotemporal dependency is a key difficulty in traffic flow prediction. Existing models often find it difficult to strike a balance between capturing the spatiotemporal interaction between regions and characterizing the dynamic changes of traffic flow. This results in poor accuracy in traffic flow prediction. Summary of the invention
[0005] The present application provides a method and related equipment for predicting urban traffic flow based on a graph convolutional network, which can solve the problem of poor accuracy of traffic flow prediction.
[0006] In a first aspect, an embodiment of the present application provides a method for predicting urban traffic flow based on a graph convolutional network, and the method for predicting urban traffic flow includes:
[0007] Obtain traffic flow data of the target urban area in multiple historical time periods, and divide the target urban area into unit areas according to multiple division scales;
[0008] For each division scale, the traffic flow time characteristics of the target urban area are calculated based on all traffic flow data and all unit areas under the division scale; the traffic flow time characteristics are used to describe the traffic flow between every two unit areas in each time step after all historical time periods are divided into multiple historical time steps;
[0009] The graph convolutional network is used to calculate the characteristics of each traffic flow time feature, and the final traffic flow characteristics of the target urban area at each division scale are obtained;
[0010] Based on all the final traffic flow characteristics, the predicted traffic flow data of the target urban area at each division scale is obtained, and the target division scale is determined from all the division scales according to all the predicted traffic flow data; the accuracy of the predicted traffic flow data corresponding to the target division scale is higher than the accuracy of the predicted traffic flow data corresponding to other division scales;
[0011] The traffic flow of the urban area to be predicted is predicted according to the target division scale, and the final predicted traffic flow data of the urban area to be predicted is obtained.
[0012] Optionally, the traffic flow time characteristics of the target urban area are calculated based on all traffic flow data and all unit areas under the division scale, including:
[0013] Divide all historical moments into historical time steps according to multiple time division scales;
[0014] Based on the traffic flow data of all historical time periods, the vehicle flow matrix of the target urban area at each time division scale is obtained;
[0015] All vehicle flow matrices are integrated to obtain the time characteristics of traffic flow.
[0016] Optionally, the vehicle flow matrix of the target urban area is:
[0017]
[0018] x rk ={X r,1 ,…,X r,k}∈R l×l×k
[0019] in, Represents the vehicle flow matrix of the target urban area under the a-th time division scale x krepresents the vehicle flow matrix in the first historical time period, x 2k represents the vehicle flow matrix in the second historical period, x dk represents the vehicle flow matrix in the dth historical time period, R m×n×k×d , R l×l×k Both represent dimensions, m×n represents the number of unit areas under the division scale, k represents the number of historical time steps divided into each historical time period, and X r,1 represents the matrix of traffic flow between every two unit areas at the first historical time step in the rth historical time period, X r,k The matrix representing the traffic flow between every two unit areas at the kth historical time step in the rth historical time period, r∈(1,2,...,d), l=m×n.
[0020] Optionally, a graph convolutional network is used to perform feature calculation on each traffic flow time feature to obtain the final traffic flow features of the target urban area at each division scale, including:
[0021] By formula:
[0022] U l+1 =f(φ l *G(U l ))
[0023] Calculate the traffic flow characteristics U of the l+1th layer l+1 ;
[0024] Among them, φ l represents the lth layer convolution kernel, f represents the output function, G represents the input conversion function, U l represents the traffic flow characteristics of the l+1th layer, l=0,1,...,L, L represents the last layer in the graph convolutional network, when l=0, U0 is the traffic flow time characteristic, when l=L, U L+1 is the final traffic flow characteristic.
[0025] Optionally, based on all final traffic flow characteristics, the predicted traffic flow data of the target urban area at each division scale is obtained, including:
[0026] Based on all the final traffic flow features, the multi-head attention mechanism is used to predict traffic flow and obtain the initial predicted traffic flow data of the target urban area at each division scale;
[0027] All the initial predicted traffic flow data are adjusted using the external factors of the target urban area in all historical time periods to obtain the predicted traffic flow data of the target urban area at each division scale.
[0028] Optionally, based on all the final traffic flow features, a multi-head attention mechanism is used to perform traffic flow prediction to obtain the initial predicted traffic flow data of the target urban area at each division scale, including:
[0029] By formula:
[0030] X att =Concat(hrad1,head2,…,head s )W o
[0031] head i =Attention(Q,K,V)
[0032]
[0033] Calculate the initial predicted traffic flow data set X att ;
[0034] Among them, Concat represents the concatenation operation, head1 represents the output of the first attention head, head2 represents the output of the second attention head, and head s represents the output of the sth attention head, head i represents the output of the i-th attention head, i∈(1,2,...,s), W o represents the weight, W Q , W K , W V All represent weight matrices, Attention represents attention calculation, Q represents query vector, K represents key vector, and V represents value vector. represents all final traffic flow characteristics, and E represents the function.
[0035] Optionally, all initial predicted traffic flow data are adjusted using external factors of the target city area in all historical time periods to obtain predicted traffic flow data of the target city area at each division scale, including:
[0036] By formula:
[0037] Y out =Concat(head'1,head'2,...,head' s )W o
[0038] head' i =Attention(Q',K',V')
[0039] Q'=E(X att ⊙X ext )*WQ
[0040] K'=E(X att ⊙X ext )*W K
[0041] V'=E(X att ⊙X ext )*W V
[0042] Calculate the set Y of predicted traffic flow data out ;
[0043] Among them, head'1 represents the output of the first attention head after the introduction of external factors, head'2 represents the output of the second attention head after the introduction of external factors, and head' s represents the output of the sth attention head after the introduction of external factors, head' i represents the output of the i-th attention head after the introduction of external factors, Q' represents the query vector after the introduction of external factors, K' represents the key vector after the introduction of external factors, V' represents the value vector after the introduction of external factors, and X ext Indicates external factors.
[0044] In a second aspect, an embodiment of the present application provides a device for predicting urban traffic flow based on a graph convolutional network, comprising:
[0045] A division module is used to obtain traffic flow data of a target city area in multiple historical time periods, and divide the target city area into unit areas according to multiple division scales;
[0046] The calculation module is used to calculate the traffic flow time characteristics of the target urban area according to all traffic flow data and all unit areas under the division scale for each division scale; the traffic flow time characteristics are used to describe the traffic flow between every two unit areas in each time step after all historical time periods are divided into multiple historical time steps;
[0047] The feature calculation module is used to calculate the feature of each traffic flow time feature using a graph convolutional network to obtain the final traffic flow feature of the target urban area at each division scale;
[0048] A determination module is used to obtain predicted traffic flow data of a target urban area at each division scale based on all final traffic flow characteristics, and determine a target division scale from all division scales based on all predicted traffic flow data; the accuracy of the predicted traffic flow data corresponding to the target division scale is higher than the accuracy of the predicted traffic flow data corresponding to other division scales;
[0049] The traffic flow prediction module is used to predict the traffic flow of the urban area to be predicted according to the target division scale, and obtain the final predicted traffic flow data of the urban area to be predicted.
[0050] In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned urban traffic flow prediction method based on a graph convolutional network when executing the above-mentioned computer program.
[0051] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, it implements the above-mentioned urban traffic flow prediction method based on graph convolutional network.
[0052] The above solution of the present application has the following beneficial effects:
[0053] In an embodiment of the present application, by obtaining the traffic flow data of the target urban area in multiple historical time periods, and dividing the target urban area into unit areas according to multiple division scales, then for each division scale, according to all traffic flow data and all unit areas under the division scale, the traffic flow time characteristics of the target urban area are calculated, and then the graph convolution network is used to perform feature calculation on each traffic flow time characteristic to obtain the final traffic flow characteristics of the target urban area under each division scale, and then based on all the final traffic flow characteristics, the predicted traffic flow data of the target urban area under each division scale is obtained, and the target division scale is determined from all division scales according to all the predicted traffic flow data, and finally the traffic flow prediction is performed on the urban area to be predicted according to the target division scale to obtain the final predicted traffic flow data of the urban area to be predicted. Among them, the use of the graph convolution network to perform feature calculation on the traffic flow time characteristics can effectively perform deep mining and processing on the time dependence of the data, overcome the limitation that the traditional model is difficult to capture complex spatiotemporal associations, and traffic flow prediction based on the final traffic flow characteristics can improve the accuracy of the predicted traffic flow data, and the traffic flow prediction of the urban area to be predicted according to the target division scale can further improve the accuracy of the traffic flow prediction.
[0054] Other beneficial effects of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0056] Figure 1 A flowchart of a method for predicting urban traffic flow based on a graph convolutional network provided in one embodiment of the present application;
[0057] Figure 2 A schematic diagram of the structure of a device for predicting urban traffic flow based on a graph convolutional network provided in one embodiment of the present application;
[0058] Figure 3 A schematic diagram of the structure of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0059] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0060] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0061] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0062] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0063] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0064] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0065] In response to the problem of poor accuracy of existing traffic flow predictions, an embodiment of the present application provides an urban traffic flow prediction method based on a graph convolutional network. The urban traffic flow prediction method obtains traffic flow data of a target urban area in multiple historical time periods, and divides the target urban area into unit areas according to multiple division scales, and then calculates the traffic flow time characteristics of the target urban area for each division scale based on all traffic flow data and all unit areas under the division scale, and then uses the graph convolutional network to perform feature calculations on each traffic flow time feature to obtain the final traffic flow characteristics of the target urban area at each division scale, and then obtains the predicted traffic flow data of the target urban area at each division scale based on all the final traffic flow characteristics, and determines the target division scale from all division scales based on all the predicted traffic flow data, and finally performs traffic flow prediction on the urban area to be predicted according to the target division scale to obtain the final predicted traffic flow data of the urban area to be predicted. Among them, the use of graph convolutional networks to calculate the temporal characteristics of traffic flow can effectively mine and process the time dependence of data in depth, overcoming the limitation of traditional models that it is difficult to capture complex spatiotemporal correlations. Traffic flow prediction based on the final traffic flow characteristics can improve the accuracy of predicted traffic flow data, and traffic flow prediction for the urban area to be predicted according to the target division scale can further improve the accuracy of traffic flow prediction.
[0066] Next, an exemplary description is given of the urban traffic flow prediction method based on graph convolutional network provided in this application.
[0067] like Figure 1 As shown, the urban traffic flow prediction method based on graph convolutional network provided by this application includes the following steps:
[0068] Step 11, obtaining traffic flow data of the target city area in multiple historical time periods, and dividing the target city area into unit areas according to multiple division scales.
[0069] The above-mentioned traffic flow data includes all traffic flow data of the target city area in the historical time period, such as subway flow data, vehicle flow data, bus flow data, etc., which are used to describe the running trajectory of vehicles, etc. in the historical time period. The historical time period can be one day, etc. For example, for private car data, the global positioning system (GPS, Global Positioning System) data (including vehicle anonymized tag ID, vehicle latitude and longitude, current time, location information) and the car's online diagnostic system (OBD, On-Board Diagnostic) data (including private car driving and parking status, speed and direction) of private cars in a preset historical time period are collected, and the private car's stop point data is extracted from them; the extracted stop point data at least includes latitude and longitude information and time information, and the above-mentioned GPS data and stop point data are integrated into traffic flow data.
[0070] In some embodiments of the present application, traffic flow data can be obtained using devices such as a global positioning system, and different division scales can be expressed as different numbers of unit areas, such as a 2×2 division (i.e., dividing the target city into 2 rows and 2 columns of unit areas), with a total of 4 unit areas, or a 9×8 division (i.e., dividing the target city into 9 rows and 8 columns of unit areas), with a total of 72 unit areas.
[0071] Step 12, for each division scale, respectively, based on all traffic flow data and all unit areas under the division scale, calculate the traffic flow time characteristics of the target urban area.
[0072] The above traffic flow time characteristics are used to describe the traffic flow between every two unit areas in each time step after all historical time periods are divided into multiple historical time steps.
[0073] In some embodiments of the present application, the step of calculating the traffic flow time characteristics of the target urban area based on all traffic flow data and all unit areas under the division scale includes:
[0074] In the first step, all historical moments are divided into historical time steps according to multiple time division scales.
[0075] Specifically, each historical time period is divided according to different time division scales to obtain multiple historical time steps. For example, if the historical time period is 24 hours and the time division scale is 6 time steps, then after dividing the historical time period, 6 historical time steps are obtained. The time span of the historical time steps is the same. There are 3 historical time periods in total, so a total of 18 historical time steps are obtained.
[0076] In the second step, statistics are performed based on the traffic flow data of all historical time periods to obtain the vehicle flow matrix of the target urban area at each time division scale.
[0077] The vehicle flow matrix of the target urban area is:
[0078]
[0079] x rk ={X r,1 ,…,X r,k}∈R l×l×k
[0080] in, Represents the vehicle flow matrix of the target urban area under the a-th time division scale x k represents the vehicle flow matrix in the first historical time period, x 2k represents the vehicle flow matrix in the second historical period, x dk represents the vehicle flow matrix in the dth historical time period, R m×n×k×d , R l×l×k Both represent dimensions, m×n represents the number of unit areas under the division scale, k represents the number of historical time steps divided into each historical time period, and X r,1 represents the matrix of traffic flow between every two unit areas at the first historical time step in the rth historical time period, X r,k The matrix representing the traffic flow between every two unit areas at the kth historical time step in the rth historical time period, r∈(1,2,...,d), l=m×n.
[0081] It should be noted that the traffic flow between each two unit areas is the number of traffic trajectories starting in one unit area and ending in another unit area in the traffic flow data of the corresponding historical time step.
[0082] The third step is to integrate all vehicle flow matrices to obtain the time characteristics of traffic flow.
[0083] Specifically, all vehicle flow matrices are integrated into one data to obtain the time characteristics of traffic flow.
[0084] It is worth mentioning that by obtaining statistics on the unit grids at different division scales and the traffic flow at different time division scales, the traffic flow analysis of the target urban area in both spatial and temporal scales is considered to improve the accuracy of traffic flow analysis.
[0085] Step 13: Use the graph convolutional network to calculate the characteristics of each traffic flow time feature to obtain the final traffic flow characteristics of the target urban area at each division scale.
[0086] Specifically, through the formula:
[0087] U l+1 =f(φ l *G(U l ))
[0088] Calculate the traffic flow characteristics U of the l+1th layer l+1 .
[0089] Among them, φ l represents the lth layer convolution kernel, f represents the output function, G represents the input conversion function, U l represents the traffic flow characteristics of the l+1th layer, l=0,1,...,L, L represents the last layer in the graph convolutional network, when l=0, U0 is the traffic flow time characteristic, when l=L, U L+1 is the final traffic flow characteristic.
[0090] Step 14, based on all the final traffic flow characteristics, obtain the predicted traffic flow data of the target urban area at each division scale, and determine the target division scale from all division scales according to all the predicted traffic flow data.
[0091] The accuracy of the predicted traffic flow data corresponding to the above target division scale is higher than that of the predicted traffic flow data corresponding to other division scales. The predicted traffic flow data is used to describe the predicted traffic flow between each two unit areas at a future time under the division scale.
[0092] In some embodiments of the present application, the steps of obtaining predicted traffic flow data of the target urban area at each division scale based on all final traffic flow characteristics, and determining the target division scale from all division scales according to all predicted traffic flow data include:
[0093] In the first step, based on all the final traffic flow features, the multi-head attention mechanism is used to predict the traffic flow and obtain the initial predicted traffic flow data of the target urban area at each division scale.
[0094] Specifically, through the formula:
[0095] Xatt =Concat(head1,head2,…,head s )W o
[0096] head i =Attention(Q,K,V)
[0097]
[0098] Calculate the initial predicted traffic flow data set X att .
[0099] Among them, Concat represents the concatenation operation, head1 represents the output of the first attention head, head2 represents the output of the second attention head, and head s represents the output of the sth attention head, head i represents the output of the i-th attention head, i∈(1,2,...,s), W o represents the weight, W Q , W K , W V All represent weight matrices, Attention represents attention calculation, Q represents query vector, K represents key vector, and V represents value vector. represents all final traffic flow characteristics, and E represents the function.
[0100] It should be noted that the set X att The data includes the initial predicted traffic flow data of the target urban area under each division scale, and the initial predicted traffic flow data includes the initial predicted traffic flow between every two unit areas of the target urban area in the future time period under the division scale.
[0101] In the second step, all the initial predicted traffic flow data are adjusted using the external factors of the target city area in all historical time periods to obtain the predicted traffic flow data of the target city area at each division scale.
[0102] Specifically, through the formula:
[0103] Y out =Concat(head'1,head'2,...,head' s )W o
[0104] head' i =Attention(Q',K',V')
[0105] Q'=E(X att ⊙X ext )*WQ
[0106] K'=E(X att ⊙X ext )*W K
[0107] V'=E(X att ⊙X ext )*W V
[0108] Calculate the set Y of predicted traffic flow data out .
[0109] Among them, head'1 represents the output of the first attention head after the introduction of external factors, head'2 represents the output of the second attention head after the introduction of external factors, and head' s represents the output of the sth attention head after the introduction of external factors, head' i represents the output of the i-th attention head after the introduction of external factors, Q' represents the query vector after the introduction of external factors, K' represents the key vector after the introduction of external factors, V' represents the value vector after the introduction of external factors, and X ext Indicates external factors.
[0110] It should be noted that the above external factors include weather data, holiday schedule information, special event data, etc. of the target city area in all historical time periods. out The predicted traffic flow data includes the predicted traffic flow data of the target urban area under each division scale, and the predicted traffic flow data includes the predicted traffic flow between every two unit areas of the target urban area in the future time period under the division scale.
[0111] The third step is to determine the target partitioning scale from all partitioning scales based on all predicted traffic flow data.
[0112] Specifically, the similarity between the predicted traffic flow data and the corresponding actual traffic flow data can be calculated (which can be calculated using the cosine similarity formula, etc.), and the similarity can be used as the accuracy of the predicted traffic flow data. The greater the similarity, the higher the accuracy. The division scale corresponding to the predicted traffic flow data with the highest accuracy is used as the target division scale.
[0113] It is worth mentioning that by incorporating external factors, the characteristic expression of traffic data can be further enriched, and the sensitivity to sudden changes and abnormal situations can be enhanced. This adjustment method not only helps to optimize the prediction accuracy, but also makes up for the limitations of modeling based solely on spatiotemporal data, thereby more comprehensively capturing the complex changes in traffic flow.
[0114] Step 15, predicting the traffic flow of the urban area to be predicted according to the target division scale, and obtaining the final predicted traffic flow data of the urban area to be predicted.
[0115] In some embodiments of the present application, in order to improve the accuracy of traffic flow prediction for the predicted urban area, before performing this step, the predicted traffic flow data obtained in step 14 can be used to perform parameter training on the graph neural network and multi-head attention mechanism mentioned above. Specifically, the loss function value is calculated based on all predicted traffic flow data and actual traffic flow data. When the loss function value is less than the preset value of the loss function, the training is completed. When the loss function value is greater than or equal to the preset value of the loss function, the parameters of the graph neural network and the multi-head attention mechanism are adjusted, and the step of using the graph convolutional network to perform feature calculation on each traffic flow time feature to obtain the final traffic flow characteristics of the target urban area at each division scale is returned. The formula for calculating the loss function value is:
[0116]
[0117] Among them, L pre is the loss function value, Y true is the real traffic flow data, Y out To predict traffic flow data, N represents the number of division scales.
[0118] The above-mentioned steps of performing traffic flow prediction on the urban area to be predicted according to the target division scale to obtain the final predicted traffic flow data of the urban area to be predicted are specifically as follows: dividing the urban area to be predicted into multiple unit areas according to the target division scale, and then calculating the traffic flow time characteristics according to the traffic flow data of the urban area to be predicted in multiple historical time periods, and then using the trained graph convolutional network to perform feature calculation on each traffic flow time feature to obtain the final traffic flow characteristics, and then based on the final traffic flow characteristics, using the trained multi-head attention mechanism to calculate the final predicted traffic flow data of the urban area to be predicted.
[0119] It should be noted that the final predicted traffic flow data includes the traffic flow between every two unit areas of the urban area to be predicted in the future time period under the target division scale.
[0120] It is worth mentioning that the use of graph convolutional networks to calculate the temporal characteristics of traffic flow can effectively conduct in-depth mining and processing of the time dependency of data, overcoming the limitation of traditional models that it is difficult to capture complex spatiotemporal correlations. Traffic flow prediction based on the final traffic flow characteristics can improve the accuracy of predicted traffic flow data, and traffic flow prediction for the urban area to be predicted according to the target division scale can further improve the accuracy of traffic flow prediction.
[0121] In addition, this application collects statistics on traffic flow data and uses graph neural networks to deeply mine and process the spatiotemporal dependencies of data, overcoming the limitation of traditional models that it is difficult to capture complex spatiotemporal correlations. On this basis, the multi-head attention mechanism is integrated to effectively extract key features, and combined with external conditions such as weather and holidays, the perception of traffic flow changes is further optimized. Through multi-level design, the prediction accuracy of traffic flow is enhanced.
[0122] The following is an exemplary description of the urban traffic flow prediction device based on graph convolutional network provided in this application.
[0123] like Figure 2 As shown, the embodiment of the present application provides a device for predicting urban traffic flow based on a graph convolutional network. The device 200 for predicting urban traffic flow based on a graph convolutional network includes:
[0124] A division module 201 is used to obtain traffic flow data of a target city area in multiple historical time periods, and divide the target city area into unit areas according to multiple division scales;
[0125] The calculation module 202 is used to calculate the traffic flow time characteristics of the target urban area according to all traffic flow data and all unit areas under the division scale for each division scale; the traffic flow time characteristics are used to describe the traffic flow between every two unit areas in each time step after all historical time periods are divided into multiple historical time steps;
[0126] The feature calculation module 203 is used to perform feature calculation on each traffic flow time feature using a graph convolutional network to obtain the final traffic flow feature of the target urban area at each division scale;
[0127] The determination module 204 is used to obtain the predicted traffic flow data of the target urban area at each division scale based on all the final traffic flow characteristics, and determine the target division scale from all the division scales according to all the predicted traffic flow data; the accuracy of the predicted traffic flow data corresponding to the target division scale is higher than the accuracy of the predicted traffic flow data corresponding to other division scales;
[0128] The traffic flow prediction module 205 is used to predict the traffic flow of the urban area to be predicted according to the target division scale, and obtain the final predicted traffic flow data of the urban area to be predicted.
[0129] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0130] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0131] like Figure 3 As shown, an embodiment of the present application provides a terminal device. The terminal device D10 of this embodiment includes: at least one processor D100 ( Figure 3 Only one processor is shown in the figure), a memory D101, and a computer program D102 stored in the memory D101 and executable on the at least one processor D100, wherein the processor D100 implements the steps of any of the above-mentioned method embodiments when executing the computer program D102.
[0132] Specifically, when the processor D100 executes the computer program D102, it obtains traffic flow data of the target urban area in multiple historical time periods, and divides the target urban area into unit areas according to multiple division scales, and then calculates the traffic flow time characteristics of the target urban area for each division scale based on all traffic flow data and all unit areas under the division scale, and then uses a graph convolutional network to perform feature calculations on each traffic flow time feature to obtain the final traffic flow characteristics of the target urban area at each division scale, and then obtains the predicted traffic flow data of the target urban area at each division scale based on all the final traffic flow characteristics, and determines the target division scale from all division scales based on all the predicted traffic flow data, and finally performs traffic flow prediction on the urban area to be predicted according to the target division scale to obtain the final predicted traffic flow data of the urban area to be predicted. Among them, the use of graph convolutional networks to calculate the temporal characteristics of traffic flow can effectively mine and process the time dependence of data in depth, overcoming the limitation of traditional models that it is difficult to capture complex spatiotemporal correlations. Traffic flow prediction based on the final traffic flow characteristics can improve the accuracy of predicted traffic flow data, and traffic flow prediction for the urban area to be predicted according to the target division scale can further improve the accuracy of traffic flow prediction.
[0133] The processor D100 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0134] In some embodiments, the memory D101 may be an internal storage unit of the terminal device D10, such as a hard disk or memory of the terminal device D10. In other embodiments, the memory D101 may also be an external storage device of the terminal device D10, such as a plug-in hard disk, a smart memory card (SMC, SmartMedia Card), a secure digital (SD, Secure Digital) card, a flash card (Flash Card), etc. equipped on the terminal device D10. Further, the memory D101 may also include both an internal storage unit of the terminal device D10 and an external storage device. The memory D101 is used to store an operating system, an application program, a boot loader (BootLoader), data and other programs, such as the program code of the computer program, etc. The memory D101 may also be used to temporarily store data that has been output or is to be output.
[0135] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0136] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0137] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium that can carry the computer program code to the urban traffic flow prediction method device / terminal device based on the graph convolution network. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0138] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0139] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0140] The above is a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles described in the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for predicting urban traffic flow based on graph convolutional networks, characterized in that: include: Acquire traffic flow data of a target city area in multiple historical time periods, and divide the target city area into unit areas according to multiple division scales; For each division scale, the traffic flow time characteristics of the target urban area are calculated based on all traffic flow data and all unit areas under the division scale; the traffic flow time characteristics are used to describe the traffic flow of every two unit areas in each time step after all historical time periods are divided into multiple historical time steps; Using a graph convolutional network to perform feature calculation on each traffic flow time feature, the final traffic flow feature of the target urban area at each division scale is obtained; Based on all the final traffic flow characteristics, the predicted traffic flow data of the target urban area at each of the division scales is obtained, and a target division scale is determined from all the division scales according to all the predicted traffic flow data; The accuracy of the predicted traffic flow data corresponding to the target division scale is higher than the accuracy of the predicted traffic flow data corresponding to other division scales; Traffic flow prediction is performed on the urban area to be predicted according to the target division scale to obtain final predicted traffic flow data of the urban area to be predicted.
2. The urban traffic flow prediction method according to claim 1, characterized in that: The traffic flow time characteristics of the target urban area are calculated based on all traffic flow data and all unit areas under the division scale, including: Divide all historical moments into historical time steps according to multiple time division scales; Based on the traffic flow data of all historical time periods, statistics are performed to obtain the vehicle flow matrix of the target urban area at each time division scale; All vehicle flow matrices are integrated to obtain the time characteristics of traffic flow.
3. The urban traffic flow prediction method according to claim 2, characterized in that: The vehicle flow matrix of the target urban area is: in, Represents the vehicle flow matrix of the target urban area under the a-th time division scale represents the vehicle flow matrix in the first historical time period, represents the vehicle flow matrix in the second historical time period, represents the vehicle flow matrix in the dth historical time period, R m×n×k×d , R l×l×k Both represent dimensions, m×n represents the number of unit areas under the division scale, k represents the number of historical time steps divided into each historical time period, and X r,1 represents the matrix of traffic flow between every two unit areas at the first historical time step in the rth historical time period, X r,k The matrix representing the traffic flow between every two unit areas at the kth historical time step in the rth historical time period, r∈(1,2,...,d), l=m×n.
4. The urban traffic flow prediction method according to claim 1, characterized in that: The graph convolution network is used to perform feature calculation on each traffic flow time feature to obtain the final traffic flow feature of the target urban area at each division scale, including: By formula: IN l+1 =f(φ l *G(U l )) Calculate the traffic flow characteristics U of the l+1th layer l+1 ; Among them, φ l represents the lth layer convolution kernel, f represents the output function, G represents the input conversion function, U l represents the traffic flow characteristics of the l+1th layer, l=0,1,...,L, L represents the last layer in the graph convolutional network, when l=0, U0 is the traffic flow time characteristic, when l=L, U L+1 is the final traffic flow characteristic.
5. The urban traffic flow prediction method according to claim 1, characterized in that: The step of obtaining predicted traffic flow data of the target urban area at each of the division scales based on all the final traffic flow characteristics includes: Based on all the final traffic flow features, a multi-head attention mechanism is used to perform traffic flow prediction to obtain the initial predicted traffic flow data of the target urban area at each division scale; All initial predicted traffic flow data are adjusted using external factors of the target city area in all historical time periods to obtain predicted traffic flow data of the target city area at each division scale.
6. The urban traffic flow prediction method according to claim 5, characterized in that: Based on all the final traffic flow features, the multi-head attention mechanism is used to perform traffic flow prediction, and the initial predicted traffic flow data of the target urban area at each division scale is obtained, including: By formula: X att =Concat(head1,head2,…,head s )W o head i =Attention(Q,K,V) Calculate the initial predicted traffic flow data set X att ; Among them, Concat represents the concatenation operation, head1 represents the output of the first attention head, head2 represents the output of the second attention head, and head s represents the output of the sth attention head, head i represents the output of the i-th attention head, i∈(1,2,...,s), W o represents the weight, W Q , W K , W V All represent weight matrices, Attention represents attention calculation, Q represents query vector, K represents key vector, and V represents value vector. represents all final traffic flow characteristics, and E represents the function.
7. The urban traffic flow prediction method according to claim 6, characterized in that: The method of adjusting all the initial predicted traffic flow data by using the external factors of the target city area in all historical time periods to obtain the predicted traffic flow data of the target city area at each division scale includes: By formula: Y out =Concat(head'1,head'2,…,head' s )W o head' i =Attention(Q',K',V') Q'=E(X att ⊙X ext )*W Q K'=E(X att ⊙X ext )*W K V'=E(X att ⊙X ext )*W V Calculate the set Y of predicted traffic flow data out ; Among them, head'1 represents the output of the first attention head after the introduction of external factors, head'2 represents the output of the second attention head after the introduction of external factors, and head' s represents the output of the sth attention head after the introduction of external factors, head' i represents the output of the i-th attention head after the introduction of external factors, Q' represents the query vector after the introduction of external factors, K' represents the key vector after the introduction of external factors, V' represents the value vector after the introduction of external factors, and X ext Indicates external factors.
8. A device for predicting urban traffic flow based on graph convolutional network, characterized in that: include: A division module, used to obtain traffic flow data of a target city area in multiple historical time periods, and divide the target city area into unit areas according to multiple division scales; A calculation module is used to calculate the traffic flow time characteristics of the target urban area according to all traffic flow data and all unit areas under the division scale for each division scale; the traffic flow time characteristics are used to describe the traffic flow between every two unit areas in each time step after all historical time periods are divided into multiple historical time steps; A feature calculation module, used to perform feature calculation on each traffic flow time feature using a graph convolutional network to obtain the final traffic flow feature of the target urban area at each division scale; A determination module, used to obtain predicted traffic flow data of the target urban area at each of the division scales based on all the final traffic flow characteristics, and determine a target division scale from all the division scales according to all the predicted traffic flow data; The accuracy of the predicted traffic flow data corresponding to the target division scale is higher than the accuracy of the predicted traffic flow data corresponding to other division scales; The traffic flow prediction module is used to predict the traffic flow of the urban area to be predicted according to the target division scale to obtain the final predicted traffic flow data of the urban area to be predicted.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the urban traffic flow prediction method based on graph convolutional network as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for predicting urban traffic flow based on a graph convolutional network as described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Traffic flow prediction method based on traffic state and related equipment
CN121281278A