A multi-strategy improved traffic flow prediction method, device, and medium

By optimizing multiple models and preprocessing data, and combining the whale optimization algorithm, CNN layer, BiLSTM layer and Attention layer, the accuracy and robustness of traffic flow prediction are improved, and the problem of insufficient spatiotemporal feature capture in existing methods is solved.

CN121148156BActive Publication Date: 2026-01-30SHANDONG UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511668121.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-14
Publication Date
2026-01-30
Estimated Expiration
2045-11-14

AI Technical Summary

Technical Problem

Existing traffic flow prediction methods struggle to effectively capture the spatiotemporal characteristics of traffic flow data, and the models lack generalization ability, resulting in insufficient prediction accuracy.

Method used

A multi-model optimization approach is adopted, combining the whale optimization algorithm, CNN layer, BiLSTM layer and Attention layer. Through data preprocessing and parameter tuning, the model's ability to extract multi-scale traffic spatiotemporal data and focus on key time step information is improved.

Benefits of technology

It improves the accuracy and robustness of traffic flow prediction, enhances the ability to extract spatiotemporal features and capture key information from traffic spatiotemporal data, and reduces prediction errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121148156B_ABST
    Figure CN121148156B_ABST
Patent Text Reader

Abstract

This invention relates to the field of intelligent transportation technology, and more particularly to a multi-strategy improved traffic flow prediction method, device, and medium. Based on acquired traffic spatiotemporal data, this method obtains the tuning parameters of a preset traffic flow prediction model through an optimization algorithm layer; updates the preset traffic flow prediction model based on the tuning parameters to obtain a first traffic flow prediction model; trains the first traffic flow prediction model using training set data to obtain a second traffic flow prediction model; updates the second traffic flow prediction model to obtain an improved traffic flow prediction model; the improved traffic flow prediction model is used to output traffic flow prediction values. This invention uses a whale optimization algorithm to update the tuning parameters, and the improved preset traffic flow prediction model enhances the model's ability to extract multi-scale spatiotemporal features of traffic spatiotemporal data and its ability to focus on key time step information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent transportation technology, and in particular to a multi-strategy improved traffic flow prediction method, device, and medium. Background Technology

[0002] Traffic flow prediction is a crucial component of intelligent transportation systems, aiming to accurately estimate traffic flow in a specific area over a given time interval. With socio-economic development and urban expansion, the number of vehicles has increased rapidly, making traffic congestion a major constraint on urban and economic development. Traffic prediction can optimize traffic management, improve traffic efficiency, enhance residents' travel experience, and drive urban transportation systems towards greater intelligence, efficiency, and sustainability. Due to the complex spatiotemporal relationships between different areas within the road network, traditional traffic prediction methods struggle to accurately describe the characteristics of traffic flow data. Therefore, deep learning-based methods have become a research hotspot for short-term traffic flow prediction.

[0003] Early methods for traffic flow prediction focused on the correlation of time-series data, but these models were not well-suited to the complexity and nonlinear relationships of traffic spatiotemporal data. Machine learning methods have gained increasing attention in intelligent transportation systems. Machine learning can effectively handle complex nonlinear relationships, utilizing algorithms such as neural networks, decision trees, and support vector machines to model and predict traffic spatiotemporal data, improving prediction accuracy. However, machine learning struggles to capture the spatiotemporal dynamic interaction characteristics of traffic flow data, and the models lack generalization ability. Current methods still require improvement in traffic flow prediction accuracy. Further research is needed on how to effectively capture the spatiotemporal characteristics of traffic flow data and achieve good convergence. Therefore, a multi-strategy improved traffic flow prediction method is needed. Summary of the Invention

[0004] In view of the above problems, this disclosure provides a multi-strategy improved traffic flow prediction method, device and medium to overcome or at least partially solve the above problems. The purpose is to improve the model's ability to extract multi-scale traffic spatiotemporal data and focus on key time step information through multi-model optimization, thereby improving the accuracy and robustness of traffic flow prediction.

[0005] The objective of this invention can be achieved through the following technical solutions:

[0006] A first aspect of the present invention provides a multi-strategy improved traffic flow prediction method, comprising:

[0007] Based on the acquired traffic spatiotemporal data, the data is divided into training set data and test set data according to a preset ratio.

[0008] The training set data is input into the optimization algorithm layer of the preset traffic flow prediction model to obtain the tuning parameters of the preset traffic flow prediction model.

[0009] The preset traffic flow prediction model is updated based on the optimization parameters to obtain the first traffic flow prediction model.

[0010] The first traffic flow prediction model is trained using the training set data to obtain the second traffic flow prediction model.

[0011] After inputting the test set data into the second traffic flow prediction model, the prediction result is output. If the error is greater than the threshold, the optimization parameters are updated and tuned based on the optimization algorithm layer to obtain the second traffic flow prediction model again; if the error is less than the threshold, the improved traffic flow prediction model is obtained.

[0012] The improved traffic flow prediction model is used to output traffic flow prediction values.

[0013] Furthermore,

[0014] Initial traffic spatiotemporal data of the area to be detected is obtained, and the initial traffic spatiotemporal data is preprocessed to obtain traffic spatiotemporal data; the preprocessing includes missing data completion, discrete point processing, data standardization, encoder assignment processing, and normalization processing.

[0015] Furthermore,

[0016] The optimization algorithm layer includes the whale optimization algorithm. First, the optimization algorithm layer is initialized by obtaining primary tuning parameters through encirclement predation, spiral update, and prey search. The primary tuning parameters are then adjusted using a stochastic learning strategy and a Cauchy mutation strategy to obtain tuning parameters. The tuning parameters include the number of hidden nodes, the initial learning rate, and the regularization coefficient.

[0017] Furthermore,

[0018] The expression for the stochastic learning strategy is as follows:

[0019]

[0020] In the formula, the learning factor Represents a random number between (0, 1). This represents the individual position vector when the number of iterations is iter. This represents a random individual whale when the number of iterations is iter. This indicates the position of the whale after learning the adjusted position at iteration number iter.

[0021] Furthermore,

[0022] The Cauchy mutation factor of the Cauchy mutation strategy is expressed as follows:

[0023] In the formula, The new value obtained after applying the Cauchy perturbation to the current optimal value. Cauchy operator

[0024] The Cauchy operator is calculated using the standard Cauchy distribution function, the formula of which is as follows:

[0025] .

[0026] Furthermore,

[0027] The first traffic flow prediction model includes a CNN layer, a BiLSTM layer, and an Attention layer;

[0028] The training set data is input into the CNN layer of the first traffic flow prediction model to obtain spatial feature vectors;

[0029] The spatial feature vector is input into the BiLSTM layer of the first traffic flow prediction model to obtain the temporal feature vector.

[0030] The temporal feature vector is input into the Attention layer of the first traffic flow prediction model to obtain the context feature vector;

[0031] Based on the trained CNN layer, BiLSTM layer, and Attention layer, a second traffic flow prediction model is obtained.

[0032] Furthermore,

[0033] The traffic spatiotemporal data in the training set is used as input. Spatial features are extracted through the CNN layer of the first traffic flow prediction model. The spatial features are then fused using the Hadamard product to obtain a spatial feature vector.

[0034] The formula for calculating the Hadamard product is as follows:

[0035] ;

[0036] Where M and N are characteristic matrices of the same type, and ⊙ represents the Hadamard product, which is multiplied element by element;

[0037] The spatial feature vector is input into the BiLSTM layer of the first traffic flow prediction model to obtain the temporal feature vector. ;

[0038] Time series feature vectors Input the Attention layer of the first traffic flow prediction model to calculate key time step information. , Among them, the time-series feature vector The feature representation of the current prediction time step, the key vector Characteristic representation of a historical time step; and These are the linear transformation weight matrices for the query and the key, respectively, used to map them to the same dimensional space; the bias term b is a trainable parameter, usually initially set to a zero vector and automatically optimized during training; This represents the transpose of a trainable weight vector, used to map intermediate features to scalar attention scores; Represented as a non-linear activation function. Based on key time step information. Attention weights are obtained through the Softmax function. ;

[0039] ;

[0040] Based on attention weights For time series feature vectors We perform a weighted summation to obtain the context feature vector Cm. .

[0041] Furthermore,

[0042] The second traffic flow prediction model is obtained by combining the trained CNN layer, BiLSTM layer, and Attention layer with a fully connected layer and an output layer; the context feature vector Cm is weighted and combined through the fully connected layer; and then the prediction result is generated through the output layer.

[0043] An apparatus comprising: at least one processor; and a memory communicatively connected to the at least one processor;

[0044] The memory stores instructions that can be executed by the at least one processor, which enable the at least one processor to execute the aforementioned multi-strategy improved traffic flow prediction method.

[0045] A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the above-described multi-strategy improved traffic flow prediction method.

[0046] The technical solution proposed in this application can bring the following beneficial effects:

[0047] This invention first preprocesses the raw data by handling outliers and standardizing the data to improve data quality. Then, it updates and optimizes the parameters using the whale optimization algorithm. Due to the optimization of the optimization parameters, the preset traffic flow prediction model of this invention is improved. The improved preset traffic flow prediction model enhances the model's ability to extract multi-scale spatiotemporal features of traffic spatiotemporal data and its ability to focus on key time step information.

[0048] The above description is merely an overview of the technical solution disclosed herein. In order to better understand the technical means of this disclosure and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this disclosure more apparent and understandable, specific embodiments of this disclosure are described below. Attached Figure Description

[0049] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this disclosure. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0050] Figure 1 This is a flowchart illustrating the steps of a multi-strategy improved traffic flow prediction method provided in the embodiments of this specification.

[0051] Figure 2 This is a comparison chart of the test results of the improved traffic flow prediction model provided in the embodiments of this specification;

[0052] Figure 3 This is a schematic diagram of the device structure provided in the embodiments of this specification. Detailed Implementation

[0053] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art. The technical solutions provided by various embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0054] This application provides a multi-strategy improved traffic flow prediction method, device, and medium.

[0055] A first aspect of the present invention provides a multi-strategy improved traffic flow prediction method, comprising:

[0056] S101. Based on the acquired traffic spatiotemporal data, divide it into training set data and test set data according to a preset ratio;

[0057] S102. Input the training set data into the optimization algorithm layer of the preset traffic flow prediction model to obtain the tuning parameters of the preset traffic flow prediction model.

[0058] S103. Update the preset traffic flow prediction model based on the optimization parameters to obtain the first traffic flow prediction model;

[0059] S104. Train the first traffic flow prediction model using the training set data to obtain the second traffic flow prediction model;

[0060] S105. After inputting the test set data into the second traffic flow prediction model, the prediction result is output. If the error is greater than the threshold, the optimization parameters are updated based on the optimization algorithm layer to obtain the second traffic flow prediction model again; if the error is less than the threshold, the improved traffic flow prediction model is obtained.

[0061] The improved traffic flow prediction model is used to output traffic flow prediction values.

[0062] In one specific embodiment,

[0063] Initial traffic spatiotemporal data of the area to be detected is obtained, and the initial traffic spatiotemporal data is preprocessed to obtain traffic spatiotemporal data; the preprocessing includes missing data completion, discrete point processing, data standardization, encoder assignment processing, and normalization processing.

[0064] Initial traffic spatiotemporal data includes relevant data such as vehicle speed, air pressure, temperature, weather, and time at intersections.

[0065] Preprocessing of initial traffic spatiotemporal data specifically includes:

[0066] S11, Missing data completion: Missing data in the initial traffic spatiotemporal data is filled in using interpolation.

[0067] Represented as:

[0068] ;

[0069] In the formula, X(t) represents the missing initial traffic spatiotemporal data, and X(t-1) and X(t+1) are the adjacent initial traffic spatiotemporal data to be processed.

[0070] S12. Outlier handling: Determine outlier data points that meet the following conditions:

[0071] ;

[0072] In the formula, Let σ and μ be the set of initial traffic spatiotemporal data at time t. The variance and mean of the initial traffic spatiotemporal data at time t; Not satisfied At that time, the initial spatiotemporal traffic data was collected. Adjacent initial traffic spatiotemporal data and ;

[0073] Pick Replace the value. ;

[0074] In complex traffic environments, the initial traffic spatiotemporal data collected contains a certain amount of noise. Outlier point processing is used to replace outlier data points and reduce the noise in the data.

[0075] S13. Data Standardization: The influence of random noise is further eliminated by using a weighted moving average method, expressed as:

[0076] In the formula, Vt represents the moving average value at time t. This represents the initial traffic spatiotemporal data at time t; β is the weighting coefficient, with a value range of (0,1). The closer its value is to 1, the smoother the curve.

[0077] S14, Encoder assignment processing:

[0078] Encode the dates, assigning values ​​1-8 to Monday through Sunday and public holidays respectively;

[0079] The time periods are divided into morning peak (7:00-9:00), noon peak (11:30-13:30), evening peak (17:30-19:30), morning (9:00-11:30), afternoon (13:30-17:30), evening (19:30-24:00), and early morning (00:00-7:00), which are assigned values ​​of 1-7 respectively.

[0080] When the date is a public holiday, the value is assigned to 8;

[0081] Weather conditions are categorized into sunny, cloudy, overcast, foggy, rainy, and snowy, with values ​​ranging from 1 to 6.

[0082] S15. Normalization processing: Normalize the processed initial traffic spatiotemporal data. Specifically, normalization means using the MinMaxScaler function to map the data to the range [0,1].

[0083] The MinMaxScaler function is:

[0084] ;

[0085] in, This represents the currently input data. This represents the minimum value in the data. This represents the maximum value in the data. This represents the normalized data.

[0086] The initial traffic spatiotemporal data is preprocessed to obtain traffic spatiotemporal data. The traffic spatiotemporal data is used as independent variables, specifically including temperature, coded weather, coded date, coded time, air pressure, average vehicle speed, and wind speed. The dependent variable is set as traffic flow. The dependent variable is obtained by predicting the independent variables through the model. Traffic flow is the number of vehicles passing through the intersection per unit time.

[0087] Furthermore,

[0088] The optimization algorithm layer includes the whale optimization algorithm. First, the optimization algorithm layer is initialized by obtaining primary tuning parameters through encirclement predation, spiral update, and prey search. The primary tuning parameters are then adjusted using a stochastic learning strategy and a Cauchy mutation strategy to obtain tuning parameters. The tuning parameters include the number of hidden nodes, the initial learning rate, and the regularization coefficient.

[0089] Encirclement and Predation: Assuming the whale population size is N and the search space is d-dimensional, the position of the nth whale in the d-dimensional space can be represented as... The location of the prey corresponds to the global optimal solution to the problem.

[0090] For example, the tuning parameters include the number of hidden nodes, the initial learning rate, and the regularization coefficient; then

[0091] ;in, This represents the optimal number of hidden nodes for the nth whale; This represents the optimal initial learning rate for the nth whale; Let represent the optimal L2 regularization coefficient for the nth whale;

[0092] The mathematical formula for the encirclement and predation phase is:

[0093] ;

[0094] ;

[0095] in, ; ;

[0096] ;

[0097] In the formula, iter represents the current iteration number. Indicates the maximum number of iterations; This represents the individual position vector when the number of iterations is iter; Let represent the prey position vector (current optimal solution) at iteration number iter; A and C represent coefficient vectors; a is the convergence factor, which decreases linearly from 2 to 0 during iteration; r is a random vector in [0, 1]; D is the encirclement vector during the prey encirclement stage. represents the bounding step vector; | represents the vector obtained by taking the absolute value of the difference between corresponding components of two position vectors.

[0098] Spiral Update: In the whale optimization algorithm, the position update method is determined by a random number P. If P is less than 0.5, the traditional method is used for position update; otherwise, a spiral position update method is used. The algorithm mimics the hunting behavior of humpback whales, which use bubble nets to surround prey. The whale optimization algorithm simulates this by shrinking the encirclement and using spiral position updates to achieve local optimization. The calculation formula is as follows:

[0099] ;

[0100] ;

[0101] ;

[0102] In the formula, This represents the distance between the nth individual whale and the current optimal position; b is a spiral shape, for example, b takes the value 1; l is a random number in [-1, 1]; where, Controlling whales to descend in a logarithmic spiral to find prey. The speed at which the whale spirals down is controlled by changing the value of l.

[0103] Searching for prey: To ensure that all whales can fully search the solution space, at this stage the whale population no longer moves towards the best individual whale, but randomly selects a whale to guide other individuals to move towards it;

[0104] The calculation formula is as follows:

[0105] ;

[0106] ;

[0107] In the formula, The position vector of a randomly selected whale; For random search vectors, This is the step size vector for the random search.

[0108] In the predator-encirclement calculation, in order to better adjust the global search capability and local exploit capability, the convergence factor 'a' is calculated nonlinearly, and the calculation formula is as follows:

[0109] ;

[0110] In the formula, max_iter is the maximum number of iterations. For example, max_iter is 20, and iter is the current iteration number.

[0111] The whale optimization algorithm is prone to getting stuck in local optima and premature convergence during later local development. By updating the initial tuning parameters with adaptive weights, the adaptive weights can be expressed as follows:

[0112] ;

[0113] in, ;

[0114] in, These are adaptive weighting coefficients; For the position vector of the next generation of individual whales; Let it be the position vector of the prey's optimal solution at iteration number iter; is a random number used to select the update strategy; A and D are coefficient vectors; b is the spiral shape parameter, set to 1; l is a random number in the range [-1, 1].

[0115] Traditional WOA algorithms employ a fixed weight strategy, which lacks flexibility throughout the algorithm, makes it difficult to balance exploration and development, and easily leads to premature convergence. In contrast, the adaptive weight proposed in this invention can dynamically adjust the search strategy, enhance global exploration in the early stage to avoid getting trapped in local optima, and strengthen local development in the later stage to improve convergence accuracy.

[0116] Furthermore,

[0117] The expression for the stochastic learning strategy is as follows:

[0118] ;

[0119] In the formula, the learning factor Represents a random number between (0, 1). This represents the individual position vector when the number of iterations is iter. This represents a random individual whale when the number of iterations is iter. This indicates the position of the whale after learning the adjusted position at iteration number iter.

[0120] Furthermore,

[0121] The Cauchy variant is expressed as follows:

[0122] In the formula, The new value obtained after applying the Cauchy perturbation to the current optimal value. Here, cauchy(0,1) is a Cauchy operator, where cauchy(0,1) represents a random number generated from the standard Cauchy distribution.

[0123] The Cauchy operator is calculated using the standard Cauchy distribution function, the formula of which is as follows:

[0124] ; where x is a random variable with a Cauchy distribution, i.e., a random number.

[0125] The Cauchy distribution's extension at both ends generates random numbers far from the origin, effectively perturbing individual whales and enabling them to quickly avoid local traps. Furthermore, compared to other functions, the Cauchy distribution has a lower peak value, reducing the time individuals spend searching the search space and thus accelerating the algorithm's convergence speed.

[0126] To address the weakness of the traditional WOA algorithm in global optimization, this invention introduces a stochastic learning strategy and a Cauchy mutation strategy. The stochastic learning mechanism enhances population diversity to avoid premature convergence, while the long-tail characteristic of Cauchy mutation helps the algorithm escape local optima traps, thereby significantly improving global exploration capability and convergence accuracy.

[0127] Each individual goes through the stages of encirclement and predation, spiral update, and prey search. When an individual is encircling and predating or spiral update, an adaptive weight strategy is used to update its position. After each updated position, the individual needs to be updated again through the Cauchy mutation strategy to take the optimal position before and after the change. This speeds up the convergence of the population and effectively prevents the population from getting stuck in local optima.

[0128] After obtaining the optimization parameters, the preset traffic flow prediction model is updated to obtain the first traffic flow prediction model; the preset traffic flow prediction model includes an optimization algorithm layer, a CNN layer, a BiLSTM layer, and an Attention layer.

[0129] The optimization algorithm layer obtains the number of hidden nodes, the initial learning rate, and the L2 regularization coefficient. The number of hidden nodes is applied to the network structure of the BiLSTM layer in the first traffic flow prediction model. The initial learning rate is configured for the optimizer during the training of the first traffic flow prediction model. The L2 regularization coefficient is applied as a constraint to the weights of the entire network of the first traffic flow prediction model.

[0130] Furthermore,

[0131] The first traffic flow prediction model includes a CNN layer, a BiLSTM layer, and an Attention layer;

[0132] The training set data is input into the CNN layer of the first traffic flow prediction model to obtain spatial feature vectors;

[0133] The spatial feature vector is input into the BiLSTM layer of the first traffic flow prediction model to obtain the temporal feature vector.

[0134] The temporal feature vector is input into the Attention layer of the first traffic flow prediction model to obtain the context feature vector;

[0135] Based on the trained CNN layer, BiLSTM layer, and Attention layer, a second traffic flow prediction model is obtained.

[0136] Furthermore,

[0137] The traffic spatiotemporal data in the training set is used as input. Spatial features are extracted through the CNN layer of the first traffic flow prediction model. The spatial features are then fused using the Hadamard product to obtain a spatial feature vector.

[0138] First, based on traffic spatiotemporal data, a multidimensional spatiotemporal tensor M is constructed. Then, the spatial features of the multidimensional spatiotemporal tensor are extracted through the CNN layer of the first traffic flow prediction model. Convolutional kernels of different sizes are used in parallel to capture multi-scale spatial features. The spatial features are fused using the Hadamard product, which effectively reduces information loss and enhances the model's ability to capture local correlations.

[0139] The formula for calculating the Hadamard product is as follows:

[0140] ;

[0141] Where M and N are characteristic matrices of the same type, ⊙ represents the Hadamard product, and represents element-wise multiplication;

[0142] The fused features are introduced with non-linearity using the ReLU activation function and the spatial dimension is reduced by pooling layers to retain key features.

[0143] Where matrix M represents the spatial features extracted from the multidimensional feature vector by the CNN layer; matrix N represents the weight matrix of the same dimension as matrix M generated by the attention mechanism;

[0144] For example, matrix M is a 7-dimensional spatial feature, which consists of vehicle speed, wind speed, coding date, air pressure, temperature, coding weather, and coding time.

[0145] The spatial feature vector is input into the BiLSTM layer of the first traffic flow prediction model to obtain the temporal feature vector. ;

[0146] Time series feature vectors Input the Attention layer of the first traffic flow prediction model to calculate key time step information. , ;

[0147] Among them, the time-series feature vector The feature representation of the current prediction time step, the key vector Characteristic representation of a historical time step; and These are the linear transformation weight matrices for the query and the key, respectively, used to map them to the same dimensional space; the bias term b is a trainable parameter, usually initially set to a zero vector and automatically optimized during training; denoted as the transpose of the trainable weight vector, used to map intermediate features to scalar attention scores; tanh represents the non-linear activation function.

[0148] Based on key time step information Attention weights are obtained through the Softmax function. ;

[0149] ;

[0150] Based on attention weights For time series feature vectors We perform a weighted summation to obtain the context feature vector Cm. .

[0151] Furthermore,

[0152] Based on the trained CNN layer, BiLSTM layer, and Attention layer, a second traffic flow prediction model is obtained by combining a fully connected layer and an output layer; the context feature vector Cm is weighted and combined through the fully connected layer; and then the prediction result is generated through the output layer.

[0153] The context feature vector Cm is the output of the Attention layer, which contains weighted temporal information. The context feature vector Cm is non-linearly weighted and combined through a fully connected layer, and then linearly transformed by the output layer to finally map to a specific traffic flow prediction value.

[0154] The fully connected layer achieves weighted combination of features by performing linear transformation and nonlinear activation on the input vector through its internal weight matrix: each output neuron is connected to all dimensions of the input vector, and its calculation process is the product of the input vector and the weight matrix plus a bias term. Each element of the weight matrix determines the contribution of the corresponding input feature to the current output neuron, while the bias term provides the adjustment benchmark. The weight matrix is ​​automatically learned through the model training process.

[0155] The second traffic flow prediction model was tested using test set data to obtain prediction results.

[0156] The second traffic flow prediction model was evaluated using mean absolute percentage error (MAPE), root mean square error (RMSE), and mean absolute error (MAE).

[0157] The specific formula is as follows:

[0158] ;

[0159] ;

[0160] ;

[0161] Where n is the number of samples in the test set. and These are the actual value and the predicted value, respectively.

[0162] To verify the effectiveness of the current traffic flow prediction model, its prediction errors are compared with those of several mainstream traffic flow prediction models.

[0163] Figure 2 This is a test graph for improving the traffic flow prediction model; where the horizontal axis represents the number of experimental samples arranged in chronological order, and the vertical axis represents the traffic flow of each experimental sample.

[0164] The prediction errors of each model are compared using Table 1.

[0165] Table 1 shows the comparison of prediction errors for each model.

[0166]

[0167] Where IWOA-CNN-BiLSTM-At represents the improved traffic flow prediction model; WOA-CNN-BiLSTM-At represents the first traffic flow prediction model.

[0168] TCN-Transformer represents a deep learning model that combines Temporal Convolutional Network (TCN) and Transformer;

[0169] LSTM stands for Long Short-Term Memory Network.

[0170] The trained and improved traffic flow prediction model is deployed to the traffic management system to collect real-time traffic spatiotemporal data of the area to be detected. By improving the traffic flow prediction model, the spatial features of the real-time traffic spatiotemporal data are extracted and the time dependence is established. Finally, the fully connected layer outputs the future traffic flow prediction value of the area to be detected, such as the traffic flow of each road segment in the next 15 minutes.

[0171] A second aspect of the present invention is a device 300, the device comprising: at least one processor 301; and a memory 302 communicatively connected to the at least one processor 301;

[0172] The memory 302 stores instructions that can be executed by the at least one processor 301, which, when executed by the at least one processor 301, enable the at least one processor 301 to perform the multi-strategy improved traffic flow prediction method described in the first aspect.

[0173] A third aspect of the present invention is a computer-readable storage medium, characterized in that it stores instructions thereon, which, when executed by one or more processors, cause the processors to perform the multi-strategy improved traffic flow prediction method described in the first aspect.

[0174] This embodiment can divide the method into functional modules based on the above method example. For example, each function can be assigned to a separate module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.

[0175] When each functional module is divided according to its corresponding function, the vehicle may include: a data processing module, a resampling module, a local reconstruction iteration module, etc. It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.

[0176] This embodiment also provides a computer-readable storage medium (including but not limited to disk storage, CD-ROM, optical storage, etc.) storing computer program code. When the computer program code is run on a computer, the computer executes the above-mentioned related method steps to realize the multi-strategy improved traffic flow prediction method, device and medium provided in the above embodiment.

[0177] This embodiment also provides a computer program product. When the computer program product is run on a computer, it causes the computer to perform the aforementioned steps to implement the multi-strategy improved traffic flow prediction method, device, and medium provided in the above embodiment. The beneficial effects of the above embodiments can be found in the beneficial effects of the corresponding methods provided above, and will not be repeated here.

[0178] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0179] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules or units is merely a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms. In the description of this disclosure, it should be understood that if terms such as "upper," "lower," "front," "rear," "left," and "right" are used to indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, they are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the indicated position or element must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this disclosure.

[0180] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

[0181] The above are merely embodiments of this disclosure and are not intended to limit the scope of this disclosure. Various modifications and variations can be made to this disclosure by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the scope of the claims of this disclosure.

Claims

1. A multi-strategy improved traffic flow prediction method, characterized in that, The method comprises the following steps: Based on the obtained traffic spatio-temporal data, a training set data and a test set data are divided according to a preset proportion; The training set data is input into an optimization algorithm layer of a preset traffic flow prediction model to obtain an optimized parameter of the preset traffic flow prediction model; The preset traffic flow prediction model is updated based on the optimized parameter to obtain a first traffic flow prediction model; The first traffic flow prediction model is trained by the training set data to obtain a second traffic flow prediction model; After the test set data is input into the second traffic flow prediction model, a prediction result is output, if the error is greater than a threshold, the optimized parameter is updated based on the optimization algorithm layer to obtain the second traffic flow prediction model again, if the error is less than the threshold, an improved traffic flow prediction model is obtained; The improved traffic flow prediction model is used to output a traffic flow prediction value; The optimization algorithm layer comprises a whale optimization algorithm, the optimization algorithm layer is initialized first, and a primary optimized parameter is obtained through surrounding predation, spiral updating and search for prey; the primary optimized parameter is adjusted through a randomness learning strategy and a Cauchy mutation strategy to obtain the optimized parameter; the optimized parameter comprises a hidden node number, an initial learning rate and a regularization coefficient; The first traffic flow prediction model comprises a CNN layer, a BiLSTM layer and an Attention layer; The training set data is input into the CNN layer of the first traffic flow prediction model to obtain a spatial feature vector; The spatial feature vector is input into the BiLSTM layer of the first traffic flow prediction model to obtain a time sequence feature vector; The time sequence feature vector is input into the Attention layer of the first traffic flow prediction model to obtain a context feature vector; Based on the trained CNN layer, BiLSTM layer and Attention layer, the second traffic flow prediction model is obtained; The traffic spatio-temporal data in the training set data is taken as input, the spatial feature is extracted through the CNN layer of the first traffic flow prediction model, and the spatial feature is fused through Hadamard product to obtain a spatial feature vector; The calculation formula of the Hadamard product is as follows: ; Wherein, M and N are the same type of feature matrix, and represents the Hadamard product. inputting the spatial feature vector into a BiLSTM layer of the first traffic flow prediction model to obtain a time sequence feature vector ; a time series feature vector an Attention layer of the first traffic flow prediction model is inputted to calculate key time step information , ; wherein the time series feature vector represents a feature representation of a current prediction time step, the key vector represents a feature representation of a historical time step; and are linear transformation weight matrices of the query and the key respectively, used to map both of them to the same dimensional space; the bias term b is a trainable parameter, which is usually initialized as a zero vector and automatically optimized during the training process; represents the transpose of a trainable weight vector, used to map the intermediate feature to a scalar attention score; represents a nonlinear activation function; Based on key time step information Attention weights are obtained by a Softmax function ; ; Based on attention weights To the timing feature vector Weighted sum, get context feature vector Cm, .

2. The method according to claim 1, wherein The initial traffic spatio-temporal data of the detection area is obtained, and the traffic spatio-temporal data is obtained by preprocessing the initial traffic spatio-temporal data; the preprocessing includes missing data filling, discrete point processing, data standardization, encoder assignment processing and normalization processing.

3. The method according to claim 1, wherein The expression of the randomness learning strategy is as follows: ; wherein the learning factor denotes a random number between (0, 1), denotes the position vector of the individual at iteration titer, denotes a random whale individual at iteration titer, denotes the position of the adjusted whale at iteration titer.

4. The method according to claim 3, wherein The Cauchy mutation factor of the Cauchy mutation strategy is expressed as follows: wherein is the new value obtained by Cauchy perturbation of the current optimal value is the Cauchy operator.

5. The method according to claim 1, wherein Based on the trained CNN layer, BiLSTM layer and Attention layer, a second traffic flow prediction model is obtained in combination with a full connection layer and an output layer; the context feature vector Cm is combined by feature weighting through the full connection layer; and then a prediction result is generated through the output layer.

6. A computing device, comprising: The device comprises at least one processor and a memory connected in communication with the at least one processor. The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the multi-policy improved traffic flow prediction method of any one of claims 1-5.

7. A computer readable storage medium characterized in that, The instructions stored thereon, when executed by one or more processors, cause the processors to perform the multi-policy improved traffic flow prediction method of any one of claims 1-5.

Citation Information

Patent Citations

  • Rail transit passenger flow prediction method fusing attention mechanism and graph neural network

    CN115081717A

  • Urban traffic jam prediction method and device, and medium

    CN118172939A