A method for predicting road traffic flow speed based on influence coefficients

By constructing a Transformer model that combines undirected graph and multi-layer graph convolution, the problem of ignoring the timeliness of speed changes in existing technologies is solved, achieving high-precision road traffic flow speed prediction and improving the model's running speed.

CN116304965BActive Publication Date: 2025-11-14SOUTHWEAT UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211089382.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-07
Publication Date
2025-11-14
Estimated Expiration
2042-09-07

AI Technical Summary

Technical Problem

Existing technologies ignore the timeliness of speed changes in road traffic flow speed prediction, resulting in insufficient prediction accuracy, and traditional deep learning models have difficulty processing long-term series data.

Method used

An undirected graph representation of the transportation network is constructed. An adjacency matrix is ​​generated by calculating the similarity of the road network influence coefficient and the distance coefficient. Spatial features are extracted by combining multi-layer graph convolution, and a Transformer model is used for time prediction. The influence coefficient weight matrix is ​​calculated for accurate prediction.

Benefits of technology

It improves the accuracy of road traffic flow speed prediction and performs faster in terms of operating speed, outperforming traditional models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116304965B_ABST
    Figure CN116304965B_ABST
Patent Text Reader

Abstract

This invention discloses a method for predicting road traffic flow speed based on influence coefficients. It constructs a road topology structure, calculates the influence coefficients of traffic flow data for each road according to a time step, and builds an adjacency matrix based on the similarity of road network influence coefficients and the similarity of road network distance coefficients. Then, it uses two multi-layer graph convolutions to fuse the feature matrix F and the adjacency matrix A, obtaining a feature matrix F″ with spatial features, which is input into a Transformer model. The weight matrix values ​​of the feature matrix are calculated based on the temporal influence, and the predicted traffic flow speed is calculated. This invention addresses the problem of existing technologies neglecting the time-sensitive nature of speed changes, effectively predicting road traffic flow speed and improving prediction accuracy. Furthermore, this invention is faster than existing technologies in terms of operating speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of intelligent transportation systems technology, and more specifically, relates to a method for predicting road traffic flow speed based on influence coefficients. Background Technology

[0002] Intelligent Transportation Systems (ITS) are a broad category of transportation systems encompassing vehicles, roads, and users. Predicting road traffic flow speeds is a crucial component of ITS traffic information collection, enabling the rational allocation of future traffic resources.

[0003] Early methods for predicting road traffic flow speed relied solely on extracting temporal features to numerically predict traffic flow speed, neglecting the impact of connectivity between roads on traffic flow speed. Graph convolution, as a convolutional network that extracts spatial features from a topological graph, has been widely applied in speed prediction in recent years. Some researchers have combined traditional deep learning models with graph convolution to predict road traffic speed.

[0004] The paper "Research on Traffic State Discrimination and Prediction Based on Multi-Feature Fusion" (Zhang Shuo, Jiangxi University of Science and Technology, 2021, 2021.000145) proposes a multi-feature spatiotemporal graph convolutional network. It uses graph convolution to extract spatial features and employs a long short-term memory network, TESNet, and gating units to predict traffic flow based on temporal features. This method considers multiple factors, including weather, and determines the magnitude of each factor's influence on speed through coefficients.

[0005] The paper "Traffic Speed ​​Prediction Based on Spatiotemporal Attention Graph Convolutional Neural Network" (Huang Weijian, Li Chungui. Journal of Guangxi University of Science and Technology, 2022, 33(01):54-62.) proposes a graph temporal convolutional neural network model based on a spatiotemporal attention mechanism. This model uses an attention mechanism module to construct a spatiotemporal attention matrix, employs graph convolution to extract spatial features, and uses gating units to extract temporal features. Introducing a gating convolutional module can improve data utilization efficiency and avoid potential gradient vanishing or gradient exploding problems during prediction.

[0006] Using traditional deep learning models for long-term series prediction has the problem of insufficient prediction length supported by the models. Traditional deep learning models have difficulty processing traffic flow data of several months, resulting in insufficient prediction accuracy.

[0007] The Transformer, a deep learning model proposed in 2017, was initially applied to the field of text translation. With ongoing research on this model both domestically and internationally, its multi-head attention mechanism, due to its ability to observe all time points, has gradually been applied to various fields, and is now widely used in image segmentation, image recognition, and numerical prediction.

[0008] The paper "Spatial-Temporal Transformer Networks for Traffic Flow Forecasting" (Mingxing Xu, Wenrui Dai et al., arXiv:2001.02908) proposes an overall model based on Transformer and graph convolution. The original Transformer model is used as a temporal Transformer model, and the Transformer model combined with graph convolution is used as a spatial Transformer model. This combines N temporal and spatial models into N temporal-spatial Transformer models, uses one-hot codes to encode the data, and passes it through a fully connected layer for tiling before output. This scheme uses a Transformer model for traffic prediction and supports long-sequence prediction.

[0009] The methods described above all ignore the time-dependent nature of speed changes. The impact of a single event on speed gradually decreases over time, leading to reduced prediction accuracy. Summary of the Invention

[0010] The purpose of this invention is to overcome the shortcomings of the prior art and provide a road traffic flow speed prediction method based on influence coefficients, so as to effectively predict road traffic flow speed and improve prediction accuracy.

[0011] To achieve the above-mentioned objective, the present invention provides a road traffic flow speed prediction method based on influence coefficients, characterized by comprising the following steps:

[0012] (1) Construct an undirected graph based on the traffic flow speed of each road segment in the transportation network over a period of time.

[0013] Obtain the traffic flow speed of each road segment in the transportation network over a period of time. Construct a road network based on the roads in the transportation network. The period of time is one day, one week, one month, or one year. The road segments between road intersections are road network nodes, and the connection between road segments is an edge. This results in an undirected graph G(V,E), where G is the road network, V is the set of road network nodes, and E is the set of edges.

[0014] (2) Construct the feature matrix F:

[0015] F = {v}ij |1≤i≤N and 1≤j≤C}

[0016] N represents the total number of road network nodes, C represents the total number of moments in that time period, and v ij This represents the traffic flow velocity at the i-th road network node at time j;

[0017] (3) Construct the adjacency matrix A

[0018] 3.1) Calculate the similarity S of the road network influence coefficient. ab

[0019] 3.1.1) Determine the steady-state moment

[0020] If the following conditions are met:

[0021] |v ij -v i(j+1) |+|v ij -v i(j-1) |≤λ

[0022] The j-th time point is called a stationary time point, where 2 ≤ j ≤ C⁻¹, and λ is the threshold value, which is calculated as follows:

[0023] Calculate the velocity change before and after the h-th time point, denoted by f. ih The formula for calculating 2≤h≤C-1 is:

[0024] f ih =|v ih -v i(h+1) |+|v ih -v i(h-1) |

[0025] Calculate the expected value μ i With standard deviation σ i :

[0026]

[0027]

[0028] Calculate the threshold λ of the i-th road network node i :

[0029] λ i =μ i -σ i

[0030] Calculate the threshold λ:

[0031]

[0032] 3.1.2) Determine the time period

[0033] The traffic flow speed of each road segment within a certain period of time is divided into multiple time periods by dividing two adjacent stable moments into one time period.

[0034] 3.1.3) Calculate the mean influence coefficient β ik

[0035] Calculate the influence coefficient of road network nodes

[0036]

[0037] in, It is the influence coefficient at time k within the q-th time interval of the time series of the i-th road network node. Let be the traffic flow speed at time k within the q-th time interval of the time series of the i-th road network node. Let be the traffic flow speed at the beginning of the q-th time interval in the time series of the i-th road network node. Let l be the traffic flow velocity at the end of the q-th time interval in the time series of the i-th road network node. iq Let be the number of moments in the q-th time period of the time series of the i-th road network node;

[0038] Calculate the mean β of the influence coefficient of the i-th road network node at the k-th time interval for each time period. ik :

[0039]

[0040] Where, ξ i Let k be the number of time intervals for the i-th road network node, where k ranges from 1 to l. i , l i This represents the number of moments in the longest time period among all time periods of the i-th road network node. For other time periods, non-existent time periods are filled with 0.

[0041] 3.1.4) Based on the mean influence coefficient β ik Calculate the road network influence coefficient similarity S ab :

[0042]

[0043] in, Let x be the mean of the first x influence coefficients of the set of influence coefficients of the a-th road network node. Let x be the mean of the first x influence coefficients of the set of influence coefficients of the b-th road network node, where x is the number of moments in the longest time period of the a-th road network node. a And the number of times in the longest time period of the b-th road network node l b The smaller value in;

[0044] 3.2) Road network distance coefficient similarity D ab :

[0045]

[0046] Where, d ab Let be the Euclidean distance between the a-th road network node and the b-th road network node, and its value is:

[0047]

[0048] in, Let γ be the latitude of the a-th and b-th road network nodes on Earth, respectively. a γ b These are the longitudes of the a-th and b-th road network nodes on Earth, respectively, where R represents the latitude or the distance of one degree between the two longitudes.

[0049] Where σ represents the standard deviation of the distances between all road network nodes, and the standard deviation σ is expressed by the formula:

[0050] And a≠b

[0051] Where μ is the expected value of the distance between all road network nodes, and the expected value μ is expressed by the formula:

[0052] And a≠b

[0053] 3.3) Based on the similarity S of the road network influence coefficient ab Similarity D with road network distance coefficient ab Calculate the adjacency matrix A:

[0054] A={r ab |r ab ={0,1},1≤a≤N and1≤b≤N}

[0055] r ab Let r represent the relationship between the a-th road network node and the b-th road network node, where 1 represents a relationship and 0 represents no relationship, and r ab =r ba Its value is:

[0056]

[0057] Among them, W ab This represents the relationship weight between the a-th road network node and the b-th road network node, and the weight is determined by the road network influence coefficient similarity S. ab Similarity D with road network distance coefficient ab Similarity determines the value:

[0058]

[0059] Where θ is the threshold, and its value is:

[0060]

[0061] g represents the number of edges connecting N road network nodes in the transportation network;

[0062] (4) Perform two multi-layer graph convolutions based on the feature matrix F and the adjacency matrix A to obtain the feature matrix F″ with spatial features.

[0063] 4.1) The first multi-layer graph convolution is:

[0064]

[0065] Among them, W l Let S be the weight matrix of the l-th layer, σ be the nonlinear activation function, S be the degree matrix, and H be the weight matrix of the l-th layer. l H is the input of the l-th layer. l+1 The output is the feature matrix H; the input of the first layer is the feature matrix H. 1 =F, starting from the second layer, the input of each layer is the output of the previous layer;

[0066] The output H after convolving the graph of layer L L+1 The feature matrix F′ is obtained after mapping with the ReLU nonlinear activation function;

[0067] 4.2) The second multi-layer graph convolution is:

[0068]

[0069] Among them, W′ l Let H' be the weight matrix of the l-th layer, σ′ be the nonlinear activation function, D be the degree matrix, and H′ be the weight matrix of the l-th layer. l H′ is the input of the l-th layer. l+1 The output is the feature matrix H; the input of the first layer is the feature matrix H. ′1 =F′, starting from the second layer, the input of each layer is the output of the previous layer;

[0070] The output H′ after graph convolution of layer L′ l+1 After mapping using the Softmax activation function, the feature matrix F″ is obtained, which is the final feature matrix F″ with spatial features.

[0071] (5) The feature matrix F″ is fed into the Transformer model to be converted into vectors and then trained.

[0072] 5.1) The feature matrix F″ with spatial features is input into the encoder of the Transformer. The encoder transforms the data in the feature matrix F″ into a vector y according to the road number. i :

[0073] y i =(y i1 ,y i2 ,…,y iC )

[0074] Where, vector y i Let y be the vector representation of the traffic flow velocity at the i-th road network node. ij Let F″ be the value of network node i at time j, where j = 1, 2, ..., C;

[0075] 5.2) Construct the velocity value matrix Y′ for prediction. i And train the Transformer model

[0076] 5.2.1) Construct the velocity value matrix Y′ for prediction. i :

[0077] Construct the velocity matrix Y i :

[0078] And 1≤n≤C}

[0079] in,

[0080] The vector (y) i1 ,y i2 ,…,y iC Repeat line C to obtain the velocity matrix Y. i The vector in the m-th row corresponds to the traffic flow velocity prediction in the m-th step;

[0081] Based on the predicted number of steps and time, construct the weight matrix T. i Its value is:

[0082] And 1≤n≤C}

[0083] in, This represents the weight value at time n in the m-th prediction step, and its value is:

[0084]

[0085] Calculate the velocity value matrix Y′ used for prediction i :

[0086] Y′ i =Y i*T i

[0087] Where * represents the Hadama product, which is the element-wise multiplication of two matrices;

[0088] 5.2.2) Training the Transformer model

[0089] The velocity value matrix Y′ i The first row is fed into the decoder as a vector for the first step of prediction, to obtain the predicted traffic flow velocity v′ at the first time step of the next time period. i1 The second row is fed into the decoder as a vector for the second prediction step, to obtain the predicted traffic flow velocity v′ at the second time step in the next time period. i2 By performing C-step prediction, the predicted traffic flow velocity v′ at C time points in the next time period can be obtained. ij j = 1, 2, ..., C;

[0090] Use the actual traffic flow velocity at time C in the next time period as the prediction target value v″ ij , j = 1, 2, ..., C, substitute the predicted traffic flow speeds and predicted target values ​​at C time points into the loss function, and update the Transformer model using the gradient descent method;

[0091] The vector y corresponding to all N road network nodes i For i = 1, 2, ..., N, repeat this step to train the Transformer model;

[0092] (6) Repeatedly select the traffic flow speed at C times for N road network nodes over a period of time, and repeat steps (2), (3), (4), and (5) until the predicted traffic flow speed v′ is obtained. ij i = 1, 2, ..., N, j = 1, 2, ..., C and the actual traffic flow velocity v″ ij The difference is less than the set threshold, or the set maximum number of training iterations is reached;

[0093] (7) Road traffic flow speed prediction

[0094] Select the traffic flow speeds at C times for N road network nodes in the most recent period, and repeat steps (2), (3), (4), 5.1), and 5.2.1). Then, generate the speed value matrix Y′ corresponding to all N road network nodes. i For i = 1, 2, ..., N, perform C-step predictions to obtain the predicted traffic flow speed v′ at the next C times. ij , i=1,2,…,N, j=1,2,…,C.

[0095] The objective of this invention is achieved as follows:

[0096] This invention presents a road traffic flow speed prediction method based on influence coefficients. It constructs a road topology structure, calculates the influence coefficients of traffic flow data for each road according to time steps, and builds an adjacency matrix based on the similarity of road network influence coefficients and road network distance coefficients. Then, it uses two multi-layer graph convolutions to fuse the feature matrix F and the adjacency matrix A, obtaining a feature matrix F″ with spatial features, which is input into a Transformer model. The weight matrix values ​​of the feature matrix are calculated based on the temporal influence, and the predicted traffic flow speed is then calculated. This invention addresses the problem of existing technologies neglecting the time-sensitive nature of speed changes, effectively predicting road traffic flow speeds and improving prediction accuracy. Furthermore, this invention is faster than existing technologies in terms of operating speed. Attached Figure Description

[0097] Figure 1 This is a flowchart of a specific implementation of the road traffic flow speed prediction method based on influence coefficients of the present invention;

[0098] Figure 2 yes Figure 1 The similarity S of the road network influence coefficient is shown in the figure. ab A flowchart of a specific implementation method;

[0099] Figure 3 This is a line graph showing the training loss and validation loss after simulation of this invention;

[0100] Figure 4 This is a line graph comparing the original and predicted values ​​of the dataset after simulation in this invention. Detailed Implementation

[0101] The specific embodiments of the present invention will now be described with reference to the accompanying drawings to enable those skilled in the art to better understand the invention. It should be particularly noted that in the following description, detailed descriptions of known functions and designs that might obscure the main content of the invention will be omitted here.

[0102] Figure 1 This is a flowchart of a specific implementation of the road traffic flow speed prediction method based on influence coefficients of the present invention.

[0103] In this embodiment, as Figure 1 As shown, the road traffic flow speed prediction method based on influence coefficients of the present invention includes the following steps:

[0104] Step S1: Construct an undirected graph based on the traffic flow velocity of each road segment in the transportation network over a period of time.

[0105] Obtain the traffic flow speed of each road segment in the transportation network over a period of time. Construct a road network based on the roads in the transportation network. The period of time is one day, one week, one month, or one year. The road segments between road intersections are road network nodes, and the connection between road segments is an edge. This results in an undirected graph G(V,E), where G is the road network, V is the set of road network nodes, and E is the set of edges.

[0106] Step S2: Construct the feature matrix F:

[0107] F = {v} ij |1≤i≤N and 1≤j≤C}

[0108] N represents the total number of road network nodes, C represents the total number of moments in that time period, and v ij Let F represent the traffic flow velocity at the i-th road network node at time j. The characteristic matrix F belongs to R. N*C That is, an N*C real matrix.

[0109] Step S3: Construct the adjacency matrix A

[0110] Step S3.1: Calculate the road network influence coefficient similarity S ab

[0111] like Figure 2 As shown, the similarity S of the road network influence coefficient is calculated. ab Includes the following steps:

[0112] Step S3.1.1: Determine the stationary moment

[0113] If the following conditions are met:

[0114] |v ij -v i(j+1) |+|v ij -v i(j-1) |≤λ

[0115] The j-th time point is called the stationary time point, where 2≤j≤C-1 and λ is the threshold.

[0116] The value of the threshold λ will affect the number of stationary moments in the time series of road network nodes. Too many stationary moments will result in a short time period, while too few stationary moments will result in a small number of time periods.

[0117] In this invention, the threshold λ is obtained through the following calculation:

[0118] Calculate the velocity change before and after the h-th time point, denoted by f. ih The formula for calculating 2≤h≤C-1 is:

[0119] f ih =|v ih -v i(h+1)|+|v ih -v i(h-1) |

[0120] Calculate the expected value μ i With standard deviation σ i :

[0121]

[0122]

[0123] Calculate the threshold λ of the i-th road network node i :

[0124] λ i =μ i -σ i

[0125] The thresholds for all road network nodes are calculated using the same method, forming a threshold sequence (λ1, λ2, ..., λ). N Finally, the threshold λ is determined by taking the average value.

[0126]

[0127] Step S3.1.2: Determine the time period

[0128] By dividing two adjacent stable moments into one time period, the traffic flow speed of each road segment within a certain period of time is divided into multiple time periods.

[0129] Step S3.1.3: Calculate the mean influence coefficient β ik

[0130] Calculate the influence coefficient of road network nodes

[0131]

[0132] in, It is the influence coefficient at time k within the q-th time interval of the time series of the i-th road network node. Let be the traffic flow speed at time k within the q-th time interval of the time series of the i-th road network node. Let be the traffic flow speed at the beginning of the q-th time interval in the time series of the i-th road network node. Let l be the traffic flow velocity at the end of the q-th time interval in the time series of the i-th road network node. iq Let be the number of moments in the q-th time period of the time series of the i-th road network node.

[0133] Calculate the mean β of the influence coefficient of the i-th road network node at the k-th time interval for each time period. ik :

[0134]

[0135] Where, ξ i Let k be the number of time intervals for the i-th road network node, where k ranges from 1 to l. i , l i This represents the number of moments in the longest time period among all time periods of the i-th road network node. For other time periods, non-existent time periods are filled with 0.

[0136] Thus, the set of average influence coefficients of the i-th road network node can be represented as:

[0137] P i ={β i1 ,β i2 ,…,β ili}

[0138] Step S3.1.4: Based on the mean influence coefficient β ik Calculate the road network influence coefficient similarity S ab :

[0139]

[0140] in, Let x be the mean of the first x influence coefficients of the set of influence coefficients of the a-th road network node. Let x be the mean of the first x influence coefficients of the set of influence coefficients of the b-th road network node, where x is the number of moments in the longest time period of the a-th road network node. a And the number of times in the longest time period of the b-th road network node l b The smaller value in the range.

[0141] Step S3.2: Road network distance coefficient similarity D ab :

[0142]

[0143] Where, d ab Let be the Euclidean distance between the a-th road network node and the b-th road network node, and its value is:

[0144]

[0145] in, Let γ be the latitude of the a-th and b-th road network nodes on Earth, respectively. a γ b These are the longitudes of the a-th and b-th road network nodes on Earth, respectively, where R represents the distance of one degree between latitude and longitude, and is 111.12 km.

[0146] Where σ represents the standard deviation of the distances between all road network nodes, and the standard deviation σ is expressed by the formula:

[0147] And a≠b

[0148] Where μ is the expected value of the distance between all road network nodes, and the expected value μ is expressed by the formula:

[0149] And a≠b

[0150] Step S3.3: Based on the similarity S of the road network influence coefficient ab Similarity D with road network distance coefficient ab Calculate the adjacency matrix A:

[0151] A={r ab |r ab ={0,1},1≤a≤N and1≤b≤N}

[0152] r ab Let r represent the relationship between the a-th road network node and the b-th road network node, where 1 represents a relationship and 0 represents no relationship, and r ab =r ba Its value is:

[0153]

[0154] Among them, W ab This represents the relationship weight between the a-th road network node and the b-th road network node, and the weight is determined by the road network influence coefficient similarity S. ab Similarity D with road network distance coefficient ab Similarity determines the value:

[0155]

[0156] Where θ is a threshold, the value of which affects the number of 1s in the adjacency matrix A, and its value is:

[0157]

[0158] g represents the number of edges connecting the N road network nodes in the transportation network.

[0159] Step S4: Perform two multi-layer graph convolutions based on the feature matrix F and the adjacency matrix A to obtain the feature matrix F″ with spatial features.

[0160] Graph convolution learns a mapping function given a defined topology and features, specifically including:

[0161] Step S4.1: The first multi-layer graph convolution is as follows:

[0162]

[0163] Among them, W l Let be the weight matrix of the l-th layer, σ be the nonlinear activation function, D be the degree matrix, and H be the weight matrix of the l-th layer. l H is the input of the l-th layer. l+1 The output is the feature matrix H; the input of the first layer is the feature matrix H. 1 =F, starting from the second layer, the input of each layer is the output of the previous layer.

[0164] The output H after convolving the graph of layer L L+1 The feature matrix F′ is obtained after mapping using the ReLU nonlinear activation function.

[0165] Step S4.2: The second multi-layer graph convolution is as follows:

[0166]

[0167] Among them, W′ l Let H' be the weight matrix of the l-th layer, σ′ be the nonlinear activation function, D be the degree matrix, and H′ be the weight matrix of the l-th layer. l H′ is the input of the l-th layer. l+1 The output is the feature matrix H; the input of the first layer is the feature matrix H. ′1 =F′, starting from the second layer, the input of each layer is the output of the previous layer.

[0168] The output H′ after graph convolution of layer L′ l+1 After mapping using the Softmax activation function, the feature matrix F″ is obtained, which is the final feature matrix F″ with spatial features.

[0169] Step S5: The feature matrix F″ is fed into the Transformer model to be converted into vectors and then trained.

[0170] Step S5.1: Input the feature matrix F″ with spatial features into the encoder of the Transformer. The encoder transforms the data in the feature matrix F″ into a vector y according to the road number. i :

[0171] y i =(y i1 ,y i2 ,…,y iC )

[0172] Where, vector y i Let y be the vector representation of the traffic flow velocity at the i-th road network node. ij Let F″ be the value of network node i at time j, where j = 1, 2, ..., C, in the feature matrix F″ with spatial characteristics.

[0173] Step S5.2: Construct the velocity value matrix Y′ for prediction i And train the Transformer model

[0174] Step S5.2.1: Construct the velocity value matrix Y′ for prediction i :

[0175] Construct the velocity matrix Y i :

[0176] And 1≤n≤C}

[0177] in,

[0178] The vector (y) i1 ,y i2 ,…,y iC Repeat line C to obtain the velocity matrix Y. i The vector in the m-th row corresponds to the traffic flow velocity prediction in the m-th step.

[0179] In this invention, influence coefficients are used to assign values ​​to the weight matrix, and when predicting the velocity at the current moment, the data weights for future moments are reset to zero. Specifically:

[0180] First, construct the weight matrix T based on the predicted number of steps and time. i Its value is:

[0181] And 1≤n≤C}

[0182] in, This represents the weight value at time n in the m-th prediction step, and its value is:

[0183]

[0184] Then, the velocity value matrix Y is calculated according to the predicted number of steps. i The values ​​and weight matrix T i The corresponding values ​​are multiplied to calculate the velocity matrix Y′ used for prediction. i :

[0185] Y′ i =Y i *T i

[0186] Here, * represents the Hadamard product, which is the element-wise multiplication of two matrices.

[0187] Step S5.2.2: Train the Transformer model

[0188] The velocity value matrix Y′i The first row is fed into the decoder as a vector for the first step of prediction, to obtain the predicted traffic flow velocity v′ at the first time step of the next time period. i1 The second row is fed into the decoder as a vector for the second prediction step, to obtain the predicted traffic flow velocity v′ at the second time step in the next time period. i2 By performing C-step prediction, the predicted traffic flow velocity v′ at C time points in the next time period can be obtained. ij , j = 1, 2, ..., C.

[0189] Use the actual traffic flow velocity at time C in the next time period as the prediction target value v″ ij For each j = 1, 2, ..., C, the predicted traffic flow speeds and the predicted target values ​​at C time points are substituted into the loss function, and the Transformer model is updated using the gradient descent method.

[0190] The vector y corresponding to all N road network nodes i For i = 1, 2, ..., N, repeat this step to train the Transformer model.

[0191] Step S6: Repeat steps S2, S3, S4, and S5 until the difference is less than the set threshold or the set maximum number of training iterations is reached.

[0192] Repeatedly select traffic flow speeds at C times for N road network nodes over a period of time, and repeat steps S2, S3, S4, and S5 to obtain the predicted traffic flow speed v′. ij i = 1, 2, ..., N, j = 1, 2, ..., C and the actual traffic flow velocity v″ ij The difference is less than the set threshold, or the set maximum number of training iterations is reached.

[0193] Step S7: Road Traffic Flow Speed ​​Prediction

[0194] Select the traffic flow speeds at C times for N road network nodes over a recent period, and repeat steps S2, S3, S4, S5, S5.1, and S5.2.1. Then, generate the speed value matrix Y′ corresponding to all N road network nodes. i For i = 1, 2, ..., N, perform C-step predictions to obtain the predicted traffic flow speed v′ at the next C times. ij , i=1,2,…,N, j=1,2,…,C.

[0195] Simulation Examples

[0196] In this simulation example, three evaluation criteria are used: (1) Mean Absolute Error (MAE); (2) Mean Square Error (MSE); and (3) Root Mean Square Error (RMSE).

[0197] The simulation data is taken from the PEMSD7 dataset, which is real-time data acquired by the Caltrans Performance Measurement System (PeMS) from over 39,000 monitoring stations distributed across major urban areas of California's highway system. The data is aggregated from 30-second samples into data every 5 minutes. Compared to other traffic datasets, this dataset records a larger number of roads over a longer period, making it suitable for predicting traffic flow.

[0198] According to the present invention, the specific implementation steps are as follows:

[0199] (1) First, calculate the traffic flow speed of each road segment in the traffic network over a period of time, construct a directed graph G(V,E), calculate the connection relationship between each road segment, calculate the distance between road segments, and then perform the relevant calculations to construct the adjacency matrix:

[0200] (1.1) Confirm the thresholds θ and λ. Each sensor in PEMSD7 has 12672 time values. According to the formula, the number of stable times is about 2010. The average length of the time period is 6. The number of connections between the 25 road network nodes is 72. θ = 0.32 and λ = 0.56.

[0201] (1.2) Next, calculate the influence coefficient of the road segment and the similarity of the influence coefficient between the road segments. Construct an adjacency matrix based on the similarity of the influence coefficient and the distance coefficient. Multiply the weight matrix with the feature matrix to obtain the feature matrix with spatial features.

[0202] (2) After obtaining the feature matrix from graph convolution with extracted spatial features, data processing is performed for subsequent training.

[0203] (2.1) For prediction, data from a specific column is selected, first dividing the data into a test set (70%) and a validation set (30%). During prediction, the first number in the vector is used as input, and the second number as the prediction target. For subsequent predictions, earlier numbers are added as historical inputs. The time influence module assigns weights by multiplying the weight matrix by the vector. Gradient descent is used for updates in the forward pass. After training, the validation set data is fed into the model for testing.

[0204] like Figure 3As shown, Figure 3 The graph shows the loss statistics for the training and test sets after training. The red line represents the loss statistics for the training set, and the blue line represents the loss statistics for the test set. The decreasing line shows that this method can control the predicted values ​​to a relatively ideal state within approximately 10 rounds, or about 5 seconds, indicating fast convergence. Furthermore, the loss values ​​can reach 0.1% and 0.4% respectively, demonstrating high accuracy. The reason the loss on the validation set is higher than the loss on the training set is mainly because the model is trained on the predictions of the training set. Applying the predictions from the training set directly to the validation set, without prior exposure to validation data, results in a higher loss value.

[0205] like Figure 4 As shown, Figure 4 To verify the comparison between predicted and actual values ​​in the validation set, one curve represents the original traffic flow speed in the validation set, and the other curve represents the predicted traffic flow speed after being input into the model. This training used 4000 values ​​from sensor 1 as input to the model for prediction; therefore, the validation set was proportionally divided into 1200 values. Figure 4 As can be seen, the two curves are basically consistent, which means that the predicted result is close to the actual value and the prediction accuracy is high.

[0206] This experiment compares its own loss results with the loss results predicted by traditional models, Recurrent Neural Networks (RNNs) and Long Short-Term Memory Networks (LSTMs), on this dataset. The comparison table is as follows:

[0207]

[0208] Table 1

[0209] Table 1 is a comparison list of MAE, MSE, and RMSE of RNN, LSTM, and the present invention during the simulation training process, arranged according to the training epochs. As can be seen from Table 1, LSTM and the present invention achieved low loss in 5 epochs, while RNN achieved low loss in 5-15 epochs, indicating that the convergence speed of the present invention is faster than some traditional models. From the overall loss results, the loss of the present invention also reached the lowest level, indicating that the present invention has higher accuracy than traditional models, demonstrating the advantages of the present invention.

[0210] Table 2 is a comparison of the time spent in the simulation training process of the present invention and the prior art RNN and LSTM (unit: seconds).

[0211]

[0212]

[0213] Table 2

[0214] As can be seen from Table 2, the present invention has a faster operating speed compared to the prior art.

[0215] Although the illustrative specific embodiments of the present invention have been described above to enable those skilled in the art to understand the invention, it should be understood that the invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the invention as defined and determined by the appended claims, and all inventions utilizing the concept of the present invention are protected.

Claims

1. A method for predicting road traffic flow speed based on influence coefficients, characterized in that, Includes the following steps: (1) Construct an undirected graph based on the traffic flow speed of each road segment in the transportation network over a period of time. Obtain the traffic flow speed of each road segment in the transportation network over a period of time. Construct a road network based on the roads in the transportation network. The period of time is one day, one week, one month, or one year. The road segments between road intersections are road network nodes, and the connection between road segments is an edge. This results in an undirected graph G(V, E), where G is the road network, V is the set of road network nodes, and E is the set of edges. (2) Construct the feature matrix F: F = {v} ij |1≤i≤N and 1≤j≤C} N represents the total number of road network nodes, C represents the total number of moments in that time period, and v ij This represents the traffic flow velocity at the i-th road network node at time j; (3) Construct the adjacency matrix A 3.1) Calculate the similarity S of the road network influence coefficient. ab 3.1.1) Determine the steady-state moment If the following conditions are met: |v ij -v i(j+1) |+|v ij -v i(j-1) |≤λ Then the j-th time point is called a stationary time point, where, 2≤j≤C-1, where λ is the threshold value, which is calculated as follows: Calculate the velocity change before and after the h-th time point, denoted by f. ih The formula for calculating 2≤h≤C-1 is: f ih =|v ih -v i(h+1) |+|v ih -v i(h-1) | Calculate the expected value μ i With standard deviation σ i : Calculate the threshold λ of the i-th road network node i : l i =μ i -s i Calculate the threshold λ: 3.1.2) Determine the time period The traffic flow speed of each road segment within a certain period of time is divided into multiple time periods by dividing two adjacent stable moments into one time period. 3.1.3) Calculate the mean influence coefficient β ik Calculate the influence coefficient of road network nodes in, It is the influence coefficient at time k within the q-th time interval of the time series of the i-th road network node. Let be the traffic flow speed at time k within the q-th time interval of the time series of the i-th road network node. Let be the traffic flow speed at the beginning of the q-th time interval in the time series of the i-th road network node. Let l be the traffic flow velocity at the end of the q-th time interval in the time series of the i-th road network node. iq Let be the number of moments in the q-th time period of the time series of the i-th road network node; Calculate the mean β of the influence coefficient of the i-th road network node at the k-th time interval for each time period. ik : Where, ξ i Let k be the number of time intervals for the i-th road network node, where k ranges from 1 to l. i , l i This represents the number of moments in the longest time period among all time periods of the i-th road network node. For other time periods, non-existent time periods are filled with 0. 3.1.4) Based on the mean influence coefficient β ik Calculate the road network influence coefficient similarity S ab : in, Let x be the mean of the first x influence coefficients of the set of influence coefficients of the a-th road network node. Let x be the mean of the first x influence coefficients of the set of influence coefficients of the b-th road network node, where x is the number of moments in the longest time period of the a-th road network node. a And the number of times in the longest time period of the b-th road network node l b The smaller value in; 3.2) Road network distance coefficient similarity D ab : Where, d ab Let be the Euclidean distance between the a-th road network node and the b-th road network node, and its value is: in, Let γ be the latitude of the a-th and b-th road network nodes on Earth, respectively. a γ b These are the longitudes of the a-th and b-th road network nodes on Earth, respectively, where R represents the latitude or the distance of one degree between the two longitudes. Where σ represents the standard deviation of the distances between all road network nodes, and the standard deviation σ is expressed by the formula: And a≠b Where μ is the expected value of the distance between all road network nodes, and the expected value μ is expressed by the formula: And a≠b 3.3) Based on the similarity S of the road network influence coefficient ab Similarity D with road network distance coefficient ab Calculate the adjacency matrix A: A={r ab |r ab = {0, 1}, 1 ≤ a ≤ N and 1 ≤ b ≤ N} r ab Let r represent the relationship between the a-th road network node and the b-th road network node, where 1 represents a relationship and 0 represents no relationship, and r ab =r ba Its value is: Among them, W ab This represents the relationship weight between the a-th road network node and the b-th road network node, and the weight is determined by the road network influence coefficient similarity S. ab Similarity D with road network distance coefficient ab Similarity determines the value: Where θ is the threshold, and its value is: g represents the number of edges connecting the N road network nodes in the transportation network; (4) Perform two multi-layer graph convolutions based on the feature matrix F and the adjacency matrix A to obtain the feature matrix F″ with spatial features. 4.1) The first multi-layer graph convolution is: in, W l Let be the weight matrix of the l-th layer, σ be the non-linear activation function, D be the degree matrix, and H be the weight matrix of the l-th layer. l H is the input of the l-th layer. l+1 The output is the feature matrix H; the input of the first layer is the feature matrix H. 1 =F, starting from the second layer, the input of each layer is the output of the previous layer; The output H after convolving the graph of layer L L+1 The feature matrix F′ is obtained after mapping with the ReLU nonlinear activation function; 4.2) The second multi-layer graph convolution is: Among them, W′ l Let H' be the weight matrix of the l-th layer, σ′ be the nonlinear activation function, D be the degree matrix, and H′ be the weight matrix of the l-th layer. l H′ is the input of the l-th layer. l+1 The output is the feature matrix H′; the input to the first layer is the feature matrix H′. 1 =F′, starting from the second layer, the input of each layer is the output of the previous layer; The output H′ after graph convolution of layer L′ l+1 After mapping using the Softmax activation function, the feature matrix F″ is obtained, which is the final feature matrix F″ with spatial features. (5) The feature matrix F″ is fed into the Transformer model to be converted into vectors and then trained. 5.1) The feature matrix F″ with spatial features is input into the encoder of the Transformer. The encoder transforms the data in the feature matrix F″ into a vector y according to the road number. i : and i =(and i1 ,and i2 ,...,and iC ) in, Vector y i Let y be the vector representation of the traffic flow velocity at the i-th road network node. ij Let F″ be the value of network node i at time j, where j = 1, 2, ..., C; 5.2) Construct the velocity value matrix Y′ for prediction. i And train the Transformer model 5.2.1) Construct the velocity value matrix Y′ for prediction. i : Construct the velocity matrix Y i : in, The vector (y) i1 y i2 , ..., y iC Repeat line C to obtain the velocity matrix Y. i The vector in the m-th row corresponds to the traffic flow velocity prediction in the m-th step; Based on the predicted number of steps and time, construct the weight matrix T. i Its value is: in, This represents the weight value at time n in the m-th prediction step, and its value is: Calculate the velocity value matrix Y′ used for prediction i : AND' i =Y i *T i Where * represents the Hadama product, which is the element-wise multiplication of two matrices; 5.2.2) Training the Transformer model The velocity value matrix Y′ i The first row is fed into the decoder as a vector for the first step of prediction, to obtain the predicted traffic flow velocity v′ at the first time step of the next time period. i1 The second row is fed into the decoder as a vector for the second prediction step, to obtain the predicted traffic flow velocity v′ at the second time step in the next time period. i2 By performing C-step prediction, the predicted traffic flow velocity v′ at C time points in the next time period can be obtained. ij j = 1, 2, ..., C; Use the actual traffic flow velocity at time C in the next time period as the prediction target value v″ ij , j = 1, 2, ..., C, substitute the predicted traffic flow speeds and predicted target values ​​at C time points into the loss function, and update the Transformer model using the gradient descent method; The vector y corresponding to all N road network nodes i For i = 1, 2, ... N, repeat this step to train the Transformer model; (6) Repeatedly select the traffic flow speed at C times for N road network nodes over a period of time, and repeat steps (2), (3), (4), and (5) until the predicted traffic flow speed v′ is obtained. ij i = 1, 2, ..., N, j = 1, 2, ..., C and the actual traffic flow velocity v″ ij The difference is less than the set threshold, or the set maximum number of training iterations is reached; (7) Road traffic flow speed prediction Select the traffic flow speeds at C times for N road network nodes in the most recent period, and repeat steps (2), (3), (4), 5.1), and 5.2.1). Then, generate the speed value matrix Y′ corresponding to all N road network nodes. i For i = 1, 2, ..., N, perform C-step predictions to obtain the predicted traffic flow speed v′ at the next C time points. ij ,i=1,2,...,N,j=1,2,...,C.

Citation Information

Patent Citations

  • Urban road traffic condition prediction method based on spatial-temporal data

    CN106652441A

  • Urban traffic control sub-area division method based on fast global K-means spectral clustering

    CN109887297A