A method, system, medium and processor for predicting short-term traffic flow on expressways based on road network topology and Transformer model
By combining the road network topology structure and Transformer model, we sort out the associated paths and calculate the traffic share ratio, the problem of difficult to capture the dynamic changes in short-term space of traffic data in the existing technology is solved, and the accuracy and calculation efficiency of short-term traffic prediction on highways are improved.
Patent Information
- Application Number
- CN202411899478.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-08
AI Technical Summary
Existing traffic prediction methods are difficult to capture the short-term spatial dynamic changes of highway traffic data, and there are problems of gradient disappearance or explosion when analyzing long-term historical data, resulting in low prediction accuracy.
Using a method based on the road network topology structure and Transformer model, we sort out the associated path set, collect historical vehicle traffic data, calculate the proportion of vehicle traffic, and use the Transformer model for training and prediction to extract long-term time correlations to improve prediction accuracy.
It improves the accuracy of short-term traffic prediction on highways and the calculation efficiency of algorithms, enhances the compatibility of the model with changes in road network structure, and can more accurately capture the spatial and temporal correlation of traffic flow data.
Smart Images

Figure CN119785582A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of highway short-term traffic flow prediction, and in particular to a highway short-term traffic flow prediction method, system, medium and processor based on a road network topology structure and a Transformer model. Background Art
[0002] With the rapid development of the economy and the acceleration of urbanization, highways, as an important link between cities and regions, are shouldering an increasingly heavy task of traffic flow. However, along with the increase in traffic, the problem of highway traffic congestion is becoming increasingly serious. Especially during holidays, the surge in short-term traffic often leads to serious traffic jams, which not only affects people's travel efficiency, but also increases the risk of traffic accidents. Therefore, accurate prediction of short-term highway traffic is crucial for the rational allocation of traffic resources, optimization of traffic management strategies, and improvement of road capacity and public travel experience. In addition, the rapid progress of technologies such as big data, the Internet of Things, and artificial intelligence has provided a technical basis and possibility for the accurate prediction of short-term highway traffic.
[0003] At present, traffic flow prediction methods are mainly divided into three categories: time series analysis methods, machine learning methods and deep learning methods. In the early days, traffic flow prediction methods mainly used time series analysis methods such as autoregressive integrated moving average and Kalman filtering for prediction, but they are all based on linear assumptions and require data to be smooth. However, actual traffic flow data is usually nonlinear, which makes it difficult for time series analysis methods to obtain satisfactory results. Machine learning methods such as vector autoregression (VAR) and support vector regression (SVR) model the characteristics of traffic data, reveal the nonlinear relationship in the data, and then continuously adjust and optimize the model parameters to predict traffic flow trends. However, these methods only consider time information and ignore the importance of spatial information for accurate prediction of traffic flow. Deep learning can automatically extract more complex traffic features and has attracted widespread attention in traffic flow prediction. Existing studies have shown that methods based on recurrent neural networks (RNNs), such as long short-term memory networks (LSTMs), have achieved better results than the above-mentioned time series analysis methods and machine learning methods. In order to simultaneously learn the spatiotemporal correlation of traffic data, a method that integrates convolutional neural networks (CNNs) and RNNs is adopted. However, CNN cannot process non-Euclidean data, resulting in the loss of spatial information contained in the road network. Therefore, the spatiotemporal graph convolutional network framework is widely used in traffic flow prediction. Some scholars have proposed introducing graph convolutional networks (GCN) into the field of traffic flow prediction, using spatiotemporal convolution to capture spatiotemporal correlations at the same time. Other scholars have further captured spatial correlations by constructing an adaptive adjacency matrix, and used temporal convolutional networks (TCN) to capture temporal correlations.
[0004] Although the above methods have achieved good results in traffic flow prediction, in fact, due to the influence of factors such as highway network structure and grade, weather changes and emergencies, the spatial correlation of traffic flow data is dynamically changing. However, it is difficult for existing methods to capture such short-term spatial dynamic changes. For the analysis of long-term historical traffic flow data, RNN-based methods have the problem of gradient disappearance or explosion; CNN-based methods are limited by limited receptive fields. Although TCN achieves an exponentially growing receptive field, the stacked convolutional layers will still reduce the performance of the model. Therefore, these methods also have certain difficulties in analyzing the correlation of long-term historical data.
[0005] With the abolition of provincial highway toll stations across the country in 2019, ETC gantries cover almost every toll station and section of the entire highway network, and ETC equipment has effective, reliable, and real-time traffic data such as traffic flow and license plate recognition. Therefore, by deeply mining ETC data through big data technology and combining it with the topological structure of the highway network, short-term traffic trends can be more targeted. The Transformer large model uses a highly parallel self-attention mechanism to achieve efficient sequence learning, which can analyze long-term historical traffic data and adaptively capture long-term temporal dependencies from the input sequence. Summary of the invention
[0006] In view of the problems in the prior art, the present invention provides a method, system, medium and processor for predicting short-term traffic flow on highways based on road network topology and Transformer model, which can better obtain spatiotemporal correlation and improve the accuracy of short-term traffic flow prediction. The specific technical solution is as follows:
[0007] On the one hand, the present invention provides a method for predicting short-term traffic flow on a highway based on a road network topology structure and a Transformer model, comprising the following steps:
[0008] Step S1, according to the road network structure of the target road section to be predicted, sort out the associated paths of the incoming traffic flow with the maximum speed limit, each associated path has a unique starting point, and obtain the associated path set of the target road section;
[0009] Step S2, collecting historical traffic flow data and vehicle speed data of each gantry at each associated path in the associated path set at each time, calculating the average vehicle speed data of each associated path, and forming a historical traffic flow data set of the gantry period of each associated path and an average vehicle speed data set of each associated path;
[0010] Step S3, calculating the historical traffic proportion of each associated path that finally merges into the target road section at time t;
[0011] Step S4: Input the traffic flow data set passing through gantry A at time t, the historical traffic flow data of each gantry at each time on all N associated paths of gantry A, the average speed data set of all N associated paths of gantry A, and the historical traffic flow proportion of all N associated paths of gantry A flowing into the target road section at each time into the Transformer model for training and prediction, and predict the traffic flow proportion g of each associated path of gantry A at time t. n (t)*, calculate g n (t)* and g n Relative error Δg of (t) n (t), when the relative error Δg n When (t) is less than the set threshold, the training of the Transformer model is terminated, and a path share prediction model based on the Transformer model, the road network topology and time-space correlation is obtained;
[0012] Step S5: predict the traffic proportion g of each associated path of gantry A at time t+Δt based on the historical traffic flow data of each gantry at each time of all N associated paths of gantry A and the average vehicle speed data set of all N associated paths of gantry A. n (t+Δt)*;
[0013] Step S6: Obtain the traffic proportion g of each associated path of gantry A at time t+Δt according to the prediction n (t+Δt)* and the real-time traffic flow data of each associated path, and calculate the real-time traffic flow of gantry A on the target section at time t+Δt.
[0014] Preferably, the step S1 specifically includes the following steps:
[0015] Step S11, determining the target road section by direction, and setting the one-way gantry of the target road section as gantry A;
[0016] Step S12, determine the maximum speed V of each associated path of gantry A max ;
[0017] Step S13, according to the position of the gantry A and the maximum speed V of each associated path max Calculate the maximum distance S that a vehicle can travel in each associated path of gantry A within time T max ; The maximum distance S that a vehicle travels within time T max The calculation method of S is as follows: max =T*V max ; Wherein, in this embodiment, time T is half an hour.
[0018] Step S14, based on the longest distance S traveled by the vehicle within time T maxThe driving path of the vehicle within the time T is estimated, that is, the set of gantries passed within the time T, and each path forms a gantries set.
[0019] Preferably, each associated path has a unique starting gantry, and each associated path forms a gantry set, including a starting gantry, an end gantry, or several process gantry. Assume that there are N associated paths in total. If there are process gantry, assuming that there are k process gantry, k is an integer greater than or equal to 1, the gantry set of associated path n is in is the starting gantry of the associated path n, is the terminal gantry of the associated path n, is the jth process gantry of the associated path n.
[0020] Preferably, the step S3 specifically includes the following steps:
[0021] Step S31, collect historical vehicle flow data X passing through gantry A at time t A (t);
[0022] Step S32, select the associated path i and calculate the starting gantry of the associated path n The time T required to reach gantry A at the average speed of the associated path n n ;
[0023] Step S33, collecting n The starting gantry that passes the associated path n within the time period Historical traffic data
[0024] Step S34, compare the license plate history data of each gantry on the associated path n, and obtain tT n The time period starts from the starting point of the associated path n The traffic volume passing through gantry A at time t after passing through associated path n
[0025] in, Step S35, according to step S33 and step S34, the historical traffic flow ratio of the traffic flow flowing into the target section in the associated path n at time t to the total traffic flow of the associated path n is obtained: Step S36, repeat the above steps S32-S35 to obtain the historical traffic flow proportions of all N associated paths flowing into the target road section gantry A at each moment.
[0026] Preferably, when the associated path n includes k process gantries, the n The vehicle flow through each process gantry of the associated path n during the time period is set at tT nThe vehicle flow through the jth process gantry of the associated path n during the time period is Then tT n The time period starts from the starting point of the associated path n The traffic volume passing through gantry A at time t after passing through associated path n for:
[0027]
[0028] Preferably, step S37 is also included, selecting different characteristic time periods, repeating steps S31 to S36, and obtaining the historical traffic flow proportions of all associated paths of gantry A in different characteristic time periods.
[0029] Preferably, the real-time traffic flow of the target section gantry A at time t+Δt in step S6 is calculated as follows:
[0030]
[0031] in, It is the real-time traffic flow data of the starting gantry of the associated path n at time t-Δt.
[0032] On the other hand, the present invention provides a highway short-term traffic flow prediction system based on a road network topology structure and a Transformer model, and the method described herein is applied, including:
[0033] The associated path set acquisition module is used to sort out the associated paths of the incoming traffic flow with the maximum speed limit according to the road network structure of the target road section to be predicted, each associated path has a unique starting point, and obtain the associated path set of the target road section;
[0034] The data collection module is used to collect the historical traffic flow data and vehicle speed data of each gantry at each associated path in the associated path set at each time, calculate the average vehicle speed data of each associated path, and form a historical traffic flow data set of the gantry period of each associated path and an average vehicle speed data set of each associated path;
[0035] The historical traffic flow ratio calculation module is used to calculate the historical traffic flow ratio of each associated path that finally merges into the target road section at time t;
[0036] The prediction model training module is used to input the traffic flow data set passing through gantry A at time t, the historical traffic flow data of each gantry at each time on all N associated paths of gantry A, the average speed data set of all N associated paths of gantry A, and the historical traffic flow proportion of all N associated paths of gantry A flowing into the target section at each time into the Transformer model for training and prediction, and predict the traffic flow proportion g of each associated path of gantry A at time t. n (t)*, calculate gn (t)* and g n Relative error Δg of (t) n (t), when the relative error Δg n When (t) is less than the set threshold, the training of the Transformer model is terminated, and a path share prediction model based on the Transformer model, the road network topology structure and time-space correlation is constructed;
[0037] The traffic flow proportion prediction module is used to predict the traffic flow proportion g of each associated path of gantry A at time t+Δt based on the historical traffic flow data of each gantry at each time of all N associated paths of gantry A and the average speed data set of all N associated paths of gantry A. n (t+Δt)*;
[0038] The real-time traffic flow calculation module is used to obtain the traffic flow proportion g of each associated path of gantry A at time t+Δt according to the prediction n (t+Δt)* and the real-time traffic flow data of each associated path, and calculate the real-time traffic flow of gantry A on the target section at time t+Δt.
[0039] On the one hand, the present invention provides a computer-readable storage medium, characterized in that the computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the method for predicting short-term traffic flow on highways based on road network topology and Transformer model.
[0040] In the last aspect, the present invention provides a processor, characterized in that the processor is used to run a program, wherein the program, when running, executes the method for predicting short-term traffic flow on highways based on road network topology and Transformer model.
[0041] Compared with the prior art, the present invention has the following beneficial effects:
[0042] The present invention is based on the fact that the highway network structure is relatively fixed for a long time. In the spatial dimension, the associated paths of the target section can be continuously used after only one combing. If a new associated road is opened later, the associated path set is also easy to update, which has no impact on the original data. This avoids the prediction algorithm model from repeatedly performing convolution operations during high-frequency calculations, and also improves the compatibility of the algorithm model with changes in the network structure. In the temporal dimension, traffic data such as traffic flow and speed of real-time ETC gantries are used to improve the accuracy of the input source of the prediction algorithm model. At the same time, through the temporal position embedding of the associated path proportion relationship, the self-attention module of the Transformer model can extract the long-term temporal correlation of the associated path, so that the predicted associated path proportion relationship is effectively improved.
[0043] In addition, the historical data analysis of the relationship between the proportion of associated paths can reflect the driver's preference for choosing a highway driving path, which is closely related to the convenience of the highway-associated municipal roads, the traffic environment of the highway itself, historical congestion or accidents, and other objective conditions. It is also related to the fact that drivers are more subjectively inclined to choose highways during free holidays. In summary, the prediction method proposed in the present invention has certain advantages over traditional methods in improving the accuracy of short-term highway traffic prediction, the calculation efficiency of the algorithm, the compatibility of the algorithm model, and the subjective and objective influences of highway traffic. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for the specific embodiments or the description of the prior art. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn according to the actual scale.
[0045] Figure 1 The figure is a flow chart of the method of the present invention.
[0046] Figure 2 Schematic diagram of the road network structure for the embodiment.
[0047] Figure 3 A schematic diagram of the complete associated paths for combing the target gantry.
[0048] Figure 4 This is a schematic diagram of the traffic proportion relationship of each path analyzed through historical data.
[0049] Figure 5 Schematic diagram of files generated for Transformer model prediction.
[0050] Figure 6 Schematic diagram of Transformer model prediction data.
[0051] Figure 7 A schematic diagram of traffic flow in the next half hour is predicted based on the traffic flow composition formula.
[0052] Figure 8 It is a system principle diagram of the present invention. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0054] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0055] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0056] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0057] Embodiment 1:
[0058] like Figure 1 As shown, this embodiment provides a method for predicting short-term traffic flow on a highway based on a road network topology structure and a Transformer model, comprising the following steps:
[0059] Step S1, according to the road network structure of the target road section to be predicted, sort out the associated paths of the incoming and outgoing traffic flow with the maximum speed limit, each associated path has a unique starting point, and obtain the associated path set of the target road section. Among them, the target road section to be predicted is a one-way road section. When sorting the associated paths, sorting them according to the maximum speed limit can ensure the integrity of the associated path data.
[0060] Step S1 specifically includes the following steps:
[0061] Step S11, determining the target road section by direction, and setting the one-way gantry of the target road section as gantry A;
[0062] Step S12, determine the maximum speed V of each associated path of gantry A max ;
[0063] Step S13, according to the position of the gantry A and the maximum speed V of each associated path max Calculate the maximum distance S that a vehicle can travel in each associated path of gantry A within time T max ; The maximum distance S that a vehicle travels within time T max The calculation method of S is as follows: max =T*V max ; Wherein, in this embodiment, time T is half an hour.
[0064] Step S14, based on the longest distance S traveled by the vehicle within time T max The driving path of the vehicle within time T is calculated, that is, the set of gantries that the vehicle passes within time T. Each path forms a gantry set. The gantries of the toll station are also counted in the gantries set for vehicles that enter the toll station within time T. The associated path combing of the target road section requires full coverage.
[0065] Each associated path has a unique starting gantry. Each associated path forms a gantry set, including a starting gantry, an end gantry or several process gantry. Suppose there are N associated paths in total. If there are process gantry, assuming there are k process gantry, k is an integer greater than or equal to 1, the gantry set of associated path n in is the starting gantry of the associated path n, is the terminal gantry of the associated path n, is the jth process gantry of the associated path n.
[0066] This embodiment plans to analyze the traffic flow between Narong Interchange and Changtang from 10:00 to 10:30 am. Figure 2 As shown in the figure, the maximum speed of each section is 120km / h, so the gantry traffic data within 60km before the Narong-Changtang gantry is counted to obtain all the associated paths of the target gantry as follows Figure 3 shown.
[0067] Figure 3 14 associated paths were sorted out, each of which has a unique starting gantry, and the end gantry is Liunan Reconstruction and Expansion Midpoint 2-Changtang 3. For example, the associated path Nanning East-Changtang Middle has only the starting gantry Nanning East Entrance-Narong Interchange 3, and the end gantry Liunan Reconstruction and Expansion Midpoint 2-Changtang 3. The associated path Wutang-Changtang Middle includes the starting gantry Wutang Entrance-Wutang 1, the process gantry Wutang 4-Narong Interchange 1, and the end gantry Liunan Reconstruction and Expansion Midpoint 2-Changtang 3.
[0068] Step S2, collect the historical traffic flow data and speed data of each gantry at each time of each associated path in the associated path set, calculate the average speed data of each associated path, and form the historical traffic flow data set of the gantry period of each associated path and the average speed data set of each associated path. Among them, the gantry historical traffic flow data is a half-hour gantry historical traffic flow data with an interval of 5 minutes, so as to ensure the real-time nature of data collection and thus improve the accuracy of short-term traffic flow prediction.
[0069] Step S3, calculate the historical traffic proportion of each associated path that finally merges into the target road section at time t. Specifically, it includes the following steps:
[0070] Step S31, collect historical vehicle flow data X passing through gantry A at time t A(t).
[0071] Step S32, select the associated path i, and calculate the starting gantry of the associated path n The time T required to reach gantry A at the average speed of the associated path n n ; Time T n The calculation method is as follows:
[0072]
[0073] Among them, S n The starting point of the associated path n Distance to gantry A, v n The starting point of the associated path n The average speed between the target section gantry A and the target section gantry A. In this embodiment, the maximum speed limit is used when combing the associated paths to ensure the integrity of the associated path data. The average speed of the associated paths is used when predicting to ensure the prediction accuracy. Step S33, collect the data at tT n The starting gantry that passes the associated path n within the time period Historical traffic data
[0074] Step S34, compare the license plate history data of each gantry on the associated path n, and obtain tT n The time period starts from the starting point of the associated path n The traffic volume passing through gantry A at time t after passing through associated path n
[0075] in, When the associated path n includes k process gantries, the n The vehicle flow through each process gantry of the associated path n during the time period is set at tT n The vehicle flow through the jth process gantry of the associated path n during the time period is Then tT n The time period starts from the starting point of the associated path n The traffic volume passing through gantry A at time t after passing through associated path n for:
[0076] Step S35, according to step S33 and step S34, the historical traffic flow ratio of the traffic flow flowing into the target section in the associated path n at time t to the total traffic flow of the associated path n is obtained: Step S36, repeat the above steps S32-S35 to obtain the historical traffic proportion of all N associated paths that flow into the target road section gantry A at each time. The traffic proportion relationship of each path is analyzed by historical data as follows Figure 4 shown.
[0077] Step S37, select different characteristic time periods, repeat steps S31 to S36, and obtain the historical traffic flow ratio of all associated paths of gantry A in different characteristic time periods.
[0078] Among them, different characteristic time periods include free highway periods and non-free highway periods.
[0079] Step S4: Input the traffic flow data set passing through gantry A at time t, the historical traffic flow data of each gantry at each time on all N associated paths of gantry A, the average speed data set of all N associated paths of gantry A, and the historical traffic flow proportion of all N associated paths of gantry A flowing into the target road section at each time into the Transformer model for training and prediction, and predict the traffic flow proportion g of each associated path of gantry A at time t. n (t)*, calculate g n (t)* and g n Relative error Δg of (t) n (t), when the relative error Δg n When (t) is less than the set threshold, the training of the Transformer model is terminated, and a path proportion prediction model based on the Transformer model, road network topology and time-space correlation is obtained.
[0080] in The Transformer model predicts the generated file as follows Figure 5 As shown, Figure 6 The following is a diagram of the predicted data for the Anji entrance. When predicting, if the real-time short-term traffic flow of gantry A during the free period of the highway is predicted, the historical traffic flow ratio of all associated paths during the free period of the highway is input to predict the traffic flow ratio of N associated paths of gantry A during the free period of the highway at time t. If the real-time short-term traffic flow of gantry A during the non-free period of the highway is predicted, the historical traffic flow ratio of all associated paths during the non-free period of the highway is input to predict the traffic flow ratio of N associated paths of gantry A during the non-free period of the highway at time t.
[0081] Step S5: predict the traffic proportion g of each associated path of gantry A at time t+Δt based on the historical traffic flow data of each gantry at each time of all N associated paths of gantry A and the average vehicle speed data set of all N associated paths of gantry A. n (t+Δt)*.
[0082] Step S6: Obtain the traffic proportion g of each associated path of gantry A at time t+Δt according to the prediction n(t+Δt)* and the real-time traffic data of each associated path are used to calculate the real-time traffic flow of the gantry A of the target section at time t+Δt. In this embodiment, the real-time traffic flow data of each associated path of gantry A in the period Δt before time t is used to predict the real-time traffic flow of gantry A in the period Δt after time t. The real-time traffic flow of gantry A of the target section at time t+Δt is calculated as follows:
[0083]
[0084] in, It is the real-time traffic flow data of the starting gantry of the associated path n at time t-Δt.
[0085] Wherein, N is the number of associated paths of gantry A. The Δt period is set to 30 minutes, and can also be set as needed. In this embodiment, N is 14, and the traffic flow in the next half hour is predicted according to the real-time traffic flow calculation formula, and the prediction relative error is used to evaluate the accuracy of the prediction. Prediction relative error = |prediction value-true value| / true value.
[0086] like Figure 7 As shown, the actual traffic flow of the target gantry (Liunan Reconstruction and Expansion Key 2-Changtang 3) from 10:00 to 10:30 on June 1, 2024 is 959 vehicles, the predicted traffic flow is 909 vehicles, and the predicted relative error is |909-959| / 959=5.21%.
[0087] This shows that the method of the present invention has a high accuracy in predicting short-term traffic flow.
[0088] Embodiment 2:
[0089] like Figure 8 As shown, based on the same inventive concept as that of Example 1, this embodiment provides a highway short-term traffic flow prediction system based on a road network topology structure and a Transformer model, which is applied to the method described, including:
[0090] The associated path set acquisition module is used to sort out the associated paths of the incoming traffic flow with the maximum speed limit according to the road network structure of the target road section to be predicted, each associated path has a unique starting point, and obtain the associated path set of the target road section;
[0091] The data collection module is used to collect the historical traffic flow data and vehicle speed data of each gantry at each associated path in the associated path set at each time, calculate the average vehicle speed data of each associated path, and form a historical traffic flow data set of the gantry period of each associated path and an average vehicle speed data set of each associated path;
[0092] The historical traffic flow ratio calculation module is used to calculate the historical traffic flow ratio of each associated path that finally merges into the target road section at time t;
[0093] The prediction model training module is used to input the traffic flow data set passing through gantry A at time t, the historical traffic flow data of each gantry at each time on all N associated paths of gantry A, the average speed data set of all N associated paths of gantry A, and the historical traffic flow proportion of all N associated paths of gantry A flowing into the target section at each time into the Transformer model for training and prediction, and predict the traffic flow proportion g of each associated path of gantry A at time t. n (t)*, calculate g n (t)* and g n Relative error Δg of (t) n (t), when the relative error Δg n When (t) is less than the set threshold, the training of the Transformer model is terminated, and a path share prediction model based on the Transformer model, the road network topology structure and time-space correlation is constructed;
[0094] The traffic flow proportion prediction module is used to predict the traffic flow proportion g of each associated path of gantry A at time t+Δt based on the historical traffic flow data of each gantry at each time of all N associated paths of gantry A and the average speed data set of all N associated paths of gantry A. n (t+Δt)*;
[0095] The real-time traffic flow calculation module is used to obtain the traffic flow proportion g of each associated path of gantry A at time t+Δt according to the prediction n (t+Δt)* and the real-time traffic flow data of each associated path, and calculate the real-time traffic flow of gantry A on the target section at time t+Δt.
[0096] Embodiment 3:
[0097] Based on the same inventive concept as Example 1, this embodiment provides a computer-readable storage medium, which includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the method for predicting short-term traffic flow on highways based on road network topology and Transformer model.
[0098] Embodiment 4:
[0099] Based on the same inventive concept as Example 1, this embodiment provides a processor, which is used to run a program, wherein the program executes the method for predicting short-term traffic flow on highways based on road network topology and Transformer model when running.
[0100] Those of ordinary skill in the art will appreciate that the modules of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition of each example has been generally described in terms of function in the above description. 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 the present invention.
[0101] In the embodiments provided by the present invention, it should be understood that the division of modules is only a logical function division, and there may be other division methods in actual implementation, for example, multiple modules can be combined into one module, one module can be split into multiple modules, or some features can be ignored, etc.
[0102] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of software functional modules.
[0103] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-0nlyMemory), random access memory (RAM, RandomAccessMemory), mobile hard disk, magnetic disk or optical disk, etc., various media that can store program codes.
[0104] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and specification of the present invention.
Claims
1. A method for predicting short-term traffic flow on highways based on road network topology and Transformer model, characterized in that: The following steps are involved: Step S1, according to the road network structure of the target road section to be predicted, sort out the associated paths of the incoming traffic flow with the maximum speed limit, each associated path has a unique starting point, and obtain the associated path set of the target road section; Step S2, collecting historical traffic flow data and vehicle speed data of each gantry at each associated path in the associated path set at each time, calculating the average vehicle speed data of each associated path, and forming a historical traffic flow data set of the gantry period of each associated path and an average vehicle speed data set of each associated path; Step S3, calculating the historical traffic proportion of each associated path that finally merges into the target road section at time t; Step S4: Input the traffic flow data set passing through gantry A at time t, the historical traffic flow data of each gantry at each time on all N associated paths of gantry A, the average speed data set of all N associated paths of gantry A, and the historical traffic flow proportion of all N associated paths of gantry A flowing into the target section at each time into the Transformer model for training and prediction, and predict the traffic flow proportion g of each associated path of gantry A at time t. n (t)*, calculate g n (t)* and g n Relative error Δg of (t) n (t), when the relative error Δg n When (t) is less than the set threshold, the training of the Transformer model is terminated, and a path share prediction model based on the Transformer model, the road network topology and time-space correlation is obtained; Step S5: predict the traffic proportion g of each associated path of gantry A at time t+Δt based on the historical traffic flow data of each gantry at each time of all N associated paths of gantry A and the average vehicle speed data set of all N associated paths of gantry A. n (t+Δt)*; Step S6: Obtain the traffic proportion g of each associated path of gantry A at time t+Δt according to the prediction n (t+Δt)* and the real-time traffic flow data of each associated path, and calculate the real-time traffic flow of gantry A on the target section at time t+Δt.
2. According to claim 1, a method for predicting short-term traffic flow on a highway based on a road network topology structure and a Transformer model is characterized in that: The step S1 specifically includes the following steps: Step S11, determining the target road section by direction, and setting the one-way gantry of the target road section as gantry A; Step S12, determine the maximum speed V of each associated path of gantry A max ; Step S13, according to the position of the gantry A and the maximum speed V of each associated path max Calculate the maximum distance S that a vehicle can travel in each associated path of gantry A within time T max ; The maximum distance S that a vehicle travels within time T max The calculation method of S is as follows: max =T*V max ; Wherein, in this embodiment, time T is half an hour. Step S14, based on the longest distance S traveled by the vehicle within time T max The driving path of the vehicle within the time T is estimated, that is, the set of gantries passed within the time T, and each path forms a gantries set.
3. The method for predicting short-term traffic flow on a highway based on a road network topology and a Transformer model according to claim 2 is characterized in that: Each associated path has a unique starting gantry. Each associated path forms a gantry set, including a starting gantry, an end gantry or several process gantry. Suppose there are N associated paths in total. If there are process gantry, assuming there are k process gantry, k is an integer greater than or equal to 1, the gantry set of associated path n in is the starting gantry of the associated path n, is the terminal gantry of the associated path n, is the jth process gantry of the associated path n.
4. The method for predicting short-term traffic flow on a highway based on a road network topology and a Transformer model according to claim 3 is characterized in that: The step S3 specifically comprises the following steps: Step S31, collect historical vehicle flow data X passing through gantry A at time t A (t); Step S32, select the associated path i and calculate the starting gantry of the associated path n The time T required to reach gantry A at the average speed of the associated path n n ; Step S33, collecting n The starting gantry that passes the associated path n during the time period Historical traffic data Step S34, compare the license plate history data of each gantry on the associated path n, and obtain tT n The time period starts from the starting point of the associated path n The traffic volume passing through gantry A at time t after passing through associated path n in, Step S35, according to step S33 and step S34, the historical traffic flow ratio of the traffic flow flowing into the target section in the associated path n at time t to the total traffic flow of the associated path n is obtained: Step S36, repeat the above steps S32-S35 to obtain the historical traffic flow proportions of all N associated paths flowing into the target road section gantry A at each moment.
5. The method for predicting short-term traffic flow on a highway based on a road network topology and a Transformer model according to claim 4, characterized in that: When the associated path n includes k process gantries, the n The vehicle flow through each process gantry of the associated path n during the time period is set at tT n The vehicle flow through the jth process gantry of the associated path n during the time period is Then tT n The time period starts from the starting point of the associated path n The traffic volume passing through gantry A at time t after passing through associated path n for:
6. The method for predicting short-term traffic flow on a highway based on a road network topology and a Transformer model according to claim 5, characterized in that: The step also includes step S37, selecting different characteristic time periods, repeating steps S31 to S36, and obtaining the historical traffic flow ratios of all associated paths of gantry A in different characteristic time periods.
7. The method for predicting short-term traffic flow on a highway based on a road network topology and a Transformer model according to claim 1, characterized in that: The calculation of the real-time traffic flow of the target section gantry A at time t+Δt in step S6 is as follows: in, It is the real-time traffic flow data of the starting gantry of the associated path n at time t-Δt.
8. A highway short-term traffic flow prediction system based on road network topology and Transformer model, characterized in that: The method according to any one of claims 1 to 7 comprises: The associated path set acquisition module is used to sort out the associated paths of the incoming traffic flow with the maximum speed limit according to the road network structure of the target road section to be predicted, each associated path has a unique starting point, and obtain the associated path set of the target road section; The data collection module is used to collect the historical traffic flow data and vehicle speed data of each gantry at each associated path in the associated path set at each time, calculate the average vehicle speed data of each associated path, and form a historical traffic flow data set of the gantry period of each associated path and an average vehicle speed data set of each associated path; The historical traffic flow ratio calculation module is used to calculate the historical traffic flow ratio of each associated path that finally merges into the target road section at time t; The prediction model training module is used to input the traffic flow data set passing through gantry A at time t, the historical traffic flow data of each gantry at each time on all N associated paths of gantry A, the average speed data set of all N associated paths of gantry A, and the historical traffic flow proportion of all N associated paths of gantry A flowing into the target section at each time into the Transformer model for training and prediction, and predict the traffic flow proportion g of each associated path of gantry A at time t. n (t)*, calculate g n (t)* and g n Relative error Δg of (t) n (t), when the relative error Δg n When (t) is less than the set threshold, the training of the Transformer model is terminated, and a path share prediction model based on the Transformer model, the road network topology structure and time-space correlation is constructed; The traffic flow proportion prediction module is used to predict the traffic flow proportion g of each associated path of gantry A at time t+Δt based on the historical traffic flow data of each gantry at each time of all N associated paths of gantry A and the average speed data set of all N associated paths of gantry A. n (t+Δt)*; The real-time traffic flow calculation module is used to obtain the traffic flow proportion g of each associated path of gantry A at time t+Δt according to the prediction n (t+Δt)* and the real-time traffic flow data of each associated path, and calculate the real-time traffic flow of gantry A on the target section at time t+Δt.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the highway short-term traffic flow prediction method based on road network topology structure and Transformer model as described in any one of claims 1 to 7.
10. A processor, characterized in that: The processor is used to run a program, wherein the program, when running, executes the highway short-term traffic flow prediction method based on road network topology and Transformer model as described in any one of claims 1 to 7.