A traffic flow prediction method and related equipment based on traffic conditions

By clustering traffic flow data and fusing external related data, and using an attention mechanism model for traffic flow prediction, the problem of inaccurate prediction in existing methods is solved, achieving higher accuracy and more comprehensive traffic flow prediction.

CN121281278BActive Publication Date: 2026-03-10XIANGJIANG LAB
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-09
Publication Date
2026-03-10

Smart Images

  • Figure CN121281278B_ABST
    Figure CN121281278B_ABST
Patent Text Reader

Abstract

This application relates to the field of traffic flow prediction technology, and provides a traffic flow prediction method and related equipment based on traffic conditions. The method includes: acquiring basic traffic operation data for multiple roads in a target area; clustering all roads based on all basic traffic operation data to obtain multiple clusters; acquiring external traffic correlation data for each traffic condition, and fusing all basic traffic operation data corresponding to the traffic condition with the external traffic correlation data to obtain fused traffic condition data; and using an attention-based traffic flow prediction model to predict traffic flow based on the fused data for each traffic condition, obtaining the traffic flow prediction result for each traffic condition. The method of this application can improve the accuracy of traffic flow prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of traffic flow prediction technology, and in particular to a traffic flow prediction method and related equipment based on traffic conditions. Background Technology

[0002] With the development of the times, traffic congestion has become increasingly serious. Accurate traffic flow prediction is crucial for traffic management and guidance, but existing methods have many shortcomings.

[0003] On the one hand, traditional prediction methods are often based on single or limited traffic data, such as relying solely on traffic flow speed prediction while ignoring other key traffic parameters like traffic density, making it difficult to comprehensively reflect the true state of traffic flow. On the other hand, they fail to fully consider the significant impact of external factors such as weather, accidents, and holidays on traffic flow. Severe weather affects drivers' visibility and the road friction coefficient, leading to reduced vehicle speed and decreased traffic capacity; traffic accidents can easily cause congestion or even traffic paralysis on localized road sections; and changes in the distribution of travelers, their purposes, and travel times during holidays cause significant variations in traffic flow characteristics. Furthermore, traditional models have simple structures, making it difficult to handle complex traffic data and effectively uncover spatiotemporal correlations and potential patterns among the data. Therefore, current traffic flow prediction methods suffer from inaccurate predictions. Summary of the Invention

[0004] This application provides a traffic flow prediction method and related equipment based on traffic conditions, which can solve the problem of inaccurate traffic flow prediction.

[0005] Firstly, this application provides a traffic flow prediction method based on traffic conditions, the traffic flow prediction method comprising:

[0006] Acquire basic traffic operation data for multiple roads in the target area; the basic traffic operation data for roads includes traffic data at multiple historical time points;

[0007] All roads are clustered based on all basic traffic operation data, resulting in multiple clusters; each cluster corresponds one-to-one with a different traffic state.

[0008] For each traffic state, external traffic correlation data for that state is acquired. All basic traffic operation data corresponding to that state are then merged with the external traffic correlation data to obtain fused traffic state data. The external traffic correlation data includes external correlation data corresponding to traffic states at multiple historical time points.

[0009] The traffic flow prediction model based on the attention mechanism is used to perform traffic flow prediction based on fused data of each traffic state, and traffic flow prediction results of each traffic state are obtained; the traffic flow prediction results include traffic flow prediction values of all roads corresponding to the traffic state.

[0010] Optionally, all roads are clustered based on all traffic basic operation data, and a plurality of clustering clusters are obtained, including:

[0011] A maximum log-likelihood function is constructed.

[0012] The parameters to be solved in the Gaussian mixture model are solved according to the maximum log-likelihood function.

[0013] The parameters to be solved are substituted into the Gaussian mixture model, and all roads are clustered based on all traffic basic operation data by using the Gaussian mixture model, and a plurality of clustering clusters are obtained.

[0014] Optionally, the maximum log-likelihood function is:

[0015] ;

[0016] wherein, denotes a set of parameters to be solved, denotes a mixing coefficient of the i-th component, denotes a mean vector of the probability density of the i-th component, denotes a covariance matrix of the probability density of the i-th component, denotes a determinant of the covariance matrix, denotes a number of roads in the target area, denotes traffic basic operation data of the i-th road, denotes a number of components of the Gaussian mixture model, denotes a transposition operation, denotes a set of traffic basic operation data, denotes A probability density generated under a probability model linearly combined by the components of the Gaussian mixture model. The parameters to be solved in the Gaussian mixture model are solved according to the maximum log-likelihood function, including: Initialize a vulture population; the individuals in the vulture population include a mixing coefficient of each component of the Gaussian mixture model, a mean vector of the probability density of each component, a one-dimensional vector of each component, and a random number matrix of each component; A probability density generated under a probability model linearly combined by the components of the Gaussian mixture model.

[0017] The parameters to be solved in the Gaussian mixture model are solved according to the maximum log-likelihood function, including:

[0018] Initialize a vulture population; the individuals in the vulture population include a mixing coefficient of each component of the Gaussian mixture model, a mean vector of the probability density of each component, a one-dimensional vector of each component, and a random number matrix of each component; ​​​

[0019] randomly selecting one individual from the vulture population for updating, and updating the vulture population by using the vulture search algorithm to obtain an updated vulture population;

[0020] calculating the optimal fitness and the average fitness of the updated vulture population based on maximizing a log-likelihood function;

[0021] determining whether the optimal fitness and the average fitness satisfy an iteration termination condition;

[0022] if yes, taking the individual corresponding to the optimal fitness of the updated vulture population as a target individual, and obtaining the to-be-solved parameters in the Gaussian mixture model according to the target individual;

[0023] otherwise, taking the updated vulture population as the vulture population, and returning to the step of randomly selecting one individual from the vulture population for updating, and updating the vulture population by using the vulture search algorithm to obtain an updated vulture population.

[0024] Optionally, a traffic flow prediction model based on an attention mechanism is used to perform traffic flow prediction based on the fusion data of each traffic state, to obtain a traffic flow prediction result of each traffic state, including:

[0025] The following steps are performed for each traffic state respectively:

[0026] feature extraction is performed on the data corresponding to each historical time in the fusion data of the traffic state, to obtain a spatio-temporal feature representation of the traffic state at each historical time;

[0027] The time weight and the space weight of the traffic state at each historical time are calculated respectively, and based on the time weight and the space weight, a spatial position encoding and a temporal position encoding are embedded into the spatio-temporal feature representation corresponding to the historical time, to obtain a spatio-temporal feature embedding of the traffic state at the historical time;

[0028] The traffic feature of the traffic state is calculated based on the attention mechanism on all spatio-temporal feature embeddings;

[0029] The traffic flow prediction result of the traffic state is obtained by performing traffic flow prediction on the traffic state based on the traffic feature.

[0030] Optionally, the calculation of the time weight and the space weight of the traffic state at each historical time includes:

[0031] The basic time weight and the basic space weight are calculated based on the corresponding spatio-temporal feature representation at the historical time;

[0032] The basic time weight and the basic space weight are nonlinearly corrected to obtain the time weight and the space weight.

[0033] Optionally, the basic temporal weights and basic spatial weights are calculated based on the spatiotemporal feature representations corresponding to historical moments, including:

[0034] Through the formula:

[0035] ;

[0036] ;

[0037] ;

[0038] ;

[0039] Calculate the base time weights and basic space weights ;

[0040] in, Represents the balance coefficient. Indicates the first The traffic condition in the first The spatiotemporal characteristics of a historical moment, Indicates time location encoding. Indicates spatial location encoding, Indicates the first The traffic condition in the first External correlation data at a historical moment, Indicates the first The traffic condition in the first External correlation data at a historical moment, The weights represent the weights of a single-layer perceptron. This represents the bias term of a single-layer perceptron. Indicates externally correlated data modulation terms. Indicates the rate of change of externally related data. The weight matrix represents the linear transformation. The bias term represents the linear transformation. This indicates the calculation of standard deviation. This indicates the calculation of the mean. This indicates taking the maximum value. Represents a collection of externally related data. This represents the Softmax function. This represents the Sigmoid activation function. Represents the hyperbolic tangent function. , Indicates the number of traffic conditions. , Indicates the number of historical moments.

[0041] Optionally, based on the time weight and the space weight, the space position code and the time position code are embedded into the spatio-temporal feature representation corresponding to the historical moment, to obtain a spatio-temporal feature embedding of the traffic state at the historical moment, including:

[0042] Through the formula:

[0043] ;

[0044] ;

[0045] ;

[0046] The spatio-temporal feature embedding of the i-th traffic state at the j-th historical moment is calculated ; ;

[0047] Wherein, represents the feature retention coefficient, represents the time weight, represents the space weight, represents the data coupling coefficient, represents the i-th traffic state at the j-th historical moment, represents the traffic basic operation data, represents the Pearson correlation coefficient of and .

[0048] Optionally, all spatio-temporal feature embeddings are calculated based on the attention mechanism, to obtain the traffic feature of the traffic state, including:

[0049] Through the formula:

[0050] ;

[0051] ;

[0052] ;

[0053] ;

[0054] ;

[0055] The traffic feature of the i-th traffic state is calculated ;

[0056] Wherein, represents layer normalization, represents self-attention output feature, represents feedforward feature,​​​ Represents the ReLU activation function. and Represents the weight matrix. and Indicates the bias term. Represents the attention weight matrix. Represents a value matrix, Represents the query matrix. Represents the key matrix. Indicates the scaling factor. This represents a vector composed of all spatiotemporal feature embeddings. This represents the query weight matrix. Represents the key weight matrix. Represents the value weight matrix.

[0057] Optionally, traffic flow prediction is performed based on traffic characteristics to obtain traffic flow prediction results for the traffic conditions, including:

[0058] Through the formula:

[0059] ;

[0060] Calculate the first Traffic flow prediction results for each traffic condition ;

[0061] in, This represents the feature corresponding to the last historical moment in the traffic features. Indicates the weights of the fully connected layer. This indicates the bias of the fully connected layer.

[0062] Secondly, this application provides a traffic flow prediction device based on traffic conditions, comprising:

[0063] The acquisition module is used to acquire basic traffic operation data for multiple roads in the target area; the basic traffic operation data of the roads includes traffic data at multiple historical time points;

[0064] The clustering module is used to cluster all roads based on all basic traffic operation data, resulting in multiple clusters; each cluster corresponds one-to-one with a different traffic state.

[0065] The fusion module is used to acquire external traffic correlation data for each traffic state, and to fuse all basic traffic operation data corresponding to the traffic state with the external traffic correlation data of the traffic state to obtain fused traffic state data. The external traffic correlation data includes external correlation data corresponding to the traffic state at multiple historical time points.

[0066] The traffic flow prediction module is configured to utilize a traffic flow prediction model based on an attention mechanism to perform traffic flow prediction based on the fusion data of each traffic state, and obtain a traffic flow prediction result of each traffic state. The traffic flow prediction result includes traffic flow prediction values of all roads corresponding to the traffic state.

[0067] In a third aspect, an embodiment of the present application provides a terminal device, which comprises a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, the traffic flow prediction method based on traffic states is realized.

[0068] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program. When the processor executes the computer program, the traffic flow prediction method based on traffic states is realized.

[0069] The above-mentioned scheme of the present application has the following advantages:

[0070] In the embodiments of the present application, traffic basic running data of a plurality of roads in a target area is acquired, and then all roads are clustered according to all traffic basic running data to obtain a plurality of clustering clusters. For each traffic state, traffic external correlation data of the traffic state is acquired, and all traffic basic running data corresponding to the traffic state and the traffic external correlation data of the traffic state are fused to obtain fusion data of the traffic state. Then, a traffic flow prediction model based on an attention mechanism is utilized to perform traffic flow prediction based on the fusion data of each traffic state, and obtain a traffic flow prediction result of each traffic state. In this way, all roads are divided into a plurality of traffic states according to traffic basic running data, and data features of each traffic state are analyzed and traffic flow prediction is performed, so that different traffic states are distinguished, the accuracy of traffic flow prediction under different traffic states is improved, traffic external correlation data is combined for traffic flow prediction, external factors related to traffic are considered, the richness of data information is improved, a traffic flow prediction model based on an attention mechanism is utilized for traffic flow prediction, the mining ability of the model for data features is improved, the spatio-temporal correlation of traffic flow is captured, and the accuracy of traffic flow prediction is further improved. BRIEF DESCRIPTION OF DRAWINGS

[0071] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort.

[0072] Figure 1A flowchart of a traffic flow prediction method based on a traffic state according to an embodiment of the present application is provided.

[0073] Figure 2 A structural schematic diagram of a traffic flow prediction device based on a traffic state according to an embodiment of the present application is provided.

[0074] Figure 3 A structural schematic diagram of a terminal device according to an embodiment of the present application is provided. DETAILED DESCRIPTION

[0075] In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular sequences of steps, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known methods, devices, circuits, and

[0076] It should be understood that the term "comprises" when used in this specification and the appended claims indicates the presence of the described features, integers, steps, operations, elements, and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0077] It should also be understood that the term "and / or" when used in this specification and the appended claims indicates that the associated listed items can be present one or more of the associated listed items, and that the items are not limited to only one of the associated listed items.

[0078] As used in this specification and the appended claims, the term "if" can be interpreted as meaning "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [a described condition or event] is detected" can be interpreted as meaning "upon determining" or "in response to determining" or "upon detecting [the described condition or event]" or "in response to detecting [the described condition or event]," depending on the context.

[0079] In addition, in the description of the specification and the appended claims, the terms "first", "second", "third", etc. are used only to distinguish descriptions, and cannot be understood as indicating or implying relative importance.

[0080] Reference within the specification of this application to "one embodiment" or "some embodiments" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the application. The appearances of the phrase "in one embodiment" or "in some embodiments" in various places within specified

[0081] To solve the problem of inaccurate traffic flow prediction, the application provides a traffic flow prediction method based on traffic state. The method includes the following steps: obtaining traffic basic running data of multiple roads in a target area; clustering all roads according to all traffic basic running data to obtain multiple clustering clusters; obtaining traffic external correlation data of each traffic state; fusing all traffic basic running data corresponding to the traffic state and the traffic external correlation data of the traffic state to obtain fusion data of the traffic state; and performing traffic flow prediction based on the fusion data of each traffic state by using a traffic flow prediction model based on an attention mechanism to obtain a traffic flow prediction result of each traffic state. In the method, all roads are divided into multiple traffic states according to the traffic basic running data, and the data features of each traffic state are analyzed and traffic flow prediction is performed, so that different traffic states are distinguished, the accuracy of traffic flow prediction under different traffic states is improved, traffic external correlation data is combined for traffic flow prediction, external factors related to traffic are considered, the richness of data information is improved, a traffic flow prediction model based on an attention mechanism is used for traffic flow prediction, the data feature mining ability of the model is improved, the spatio-temporal correlation of traffic flow is captured, and the accuracy of traffic flow prediction is improved.

[0082] Next, the traffic flow prediction method based on traffic state provided by the application is described by way of example.

[0083] As shown in Figure 1 The traffic flow prediction method based on traffic state provided by the application includes the following steps:

[0084] Step 11, obtaining traffic basic running data of multiple roads in a target area.

[0085] The target area mentioned above refers to the area where traffic flow prediction needs to be performed, such as a certain urban area. The basic traffic operation data of the aforementioned roads includes traffic data at multiple historical time points. The traffic data can be traffic flow data (i.e., traffic volume data), traffic flow speed data (i.e., traffic flow velocity data), or traffic flow density data (i.e., vehicle density data). Multiple historical time points refer to the time points prior to the point when traffic flow prediction is needed. For example, if it is necessary to predict the traffic flow at the next time point after the current time, then multiple historical time points include the previous multiple time points, including the current time point.

[0086] In some embodiments of this application, basic traffic operation data of roads can be obtained using devices such as vehicle counters and vehicle speed detectors.

[0087] Step 12: Cluster all roads based on all basic traffic operation data to obtain multiple clusters.

[0088] Multiple clusters correspond one-to-one with multiple traffic states, which describe the traffic conditions on a road, such as congestion or idleness. Each cluster contains basic traffic operation data for multiple roads.

[0089] In some embodiments of this application, the above-mentioned clustering of all roads based on all basic traffic operation data yields multiple clusters, including:

[0090] The first step is to construct a function that maximizes the log-likelihood.

[0091] The maximum log-likelihood function is:

[0092] ;

[0093] in, This represents the set of parameters to be solved. Indicates the first The mixing coefficient of each component, Indicates the first The mean vector of the probability density of each component. Indicates the first The covariance matrix of the probability density of each component. express The determinant, Indicates the number of roads in the target area. Indicates the first Basic traffic operation data for each road. This represents the number of components in a Gaussian mixture model. This indicates the transpose operation. This represents a collection of basic traffic operation data. express In the A probability density generated under a probability model composed of linear combinations of components of a Gaussian mixture model.

[0094] Secondly, the parameters to be solved in the Gaussian mixture model are solved according to maximizing the log-likelihood function.

[0095] For example, the expression of the Gaussian mixture model (GMM) is as follows:

[0096] ;

[0097] wherein, p (x) represents the probability density of the Gaussian mixture model, pi represents the mixing coefficient of the i-th component, p (x | xi) represents the posterior probability corresponding to all roads, pi represents the probability density of the i-th component, , pi represents the mean vector of the probability density of the i-th component, , pi represents the covariance matrix of the probability density of the i-th component. The parameters to be solved are as follows: .

[0098] Firstly, a vulture population is initialized. The individuals in the vulture population include the mixing coefficient of each component in the Gaussian mixture model, the mean vector of the probability density of each component, the one-dimensional vector of each component and the random number matrix of each component.

[0099] Then, one individual is randomly selected from the vulture population for updating, and the vulture population is updated by using the vulture search algorithm to obtain an updated vulture population.

[0100] Then, the best fitness and the average fitness of the updated vulture population are calculated based on maximizing the log-likelihood function.

[0101] Finally, it is judged whether the best fitness and the average fitness meet the iteration termination condition.

[0102] If yes, the individual corresponding to the best fitness of the updated vulture population is taken as a target individual, and the parameters to be solved in the Gaussian mixture model are obtained according to the target individual.

[0103] ​​​​Specifically, the mixing coefficient of each component in the target individual is used as the mixing coefficient of the corresponding component in the Gaussian mixture model, and the mean vector of the probability density of each component is used as the mean vector of the probability density of the corresponding component in the Gaussian mixture model. The covariance vector of the probability density of the corresponding component in the Gaussian mixture model is calculated based on the one-dimensional vector of each component in the target individual and the random number matrix. The expression is as follows:

[0104] ;

[0105] in, Indicates the first An orthonormal basis of a one-dimensional vector and a random number matrix with components. Indicates the first A one-dimensional vector with 1 component is a diagonal matrix with diagonal elements.

[0106] Otherwise, the updated vulture population is taken as the vulture population, and the process of randomly selecting an individual from the vulture population for updating and using the vulture search algorithm to update the vulture population is repeated to obtain the updated vulture population.

[0107] It should be noted that the Expectation Maximization Algorithm (EM) can be used to update randomly selected individuals, and the updated individuals can be returned to the vulture population to participate in the updating of the vulture search algorithm. The expression for the vulture search algorithm is:

[0108] ;

[0109] ;

[0110] ;

[0111] in, Indicates the Levy random step size. This represents the power coefficient of the random step size. To show obedience Parameters of Gaussian distribution To show obedience Parameters of Gaussian distribution Indicates the updated number The position of each individual (obtained by unfolding and concatenating all parameters included in the individual in a one-dimensional form). Indicates the first The original position of each individual before it has been updated in the current iteration step. Indicates the first The original position of an individual in its current, unupdated state. Indicates position control parameters, and represents a random number between (0, 1), represents an average position, represents the position of the i-th individual, represents the position of the i-th individual, represents the random step length of the i-th individual, represents the random step length of the i-th individual, represents a random number subject to a t-distribution with a degree of freedom of represents the current iteration number (initially 0, and increases by 1 each time the vulture search algorithm is updated), represents a given probability limit, , represents the number of individuals in the vulture population.

[0112] The individual in the updated vulture population is substituted into the maximization of the log-likelihood function, the value of the maximization of the log-likelihood function is used as the fitness of the individual, the fitness with the largest value is used as the optimal fitness, and the average fitness is obtained by averaging all the fitnesses. The iteration termination condition is:

[0113] ;

[0114] wherein, represents the optimal fitness of the current iteration number, represents the average fitness of the current iteration number, represents the optimal fitness of the i-th iteration, represents the size of the sliding window (i), represents the average fitness of the i-th iteration, and represents a preset iteration termination threshold.

[0115] In the third step, the to-be-solved parameters are substituted into the Gaussian mixture model, and the Gaussian mixture model is used to cluster all the roads according to all the traffic basic operation data, to obtain a plurality of clustering clusters.

[0116] The road is divided into the component with the largest probability in the posterior probability corresponding to the road, and this operation is sequentially performed on each road to obtain clustering clusters, and a corresponding traffic state is set for each clustering cluster (according to the traffic condition of the road in the clustering cluster).

[0117] In step 13, the traffic external correlation data of the traffic state is obtained for each traffic state, and the fusion data of the traffic state is obtained by fusing all the traffic basic operation data corresponding to the traffic state and the traffic external correlation data of the traffic state. ​​​​

[0118] The traffic external correlation data includes external correlation data (such as weather, temperature, rainfall, etc.) corresponding to the traffic state at a plurality of historical moments, and specifically includes external correlation data of all roads belonging to the traffic state at a plurality of historical moments.

[0119] In some embodiments of the present application, the external correlation data can be obtained by using temperature collection instruments, weather sensors and other devices. The step of fusing all traffic basic running data corresponding to the traffic state and the traffic external correlation data of the traffic state to obtain the fusion data of the traffic state is specifically as follows:

[0120] Through the formula:

[0121] ;

[0122] ;

[0123] The fusion data of the i-th traffic state is calculated . .

[0124] Wherein, the fusion data of the i-th traffic state at the j-th historical moment is represented by , the fusion data of the i-th traffic state at the first historical moment is represented by , the fusion data of the i-th traffic state at the j-th historical moment is represented by , the fusion data of the i-th traffic state at the first historical moment is represented by , the number of historical moments is represented by , the traffic basic running data of the i-th traffic state at the j-th historical moment is represented by , and the external correlation data of the i-th traffic state at the j-th historical moment is represented by .

[0125] Step 14, using a traffic flow prediction model based on attention mechanism, performing traffic flow prediction based on the fusion data of each traffic state to obtain traffic flow prediction results of each traffic state.

[0126] The traffic flow prediction results include traffic flow prediction values of all roads corresponding to the traffic state, and the traffic flow prediction value is the prediction value of the traffic flow at the next moment of the last historical moment. For example, if the last historical moment is the current moment, the traffic flow prediction value is the prediction value of the traffic flow at the next moment.

[0127] ​​​​​​​​​In some embodiments of the present application, the traffic flow prediction model based on the attention mechanism is used to predict traffic flow based on the fusion data of each traffic state, and the traffic flow prediction result of each traffic state is obtained, including:

[0128] For each traffic state, the following steps are performed respectively:

[0129] First, feature extraction is performed on the data corresponding to each historical time in the fusion data of the traffic state, to obtain the spatio-temporal feature representation of the traffic state at each historical time.

[0130] Specifically, time and space feature extraction is performed on the data corresponding to each historical time in the fusion data of the traffic state (i.e., the element corresponding to the historical time in the fusion data), to obtain traffic time features and traffic space features, and then the traffic time features and the traffic space features are fused to obtain the spatio-temporal feature representation of the traffic state at each historical time.

[0131] For example, the attention mechanism can be used for spatial feature extraction, and the expression is:

[0132] ;

[0133] ;

[0134] ;

[0135] ;

[0136] ;

[0137] ;

[0138] ;

[0139] wherein, represents the traffic space feature, represents the normalized output of self-attention, represents the output of the feedforward time network, and represent weight matrices, and represent bias terms, represents a query matrix based on , represents a key matrix based on , represents a value matrix based on , represents a query weight matrix, represents a key weight matrix, and Represents the value weight matrix, This indicates that the convolution output will be used. The spatial feature sequence obtained by flattening Indicates the scaling factor. This represents the feature sequence after self-attention weighted aggregation. Indicates based on Attention weight matrix, , , This represents the weights of convolution kernels at different scales.

[0140] Multi-scale temporal convolution can be used for temporal feature extraction, as expressed in the following expression:

[0141] ;

[0142] ;

[0143] ;

[0144] ;

[0145] in, Indicates the first The output of the layer, when hour, For traffic time characteristics, Indicates the number of layers being calculated. Indicates the first The output of the layer, when hour, This refers to the historical time data within the fused traffic status data. Indicates splicing characteristics, This represents the output of the first convolution branch. This represents the output of the second convolution branch. This indicates the dilated causal convolution operation. This represents the kernel weights of the first convolutional branch. This represents the kernel weights of the second convolutional branch. This indicates the bias of the first convolution branch. This indicates the bias of the second convolution branch. This represents the expansion rate of the first convolutional branch. This represents the expansion rate of the second convolution branch.

[0146] Exemplarily, the step of fusing the traffic time feature and the traffic space feature to obtain the spatio-temporal feature representation of the traffic state at each historical time is as follows: feature extraction is respectively performed on the traffic time feature and the traffic space feature (a convolutional network or the like can be used), to obtain a deep time feature and a deep space feature, then the deep time feature and the deep space feature are spliced to obtain a comprehensive feature, then the comprehensive feature and the deep time feature are fused to obtain the spatio-temporal feature representation, and the expression is as follows:

[0147] ;

[0148] wherein, denotes the spatio-temporal feature representation of the i-th traffic state at the j-th historical time, denotes the weight, denotes the deep time feature, denotes the deep space feature. The second step is to calculate the time weight and the space weight of the traffic state at each historical time, and embed the spatial position code and the temporal position code into the spatio-temporal feature representation corresponding to the historical time based on the time weight and the space weight, to obtain the spatio-temporal feature embedding of the traffic state at the historical time.

[0149] Specifically, the basic time weight and the basic space weight are calculated based on the corresponding spatio-temporal feature representation at the historical time, then the basic time weight and the basic space weight are nonlinearly corrected to obtain the time weight and the space weight, and finally the spatial position code and the temporal position code are embedded into the spatio-temporal feature representation corresponding to the historical time based on the time weight and the space weight, to obtain the spatio-temporal feature embedding of the traffic state at the historical time.

[0150] It should be noted that the basic time weight

[0151]

[0152] ;

[0153] ;

[0154] ;

[0155] ;

[0156] The basic time weight and the basic space weight are calculated.

[0157] wherein, denotes the balance coefficient, denotes the i-th traffic state, ​​a spatial-temporal feature representation of the th traffic state at the th historical time point, th traffic state at the th historical time point, th traffic state at the th historical time point, th traffic state at the th historical time point, th historical time point, th traffic state at the th historical time point, th traffic state at the th historical time point, th traffic state at the th historical time point, th traffic state at the th historical time point, th traffic state at the th historical time point, th traffic state at the th historical time point, th traffic state at the th historical time point, th traffic state at the th historical time point, th traffic state at the th historical time point.

[0158] It should be noted that after the base time weight and the base space weight are calculated through the above formula, a three-level weight mechanism is adopted for nonlinear correction, and the parameters in the above formula are shared by parameters, and indirect coupling is realized through the way of parameter sharing. Specifically, through the formula:

[0159] ;

[0160] ;

[0161] ;

[0162] ;

[0163] ;

[0164] ;

[0165] the time weight and the space weight .

[0166] wherein, = , , }, represent the three-level weight base value, respectively representing the basic time weight, the similarity weight, and the topology weight, represents the projection matrix, is the bias term, represents and the time position encoding similarity, represents the topology enhancement factor, represents the adaptive scaling coefficient, and are the weight and bias term, respectively, represents the self-connection weight of the road node (i.e., the node corresponding to the road in the graph network, a plurality of nodes of the graph network correspond to a plurality of roads one by one, and the edge of the node is the connection relationship of the corresponding two roads), represents the degree centrality of the road node , represents the variance of the spatio-temporal feature representation, represents a minimum constant (to prevent the denominator from being zero).

[0167] In the calculation of the time weight and the space weight through the above formula, the physical constraint is:

[0168] ;

[0169] wherein, represents and Pearson correlation coefficient, represents the spatial correlation threshold, represents the learning rate coefficient.

[0170] The expression of the spatial position encoding is:

[0171] ;

[0172] wherein, and are the weight and bias, respectively, represents the adjacency matrix of all roads in the target area.

[0173] The expression of the time position encoding is:

[0174] ;

[0175] ;

[0176] in, Indicates even-numbered dimension encoding. Indicates odd-dimensional encoding. Indicates a dimension index. This represents the total dimension of the positional encoding (consistent with the hidden layer dimension).

[0177] It should be noted that, based on time and spatial weights, the specific steps for embedding spatial location codes and temporal location codes into the spatiotemporal feature representations corresponding to historical moments to obtain the spatiotemporal feature embeddings of traffic states at historical moments are as follows:

[0178] Through the formula:

[0179] ;

[0180] ;

[0181] ;

[0182] Calculate the first The traffic condition in the first Spatiotemporal features embedded in historical moments ;

[0183] in, Represents the feature retention coefficient. Indicates time weight, Indicates spatial weights, Represents the data coupling coefficient. Indicates the first The traffic condition in the first Basic traffic operation data at a historical moment, express and The Pearson correlation coefficient.

[0184] The third step involves calculating the embeddings of all spatiotemporal features based on an attention mechanism to obtain the traffic features of the traffic state.

[0185] Specifically, through the formula:

[0186] ;

[0187] ;

[0188] ;

[0189] ;

[0190] ;

[0191] Calculate the first traffic feature of the traffic state .

[0192] wherein, denotes layer normalization, denotes self-attention output feature, denotes feed-forward feature, denotes ReLU activation function, and denotes weight matrix, and denotes bias term, denotes attention weight matrix, denotes value matrix, denotes query matrix, denotes key matrix, denotes scaling factor, denotes vector composed of all spatio-temporal feature embeddings, denotes query weight matrix, denotes key weight matrix, denotes value weight matrix.

[0193] In the fourth step, traffic flow prediction is performed on the traffic state based on the traffic feature, and a traffic flow prediction result of the traffic state is obtained.

[0194] Specifically, the traffic flow prediction result of the i-th traffic state is calculated by the formula:

[0195] ;

[0196] .

[0197] wherein, denotes the feature corresponding to the last historical moment in the traffic feature, denotes weight of the fully connected layer, denotes bias of the fully connected layer.

[0198] It can be understood that the operation process of the above step 14 is the operation process of the traffic flow prediction model.

[0199] ​​For example, to improve the performance of the traffic flow prediction model, before proceeding to this step, the model can be trained using basic traffic operation data from multiple roads in the sample area. For instance, the traffic flow prediction model can be used to predict the traffic flow for each road in the sample area, obtaining the predicted traffic flow value for each road. A loss function is then constructed based on all the predicted traffic flow values. If the value of the loss function is less than or equal to a preset loss value, training is complete. If the value of the loss function is greater than a preset loss value, the parameters in the traffic flow prediction model are adjusted, and the process returns to the step of predicting the traffic flow for each road in the sample area using the traffic flow prediction model. The loss function is:

[0200] ;

[0201] in, This represents the value of the loss function. Indicates comparative loss, Indicates the predicted loss. This indicates the uncertainty of the comparison task. This indicates the uncertainty of the prediction task:

[0202] ;

[0203] ;

[0204] in, Indicates batch size, Indicates the first The traffic condition in the first The spatiotemporal characteristics of a historical moment are represented. Indicates the first The traffic condition in the first The spatiotemporal characteristics of a historical moment are represented. and For randomly selected historical moments, Indicates the number of negative samples. Indicates the first The traffic condition in the first The spatiotemporal characteristics of a historical moment are represented. This represents a temperature parameter used to control the smoothness of the similarity distribution. Indicates the first The traffic condition in the first Traffic flow forecasts at a historical moment, Indicates the first The traffic condition in the first The actual traffic flow value at a historical moment Indicates the first The depth-time characteristics of each traffic state Indicates the first a deep spatial feature of a traffic state, representing a feature consistency loss weight.

[0205] In some embodiments of the present application, the traffic states calculated by the traffic prediction model during the training process can be fitted. The fitting process is as follows: first, collect the prediction results of the model on the training set and the corresponding true observation values, and extract the spatio-temporal feature vectors output by the intermediate layers of the model. Similar traffic states are automatically classified into several categories using a clustering algorithm. Then, for each state category, the prediction error distribution characteristics (including mean deviation and dispersion) of the included samples are counted and fitted into a probability distribution model. The final error fitting set records the standard error characteristics of each traffic state. After obtaining the traffic flow prediction results of the target area through this step, the error fitting set can be used to correct the traffic flow prediction results. If the error fitting set shows that the predicted value is usually high under a certain traffic state, then the preliminary prediction result under that traffic state is reduced by the corresponding error value, and vice versa.

[0206] It is worth mentioning that all roads are divided into multiple traffic states according to the basic traffic operation data, and the data characteristics of each traffic state are analyzed and the traffic flow is predicted, realizing the differentiation of different traffic states, improving the accuracy of traffic flow prediction under different traffic states, combining traffic external correlation data for traffic flow prediction, considering external factors related to traffic, improving the richness of data information, using the traffic flow prediction model based on attention mechanism for traffic flow prediction, which can improve the data feature mining ability of the model, capture the spatio-temporal correlation of traffic flow, and further improve the accuracy of traffic flow prediction.

[0207] The traffic flow prediction device based on traffic states provided by the present application will be described below.

[0208] As shown in Figure 2 , the embodiment of the present application provides a traffic flow prediction device based on traffic states, which comprises:

[0209] The acquisition module 201 is configured to acquire the basic traffic operation data of a plurality of roads in a target area. The basic traffic operation data of a road includes traffic data of the road at a plurality of historical time points.

[0210] The clustering module 202 is configured to cluster all roads according to all basic traffic operation data to obtain a plurality of clustering clusters. The plurality of clustering clusters correspond one by one to a plurality of traffic states.

[0211] The fusion module 203 is used to acquire the external traffic correlation data for each traffic state, and to fuse all the basic traffic operation data corresponding to the traffic state with the external traffic correlation data of the traffic state to obtain the fused traffic state data; the external traffic correlation data includes the external correlation data corresponding to the traffic state at multiple historical time points.

[0212] The traffic flow prediction module 204 is used to predict traffic flow based on the fused data of each traffic state using an attention-based traffic flow prediction model, and to obtain the traffic flow prediction result for each traffic state; the traffic flow prediction result includes the traffic flow prediction value of all roads corresponding to the traffic state.

[0213] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0214] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0215] like Figure 3 As shown, an embodiment of this application provides a terminal device, wherein the terminal device D10 of this embodiment includes: at least one processor D100 ( Figure 3 The diagram shows only one processor, a memory D101, and a computer program D102 stored in the memory D101 and executable on the at least one processor D100, wherein the processor D100 executes the computer program D102 to implement the steps in any of the above method embodiments.

[0216] Specifically, the processor D100 executes the computer program D102, obtains traffic basic operation data of multiple roads in the target area, clusters all roads according to all traffic basic operation data, obtains multiple clustering clusters, respectively obtains traffic external correlation data of a traffic state for each traffic state, fuses all traffic basic operation data corresponding to the traffic state and the traffic external correlation data of the traffic state, obtains fusion data of the traffic state, and then uses a traffic flow prediction model based on an attention mechanism to perform traffic flow prediction based on the fusion data of each traffic state, and obtains a traffic flow prediction result of each traffic state. Wherein, all roads are divided into multiple traffic states according to the traffic basic operation data, and the data characteristics of each traffic state are analyzed and traffic flow prediction is performed, so as to realize the differentiation of different traffic states, improve the accuracy of traffic flow prediction under different traffic states, combine the traffic external correlation data to perform traffic flow prediction, consider the external factors related to traffic, improve the richness of data information, use the traffic flow prediction model based on the attention mechanism to perform traffic flow prediction, which can improve the mining ability of the model to data characteristics, capture the space-time correlation of traffic flow, and then improve the accuracy of traffic flow prediction.

[0217] The processor D100 can be a central processing unit (CPU), and the processor D100 can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0218] The storage D101 can be an internal storage unit of the terminal device D10 in some embodiments, such as a hard disk or a memory of the terminal device D10. The storage D101 can also be an external storage device of the terminal device D10 in other embodiments, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device D10. Further, the storage D101 can include both the internal storage unit and the external storage device of the terminal device D10. The storage D101 is used to store an operating system, an application program, a boot loader, data, and other programs, such as program codes of the computer program, etc. The storage D101 can also be used to temporarily store data that has been output or will be output.

[0219] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the steps in the above-mentioned various method embodiments.

[0220] The embodiments of the present application provide a computer program product. When the computer program product is run on a terminal device, the terminal device is caused to implement the steps in the above-mentioned various method embodiments.

[0221] The integrated unit, if realized in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the embodiments of the present application can implement all or part of the processes in the above-mentioned method embodiments by a computer program to instruct related hardware to complete, and the computer program can be stored in a computer readable storage medium. The computer program is executed by a processor to implement the steps in the above-mentioned various method embodiments. The computer program includes computer program codes, which can be in the form of source code, object code, executable files or some intermediate forms, etc. The computer readable medium at least includes any entity or device capable of carrying the computer program codes of the traffic state based traffic flow prediction method and terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunications signal and a software distribution medium. For example, a U disk, a mobile hard disk, a magnetic disk or an optical disk, etc.

[0222] In the above embodiments, the description of each embodiment is focused on, and the part not described or recorded in a certain embodiment can be referred to the relevant description of other embodiments.

[0223] Those skilled in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0224] The above is the preferred embodiment of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should be considered as the protection scope of the present application.

Claims

1. A traffic flow prediction method based on traffic state, characterized by, The method comprises the following steps: acquiring traffic basic operation data of a plurality of roads in a target area; the traffic basic operation data of the roads comprises traffic data of the roads at a plurality of historical time points; clustering all the roads according to all the traffic basic operation data to obtain a plurality of clustering clusters; the plurality of clustering clusters correspond to a plurality of traffic states one by one; for each traffic state, acquiring traffic external correlation data of the traffic state, and fusing all the traffic basic operation data corresponding to the traffic state and the traffic external correlation data of the traffic state to obtain fusion data of the traffic state; the traffic external correlation data comprises external correlation data corresponding to the traffic state at a plurality of historical time points; using a traffic flow prediction model based on an attention mechanism to perform traffic flow prediction based on the fusion data of each traffic state to obtain a traffic flow prediction result of each traffic state; the traffic flow prediction result comprises traffic flow prediction values of all the roads corresponding to the traffic state; wherein, the clustering of all the roads according to all the traffic basic operation data to obtain a plurality of clustering clusters comprises: constructing a maximum log-likelihood function; solving to-be-solved parameters in a Gaussian mixture model according to the maximum log-likelihood function; substituting the to-be-solved parameters into the Gaussian mixture model, and using the Gaussian mixture model to cluster all the roads according to all the traffic basic operation data to obtain a plurality of clustering clusters; the maximum log-likelihood function is: ; wherein, denotes a set of parameters to be solved, denotes a mixing coefficient of the th component, denotes a mean vector of the probability density of the th component, denotes a covariance matrix of the probability density of the th component, denotes a determinant of , and denotes a number of roads in the target area, denotes traffic basic operation data of the th road, denotes a number of components of the Gaussian mixture model, denotes a transpose operation, denotes a set of traffic basic operation data, denotes a probability density generated under a probability model linearly combined from components of the Gaussian mixture model; the solving of the to-be-solved parameters in the Gaussian mixture model according to the maximum log-likelihood function comprises: initializing a vulture population; the individuals in the vulture population comprise a mixing coefficient of each component in the Gaussian mixture model, a mean vector of a probability density of each component, a one-dimensional vector of each component, and a random number matrix of each component; randomly selecting an individual from the vulture population for updating, and updating the vulture population using a vulture search algorithm to obtain an updated vulture population; calculating the best fitness and the average fitness of the updated vulture population based on the maximum log-likelihood function; judging whether the best fitness and the average fitness meet an iteration termination condition; if yes, taking an individual corresponding to the best fitness of the updated vulture population as a target individual, and obtaining the to-be-solved parameters in the Gaussian mixture model according to the target individual; otherwise, taking the updated vulture population as the vulture population, and returning to the step of randomly selecting an individual from the vulture population for updating and updating the vulture population using the vulture search algorithm to obtain an updated vulture population.

2. The traffic flow prediction method according to claim 1, characterized in that, the traffic flow prediction based on the fusion data of each traffic state using the traffic flow prediction model based on the attention mechanism to obtain the traffic flow prediction result of each traffic state comprises: for each traffic state, the following steps are performed: performing feature extraction on data corresponding to each historical time point in the fusion data of the traffic state to obtain a spatio-temporal feature representation of the traffic state at each historical time point; The time weight and the space weight of the traffic state at each historical moment are calculated respectively, and based on the time weight and the space weight, spatial position encoding and time position encoding are embedded into the spatiotemporal feature representation corresponding to the historical moment, to obtain the spatiotemporal feature embedding of the traffic state at the historical moment; The traffic feature of the traffic state is calculated based on the attention mechanism on all spatiotemporal feature embeddings; The traffic flow prediction result of the traffic state is obtained by predicting the traffic flow of the traffic state based on the traffic feature.

3. The traffic flow prediction method according to claim 2, characterized in that, The calculation of the time weight and the space weight of the traffic state at the historical moment comprises: The basic time weight and the basic space weight are calculated based on the spatiotemporal feature representation corresponding to the historical moment; The basic time weight and the basic space weight are nonlinearly corrected to obtain the time weight and the space weight.

4. The traffic flow prediction method according to claim 3, characterized in that, The calculation of the basic time weight and the basic space weight based on the spatiotemporal feature representation corresponding to the historical moment comprises: Through the formula: ; ; ; ; Computing a base time weight and a base space weight ; wherein, denotes a balance coefficient, denotes a spatio-temporal feature representation of the th traffic state at the th historical time instant, denotes a temporal position encoding, denotes a spatial position encoding, denotes a spatio-temporal feature representation of the th traffic state at the th historical time instant, denotes a spatio-temporal feature representation of the th traffic state at the th historical time instant, denotes a weight of the single-layer perceptron, denotes a bias term of the single-layer perceptron, denotes an external correlation data modulation term, denotes a rate of change of the external correlation data, denotes a weight matrix of the linear transformation, denotes a bias term of the linear transformation, denotes a standard deviation computation, denotes a mean computation, denotes a maximum value, denotes a set of external correlation data, denotes a Softmax function, denotes a Sigmoid activation function, denotes a hyperbolic tangent function, , denotes a number of traffic states, , denotes a number of historical time instants.

5. The traffic flow prediction method according to claim 4, characterized in that, The embedding of the spatial position encoding and the time position encoding into the spatiotemporal feature representation corresponding to the historical moment based on the time weight and the space weight to obtain the spatiotemporal feature embedding of the traffic state at the historical moment comprises: Through the formula: ; ; ; computing a spatiotemporal feature embedding of the first traffic state at the first historical time instant ; wherein, denotes a feature retention coefficient, denotes a temporal weight, denotes a spatial weight, denotes a data coupling coefficient, denotes the basic traffic operation data of the th traffic state at the th historical time instant, denotes the Pearson correlation coefficient of the Pearson correlation coefficient of 6. The traffic flow prediction method according to claim 5, characterized in that, The calculation of the traffic feature of the traffic state based on the attention mechanism on all spatiotemporal feature embeddings comprises: Through the formula: ; ; ; ; ; computing traffic features of the traffic state ; wherein, denotes layer normalization, denotes self-attention output features, denotes feed-forward features, denotes a ReLU activation function, and denotes a weight matrix, and denotes a bias term, denotes an attention weight matrix, denotes a value matrix, denotes a query matrix, denotes a key matrix, denotes a scaling factor, denotes a vector of all spatio-temporal feature embeddings, denotes a query weight matrix, denotes a key weight matrix, denotes a value weight matrix.

7. The traffic flow prediction method according to claim 6, characterized in that, The traffic flow prediction result of the traffic state is obtained by predicting the traffic flow of the traffic state based on the traffic feature. The processor executes the computer program to realize the traffic flow prediction method based on the traffic state according to any one of claims 1 to 7. ; computing the traffic flow prediction result for the ;​ wherein, denotes a feature corresponding to the last historical time in the traffic feature, denotes a weight of the fully connected layer, denotes a bias of the fully connected layer.

8. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, ​

Citation Information

Patent Citations

  • Traffic flow prediction method and device, computer device, and storage medium

    CN109272169A

  • Markov chain model based traffic factor network construction method

    CN109377761A