Road traffic state prediction method and device based on graph attention network
By using a graph attention network-based approach, the spatiotemporal characteristics of traffic flow are dynamically modeled, which solves the problem of insufficient accuracy of traditional traffic forecasting under special events, and achieves high-accuracy traffic flow forecasting to support traffic management decisions.
Patent Information
- Application Number
- CN202411831631.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2044-12-12
AI Technical Summary
Traditional traffic forecasting methods struggle to capture the sudden and nonlinear changes brought about by special events, resulting in a significant decrease in forecast accuracy and making it difficult to provide a reliable basis for traffic management decisions.
A graph attention network-based approach is adopted to obtain spatiotemporal embedding representations through event encoding, perform feature extraction and hierarchical modeling, dynamically capture the spatiotemporal features of traffic flow, and use multi-timescale spatiotemporal graphs for prediction.
It improves the accuracy of traffic flow prediction under special events, provides reliable data support for traffic management decisions, and enhances traffic management efficiency and the construction of an intelligent urban traffic management system.
Smart Images

Figure CN119625987B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of traffic engineering. More particularly, the present application relates to a road traffic state prediction method and device based on a graph attention network. BACKGROUND
[0002] With the acceleration of urbanization and the development of economic society, special events such as holidays (such as the Spring Festival, National Day and May Day holidays, etc.), large-scale activities in cities (such as large-scale comprehensive sports meetings) have an increasingly significant impact on urban traffic. These special events are prone to cause a sharp increase in traffic flow in local areas, resulting in serious congestion on the road network. Traditional traffic prediction methods mainly rely on statistical analysis of historical data, using time series models such as ARIMA, Kalman filtering, etc. for prediction. Such methods perform well in daily traffic flow prediction, but in the case of the above-mentioned special events, due to the inability to effectively capture the suddenness and non-linear change characteristics brought about by the events, the prediction accuracy is significantly reduced, and it is difficult to provide reliable data support for traffic management decisions. SUMMARY
[0003] The purpose of the present application is to provide a road traffic state prediction method and device based on a graph attention network, which can improve the accuracy of traffic flow prediction in the case of special events and provide reliable data support for traffic management decisions. The present application is mainly realized through the following technical solutions:
[0004] In a first aspect of the present application, a road traffic state prediction method based on a graph attention network is provided, comprising:
[0005] obtaining historical traffic sequence information;
[0006] performing event encoding processing on the historical traffic sequence information to obtain a spatio-temporal embedding representation;
[0007] performing feature extraction processing on the spatio-temporal embedding representation to obtain historical spatio-temporal features;
[0008] performing fine-grained hierarchical modeling processing on the historical spatio-temporal features to obtain a two-step spatio-temporal graph and a three-step spatio-temporal graph;
[0009] performing conversion processing on the historical spatio-temporal features, the two-step spatio-temporal graph and the three-step spatio-temporal graph to obtain a first time scale spatio-temporal graph, a second time scale spatio-temporal graph and a third time scale spatio-temporal graph;
[0010] performing decoding processing on the first time scale spatio-temporal graph, the second time scale spatio-temporal graph and the third time scale spatio-temporal graph to obtain predicted traffic flow information.
[0011] According to one embodiment of the present application, the step of performing event encoding processing on the historical traffic sequence information to obtain a spatio-temporal embedding representation comprises:
[0012] Setting a first time step;
[0013] Dividing the historical traffic sequence information based on the first time step to obtain a plurality of historical traffic segments and a plurality of time steps, each time step being in a one-to-one correspondence with one of the historical traffic segments;
[0014] Encoding the day of the week information of all historical traffic segments as an R 7 vector using one-hot encoding;
[0015] Encoding the specific time of day information of all historical traffic segments as an R 720 vector using one-hot encoding;
[0016] In the case where the traffic flow change of a target historical traffic segment exceeds a first preset value and / or the target historical traffic segment belongs to a preset rule, marking the target historical traffic segment as event information, wherein the target historical traffic segment is any one of the plurality of historical traffic segments;
[0017] Encoding all event information as an R 3 vector using one-hot encoding;
[0018] Concatenating the R 7 vector, the R 720 vector, and the R 3 vector into an R 730 vector;
[0019] Converting the R 730 vector to obtain an R D vector, wherein D is set to 64;
[0020] Obtaining a traffic flow time feature embedding representation and a traffic flow space feature embedding representation of a first target road information at a first target time step based on the R D vector, wherein the first target road information is any road information in the historical traffic sequence information, and the first target time step is any one of the time steps;
[0021] Splicing the traffic flow time feature embedding representation and the traffic flow space feature embedding representation to form an event encoding of the first target road information at the first target time step;
[0022] Taking all the event encodings as the spatio-temporal embedding representation.
[0023] According to one embodiment of the present application, the step of performing feature extraction processing on the spatio-temporal embedding representation to obtain historical spatio-temporal features comprises:
[0024] calculating a first time attention corresponding to the first target road information based on the spatio-temporal embedding representation and all the time steps;
[0025] calculating a first space attention corresponding to the first target road information based on the spatio-temporal embedding representation and all the road information;
[0026] calculating a fusion attention feature corresponding to the first target road information based on the first time attention and the first space attention;
[0027] combining the fusion attention features of the target road information at all time steps into the historical spatio-temporal features.
[0028] According to one embodiment of the present application, the step of performing fine-grained hierarchical modeling processing on the historical spatio-temporal features to obtain a two-step spatio-temporal graph and a three-step spatio-temporal graph comprises:
[0029] performing residual calculation on the historical spatio-temporal features to obtain the two-step spatio-temporal graph;
[0030] performing a convolution operation on the historical spatio-temporal features in the time scale by a second time step to obtain the three-step spatio-temporal graph.
[0031] According to one embodiment of the present application, the step of performing conversion processing on the historical spatio-temporal features, the two-step spatio-temporal graph and the three-step spatio-temporal graph to obtain a first time scale spatio-temporal graph, a second time scale spatio-temporal graph and a third time scale spatio-temporal graph comprises:
[0032] performing conversion processing on the historical spatio-temporal features by a first preset algorithm to obtain the first time scale spatio-temporal graph;
[0033] performing conversion processing on the two-step spatio-temporal graph by a second preset algorithm to obtain the second time scale spatio-temporal graph;
[0034] performing conversion processing on the three-step spatio-temporal graph by a third preset algorithm to obtain the third time scale spatio-temporal graph.
[0035] According to one embodiment of the present application, the step of performing decoding processing on the first time scale spatio-temporal graph, the second time scale spatio-temporal graph and the third time scale spatio-temporal graph to obtain predicted traffic flow information comprises:
[0036] performing integration processing on the first time scale spatio-temporal graph, the second time scale spatio-temporal graph and the third time scale spatio-temporal graph by a gated fusion mechanism to obtain a fusion feature;
[0037] performing feature extraction processing on the fusion features to obtain future spatiotemporal features;
[0038] performing integration processing on the future spatiotemporal features to obtain the predicted traffic flow information.
[0039] According to one embodiment of the present application, the step of performing feature extraction processing on the fusion features to obtain future spatiotemporal features comprises:
[0040] calculating a second temporal attention based on the fusion features and all the time steps;
[0041] calculating a second spatial attention based on the fusion features and all the road information;
[0042] calculating the future spatiotemporal features based on the second temporal attention and the second spatial attention.
[0043] According to a second aspect of the present application, a road traffic state prediction device based on a graph attention network is provided, comprising:
[0044] a historical traffic sequence information acquisition module configured to acquire historical traffic sequence information;
[0045] an event encoding module configured to perform event encoding processing on the historical traffic sequence information to obtain a spatiotemporal embedding representation;
[0046] a first multi-head spatiotemporal attention module configured to perform feature extraction processing on the spatiotemporal embedding representation to obtain historical spatiotemporal features;
[0047] a multi-time scale module configured to perform fine-grained hierarchical modeling processing on the historical spatiotemporal features to obtain a two-step spatiotemporal graph and a three-step spatiotemporal graph;
[0048] a conversion module configured to perform conversion processing on the historical spatiotemporal features, the two-step spatiotemporal graph, and the three-step spatiotemporal graph to obtain a first time scale spatiotemporal graph, a second time scale spatiotemporal graph, and a third time scale spatiotemporal graph;
[0049] a decoder configured to perform decoding processing on the first time scale spatiotemporal graph, the second time scale spatiotemporal graph, and the third time scale spatiotemporal graph to obtain predicted traffic flow information.
[0050] According to a third aspect of the present application, a terminal device is provided, comprising a processor and a memory, the memory being configured to store a computer program, and the processor being configured to invoke and run the computer program stored in the memory to execute the steps of the road traffic state prediction method based on a graph attention network provided in the first aspect of the present application.
[0051] In a fourth aspect, the present application provides a computer readable storage medium for storing a computer program, which causes a computer to execute the steps of the method for predicting road traffic state based on graph attention network according to the first aspect of the present application.
[0052] The present application has the following advantages:
[0053] The present application can identify the influence of events to predict the traffic flow of roads under special events by event encoding processing of historical traffic sequence information. Specifically, the present application is to obtain a spatiotemporal embedding representation by event encoding processing of historical traffic sequence information; obtain historical spatiotemporal features by feature extraction processing of the spatiotemporal embedding representation; obtain a two-step spatiotemporal graph and a three-step spatiotemporal graph by fine-grained hierarchical modeling processing of the historical spatiotemporal features; obtain a first time scale spatiotemporal graph, a second time scale spatiotemporal graph and a third time scale spatiotemporal graph by conversion processing of the historical spatiotemporal features, the two-step spatiotemporal graph and the three-step spatiotemporal graph; and obtain predicted traffic flow information by decoding processing of the first time scale spatiotemporal graph, the second time scale spatiotemporal graph and the third time scale spatiotemporal graph. Thus, compared with the prior art, the present application can improve the accuracy of traffic flow prediction under special events, and provide reliable data support for traffic management decisions. BRIEF DESCRIPTION OF DRAWINGS
[0054] In order to more clearly illustrate the technical solutions in the present application or prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative effort based on these drawings.
[0055] Figure 1 Flowchart of the method for predicting road traffic state based on graph attention network in some embodiments of the present application;
[0056] Figure 2 Flowchart of the method for predicting road traffic state based on graph attention network in some other embodiments of the present application;
[0057] Figure 3 Principle block diagram of the device for predicting road traffic state based on graph attention network in some embodiments of the present application;
[0058] Figure 4 Principle block diagram of the terminal device in some embodiments of the present application. DETAILED DESCRIPTION
[0059] In order to make the above objectives, features and advantages of the present application more clear and comprehensible, specific embodiments of the present application will be described below in detail with reference to the accompanying drawings. In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. It will be apparent, however, to one skilled in the art that the present application can be practiced without using some or all of these specific details. In other instances, well known process steps have not been described in detail in order to avoid obscuring the present application. The purpose of the above summary is to enable the patent applicant to draw attention to particular features of the application considered by the patent applicant as the most important in connection with the commercial utilization of the application. Since those skilled in the art will be enabled to learn the most important characteristics of the patented invention by reading the above summary, further specific details will become more fully apparent from the detailed description and claims that follow. Therefore, specific structural and functional details disclosed herein are not to be interpreted as limiting but merely as a basis for the claims and as a representative basis for teaching one skilled in the art to make or use the application.
[0060] It should be noted that the terms "first", "second", and the like, are used merely as labels, and are not intended to signify relative importance or a quantity of objects signified by the labels. Thus, a feature defined with "first", "second" can include at least one of the features, explicitly or implicitly. In the description of the application, the meaning of "a plurality" is at least two, for example, two, three, etc., unless otherwise specifically defined.
[0061] The term "exemplary" or "for example" is used to indicate that an example is one of a possible set of alternatives. Any embodiment or design scheme described as "exemplary" or "for example" should not be construed as necessarily being preferred or advantageous over other embodiments or design schemes. Rather, use of the terms "exemplary" or "for example" is merely intended to present concepts in a concrete manner.
[0062] The terms "include", "comprise" or their other variants are meant to encompass non-exclusive inclusions, for example, a process, method, system, product, or apparatus that comprises a list of steps or units need not be limited to those steps or units explicitly listed, but can include other steps or units that are not expressly listed or inherent to such processes, methods, products, or apparatus.
[0063] Unless otherwise defined, all technical and scientific terms used in the specification of the present application have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description of the present application only for the purpose of describing a specific embodiment of the present application, and is not intended to limit the present application. The term "and / or" used in the specification of the present application includes any and all combinations of one or more of the associated listed items.
[0064] With the acceleration of urbanization and the development of economy and society, special events such as holidays (such as the Spring Festival, National Day and May Day holidays) and large-scale activities in cities (such as large-scale comprehensive sports meetings) have an increasingly significant impact on urban traffic. These special events are prone to cause a sharp increase in traffic flow in local areas, resulting in serious congestion on the road network. Traditional traffic prediction methods mainly rely on statistical analysis of historical data and use time series models such as ARIMA, Kalman filtering, etc. for prediction. Such methods perform well in daily traffic flow prediction, but in the case of the above special events, they cannot effectively capture the suddenness and non-linear changes brought about by the events, resulting in a significant decrease in prediction accuracy and making it difficult to provide reliable basis for traffic management decisions.
[0065] With the development of deep learning technology, some scholars have attempted to use recurrent neural networks (RNN), long short-term memory networks (LSTM), etc. to achieve traffic prediction capabilities under special events. These methods have improved prediction accuracy to some extent, but they have not fully considered the spatio-temporal correlation characteristics of special events and how to dynamically capture and identify the occurrence of events, so there is still much room for improvement in their prediction effectiveness. For example, during large-scale sports events, traditional deep learning models have difficulty accurately predicting the degree of traffic impact caused by different events and the spatio-temporal distribution characteristics of the impact of events on traffic.
[0066] In recent years, graph neural networks have shown good application prospects in the field of traffic prediction. For example, the patent document CN114220271 B proposes a traffic flow prediction method based on dynamic spatio-temporal graph convolution recurrent network, which improves prediction accuracy by establishing a road network topology. Patent document CN117688453B proposes a traffic prediction model combining spatio-temporal attention mechanism, which has achieved good results in conventional traffic flow prediction. However, these methods have not fully considered the impact of event type, size, duration, etc. on traffic patterns when dealing with traffic prediction under the influence of special events, and have not effectively modeled the special scenario of special events to capture the dynamic evolution characteristics of traffic flow.
[0067] The existing methods generally have the following problems: first, they are difficult to effectively extract and utilize event feature information; second, they do not effectively model to capture the complex spatio-temporal dynamic evolution process. These problems seriously restrict the practical application effect of traffic prediction models in special event scenarios.
[0068] To address the aforementioned problems, this invention proposes a road traffic state prediction method based on graph attention networks. By dynamically modeling the spatiotemporal graph of traffic flow at different time scales using a graph attention mechanism, it achieves in-depth mining and dynamic modeling of traffic flow characteristics under the influence of events. Simultaneously, it dynamically captures traffic patterns and event information, improving prediction accuracy while possessing strong generalization ability and stability, providing powerful support for traffic management decisions under special events. The specific embodiments of this invention are further described below with reference to the accompanying drawings.
[0069] like Figure 1 The diagram shown is a flowchart of a road traffic state prediction method based on graph attention networks, provided by the first aspect of this invention. Figure 1 The road traffic state prediction method based on graph attention networks includes:
[0070] S1. Obtain historical traffic sequence information.
[0071] The historical traffic sequence information is historical traffic flow data for the area to be predicted over a preset time period. Each data point in the historical traffic sequence information includes, but is not limited to, spatial location information, time information, traffic flow information, traffic density information, and traffic speed information. In other embodiments, each data point in the historical traffic sequence information may also include event information, which can be specifically set by those skilled in the art according to actual needs.
[0072] The preset time period can be one day, one week, or one month. In other embodiments, the preset time period can be set by those skilled in the art according to actual needs.
[0073] Since the historical traffic sequence information is collected in real time, the present invention is able to accurately assess and predict the traffic flow evolution trend of the road network within the data coverage area.
[0074] Step S1 can be understood as... Figure 2 The "Historical Traffic Sequence Information Collection" step in the process.
[0075] S2. Perform event encoding processing on the historical traffic sequence information to obtain a spatiotemporal embedded representation.
[0076] Further, step S2 includes:
[0077] S201, Set the first time step.
[0078] In this invention, the first time step is 2 minutes. In other embodiments, the first time step can be other time values, which can be set by those skilled in the art according to actual needs, and this invention does not impose further limitations on this.
[0079] S202, performing division processing on the historical traffic sequence information based on the first time step, to obtain a plurality of historical traffic segments and a plurality of time steps, each time step being in one-to-one correspondence with one historical traffic segment.
[0080] S203, using one-hot encoding to encode the day of the week of the time information in all historical traffic segments as R 7 vector.
[0081] The one-hot encoding, also known as one-bit effective encoding, is a method of using an N-bit state register to encode N states, each state having its own independent register bit, and at any time, only one bit is effective.
[0082] The R 7 vector is a binary vector of length 7, that is, a real vector space with 7 dimensions.
[0083] The day of the week has 7 categories, namely Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday, so the application uses a binary vector of length 7 for one-hot encoding.
[0084] S204, using one-hot encoding to encode the specific time of day of all historical traffic segments as R 720 vector.
[0085] The R 720 vector is a binary vector of length 720, that is, a real vector space with 720 dimensions.
[0086] The specific time of day has 24 hours, and each hour has 60 minutes, so there are 1440 minutes in a day. Since the application takes 2 minutes as the first time step, the application adopts a dimension of 720.
[0087] S205, in the case where the traffic flow change of a target historical traffic segment exceeds a first preset value and / or the target historical traffic segment belongs to a preset rule, marking the target historical traffic segment as event information, wherein the target historical traffic segment is any one of the plurality of historical traffic segments.
[0088] The first preset value is 50%. In other embodiments, the first preset value can be set by those skilled in the art according to actual needs.
[0089] The preset rule refers to the time information of the target historical traffic segment meeting the time when a special event will occur. In other embodiments, the preset rule can also be other rules, which can be set by those skilled in the art according to actual needs.
[0090] The event information is actually special event information.
[0091] In the present application, special event or special event information refers to holidays (such as the Spring Festival, National Day and May Day holidays, etc.), city large-scale activities (such as large-scale comprehensive sports meeting) and the like.
[0092] S206, using one-hot encoding to encode all event information into R 3 vector.
[0093] The R 3 vector is a binary vector with a length of 3, that is, a real vector space with 3 dimensions.
[0094] S207, connecting the R 7 vector, the R 720 vector and the R 3 vector into R 730 vector.
[0095] The R 730 vector is a binary vector with a length of 730, that is, a real vector space with 730 dimensions.
[0096] The R 7 vector and the R 720 vector as time embedding, the R 3 vector as event embedding, after the S207 step is executed, the time embedding and the event embedding are fused together, so that the present application can realize accurate prediction of traffic state under the influence of holidays, large-scale activities and the like special events, can provide reliable decision basis for traffic management department to formulate traffic relief scheme, optimize signal timing and dispatch emergency resources, thereby can significantly improve the efficiency of traffic management under special events, and also provides strong technical support for building intelligent and fine urban traffic management system.
[0097] S208, converting the R 730 vector to obtain R D vector, wherein D is set to 64.
[0098] The R D vector is a binary vector with a length of D, that is, a real vector space with D dimensions.
[0099] The S208 step is realized by the first fully connected layer of the event encoding module in the road traffic state prediction device based on graph attention network.
[0100] Further, the S208 step includes:
[0101] S2081, setting a weight matrix and a bias vector.
[0102] The weight matrix is a matrix of size 730 x D, where 730 is the dimension of the input vector (i.e., the R 730 vector), and D is the dimension of the output vector (i.e., the R D vector).
[0103] The bias vector is a vector of size D, which is used to add an additional bias term in the output.
[0104] S2082, performing matrix multiplication operation on the R 730 vector and the weight matrix to obtain an intermediate result.
[0105] The intermediate result is a vector of size D, which represents the result of the linear transformation of the R 730 vector by the weight matrix.
[0106] Further, the calculation formula of the S2082 step is z = W * x, where z is the intermediate result, W is the weight matrix, and x is the R 730 vector.
[0107] S2083, performing element-wise addition operation on the intermediate result and the bias vector to obtain the R D vector.
[0108] S209, obtaining the traffic flow time feature embedding representation and the traffic flow space feature embedding representation of the first target road information at the first target time step based on the R D vector, where the first target road information is any road information in the historical traffic sequence information, and the first target time step is any time step in all the time steps.
[0109] S210, concatenating the traffic flow time feature embedding representation and the traffic flow space feature embedding representation to form the event encoding of the first target road information at the first target time step.
[0110] Specifically, the calculation formula of the S210 step is wherein, is the event encoding of the first target road information at the first target time step; is the traffic flow space feature embedding representation, i.e., the traffic flow space feature embedding representation of the first target road information v i (the i-th road information) at the first target time step t j (the j-th time step), The traffic flow time feature embedding representation of the first target road information v i In the first target time step t j The traffic flow time feature embedding representation of the first target road information v The data splicing operation R D The R D Vector.
[0111] The traffic flow time feature embedding representation of the first target road information v i may be a special node, that is, a special road. In the present application, each road information can be understood as a node.
[0112] The present application can set a second preset value, and use the mean value of one or more attributes of all nodes in the historical traffic sequence information to calculate the first correlation coefficient between any two nodes. If the first correlation coefficient is greater than the second preset value, it is considered that the two nodes are connected in the graph structure, thereby obtaining an analog adjacency matrix; then, the node2vec method is used to learn the vertex representation as the traffic flow space feature embedding representation of the first target road information v i , that is, the space embedding.
[0113] S211, encode all the events as the spatiotemporal embedding representation.
[0114] The S2 step can be understood as Figure 2 "spatiotemporal information and event information extraction" and "time embedding, space embedding, and event information embedding" steps in the present application.
[0115] S3, performing feature extraction processing on the spatiotemporal embedding representation to obtain historical spatiotemporal features. The S3 step can be understood as Figure 2 "historical spatiotemporal feature calculation" in the present application.
[0116] The S3 step is realized by a first multi-head spatiotemporal attention module in the graph attention network-based road traffic state prediction device. Therefore, it can be understood as Figure 2 the "first multi-head spatiotemporal attention module" process in the present application.
[0117] Further, the S3 step includes:
[0118] S301, calculating a first time attention corresponding to the first target road information based on the spatiotemporal embedding representation and all the time steps.
[0119] The S301 step includes:
[0120] S3011, in all the time steps, all the time steps except the first target time step form a first to-be-processed set.
[0121] S3012. Calculate the first correlation between the first target road information at the first target time step and the second target time step, where the second target time step is any time step in the first set to be processed.
[0122] Specifically, the calculation formula for step S3012 is as follows:
[0123]
[0124] in, For the first target road information ν i (The i-th road information) is at the first target time step t j The first correlation between (the j-th time step) and the second target time step; K is the total number of attention heads; t is the second target time step, which is also the t-th time step in the first set of objects to be processed; The length of the first set to be processed is the total number of all other time steps besides the first target time step. For the first target time step t j The second correlation coefficient between the second target time step t and the second target time step t; For the first target road information ν i The value of the traffic flow state at the second target time step t; exp(·) is an exponential function with the natural constant e as the base; For the first target time step t in the k-th attention head j The second correlation between the second target time step t and the second correlation between t and the second target time step t; r For the t-th element in the first set to be processed r One time step; For the first target time step t in the k-th attention head j With the tth r The third correlation between time steps; For the first target road information ν i At the first target time step t j The value of the traffic flow status; In the spatiotemporal embedding representation, the event encoding of the first target road information at the first target time step; For data concatenation operations; In the spatiotemporal embedding representation, the event encoding of the first target road information at time step t is defined; d is the output dimension, d = D / k, D = 64.
[0125] S3013, The first correlation is used as the first temporal attention.
[0126] S302、based on the spatio-temporal embedding representation and all the road information, calculating a first spatial attention corresponding to the first target road information.
[0127] The S302 step includes:
[0128] S3021, among all the road information, all other road information except the first target road information constitutes a second to-be-processed set.
[0129] S3022, calculating a fourth correlation of the first target road information at the first target time step and a second target road information, the second target road information being any one road information in the second to-be-processed set.
[0130] Specifically, the calculation formula of the S3022 step is:
[0131]
[0132] Among them, is the fourth correlation of the first target road information ν i at the first target time step t j and the second target road information; K is the total number of attention heads; ν is the second target road information, that is, the νth road information in the second to-be-processed set; V is the length of the second to-be-processed set, that is, the total number of all other road information except the first target road information; is the third correlation coefficient of the first target road information ν i and the second target road information ν; is the value of the traffic flow state of the second target road information ν at the first target time step t j ; exp(·) is an exponential function with natural constant e as the base; is the sixth correlation of the first target road information ν i and the second target road information ν in the kth attention head; ν r is the νth road information in the second to-be-processed set; r is the value of the traffic flow state of the first target road information ν i at the first target time step t j ; is the event encoding of the first target road information at the first target time step in the spatio-temporal embedding representation; is a data concatenation operation; d is the output dimension, d=D / k, D=64.
[0133] S3023, The fifth correlation is used as the first spatial attention.
[0134] S303. Calculate the fused attention feature corresponding to the first target road information based on the first temporal attention and the first spatial attention.
[0135] Furthermore, the calculation formula for step S303 is as follows:
[0136] H = z⊙Hs + (1-z)⊙Ht;
[0137] z=σ(HsW z,1 +HtW z,2 +b z );
[0138] Wherein, H is the fused attention feature corresponding to the first target road information; z is the gating value; ⊙ is the element-wise product; Hs is the first temporal attention; Ht is the first spatial attention; σ(·) is the sigmoid activation function; W z,1 W is the first learnable parameter. z,2 b is a learnable second parameter; z This is the bias term for z.
[0139] H can be the fused attention feature of the first target road information at the first target time step. Therefore, H can also be represented as H ti i = 1, 2, ..., P, where P is the total number of time steps.
[0140] Step S303 is implemented by the gating fusion module of the first multi-head spatiotemporal attention module in the road traffic state prediction device based on graph attention network.
[0141] S304. Combine the fused attention features of the target road information at all time steps into the historical spatiotemporal features.
[0142] Specifically, the historical spatiotemporal features are represented as H one =(H t1 H t2 H t3 ...,H tP-1 H tP ), where H one H represents the historical spatiotemporal characteristics. t1 H represents the fused attention features of the target road information at the first time step t1. t2 H represents the fused attention features of the target road information at the second time step t2. t3The fused attention features of the target road information at the third time step t3, and so on, H tP-1 H represents the fusion attention feature of the target road information at time step P-1 tP-1. tP The fused attention feature of the target road information at the P-th time step tP.
[0143] The historical spatiotemporal features are single-step spatiotemporal diagrams.
[0144] S4. Perform fine-grained hierarchical modeling on the historical spatiotemporal features to obtain a two-step spatiotemporal graph and a three-step spatiotemporal graph. Step S4 can be understood as... Figure 2 The "Fine-grained multi-layer spatiotemporal graph construction" step.
[0145] The historical spatiotemporal features, the two-step spatiotemporal diagram, and the three-step spatiotemporal diagram constitute a multi-timescale spatiotemporal diagram. Therefore, S4 can also be understood as... Figure 2 The "multi-timescale spatiotemporal map calculation" step is included. The implementation of step S4 can effectively capture the dynamic evolution characteristics of traffic flow.
[0146] Further, step S4 includes:
[0147] S401. Perform residual calculation on the historical spatiotemporal features to obtain the two-step spatiotemporal map.
[0148] The bistep spacetime diagram can be represented as H res =(H t2 -H t1 H t3 -H t2 ,...,H tP -H tP-1 ), where H res For the bistep spatiotemporal graph, H t1 H represents the fused attention features of the target road information at the first time step t1. t2 H represents the fused attention features of the target road information at the second time step t2. t3 The fused attention features of the target road information at the third time step t3, and so on, H tP-1 H represents the fusion attention feature of the target road information at time step P-1 tP-1. tP The fused attention feature of the target road information at the P-th time step tP.
[0149] S402. Perform a convolution operation with a second time step on the historical spatiotemporal features at the time scale to obtain the three-step spatiotemporal map.
[0150] The second time step is 3 minutes. In other embodiments, the second time step can be changed to a higher integer to adapt to the prediction task under different time scales.
[0151] The three-step spatiotemporal graph can be represented as H conv = σ(Φ1*H one ), where H conv is the three-step spatiotemporal graph; σ(·) is a sigmoid activation function; Φ1 is a convolution parameter; H one is the historical spatiotemporal feature, that is, the one-step spatiotemporal graph.
[0152] S5, converting the historical spatiotemporal feature, the two-step spatiotemporal graph, and the three-step spatiotemporal graph to obtain a first time scale spatiotemporal graph, a second time scale spatiotemporal graph, and a third time scale spatiotemporal graph. The S5 step can be understood as the “conversion to obtain multi-time scale spatiotemporal graphs” step in Figure 2
[0153] The S5 step is implemented by a conversion module of the road traffic state prediction device based on the graph attention network, so it can be understood as the “conversion module” process in Figure 2
[0154] Further, the S5 step includes:
[0155] S501, converting the historical spatiotemporal feature by using a first preset algorithm to obtain the first time scale spatiotemporal graph.
[0156] The calculation formula of the S501 is:
[0157]
[0158] wherein, is the first time scale spatiotemporal graph, that is, the future traffic flow state after conversion of the historical spatiotemporal feature; K is the total number of attention heads; t = t1, t2, …, t p ; t1 is the first time step; t2 is the second time step; t p is the pth time step; is the seventh correlation between the first target time step t j and the tth time step in the kth attention head; is the spatiotemporal representation value of the first target road information v one at the tth time step in the historical spatiotemporal feature H i ; exp(·) is an exponential function with the natural constant e as the base; is the spatiotemporal representation value of the first target road information v j The eighth correlation with the t-th time step; t r =t1,t2,…,t p ; For the first target time step t in the k-th attention head j With the tth r The ninth correlation between time steps; In the spatiotemporal embedding representation, the event encoding of the first target road information at the first target time step; In the spatiotemporal embedding representation, the event encoding of the first target road information at the t-th time step is: d = D / k, D = 64.
[0159] S502. The second preset algorithm is used to transform the two-step spatiotemporal graph to obtain the second time-scale spatiotemporal graph.
[0160] The calculation formula for S502 is as follows:
[0161]
[0162] in, This represents the second timescale spatiotemporal diagram, i.e., the future traffic flow state after the transformation of the two-step spatiotemporal diagram; K is the total number of attention heads; t = t1, t2, ..., t p t1 is the first time step; t2 is the second time step; t p This is the p-th time step; To predict the first target time step t in the k-th attention head j The seventh correlation with the t-th time step; For the two-step spacetime graph H res Information on the first target road in the middle i The spatiotemporal representation value at the t-th time step; exp(·) is an exponential function with the natural constant e as its base; For the first target time step t in the k-th attention head j The eighth correlation with the t-th time step; t r =t1,t2,…,t p ; For the first target time step t in the k-th attention head j With the tth r The ninth correlation between time steps; In the spatiotemporal embedding representation, the event encoding of the first target road information at the first target time step; In the spatiotemporal embedding representation, the event encoding of the first target road information at the t-th time step is: d = D / k, D = 64.
[0163] S503, converting the three-step spatio-temporal graph using a third preset algorithm to obtain a third time-scale spatio-temporal graph.
[0164] The calculation formula of S503 is:
[0165]
[0166]
[0167] wherein, is the third time-scale spatio-temporal graph, i.e., the future traffic flow state after conversion of the three-step spatio-temporal graph; K is the total number of attention heads; t = t1, t2, …, t p ; t1 is the first time step; t2 is the second time step; t p is the pth time step; is the seventh correlation between the first target time step t j and the tth time step in the kth attention head; is the first target road information v conv in the three-step spatio-temporal graph H i ; exp(·) is an exponential function with a natural constant e as the base; is the eighth correlation between the first target time step t j and the tth time step in the kth attention head; t r = t1, t2, …, t p ; is the ninth correlation between the first target time step t j and the tth time step in the kth attention head; r ; is the event encoding of the first target road information at the first target time step in the spatio-temporal embedding representation; is the event encoding of the first target road information at the tth time step in the spatio-temporal embedding representation; d = D / k, D = 64.
[0168] S6, decoding the first time-scale spatio-temporal graph, the second time-scale spatio-temporal graph, and the third time-scale spatio-temporal graph to obtain predicted traffic flow information. The S6 step can be understood as Figure 2 the step of "predicting a future traffic flow state" in the above description.
[0169] The predicted traffic flow information is the predicted traffic flow information of the first target road information. After the S1-S6 steps, the present application can predict the predicted traffic flow information of all road information in the historical traffic sequence information.
[0170] Further, the S6 step comprises:
[0171] S601, adopt a gating fusion mechanism to integrate the first time scale space-time graph, the second time scale space-time graph and the third time scale space-time graph, and obtain a fusion feature.
[0172] Specifically, the first time scale space-time graph, the second time scale space-time graph and the third time scale space-time graph are adaptively integrated twice by the gating fusion to obtain the fusion feature.
[0173] The fusion feature is a future space-time graph representation predicted for the first target road information.
[0174] S602, performing feature extraction processing on the fusion feature to obtain a future space-time feature.
[0175] The S602 is realized by a second multi-head space-time attention module of a decoder in the road traffic state prediction device based on the graph attention network.
[0176] Further, the S602 step comprises:
[0177] S6021, calculating a second time attention corresponding to the first target road information based on the fusion feature and all the time steps.
[0178] The specific implementation of the S6021 step is referred to the specific implementation of the S301 step.
[0179] S6022, calculating a second space attention corresponding to the first target road information based on the fusion feature and all the road information.
[0180] The specific implementation of the S6022 step is referred to the specific implementation of the S302 step.
[0181] S6023, calculating the future space-time feature corresponding to the first target road information based on the second time attention and the second space attention.
[0182] The specific implementation of the S6023 step is referred to the specific implementation of the S303 step.
[0183] S603, integrating the future space-time feature to obtain the predicted traffic flow information.
[0184] The S603 step is realized by a second fully connected layer of the decoder. The specific implementation of the S603 step can be referred to the specific implementation of the S208 step.
[0185] In the above-mentioned embodiments, the application can identify the influence of events by event encoding processing on historical traffic sequence information, so as to predict the traffic flow of the road under special events. Compared with the prior art, the application can improve the accuracy of traffic flow prediction under special events, effectively capture the traffic flow evolution mode, and provide reliable data support for traffic management decisions, which has a wide application prospect and important social value.
[0186] Reference Figure 3 As shown in the figure, it is a principle block diagram of a road traffic state prediction device based on a graph attention network provided by the second aspect of the application. In Figure 3 , the road traffic state prediction device based on the graph attention network 100 comprises:
[0187] A historical traffic sequence information acquisition module 101 is configured to acquire historical traffic sequence information.
[0188] An event encoding module 102 is configured to perform event encoding processing on the historical traffic sequence information to obtain a spatio-temporal embedding representation.
[0189] A first multi-head spatio-temporal attention module 103 is configured to perform feature extraction processing on the spatio-temporal embedding representation to obtain historical spatio-temporal features.
[0190] A multi-time scale module 104 is configured to perform hierarchical modeling processing on the historical spatio-temporal features in a fine-grained manner to obtain a two-step spatio-temporal graph and a three-step spatio-temporal graph.
[0191] A conversion module 105 is configured to perform conversion processing on the historical spatio-temporal features, the two-step spatio-temporal graph and the three-step spatio-temporal graph to obtain a first time scale spatio-temporal graph, a second time scale spatio-temporal graph and a third time scale spatio-temporal graph.
[0192] A decoder 106 is configured to perform decoding processing on the first time scale spatio-temporal graph, the second time scale spatio-temporal graph and the third time scale spatio-temporal graph to obtain predicted traffic flow information.
[0193] The third aspect of the application provides a terminal device, and the principle block diagram of the terminal device can be as shown in the figure Figure 4As shown in the principle block diagram shown in the accompanying drawings, the terminal device includes a processor, a memory, a network interface, a display screen and a temperature sensor connected through a system bus. Among them, the processor is used to provide computing and control capabilities. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the terminal device is used to communicate with external terminals through network connection. The computer program is executed by the processor to realize the road traffic state prediction method based on the graph attention network. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the temperature sensor is pre-set inside the terminal device to detect the operating temperature of the internal device.
[0194] Those skilled in the art can understand that, Figure 4 The principle block diagram shown in the accompanying drawings is only a block diagram of part of the structure related to the present application scheme, and does not constitute a limitation on the terminal device to which the present application scheme is applied. The specific terminal device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0195] In some embodiments, the present application provides a terminal device including a processor and a memory for storing a computer program, wherein the processor is used to call and run the computer program stored in the memory to execute the steps of the road traffic state prediction method based on the graph attention network provided in the first aspect of the present application.
[0196] In a fourth aspect of the present application, a computer readable storage medium is provided for storing a computer program, wherein the computer program enables a computer to execute the steps of the road traffic state prediction method based on the graph attention network provided in the first aspect of the present application.
[0197] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synch link) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0198] The technical features of the above embodiments can be combined without changing the basic principles of the present application. In order to make the description simple, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not contradict, they should be considered as the scope of the present application.
[0199] The above embodiments only express several embodiments of the present application, and the description is more specific and detailed, but it should not be understood as limiting the scope of the patent application. It should be noted that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the patent protection scope of the present application should be subject to the appended claims.
Claims
1. A road traffic state prediction method based on a graph attention network, characterized in that, The method comprises the following steps: obtaining historical traffic sequence information; performing event coding processing on the historical traffic sequence information to obtain a spatio-temporal embedding representation; performing feature extraction processing on the spatio-temporal embedding representation to obtain historical spatio-temporal features; performing fine-grained hierarchical modeling processing on the historical spatio-temporal features to obtain a two-step spatio-temporal graph and a three-step spatio-temporal graph; performing conversion processing on the historical spatio-temporal features, the two-step spatio-temporal graph and the three-step spatio-temporal graph to obtain a first time scale spatio-temporal graph, a second time scale spatio-temporal graph and a third time scale spatio-temporal graph; performing decoding processing on the first time scale spatio-temporal graph, the second time scale spatio-temporal graph and the third time scale spatio-temporal graph to obtain predicted traffic flow information; The step of performing event coding processing on the historical traffic sequence information to obtain a spatio-temporal embedding representation comprises: in the case that traffic flow changes of a target historical traffic segment exceed a first preset value and / or the target historical traffic segment belongs to a preset rule, marking the target historical traffic segment as event information, wherein the target historical traffic segment is any one of a plurality of historical traffic segments in the historical traffic sequence information; obtaining a traffic flow time feature embedding representation and a traffic flow space feature embedding representation of first target road information at a first target time step based on all event information and all historical traffic segments, the first target road information being any one of road information in the historical traffic sequence information, and the first target time step being any one of all time steps; splicing the traffic flow time feature embedding representation and the traffic flow space feature embedding representation to form event coding of the first target road information at the first target time step; and taking all the event coding as the spatio-temporal embedding representation; The step of performing fine-grained hierarchical modeling processing on the historical spatio-temporal features to obtain a two-step spatio-temporal graph and a three-step spatio-temporal graph comprises: performing residual calculation on the historical spatio-temporal features to obtain the two-step spatio-temporal graph; and performing a second time step convolution operation on the historical spatio-temporal features in the time scale to obtain the three-step spatio-temporal graph. 2.The road traffic state prediction method based on the graph attention network according to claim 1, wherein, The step of performing event coding processing on the historical traffic sequence information to obtain a spatio-temporal embedding representation further comprises: setting a first time step; and dividing the historical traffic sequence information based on the first time step to obtain a plurality of historical traffic segments and a plurality of time steps, each time step having a one-to-one correspondence with one historical traffic segment; The step of obtaining the traffic flow time feature embedding representation and the traffic flow space feature embedding representation of the first target road information at the first target time step based on all the event information and all the historical traffic segments comprises: using one-hot encoding to encode the day of the week information of all the historical traffic segments as a vector; using one-hot encoding to encode the specific time of the day information of all the historical traffic segments as a vector; using one-hot encoding to encode all the event information as a vector; concatenating the vector, the vector and the vector into a vector; converting the vector to obtain a vector, wherein D is set as 64; obtaining the traffic flow time feature embedding representation and the traffic flow space feature embedding representation of the first target road information at the first target time step based on the vector. 3.The road traffic state prediction method based on the graph attention network according to claim 2, characterized in that, The step of performing feature extraction processing on the spatio-temporal embedding representation to obtain historical spatio-temporal features comprises: calculating a first time attention corresponding to the first target road information based on the spatio-temporal embedding representation and all the time steps; calculating a first space attention corresponding to the first target road information based on the spatio-temporal embedding representation and all the road information; calculating a fusion attention feature corresponding to the first target road information based on the first time attention and the first space attention; combining the fusion attention features of the target road information at all time steps into the historical spatio-temporal features. 4.The road traffic state prediction method based on the graph attention network according to claim 1, wherein, The step of converting the historical spatiotemporal features, the two-step spatiotemporal graph, and the three-step spatiotemporal graph respectively to obtain a first time scale spatiotemporal graph, a second time scale spatiotemporal graph, and a third time scale spatiotemporal graph includes: The historical spatiotemporal features are converted using a first preset algorithm to obtain the first time scale spatiotemporal graph; The two-step spatiotemporal graph is converted using a second preset algorithm to obtain the second time scale spatiotemporal graph; The three-step spatiotemporal graph is converted using a third preset algorithm to obtain the third time scale spatiotemporal graph. 5.The road traffic state prediction method based on the graph attention network according to claim 2, characterized in that, The step of decoding the first time scale spatiotemporal graph, the second time scale spatiotemporal graph, and the third time scale spatiotemporal graph to obtain predicted traffic flow information includes: The first time scale spatiotemporal graph, the second time scale spatiotemporal graph, and the third time scale spatiotemporal graph are integrated using a gated fusion mechanism to obtain fusion features; The fusion features are subjected to feature extraction processing to obtain future spatiotemporal features; The future spatiotemporal features are integrated to obtain the predicted traffic flow information. 6.The road traffic state prediction method based on the graph attention network according to claim 5, characterized in that, The step of extracting features from the fusion features to obtain future spatiotemporal features includes: Based on the fusion features and all the time steps, a second time attention is calculated; Based on the fusion features and all the road information, a second spatial attention is calculated; Based on the second time attention and the second spatial attention, the future spatiotemporal features are calculated.
7. A road traffic state prediction device based on a graph attention network, characterized by, It includes: A historical traffic sequence information acquisition module is configured to acquire historical traffic sequence information; An event encoding module is configured to perform event encoding processing on the historical traffic sequence information to obtain a spatiotemporal embedding representation; A first multi-head spatiotemporal attention module is configured to perform feature extraction processing on the spatiotemporal embedding representation to obtain historical spatiotemporal features; A multi-time scale module is configured to perform fine-grained hierarchical modeling processing on the historical spatiotemporal features to obtain a two-step spatiotemporal graph and a three-step spatiotemporal graph; A conversion module is configured to convert the historical spatiotemporal features, the two-step spatiotemporal graph, and the three-step spatiotemporal graph to obtain a first time scale spatiotemporal graph, a second time scale spatiotemporal graph, and a third time scale spatiotemporal graph; A decoder is configured to decode the first time scale spatiotemporal graph, the second time scale spatiotemporal graph, and the third time scale spatiotemporal graph to obtain predicted traffic flow information; The event coding module is further configured to mark the target historical traffic segment as event information in a case where traffic flow of the target historical traffic segment changes by more than a first preset value and / or the target historical traffic segment belongs to a preset rule, the target historical traffic segment being any one of a plurality of historical traffic segments in the historical traffic sequence information; obtain a traffic flow time feature embedding representation and a traffic flow space feature embedding representation of first target road information at a first target time step based on all event information and all historical traffic segments, the first target road information being any one of road information in the historical traffic sequence information, the first target time step being any one of all the time steps; splice the traffic flow time feature embedding representation and the traffic flow space feature embedding representation to form event coding of the first target road information at the first target time step; and use all the event coding as the spatiotemporal embedding representation. The multi-time scale module is further configured to perform residual calculation on the historical spatiotemporal features to obtain the two-step spatiotemporal graph; and perform convolution operation on the historical spatiotemporal features in a time scale with a second time step to obtain the three-step spatiotemporal graph.
8. A terminal device, comprising: Comprising: A processor and a memory for storing a computer program, the processor being configured to invoke and run the computer program stored in the memory to perform the steps of the road traffic state prediction method based on the graph attention network according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, A computer program for causing a computer to perform the steps of the road traffic state prediction method based on the graph attention network according to any one of claims 1 to 6.
Citation Information
Patent Citations
Traffic flow prediction method, device and storage medium based on dynamic spatiotemporal graph convolutional recurrent network
CN114220271B
A traffic flow prediction method based on spatiotemporal embedded attention network
CN117688453B