Method, computer program product and electronic device for predicting road traffic flow
Patent Information
- Application Number
- CN202610806620.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-05
- Publication Date
- 2026-10-13
AI Technical Summary
相关现有技术中,短时交通流量预测大多仅依赖历史流量数据,在施工、事故、极端天气、节假日等情况下的预测精度不足
[0003]本公开的实施例提供了一种用于预测道路交通流量的方法、计算机程序产品及电子设备,旨在解决上述问题以及其他潜在的问题中的一个或多个。
Smart Images

Figure CN122906868A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this disclosure generally relate to the field of traffic flow prediction technology, and specifically to a method, computer program product, and electronic device for predicting road traffic flow. Background Technology
[0002] Smart roads require accurate short-term traffic flow forecasting to achieve intelligent road management. Currently, most existing short-term traffic flow forecasting technologies rely solely on historical traffic data, resulting in insufficient accuracy during periods of construction, accidents, extreme weather, and holidays. Summary of the Invention
[0003] Embodiments of this disclosure provide a method, computer program product, and electronic device for predicting road traffic flow, designed to address one or more of the problems described above and other potential problems.
[0004] According to a first aspect of this disclosure, a method for predicting road traffic flow is provided. This method is used to predict the traffic flow of a road in a future time period. The future time period includes corresponding future holiday data and future weather data, and the road to be predicted has a corresponding road network map, which includes multiple nodes for monitoring traffic flow and edges corresponding to roads between nodes. The method includes generating historical aggregated feature data of the road to be predicted based on historical traffic flow data of the road to be predicted using a graph attention network. The historical traffic flow data includes corresponding historical holiday data and historical weather data. The graph attention network has an initial adjacency matrix generated based on the road network map, and the historical traffic flow data includes historical traffic monitoring data for each node. The method also includes generating historical feature encoded data of the road to be predicted based on historical holiday data, historical weather data, and historical aggregated feature data, using Transformer encoding under the constraints of the graph attention network. Furthermore, the method also includes generating traffic flow features of the road to be predicted in a future time period based on future holiday data, future weather data, and historical feature encoded data, using Transformer decoding under the constraints of the graph attention network.
[0005] According to a second aspect of this disclosure, a computer program product is provided, comprising a computer program. When executed by a processor, the computer program implements the method of the first aspect described above.
[0006] According to a third aspect of this disclosure, an electronic device is provided, including one or more processors and a memory associated with the one or more processors. The memory is used to store program instructions that, when read and executed by the one or more processors, perform the steps of the method described in the first aspect. Attached Figure Description
[0007] The above and other objects, features, and advantages of embodiments of the present disclosure will become readily apparent from the following detailed description taken in conjunction with the accompanying drawings. Several embodiments of the present disclosure are illustrated in the drawings by way of example and not limitation.
[0008] Figure 1 An exemplary application scenario diagram of a method for predicting road traffic flow according to an embodiment of the present disclosure is shown.
[0009] Figure 2 A flowchart illustrating a method for predicting road traffic flow according to an embodiment of the present disclosure is shown.
[0010] Figure 3 A schematic diagram illustrating the working process of a method for predicting road traffic flow according to an embodiment of the present disclosure is shown.
[0011] Figure 4 A block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0012] In the various figures, the same or corresponding reference numerals indicate the same or corresponding parts. Detailed Implementation
[0013] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0014] In the description of embodiments of this disclosure, the term "comprising" and similar terms should be understood as open-ended inclusion, i.e., "including but not limited to". The term "based on" should be understood as "at least partially based on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc., may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0015] As mentioned earlier, smart roads integrate technologies such as the Internet of Things, 5G, artificial intelligence, and big data to comprehensively perceive, analyze in real time, and intelligently manage road operation. Accurate short-term traffic flow forecasting is the data foundation for smart roads to implement management measures such as variable speed limits, lane control, automatic accident detection, and travel guidance.
[0016] In existing technologies, short-term traffic flow prediction mostly relies solely on historical traffic data, failing to fully integrate external variables affecting traffic such as weather, holidays / special events, and temporary traffic controls. These factors dynamically alter the propagation speed and path selection of traffic flow, making predictions prone to detachment from reality. Specifically, traditional time series models (such as the Autoregressive Integral Moving Average (ARIMA) model and the Seasonal Autoregressive Integral Moving Average (SARIMA) model) require stationary data (mean and variance do not change drastically over time) and a dominant linear relationship. However, actual traffic flow exhibits significant nonlinearity (such as sudden congestion changes and traffic flow oscillations) and nonstationarity (such as peak hours and holiday fluctuations), making it difficult for these models to capture real dynamics and limiting prediction accuracy. While recurrent neural network models (such as Long Short-Term Memory (LSTM) and Gated Recurrent Units (GRUs) can effectively model time dependencies, they typically treat the traffic flow at each monitoring point (such as an ETC gantry) as an independent time series, ignoring the spatial relationships between road segments in the road network (e.g., downstream congestion can have a reverse impact on upstream). Furthermore, these models have limited ability to model very long-term dependencies (e.g., several hours or more) in practice, easily overlooking early critical information. Pure Transformer models (such as Informer and Autoformer) leverage their self-attention mechanism to efficiently model long-sequence dependencies and complex time patterns, performing excellently in general time series prediction tasks. However, they typically treat the input as an unstructured sequence, making it difficult for them to reasonably infer how traffic flow will be redistributed when sudden disturbances occur (e.g., road closures or traffic accidents), resulting in poor prediction robustness and large biases.
[0017] In view of this, embodiments of this specification provide a method for predicting road traffic flow. This method is used to predict the traffic flow of a road in a future time period. The future time period includes corresponding future holiday data and future weather data, and the road to be predicted has a corresponding road network map, which includes multiple nodes for monitoring traffic flow and edges corresponding to roads between nodes. The method includes generating historical aggregated feature data of the road to be predicted based on historical traffic flow data of the road to be predicted using a graph attention network. The historical traffic flow data includes corresponding historical holiday data and historical weather data. The graph attention network has an initial adjacency matrix generated based on the road network map, and the historical traffic flow data includes historical traffic monitoring data for each node. The method also includes generating historical feature encoded data of the road to be predicted based on historical holiday data, historical weather data, and historical aggregated feature data, using Transformer encoding under the constraints of the graph attention network. Furthermore, the method also includes generating traffic flow features of the road to be predicted in a future time period based on future holiday data, future weather data, and historical feature encoded data, using Transformer decoding under the constraints of the graph attention network. The method according to the embodiments of this disclosure can fully integrate external factors that dynamically change the propagation speed and path selection of traffic flow, such as weather, holidays / special events, and temporary traffic control, thereby improving the accuracy of short-term traffic flow prediction.
[0018] The embodiments of this disclosure will now be described in further detail with reference to the accompanying drawings. Figure 1 An example application environment for a method for predicting road traffic flow according to embodiments of the present disclosure is illustrated. Example environment 100 includes a computing device 110 and a data acquisition device 120. The computing device may be equipped with an intelligent model 110, which is trained to predict short-term road traffic flow. The data acquisition device can provide the intelligent model with the traffic flow data required for prediction. In some embodiments, the computing device and the data acquisition device communicate directly or indirectly via a network 130. The network may include a wired network, a wireless network, or a combination thereof, for providing communication between the computing device and the data acquisition device. In some embodiments, the computing device and the data acquisition device may be connected via a data cable; the present disclosure does not limit the connection method between the computing device and the data acquisition device.
[0019] Data acquisition equipment can be sensors or detection devices deployed on the road surface, physical devices that directly sense or record traffic conditions. In some embodiments, the data acquisition equipment may include geomagnetic coils buried under the road surface, capable of detecting changes in the magnetic field when vehicles pass by, and outputting data such as traffic flow, vehicle speed, and vehicle type. In some embodiments, the data acquisition equipment may be microwave radar installed on roadside poles or gantry, capable of emitting microwaves and receiving reflected signals, and outputting data such as real-time vehicle speed, traffic flow, and lane occupancy. In some embodiments, the data acquisition equipment may include video cameras and AI video analysis units installed on road gantry or poles, capable of capturing video and analyzing it by built-in or external AI chips, and outputting data such as traffic density, queue length, and abnormal events. In some embodiments, the data acquisition equipment may include an ETC gantry system installed on the main road gantry, capable of communicating with on-board units (OBUs) and outputting vehicle passage time, location, and direction of travel. In some embodiments, the data acquisition equipment is a laser / infrared detector installed on the roadside or gantry, capable of detecting vehicles using beam obstruction, and outputting data such as traffic flow and headway. In some embodiments, the data acquisition device may be a weather sensor installed at a roadside weather station, capable of monitoring environmental conditions and outputting visibility, rainfall, road surface moisture, and whether icing has occurred, etc. Figure 1 Taking system 100 as an example, data acquisition device 120 can communicate with computing device 110 through network 130 and send traffic data generated based on the acquired raw observation data to computing device.
[0020] Computing devices can include, but are not limited to, personal computers, server computers, handheld or laptop devices, mobile devices (such as mobile phones, personal digital assistants (PDAs), media players, etc.), multiprocessor systems, consumer electronics, wearable electronic devices, smart home devices, minicomputers, mainframe computers, edge computing devices, and distributed computing systems that include any of the above systems or devices. The intelligent models within these computing devices can perform short-term traffic flow predictions based on raw observation data sent by data acquisition devices, obtaining short-term traffic flow information for the next 2-3 hours, providing data support for the management and control of smart roads.
[0021] Understandably, despite Figure 1 The intelligent model 111 is deployed in the computing device 110. However, depending on the actual needs, the intelligent model 111 can be split into multiple sub-models, and each sub-model can be deployed in a corresponding computing device to achieve distributed deployment, such as to support large-scale models.
[0022] The above combination Figure 1 A block diagram of an example environment 100 in which embodiments of the present disclosure can be implemented is described. The following is in conjunction with… Figure 2An interactive method for predicting road traffic flow according to embodiments of the present disclosure is described. Figure 2 A flowchart of an interactive method 200 for multimedia content according to an embodiment of the present disclosure is shown. Method 200 can... Figure 1 The method is executed at computing device 110 and any suitable computing device. It should be understood that the numbers in the flowchart of method 200 do not indicate the order in which these steps are executed; some or all of these steps may be executed in parallel, or their execution order may be interchanged, and this disclosure does not limit this. Furthermore, Figure 2 Method 200 may also include additional steps not shown and / or the steps shown may be omitted, and the scope of this disclosure is not limited in this respect.
[0023] Method 200 can be used to predict road traffic flow in the future (e.g., the next 2-3 hours). Figure 2 As shown in box 202, method 200 may include generating historical aggregated feature data of the road to be predicted using a graph attention network based on historical traffic flow data of the road to be predicted. In some embodiments, a corresponding road network map may be constructed based on the road to be predicted. In the road network map, corresponding nodes are defined based on important traffic flow monitoring locations such as road intersections, entrances, and exits. The road network map also constructs edges based on the road connection relationships between nodes in the road to be predicted in a geographic information system (GIS), with each edge representing a road segment between two nodes. Depending on the traffic rules of the road segment, the edges can be directed or undirected. For example, in the case of a one-way street, the edges are directed; while in the case of a two-way street, the edges can be undirected. The edges of the road network map may also have weights to represent the cost from one node to another, such as travel time, distance, or toll fees. Historical traffic flow data may include traffic flow (i.e., vehicle flow) at each node location in the road network map over a past period (e.g., one week). In some embodiments, the traffic flow at each node location can be determined based on... Figure 1 The raw observation data is obtained from the data acquisition terminal. The graph attention network is constructed based on the road network map of the road to be predicted. In some embodiments, the road network map of the road to be predicted can be represented as an adjacency matrix, which serves as the initial adjacency matrix of the graph attention network. The graph attention network enables historical aggregated feature data to undergo spatial topological aggregation, which not only includes the flow characteristics of the nodes themselves, but also incorporates geospatial constraints and the states of neighboring nodes.
[0024] In box 204, method 200 may include generating historical feature encoding data of the road to be predicted based on historical holiday data, historical weather data, and historical aggregated feature data, using Transformer encoding under the constraints of a graph attention network. Historical holiday data corresponds to historical traffic flow data and is used to characterize the temporal characteristics of each historical observation period in the historical traffic flow data (e.g., time of day, whether it is a holiday, etc.). Historical weather data corresponds to historical traffic flow data and is used to characterize the weather conditions of each traffic monitoring node within each historical observation period in the historical traffic flow data. The graph attention network in box 204 is the same as that in box 202, both constructed based on the road network map of the road to be predicted. Through the constraints of the graph attention network, the Transformer encoder can perform calculations in the temporal dimension while also focusing on spatial relationships.
[0025] In box 206, method 200 may include generating traffic flow features for the road to be predicted in the future time period based on future holiday data, future weather data, and historical feature encoding data, using Transformer decoding and under the constraints of a graph attention network. Future holiday data includes the temporal features of the future time period to be predicted (e.g., time of day, whether it is a holiday, etc.). Future weather data includes weather forecast information for each node location in the road network map within the future time period to be predicted. The graph attention network in box 206 is the same as that in box 202, both constructed based on the road network map of the road to be predicted. The constraints of the graph attention network enable the Transformer decoder to fuse temporal and spatial features to obtain more accurate traffic flow features.
[0026] In this way, the method of this disclosure can fully integrate external factors such as weather, holidays / special events, and temporary traffic control that dynamically change the propagation speed and path selection of traffic flow, thereby improving the accuracy of short-term traffic flow prediction.
[0027] Figure 3 A schematic diagram illustrating the working process of a method for predicting road traffic flow according to an embodiment of the present disclosure is shown. Figure 3 As shown, in one or more embodiments of this disclosure, the method may be invoked Figure 1 The intelligent model 111 predicts short-term traffic flow. In one or more embodiments of this disclosure, the intelligent model may include a graph attention network 310, a Transformer encoder 320, and a Transformer decoder 330. Figure 1 The data acquisition device 120 and computing device 110 can at least obtain Figure 2Historical traffic flow data required for short- to medium-term traffic flow. In one or more embodiments of this disclosure, edge servers can be set up at each traffic monitoring node. The edge servers can receive and process the raw observation data from the data acquisition devices associated with the traffic monitoring node to obtain the traffic data at that traffic monitoring node and send it to the computing device. In one or more embodiments of this disclosure, the raw observation data from the data acquisition devices can also be directly sent to the computing device for processing to obtain the traffic data at each traffic monitoring node.
[0028] In one or more embodiments of this disclosure, the road network map can be based on Geographic Information System (GIS) data and road connectivity relationships, defining each traffic monitoring node in the road to be predicted as a set of graph nodes V={v1,v2,…,v…}. N}, each node V i Each node has a corresponding traffic flow value as its feature. The road network diagram also includes edges representing connecting road segments between two nodes, for example, A. ij Representative node v i to node v j The road segment in the direction, side A ji Representative node v j to node v i The road segment represents the direction of the road. Each edge in the road network graph has a corresponding weight, which represents the cost of traveling from one node to another. In one or more embodiments of this disclosure, the weight of an edge can be the length of the road segment between two nodes. In one or more embodiments of this disclosure, an initial adjacency matrix of the graph attention network 310 can be constructed based on the road network graph of the road to be predicted. Matrix element A ji The matrix elements correspond one-to-one with the nodes in the road network diagram. Based on the weights of each edge in the road network diagram, the values of the matrix elements can be determined.
[0029]
[0030] in, Represents node v i With node v j The length of the road segment.
[0031] In one or more embodiments of this disclosure, three sub-sequences—recent, daily, and weekly—can be extracted from historical traffic flow data to display the multi-scale time dependence of modeled traffic flow. This allows intelligent models to more accurately capture short-term fluctuations, daily patterns, and weekly trends, thereby improving prediction accuracy. In one or more embodiments of this disclosure, traffic flow data for the corresponding duration prior to the current moment can be extracted from historical traffic flow data based on the duration of the future time period to be predicted, forming a recent historical traffic flow sequence. Based on the future time period to be predicted, traffic flow data for the corresponding time period of the day preceding the future time period can be extracted from historical traffic flow data, forming a daily historical traffic flow sequence. Based on the future time period to be predicted, traffic flow data for the corresponding time period of the week preceding the future time period can be extracted from historical traffic flow data, forming a weekly historical traffic flow sequence. In one or more embodiments of this disclosure, historical traffic flow data can be a two-dimensional tensor matrix. (i.e., historical traffic flow tensor), representing traffic flow at each node over at least the past week. Here, N is the number of traffic flow monitoring nodes (i.e., nodes in the road network diagram), T is the number of historical observation periods, and each element X... it This represents the traffic flow value of node i in time period t. The number of historical observation time periods T is determined by the observation time step. If the historical traffic flow tensor includes traffic flow over the past week (168 hours) and the observation time step is 15 minutes, then the number of historical observation time periods per hour is 4, and the total number of historical observation time periods T in the historical traffic flow tensor is 672 (168 * 4). For example, if the current time is 8:00 AM on Tuesday, and we need to predict the traffic flow for the next 2-3 hours (i.e., 10:00 AM to 11:00 AM this Tuesday), we can extract the traffic flow values from the historical traffic flow tensor X for the 2-3 hours prior to the current time, i.e., from 5:00 AM to 6:00 AM this morning, to form the recent historical traffic flow sequence. Extract the traffic flow values for the corresponding time period yesterday, i.e., Monday morning from 10:00 to 11:00, from the historical traffic flow tensor X to form a daily periodic historical traffic flow sequence. Extract the traffic flow values for the corresponding time period from the previous week (i.e., from 10:00 AM to 11:00 AM on Tuesday of last week) from the historical traffic flow tensor X to form a weekly historical traffic flow sequence. Since the observation time for each subsequence is the same (1 hour), the number of observation time periods T for each subsequence is... * All are 4.
[0032] In one or more embodiments of this disclosure, recent historical traffic sequence X r Daily periodic historical flow sequence X d , Weekly historical flow sequence X wThe data is fed into the graph attention network 310 in parallel. In the graph attention network, different attention mechanisms can be introduced based on each periodic subsequence, assigning different weights to different neighboring nodes of each node in the road network graph, resulting in three historical aggregated feature sequences that form historical aggregated feature data. For example, based on the initial adjacency matrix A, the input recent historical traffic sequence X can be used to... r By introducing a corresponding attention mechanism, different weights are assigned to different neighboring nodes of each node in the road network graph, thus obtaining the recent historical aggregated feature sequence X corresponding to the recent historical traffic sequence. r ’ It can be based on the initial adjacency matrix A, according to the input daily periodic historical flow sequence X. d By introducing a corresponding attention mechanism, different weights are assigned to different neighbor nodes of each node in the road network diagram to obtain the daily periodic historical aggregated feature sequence X corresponding to the daily periodic historical traffic sequence. d ’ It can be based on the initial adjacency matrix A, according to the input daily periodic historical flow sequence X. w By introducing a corresponding attention mechanism, different weights are assigned to different neighboring nodes of each node in the road network diagram to obtain the daily periodic historical aggregated feature sequence X corresponding to the daily periodic historical traffic sequence. w ’ Specifically, for First, regarding X * Perform a linear transformation to adjust the feature dimensions, and obtain the corresponding linear projection H. ’ :
[0033]
[0034] in, Let d be a learnable weight matrix, and let d represent X. * The original node feature dimension is given by F, and the transformed feature dimension is given by F. Then, the feature dimension of any node pair (v) in the road network graph is calculated. i , v j Attention score e ij :
[0035]
[0036] in, For a learnable vector, the symbol " " indicates vector concatenation. Then, for node v..." i Softmax is performed on the set N(i) of all neighboring nodes:
[0037]
[0038] Subsequently, a dynamic adjacency matrix is generated. , where the symbol " "" indicates the Hadama product operation.
[0039] Finally, by aggregating the neighbor information, we obtain... Corresponding historical aggregated feature sequence σ is the ReLU activation function. The final obtained historical aggregated feature sequence X s It is a tensor of shape N*F (N is the number of nodes in the road network graph, and F is the feature dimension of the node after linear transformation). It not only contains the flow characteristics of the node itself, but also incorporates the geospatial constraints and neighbor node states contained in the road network graph through the adjacency matrix.
[0040] In one or more embodiments of this disclosure, the recent historical aggregation feature sequence X in the historical aggregation feature data obtained by the graph attention network 310 r 'Daily Periodic Historical Aggregated Feature Sequence X' d ', Weekly Periodic Historical Aggregated Feature Sequence X w The data will be fed into encoder 320 in parallel for processing, thereby obtaining the corresponding recent historical spatiotemporal dimension features Y. r Daily cycle historical spatiotemporal dimension characteristics Y d , Periodic historical spatiotemporal dimension features Y w This constitutes the historical feature encoding data Y. Specifically, for each historical aggregated feature sequence in the historical aggregated feature data... First, based on the historical holiday data corresponding to the historical traffic data, X is generated. s The corresponding semantic temporal embedding E time And add them together. In one or more embodiments of this disclosure, historical holiday data may include each element X in the historical traffic tensor X. it A one-to-one time tag is a vector m{hour, weekday, is_holiday, is_workday} composed of multiple type variables. The field hour is used to represent the corresponding element X. it The observation period is the hour of a 24-hour day; the field weekday is used to represent the corresponding element X. it The observation period is the day of the week out of the 7 days of the week; the field is_holiday is used to represent the corresponding element X. it Whether the day of the observation period is a holiday, such as May Day or National Day; the field is_workday is used to indicate whether the corresponding element X it Is the observation period a weekday? Based on the elements X in the historical flow tensor X. itThe time tags can be used to construct a historical holiday tensor corresponding to historical traffic. Since each element of each vector in the tensor is discrete and not numerically continuous, in one or more embodiments of this disclosure, the historical holiday tensor can be mapped to a historical time embedding through an embedding layer. Afterwards, with X s The sum is used as the input to encoder 320.
[0041] like Figure 3 As shown, in one or more embodiments of this disclosure, the encoder 320 may be a Transformer encoder, and each layer of the encoder may include three sub-modules: a multi-head self-attention network 321, a graph attention network 322, and a feedforward network 323. The historical aggregated feature sequences in the historical aggregated feature data... Embedded in historical time After addition, the sums are fed into encoder 320 in parallel, and then the output is aggregated with the recent historical feature sequence X. r 'Corresponding recent historical spatiotemporal dimension feature sequence Y r , and the daily cycle historical aggregation feature sequence X d 'Corresponding daily cycle historical spatiotemporal dimension feature sequence Y d , and the periodic historical aggregation feature sequence X w 'Corresponding periodic historical spatiotemporal dimension feature sequence Y w Composed of historical spatiotemporal dimension feature data In one or more embodiments of this disclosure, the multi-head self-attention submodule 321 can perform a multi-head self-attention mechanism on the input of encoder 320 based on historical weather data to obtain historical time dimension features corresponding to the historical aggregated feature sequence. In one or more embodiments of this disclosure, the historical weather day data corresponding to the historical traffic flow tensor can be a historical weather tensor representing historical weather information. Where E represents the number of weather features (i.e., how many weather indicators are there for each historical observation period), and each element p in the historical weather tensor P... it p represents the weather information of node i in the t-th historical observation period. it It can be a matrix of T rows and E columns, with each row corresponding to the weather conditions for a specific observation period. In one or more embodiments of this disclosure, weather features may include quantified humidity, temperature, rainfall, visibility, wind speed, icing conditions, and fog conditions. In one or more embodiments of this disclosure, the historical weather tensor P can be input into a small multilayer perceptron (MLP) to obtain the corresponding attention bias matrix. The multi-head self-attention submodule can execute based on Temporal self-attention mechanism:
[0042]
[0043] Where Q represents the query vector of the attention mechanism, K represents the key vector of the attention mechanism, and V represents the value vector of the attention mechanism, all of which are obtained by linear transformation based on the input of the multi-head self-attention submodule. d represents the feature dimension of each node in the input of the multi-head self-attention submodule, and T represents the total number of observation time steps for each node in the input of the multi-head self-attention submodule. It can modify the original attention score in the multi-head self-attention mechanism, so that the multi-head self-attention mechanism submodule can know that the traffic is more relevant in certain weather conditions and certain time periods, and output the historical time dimension features corresponding to the historical aggregated feature sequence.
[0044] The multi-head self-attention submodule only performs operations on the time dimension. This weighted fusion on the time axis can easily dilute the local spatial structure information extracted by the graph attention network 310. Therefore, in one or more embodiments of this disclosure, the historical time dimension features output by the multi-head self-attention submodule can be input into the graph attention network 322 submodule to refocus spatial relationships. In one or more embodiments of this disclosure, the graph attention network 322 is the same as the graph attention network 310 (i.e., it has the same initial adjacency matrix A). The graph attention network 322 can introduce a corresponding attention mechanism based on the input historical time dimension features, assign different weights to different neighbor nodes of each node in the road network graph, and output the historical spatiotemporal dimension features corresponding to the historical feature aggregation sequence through the feedforward network 323. That is, the recent historical aggregation feature sequence X r 'Corresponding recent historical spatiotemporal dimension feature sequence Y r Daily periodic historical aggregated feature sequence X d 'Corresponding daily cycle historical spatiotemporal dimension feature sequence Y d Weekly historical aggregated feature sequence X w 'Corresponding periodic historical spatiotemporal dimension feature sequence Y w Thus, historical spatiotemporal dimension feature data is obtained. .
[0045] In one or more embodiments of this disclosure, the historical feature encoding data Y' can be obtained by adaptively weighting the three sets of historical spatiotemporal dimension feature sequences output by encoder 320 through gating fusion 350:
[0046]
[0047] like Figure 3As shown, in one or more embodiments of this disclosure, an initial feature sequence of traffic flow features can be randomly generated and passed through a graph attention network 360 to obtain initial graph attention features of the traffic flow features. In one or more embodiments of this disclosure, the graph attention network 360 is the same as the graph attention network 310 (i.e., it has the same initial adjacency matrix). The graph attention network 360 can introduce a corresponding attention mechanism based on the input initial feature sequence, assign different weights to different neighbor nodes of each node in the road network graph, and output the initial graph attention features.
[0048] Based on the initial graph attention features and the future holiday data for the desired future time period, initial encoded data can be generated and fed into encoder 330 for encoding. In one or more embodiments of this disclosure, future holiday data can be constructed based on the observation time step of the historical traffic tensor X and the specific time of the future time period. For example, if the current time is 8:00 AM on Tuesday, it is necessary to predict the traffic flow for the next 2-3 hours (i.e., 10:00 AM to 11:00 AM this Tuesday). If the observation time step is 15 minutes, then there should be 4 future observation time periods per hour. For each future observation time period, a time label corresponding one-to-one with a node in the road network graph can be constructed. This time label is a vector m{hour, weekday, is_holiday, is_workday} composed of multiple type variables. The field hour indicates which hour of the 24-hour period the future observation time period is; the field weekday indicates which day of the week the future observation time period is; the field is_holiday indicates whether the day of the future observation time period is a holiday, such as May Day or National Day; and the field is_workday indicates whether the future observation time period is a workday. Based on the time labels of each node in the road network map, a tensor for future holidays can be constructed, which can then be mapped to future time embeddings through an embedding layer. The future time embedding is added to the initial graph attention features output by the graph attention network 360 and then fed into the decoder 330 for processing. The decoder 330 can generate traffic flow features of the road to be predicted in the future time period based on historical spatiotemporal encoded data Y' and future weather data.
[0049] In one or more embodiments of this disclosure, the decoder 330 may employ a Transformer decoder, and each layer of the decoder may include four sub-modules: a masked multi-head self-attention network 331, a graph attention network 332, a cross-multi-head self-attention network 333, and a feedforward network 334. In one or more embodiments of this disclosure, the masked multi-head self-attention module 331 may perform a masked multi-head self-attention mechanism on the input of the decoder 330 based on future weather data to obtain the future time dimension features of traffic flow characteristics. In one or more embodiments of this disclosure, the future weather data corresponding to the predicted future time period may be a future weather tensor representing future weather information. Where E represents the number of weather features (i.e., how many weather indicators are there for each future observation period), and each element p in the future weather tensor P... it p represents the weather information for node i in the t-th future observation period. it It can be a matrix of T rows and E columns, with each row corresponding to the weather conditions for a future observation period. In one or more embodiments of this disclosure, weather features may include quantified humidity, temperature, rainfall, visibility, wind speed, whether icing occurs, and whether there is fog, etc. In one or more embodiments of this disclosure, the future weather tensor P can be input into a small multilayer perceptron (MLP) to obtain the corresponding attention bias matrix. The multi-head self-attention submodule can execute based on Temporal self-attention mechanism:
[0050]
[0051] Where Q represents the query vector of the attention mechanism, K represents the key vector of the attention mechanism, and V represents the value vector of the attention mechanism, all of which are obtained by linear transformation based on the input of the masked multi-head self-attention submodule. d represents the feature dimension of each node in the input of the masked multi-head self-attention submodule, T represents the total number of observation time steps for each node in the input of the masked multi-head self-attention submodule, and M represents the upper triangular mask matrix. It can modify the original attention score in the masked multi-head self-attention mechanism and the future time dimension features of traffic flow.
[0052] In one or more embodiments of this disclosure, the future temporal dimension features output by the masked multi-head self-attention submodule can be input into the graph attention network 332 submodule to refocus spatial relationships. In one or more embodiments of this disclosure, the graph attention network 332 is the same as the graph attention network 310 (i.e., it has the same initial adjacency matrix A). The graph attention network 332 can introduce a corresponding attention mechanism based on the input future temporal dimension features, assigning different weights to different neighboring nodes of each node in the road network graph, and outputting the future spatiotemporal dimension features of traffic flow.
[0053] In one or more embodiments of this disclosure, future spatiotemporal dimension features are fed into decoder 330 to transform and obtain the Q-matrix of the cross-multi-head self-attention submodule 333. The encoder 320 outputs historical feature encoded data Y. ‘ The data are fed into decoder 330 to transform and obtain the K and V matrices of the cross-multi-head self-attention 333 submodule. The cross-multi-head self-attention mechanism is then implemented through the cross-multi-head self-attention 333 module.
[0054]
[0055] Where d represents the feature dimension of each node in the input of the multi-head cross self-attention submodule, and T represents the total number of observation time steps of each node in the input of the multi-head cross self-attention submodule.
[0056] In one or more embodiments of this disclosure, the traffic flow features obtained by passing the output of the cross-head self-attention 333 module through a feedforward network can be fed into a linear network 350 to generate a prediction result of the future traffic flow of the road to be predicted.
[0057] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this specification are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., Digital Versatile Discs (DVDs)), or semiconductor media (e.g., Solid State Disks (SSDs)).
[0058] Figure 4 A block diagram of an electronic device 400 that can implement various embodiments of the present disclosure is shown. For example... Figure 4 As shown, the electronic device 400 includes a processor 410, a disk drive 420, an input / output interface 430, a network interface 440, and a memory 450. The processor 410, disk drive 420, input / output interface 430, network interface 440, and memory 450 can communicate with each other via a communication bus 460.
[0059] The processor 410 can be implemented using a general-purpose CPU, microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits to execute relevant programs and implement the technical solution provided in this application.
[0060] The memory 450 can be implemented in the form of ROM (Read Only Memory), RAM (Read Access Memory), static memory, dynamic storage devices, etc. The memory 450 can store the operating system 451 used to control the operation of the electronic device 400, and the basic input / output system (BIOS) 452 used to control the low-level operations of the electronic device 400. Additionally, it can store a web browser 453, a data storage management system 454, etc. In summary, when the technical solution provided in this application is implemented through software or firmware, the relevant program code is stored in the memory 450 and is called and executed by the processor 410.
[0061] Input / output interface 430 is used to connect input / output modules to realize information input and output. Input / output modules can be configured as components in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touch screens, microphones, various sensors, etc., and output devices may include displays, speakers, vibrators, indicator lights, etc.
[0062] Network interface 440 is used to connect a communication module (not shown in the figure) to enable communication and interaction between the device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0063] Bus 460 includes a pathway for transmitting information between various components of the device, such as processor 410, disk drive 420, input / input interface 430, network interface 440, and memory 450.
[0064] It should be noted that although the above-described device only shows the processor 410, disk drive 420, input / output interface 430, network interface 440, memory 450, bus 460, etc., in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the method of this application, and does not necessarily include all the components shown in the figures.
[0065] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0066] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing. Furthermore, although operations are depicted in a specific order, this should be understood as requiring that such operations be performed in the specific order shown or in sequential order, or requiring that all illustrated operations be performed to achieve the desired result. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the foregoing discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single implementation. Conversely, various features described in the context of a single implementation may also be implemented individually or in any suitable sub-combination in multiple implementations.
[0067] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A method for predicting road traffic flow, used to predict the traffic flow of a road in a future time period; characterized in that, The future time period includes corresponding future holiday data and future weather data; the road to be predicted has a corresponding road network map, which includes multiple nodes for monitoring traffic flow and edges corresponding to the roads between the nodes; and the method includes: Based on the historical traffic data of the road to be predicted, historical aggregated feature data of the road to be predicted is generated through a graph attention network. The historical traffic data includes corresponding historical holiday data and historical weather data. The graph attention network has an initial adjacency matrix generated based on the road network graph. The historical traffic data includes historical traffic monitoring data of each node. Based on the historical holiday data, the historical weather data, and the historical aggregated feature data, historical feature encoding data of the road to be predicted is generated under the constraints of the graph attention network using Transformer encoding; and Based on the future holiday data, the future weather data, and the historical feature encoding data, the traffic flow characteristics of the road to be predicted in the future time period are generated by decoding with Transformer and under the constraints of the graph attention network.
2. The method according to claim 1, characterized in that, The historical aggregated feature data includes recent historical aggregated feature sequences, daily periodic historical aggregated feature sequences, and weekly periodic historical aggregated feature sequences. Furthermore, the generation of historical feature encoding data for the road to be predicted, based on the historical holiday data, the historical weather data, and the aggregated historical feature data, through Transformer encoding under the constraints of the graph attention network, includes: Based on the recent historical aggregated feature sequence, the daily periodic historical aggregated feature sequence, and the weekly periodic historical aggregated feature sequence, a historical periodic gated fusion feature sequence of the road to be predicted is generated through gated fusion; and Based on the historical periodic gating fusion feature sequence, the historical holiday data, and the historical weather data, historical feature encoding data of the road to be predicted is generated under the constraints of the graph attention network through Transformer encoding.
3. The method according to claim 2, characterized in that, The generation of the historical aggregated feature data includes: Based on the historical traffic data, the recent historical traffic sequence, daily periodic historical traffic sequence, and weekly periodic historical traffic sequence of the road to be predicted are obtained; and The graph attention network is used to obtain the corresponding recent historical aggregated feature sequence, the daily historical aggregated feature sequence, and the weekly historical aggregated feature sequence based on the recent historical traffic sequence, the daily historical traffic sequence, and the weekly historical traffic sequence, respectively.
4. The method according to claim 3, characterized in that, The step of obtaining the corresponding recent historical aggregated feature sequence, the daily historical aggregated feature sequence, and the weekly historical aggregated feature sequence through the graph attention network, based on the recent historical traffic feature sequence, the daily periodic historical traffic feature sequence, and the weekly periodic historical traffic feature sequence, respectively, includes: Based on the historical traffic sequence, a linear projection of the historical traffic sequence is generated; Based on the linear projection of the historical traffic feature sequence and the initial adjacency matrix, a dynamic adjacency matrix of the initial adjacency matrix with respect to the historical traffic feature sequence is generated; and Based on the dynamic adjacency matrix and the linear projection, a historical aggregated feature sequence corresponding to the historical traffic feature sequence is generated.
5. The method according to claim 2, characterized in that, The generation of the historical feature encoded data includes: Based on the historical holiday data, the historical weather data, and the historical aggregated feature data, a multi-head self-attention network is used to generate historical time dimension features corresponding to the historical aggregated feature data. Based on the historical time dimension features, the historical spatiotemporal dimension features corresponding to the historical aggregated feature data are generated through the graph attention network; and Based on the aforementioned historical spatiotemporal features, the historical feature encoding data is generated through gating fusion.
6. The method according to claim 5, characterized in that, The step of generating historical spatiotemporal dimension features corresponding to the historical time dimension features through the graph attention network based on the historical time dimension features includes: Based on the historical time dimension features and the initial adjacency matrix, a dynamic adjacency matrix of the initial adjacency matrix with respect to the historical time dimension features is generated; and Based on the dynamic adjacency matrix and the historical time dimension features, the historical spatiotemporal dimension features are generated.
7. The method according to claim 2, characterized in that, The generation of the traffic flow characteristics includes: Based on the initial feature sequence, the initial graph attention features of the traffic flow features are generated through the graph attention network; Based on the future holiday data, the future weather data, and the initial graph attention features, the future time dimension features of the traffic flow features are generated through a masked multi-head self-attention network. Based on the aforementioned future time dimension features, the graph attention network is used to generate future spatiotemporal dimension features of the traffic flow characteristics; and Based on the future spatiotemporal dimension features and the historical feature encoding data, the traffic flow features are generated through a cross-multi-head self-attention network.
8. The method according to claim 7, characterized in that, The future time dimension features, generated through the graph attention network, include the following future spatiotemporal dimension features of the traffic flow features: Based on the future time dimension features and the initial adjacency matrix, a dynamic adjacency matrix of the initial adjacency matrix with respect to the future time dimension features is generated; and Based on the dynamic adjacency matrix and the future time dimension features, the future spatiotemporal dimension features are generated.
9. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-8.
10. Electronic devices, including: One or more processors, and A memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the steps of the method according to any one of claims 1-8.