An intelligent real-time traffic flow prediction method

By constructing a hybrid feature network model and Shark Tuna Alliance optimization algorithm, the problems of insufficient feature extraction and low hyperparameter optimization efficiency in traditional traffic flow prediction are solved, and high-precision real-time traffic flow prediction is achieved.

CN120148252BActive Publication Date: 2025-08-12NANJING PINGAN TRANSPORTATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510636255.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-16
Publication Date
2025-08-12
Estimated Expiration
2045-05-16

AI Technical Summary

Technical Problem

Traditional traffic flow prediction methods cannot fully reflect the local characteristics, global characteristics and key information of traffic flow, the model's hyperparameter optimization efficiency is insufficient, and the static prediction model based on historical data is difficult to reflect the latest traffic flow trend.

Method used

A parallel convolutional layer-long and short-term memory layer combines a hybrid feature network model with a multi-head attention mechanism, and uses the Shark and Tuna Alliance optimization algorithm to optimize hyperparameters, and combines moving average error to achieve real-time dynamic update of the model.

Benefits of technology

It improves the accuracy and efficiency of traffic flow prediction, can dynamically adapt to the latest trends in traffic flow, and provides more reliable real-time prediction support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120148252B_ABST
    Figure CN120148252B_ABST
Patent Text Reader

Abstract

The present invention provides an intelligent real-time traffic flow prediction method, which belongs to the field of smart transportation. The method comprises the following steps: obtaining online monitored traffic flow data and preprocessing the data; optimizing the hyperparameters of a hybrid feature network model based on the Shark and Tuna Alliance Optimization Algorithm (STA); training and constructing the hybrid feature network model based on the optimized hyperparameters; evaluating the prediction results using a moving average error each time the latest monitoring data is obtained, and training and fine-tuning the hybrid feature network in real time based on the evaluation results to achieve real-time dynamic updating of the hybrid feature network; and finally, predicting the traffic flow for the next time period based on the updated hybrid feature network. The present invention can provide a basis for accurately measuring traffic flow and for achieving refined traffic management, low-carbon emission reduction, and energy optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of smart transportation, and in particular to a method for real-time intelligent traffic flow prediction. Background Art

[0002] Intelligent Transportation Systems (ITS) are a key technological path to improving traffic congestion, enhancing traffic safety, achieving energy conservation and emission reduction, and sustainable development. Through the deep integration of the Internet of Things, big data, and artificial intelligence technologies, ITS can perceive road network status in real time, optimize resource allocation, and predict traffic trends, thereby reducing congestion costs, reducing carbon emissions, and improving the travel experience. Within the multidimensional data ecosystem of intelligent transportation, traffic flow prediction is a crucial component of the Intelligent Transportation System (ITS), enabling safer and more intelligent use of the transportation network by transportation stakeholders. It is crucial for achieving refined traffic management, coordinated control of tunnel lighting safety, low-carbon emission reduction, and energy optimization.

[0003] Traditional model-driven traffic flow forecasting methods fail to fully reflect the complexity and nonlinear variations of traffic data, making it difficult to effectively predict traffic flow. Recently developed prediction methods based on deep learning models based on historical data can better describe the distributed and hierarchical characteristics of traffic flow data, resulting in improved prediction results. However, existing methods still suffer from the following problems: First, single deep learning models have limitations when extracting traffic flow characteristics and cannot fully reflect local, global, and key information about traffic flow. Second, the selection of model hyperparameters directly affects model performance, necessitating high-performance optimization methods. Third, historical data cannot fully reflect the changing characteristics of traffic flow that evolve with economic development, urban construction, and changes in people's living standards. Therefore, establishing a high-performance model that can fully mine and optimize traffic flow information, and enabling lightweight dynamic adjustment and updating of the model based on the latest traffic flow data, is crucial for intelligent, high-precision, and efficient real-time traffic flow forecasting. Summary of the Invention

[0004] The purpose of the present invention is to provide an intelligent real-time traffic flow prediction method, which can solve the problems of insufficient feature extraction of traditional single models, insufficient efficiency of hyperparameter optimization, and the difficulty of static prediction models based on historical data to reflect the latest traffic flow trends. A new intelligent real-time traffic flow prediction method is proposed to provide reliable technical support for improving the accuracy and efficiency of intelligent real-time traffic flow prediction.

[0005] The present invention is achieved in that:

[0006] The technical solution to achieve the purpose of the present invention is: an intelligent real-time traffic flow prediction method, comprising the following steps:

[0007] Step 1: Obtain historical traffic flow data from online monitoring and pre-process the data;

[0008] Step 2: Build a hybrid feature network model framework based on parallel convolutional layers and long short-term memory layers combined with a multi-head attention mechanism, and set the hyperparameters to be optimized and the optimization range;

[0009] Step 3: Based on the shark and tuna alliance optimization algorithm and historical traffic flow data, optimize the hyperparameters of the hybrid feature network model;

[0010] Step 4: Based on the optimized hyperparameters and historical traffic flow data, a hybrid feature network model is constructed and trained;

[0011] Step 5: Set the moving average error window size W1, the dynamic update start error E, and the dynamic update window size W2;

[0012] Every time the latest monitoring data is obtained, the average of the most recent W1 prediction values is calculated, that is, the moving average error P. If P is greater than E, the latest W2 monitoring data is extracted to perform real-time training and fine-tuning on the hybrid feature network to achieve real-time dynamic update of the hybrid feature network;

[0013] Step 6: Predict the traffic flow in the next time period based on the latest hybrid feature network.

[0014] Furthermore, in step one, the historical traffic flow data includes date, time, day of the week, whether it is a holiday, and traffic flow data; the data preprocessing includes using a moving average method to smooth the traffic flow data, thereby removing short-term fluctuations and noise and retaining long-term trends; aggregating high-frequency data into low-frequency data to reduce data complexity and improve computational efficiency; and normalizing the data to eliminate dimensional differences and improve model training effects.

[0015] Furthermore, in step 2, the hybrid feature network model framework includes connecting the input layer to the parallel multi-scale convolution layer and the long short-term memory layer, and then splicing the parallel outputs into one output through the splicing layer, and sequentially connecting them in series through the maximum pooling layer, the multi-scale self-attention mechanism layer, the random dropout layer, the global pooling layer, the fully connected layer and the output layer; wherein the input layer receives historical traffic flow data; in the parallel multi-scale convolution layer and the long short-term memory layer, the multi-scale convolution layer uses different convolution kernel sizes to extract local features, and the long short-term memory layer captures the time series. long-term dependencies; the splicing layer splices the outputs of the CNN and LSTM branches in the feature dimension; the maximum pooling layer performs 1D maximum pooling on the spliced output; the multi-head self-attention mechanism layer uses the multi-head self-attention mechanism to capture the importance of different time steps in the sequence; the random dropout (Dropout) layer applies Dropout to the output of the multi-head self-attention layer to prevent overfitting; the global pooling layer performs global aggregation on the features; the fully connected layer performs nonlinear transformation on the selected time step features to further extract features; the output layer uses the fully connected layer to generate the final prediction result.

[0016] Furthermore, in step 2, the hyperparameters include the number of filters of the convolutional layer, the learning rate, the random dropout rate, the L2 regularization strength, the number of units in the long short-term memory layer, and the number of heads in the multi-head attention mechanism.

[0017] Furthermore, in step 3, the shark and tuna alliance optimization algorithm includes the following four stages:

[0018] (1) Population initialization:

[0019] 1. Generate initial population: randomly generate initial population M i 0 , where each individual M i 0 The position is determined by the following formula:

[0020] M i 0 = lb + (ub - lb) ×rand(1, dim )

[0021] in M i 0 Representative i The location of an individual, i The serial number representing the individual, i =1,2,…, N , Nis the population size, the superscript represents the number of iterations, where 0 represents the initialization stage; lb and ub are the lower and upper bounds of the search space, respectively. dim is the dimension of the problem to be optimized, rand(1 ,dim ) generates a 1× dim A random vector whose elements range from [0,1];

[0022] 2. Calculate the initial fitness value:

[0023] Calculate the fitness value of each individual fitness(i) , fitness(i) = f obj (M i 0 ) ,in f obj () Is the fitness function; records the historical optimal solution position best_M and the historical optimal fitness value best_cost , and mark the individual with the best fitness as shark individual, and the other individuals as tuna individuals;

[0024] (2) Shark individual updates:

[0025] Shark individuals perform global search via Lévy flights and random perturbations:

[0026] x shark iter+1 =x shark iter +α×levy(β, dim)+γ×(best_M - x shark iter )+ 0.1 × randn (1, dim)

[0027] in x shark iter is the position of the individual shark, iter is the current iteration number, levy (β, dim) is the Lévy flight function, randn (1, dim) Generate a 1× dim The matrix, the elements of which follow the standard normal distribution, parameter α、β and γ The calculation formula is:

[0028] α = 0.1×(1 - iter / T)

[0029] β = 1.5×(1 - iter / T)

[0030] γ = 1 - 0.5×(1 - iter / T)

[0031] in, T is the maximum number of iterations;

[0032] (3) Tuna individual update:

[0033] The steps for updating tuna individuals are: 1. For each tuna individual i , a random number between 0 and 1 at birth R i ; 2. According to R i The value selects whether to update directly or mirror:

[0034] when R i ≥0.5, the tuna is directly updated, the direct update method is:

[0035] M i iter+1 = M i iter + C 1 ×rand(1, dim )×( x shark iter - M i iter );

[0036] in C 1 is the direct update coefficient;

[0037] when R i <0.5, the tuna is a mirror update, divided into 3 steps:

[0038] Step 1: Generate a mirror image x mirror,i iter :

[0039] x mirror,i iter =2×x shark iter -Mi iter +0.1× randn (1, dim)

[0040] Step 2: Determine whether the mirror image individual exceeds the search space boundary in each dimension. j If a dimension exceeds the boundary, the position of the dimension is corrected:

[0041] x mirror,i,j iter = ub j - R i ×( ub j -x shark,j iter ) if x mirror,i,j iter >ub j

[0042] x mirror,i,j iter = lb j + R i ×( x shark,j iter - lb j ) if x mirror,i,j iter <lb j

[0043] in x mirror,i,j iter For the i Individuals in j The corrected mirror position in each dimension, x shark,j iter Representative shark individuals j The value of the dimension; j =1,2,…, dim ; ub j and lb j Respectively represented in j The upper and lower limits of the search in each dimension;

[0044] Step 3: Update the position of the tuna individual according to the position of the mirror individual:

[0045] M i iter+1 = x mirror,i iter + C 2 ×rand(1, dim )×( x shark iter - x mirror,i iter );

[0046] in C 2 is the mirror update coefficient;

[0047] (IV) Fitness Update and Iteration Termination

[0048] 1. Recalculate the fitness values of all individuals at their latest positions and update best_M and best_cost ;

[0049] 2. Determine whether the iteration termination condition is met. If the iteration termination condition is met, output best_M and best_cost The calculation terminates if the termination condition is not met. If the individual with the best fitness value in this iteration is updated to the shark individual, the remaining individuals are defined as tuna individuals, and the calculation of stage (2) to stage (4) is repeated.

[0050] The present invention provides an intelligent real-time traffic flow prediction method. The hybrid feature network model constructed is a Parallel CNN-LSTM with MHSA (PCL-MHSA) model. This PCL-MHSA model uses parallel convolutional layer (CNN) branches and long short-term memory (LSTM) layer branches to extract local features and global temporal dependencies, respectively. A pooling layer then performs dimensionality reduction and extracts key information. A multi-head self-attention model (MHSA) is then used to dynamically weight the fused features, ultimately achieving high-precision predictions. Furthermore, the constructed Shark and Tuna Alliance Optimization Algorithm (STAO) is a heuristic optimization algorithm based on the natural feeding behavior of sharks and tuna. By simulating the global search capabilities of sharks and the local search capabilities of tuna, this algorithm combines the advantages of both strategies to efficiently solve complex optimization problems. It can enhance local search capabilities and accelerate convergence speed; finally, by conducting real-time training and parameter fine-tuning on the optimized PCL-MHSA model based on the latest monitoring data, it can dynamically update the latest changing trends of traffic flow, so that the model has better prediction accuracy and provides more reliable technical support for real-time prediction of traffic flow. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.

[0052] Figure 1 This is a flow chart of an intelligent real-time traffic flow prediction method provided by an embodiment of the present invention;

[0053] Figure 2 1 is a framework diagram of the PCL-MASH model provided in an embodiment of the present invention;

[0054] Figure 3 This is a comparison chart of the predicted values and actual values of the method of the present invention provided in an embodiment of the present invention;

[0055] Figure 4 It is a box plot comparison of R2 values of prediction results of different models provided by the embodiment of the present invention; DETAILED DESCRIPTION

[0056] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in combination with the implementation cases and drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention for which protection is sought, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0057] The method of the present invention is described below by taking a specific case of real-time prediction of landslide displacement as an example.

[0058] like Figure 1 , an intelligent real-time traffic flow prediction method, comprising the following steps:

[0059] Step 1: Obtain historical traffic flow data from online monitoring and pre-process the data;

[0060] Step 2: Build a hybrid feature network model framework based on parallel convolutional layers and long short-term memory layers combined with a multi-head attention mechanism, and set the hyperparameters to be optimized and the optimization range;

[0061] Step 3: Based on the shark and tuna alliance optimization algorithm and historical traffic flow data, optimize the hyperparameters of the hybrid feature network model;

[0062] Step 4: Based on the optimized hyperparameters and historical traffic flow data, a hybrid feature network model is constructed and trained;

[0063] Step 5: Set the moving average error window size W1, the dynamic update start error E, and the dynamic update window size W2;

[0064] Every time the latest monitoring data is obtained, the average of the most recent W1 prediction values is calculated, that is, the moving average error P. If P is greater than E, the latest W2 monitoring data is extracted to perform real-time training and fine-tuning on the hybrid feature network to achieve real-time dynamic update of the hybrid feature network;

[0065] Step 6: Predict the traffic flow in the next time period based on the latest hybrid feature network.

[0066] Furthermore, in step one, the historical traffic flow data includes date, time, day of the week, whether it is a holiday, and traffic flow data; the data preprocessing includes using a moving average method to smooth the traffic flow data, thereby removing short-term fluctuations and noise and retaining long-term trends; aggregating high-frequency data into low-frequency data to reduce data complexity and improve computational efficiency; and normalizing the data to eliminate dimensional differences and improve model training effects.

[0067] Furthermore, in step 2, the hybrid feature network model framework includes connecting the input layer to the parallel multi-scale convolution layer and the long short-term memory layer, and then splicing the parallel outputs into one output through the splicing layer, and sequentially connecting them in series through the maximum pooling layer, the multi-scale self-attention mechanism layer, the random dropout layer, the global pooling layer, the fully connected layer and the output layer; wherein the input layer receives historical traffic flow data; in the parallel multi-scale convolution layer and the long short-term memory layer, the multi-scale convolution layer uses different convolution kernel sizes to extract local features, and the long short-term memory layer captures the time series. long-term dependencies; the splicing layer splices the outputs of the CNN and LSTM branches in the feature dimension; the maximum pooling layer performs 1D maximum pooling on the spliced output; the multi-head self-attention mechanism layer uses the multi-head self-attention mechanism to capture the importance of different time steps in the sequence; the random dropout (Dropout) layer applies Dropout to the output of the multi-head self-attention layer to prevent overfitting; the global pooling layer performs global aggregation on the features; the fully connected layer performs nonlinear transformation on the selected time step features to further extract features; the output layer uses the fully connected layer to generate the final prediction result.

[0068] Furthermore, in step 2, the hyperparameters include the number of filters of the convolutional layer, the learning rate, the random dropout rate, the L2 regularization strength, the number of units in the long short-term memory layer, and the number of heads in the multi-head attention mechanism.

[0069] Furthermore, in step 3, the shark and tuna alliance optimization algorithm includes the following four stages:

[0070] (1) Population initialization:

[0071] 1. Generate initial population: randomly generate initial population M i 0 , where each individual M i 0 The position is determined by the following formula:

[0072] M i 0 = lb + (ub - lb)×rand(1, dim )

[0073] in M i 0 Representative i The location of an individual, i The serial number representing the individual, i =1,2,…, N , N is the population size, the superscript represents the number of iterations, where 0 represents the initialization stage; lb and ub are the lower and upper bounds of the search space, respectively. dim is the dimension of the problem to be optimized, rand(1 ,dim ) generates a 1× dim A random vector whose elements range from [0,1];

[0074] 2. Calculate the initial fitness value:

[0075] Calculate the fitness value of each individual fitness(i) , fitness(i) = f obj (M i 0 ) ,in f obj () Is the fitness function; records the historical optimal solution position best_M and the historical optimal fitness value best_cost , and mark the individual with the best fitness as shark individual, and the other individuals as tuna individuals;

[0076] (2) Shark individual updates:

[0077] Shark individuals perform global search via Lévy flights and random perturbations:

[0078] x shark iter+1 =x shark iter +α×levy(β, dim)+γ×(best_M - x shark iter )+ 0.1 × randn (1, dim)

[0079] in x shark iter is the position of the individual shark,iter is the current iteration number, levy (β, dim) is the Lévy flight function, randn (1, dim) Generate a 1× dim The matrix, the elements of which follow the standard normal distribution, parameter α、β and γ The calculation formula is:

[0080] α = 0.1×(1 - iter / T)

[0081] β = 1.5×(1 - iter / T)

[0082] γ = 1 - 0.5×(1 - iter / T)

[0083] in, T is the maximum number of iterations;

[0084] (3) Tuna individual update:

[0085] The steps for updating tuna individuals are: 1. For each tuna individual i , a random number between 0 and 1 at birth R i ; 2. According to R i The value selects whether to update directly or mirror:

[0086] when R i ≥0.5, the tuna is directly updated, the direct update method is:

[0087] M i iter+1 = M i iter + C 1 ×rand(1, dim )×( x shark iter - M i iter );

[0088] in C 1 is the direct update coefficient;

[0089] when R i <0.5, the tuna is a mirror update, divided into 3 steps:

[0090] Step 1: Generate a mirror image x mirror,i iter :

[0091] x mirror,i iter =2×x shark iter -M i iter +0.1× randn (1, dim)

[0092] Step 2: Determine whether the mirror image individual exceeds the search space boundary in each dimension. j If a dimension exceeds the boundary, the position of the dimension is corrected:

[0093] x mirror,i,j iter = ub j - R i ×( ub j -x shark,j iter ) if x mirror,i,j iter >ub j

[0094] x mirror,i,j iter = lb j + R i ×( x shark,j iter - lb j ) if x mirror,i,j iter <lb j

[0095] in x mirror,i,j iter For the i Individuals in j The corrected mirror position in each dimension, x shark,j iter Representative shark individualsj The value of the dimension; j =1,2,…, dim ; ub j and lb j Respectively represented in j The upper and lower limits of the search in each dimension;

[0096] Step 3: Update the position of the tuna individual according to the position of the mirror individual:

[0097] M i iter+1 = x mirror,i iter + C 2 ×rand(1, dim )×( x shark iter - x mirror,i iter );

[0098] in C 2 is the mirror update coefficient;

[0099] (IV) Fitness Update and Iteration Termination

[0100] 1. Recalculate the fitness values of all individuals at their latest positions and update best_M and best_cost ;

[0101] 2. Determine whether the iteration termination condition is met. If the iteration termination condition is met, output best_M and best_cost The calculation terminates if the termination condition is not met. If the individual with the best fitness value in this iteration is updated to the shark individual, the remaining individuals are defined as tuna individuals, and the calculation of stage (2) to stage (4) is repeated.

[0102] The experimental data comes from 5,000 sets of actual traffic flow monitoring data on a certain highway.

[0103] The specific implementation process is as follows:

[0104] like Figure 1 , an intelligent real-time traffic flow prediction method, comprising the following steps:

[0105] Step 1: Obtain historical traffic flow data from online monitoring and pre-process the data;

[0106] Step 2: Build a hybrid feature network model framework based on parallel convolutional layer-long short-term memory layer and combined with multi-head attention mechanism. The model framework is as follows Figure 2 As shown, set the hyperparameters to be optimized and the optimization range;

[0107] The hyperparameters to be optimized and their optimization ranges are: the number of filters in the convolutional layer (16-128), the learning rate (0.0001-0.1), the random dropout rate (0-0.5), the L2 regularization strength (0-0.01), the number of units in the long short-term memory layer (16-128), and the number of heads in the multi-head attention mechanism (1-8);

[0108] Step 3: Based on the shark and tuna alliance optimization algorithms and historical traffic flow data, optimize the hyperparameters of the hybrid feature network model. The model training times are set to 500 times, the population size of the tuna alliance optimization algorithm is N=10, the number of iterations is T=10, C1=1.5, and C2=1.5.

[0109] Step 4: Based on the optimized hyperparameters and historical traffic flow data, a hybrid feature network model is constructed and trained;

[0110] Step 5: Set the moving average error window size W1=5, the dynamic update startup error E=2, and the dynamic update window size W2=10. Each time the latest monitoring data is obtained, calculate the average value P of the most recent W1 prediction values. If P is greater than E, extract the latest W2 monitoring data to perform real-time training and fine-tuning on the hybrid feature network to achieve real-time dynamic update of the hybrid feature network. The number of dynamic update iterations is set to 10.

[0111] Step 6: Predict the traffic flow in the next time period based on the latest hybrid feature network.

[0112] Figure 3 The comparison between the predicted results and the true values is presented, demonstrating that the present invention can accurately predict traffic flow. To verify the advantages of the present method, several related models were used for calculations and the results were compared. These models are: LSTM-CNN model, CNN-LSTM model, PCL-MHSA model, particle swarm optimized PCL-MHSA model (PSO-PCL-MHSA), and STAO-PCL-MHSA model. These models are all static models and do not incorporate a real-time prediction mechanism. For the LSTM-CNN model, CNN-LSTM model, and PCL-MHSA model, the number of convolutional layer filters, the number of LSTM units, the learning rate, the dropout rate, the L2 regularization strength, and the number of multi-head attention heads are 64, 64, 0.01, 0.25, 0.005, and 4, respectively. All other model parameters are consistent with the settings of the model proposed in this paper.

[0113] In order to fully compare the performance of each model, the mean absolute error (MAE), absolute percentage error (MAPE), root mean square error (RMSE) and goodness of fit R 2 A total of four indicators were used to quantitatively evaluate each model. Each model was calculated ten times and the average value of each indicator was obtained. The evaluation results of each model are shown in Table 1:

[0114]

[0115] As shown in Table 1, the method of the present invention has the following advantages in MAE, MAPE, RMSE and goodness of fit R 2 The four indicators reached 1.063, 8.063, 1.499, and 0.9997 respectively, which are the best values among all methods, fully demonstrating the advantages of the model in traffic flow prediction. At the same time, in order to observe the performance of the model more carefully, the R 2 Box plot of values, such as Figure 4 shown.

[0116] Depend on Figure 4 As can be seen, the proposed model not only outperforms the comparison model in terms of median, but also has a smaller interquartile range and range, good symmetry, and no outliers. This indicates that the proposed method's prediction results are more concentrated and stable, validating its superiority and robustness. In summary, the results of the proposed method can effectively improve the accuracy of traffic flow predictions and provide a basis for refined traffic management, low-carbon emission reduction, and energy optimization.

[0117] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.

Claims

1. An intelligent real-time traffic flow prediction method, characterized in that: The following steps are involved: Step 1: Obtain historical traffic flow data from online monitoring and pre-process the data; Step 2: Build a hybrid feature network model framework based on parallel convolutional layers and long short-term memory layers combined with a multi-head attention mechanism, and set the hyperparameters to be optimized and the optimization range; Step 3: Based on the shark and tuna alliance optimization algorithm and historical traffic flow data, optimize the hyperparameters of the hybrid feature network model; The shark and tuna alliance optimization algorithm includes the following four stages: (1) Population initialization:

1. Generate initial population: randomly generate initial population M i 0 , where each individual M i 0 The position is determined by the following formula: M i 0 = lb + (ub-lb) ×rand(1, dim ) Among them M i 0 Representative i The location of an individual, i The serial number representing the individual, i =1,2,…, N , N is the population size, the superscript represents the number of iterations, where 0 represents the initialization stage; lb and ub are the lower and upper bounds of the search space, respectively. dim is the dimension of the problem to be optimized, rand(1, dim ) generates a 1× dim A random vector whose elements range from [0,1]; 2. Calculate the initial fitness value: Calculate the fitness value of each individual fitness(i) , fitness(i)=f obj (M i 0 ) ,in f obj () Is the fitness function; records the historical optimal solution position best_M and the historical optimal fitness value best_cost , and mark the individual with the best fitness as shark individual, and the other individuals as tuna individuals; (2) Shark individual updates: Shark individuals perform global search via Lévy flights and random perturbations: x shark iter+1 =x shark iter +α×levy ( β,dim ) +γ× ( best_M-x shark iter ) + 0.1 × randn( 1,dim ) in x shark iter is the position of the individual shark, iter is the current iteration number, levy (β,dim) is the Lévy flight function, randn (1,dim) Generate a 1× dim The matrix, the elements of which follow the standard normal distribution, parameter α、β and γ The calculation formula is: α=0.1×(1-iter / T) β=1.5×(1-iter / T) γ=1-0.5×(1-iter / T) in, T is the maximum number of iterations; (3) Tuna individual update: The steps for updating tuna individuals are:

1. For each tuna individual i , a random number between 0 and 1 at birth R i ; 2. According to R i The value selects whether to update directly or mirror: when R i ≥0.5, the tuna is directly updated, the direct update method is: M i iter+1 = M i iter + C 1 ×rand(1, dim )×( x shark iter - M i iter ); in C 1 is the direct update coefficient; when R i <0.5, the tuna is a mirror update, divided into 3 steps: Step 1: Generate a mirror image x mirror,i iter : x mirror,i iter =2×x shark iter - M i iter +0.1× rand (1,dim) Step 2: Determine whether the mirror image individual exceeds the search space boundary in each dimension. j If a dimension exceeds the boundary, the position of the dimension is corrected: x mirror,i,j iter = ub j - R i ×( ub j -x shark,j iter ) if x mirror,i,j iter >ub j x mirror,i,j iter = lb j + R i ×( x shark,j iter - lb j ) if x mirror,i,j iter <lb j in x mirror,i,j iter For the i Individuals in j The corrected mirror position in each dimension, x shark,j iter Representative shark individuals j The value of the dimension; j =1,2,…, dim ; ub j and lb j Respectively represented in j The upper and lower limits of the search in each dimension; Step 3: Update the position of the tuna individual according to the position of the mirror individual: M i iter+1 = x mirror,i iter + C 2 ×rand(1, dim )×( x shark iter - x mirror,i iter ); in C 2 is the mirror update coefficient; (IV) Fitness update and iteration termination:

1. Recalculate the fitness values of all individuals at their latest positions and update best_M and best_cost ; 2. Determine whether the iteration termination condition is met. If the iteration termination condition is met, output best_M and best_cost The calculation terminates if the termination condition is not met. The individual with the best fitness value in this iteration is updated to the shark individual, and the remaining individuals are defined as tuna individuals. The calculation of stage (2) to stage (4) is repeated. Step 4: Based on the optimized hyperparameters and historical traffic flow data, a hybrid feature network model is constructed and trained; Step 5: Set the moving average error window size W1, the dynamic update start error E, and the dynamic update window size W2; Every time the latest monitoring data is obtained, the average of the most recent W1 prediction values is calculated, that is, the moving average error P. If P is greater than E, the latest W2 monitoring data is extracted to perform real-time training and fine-tuning on the hybrid feature network to achieve real-time dynamic update of the hybrid feature network; Step 6: Predict the traffic flow in the next time period based on the latest hybrid feature network.

2. The intelligent real-time traffic flow prediction method according to claim 1, characterized in that: In step one, the historical traffic flow data includes date, time, day of the week, whether it is a holiday, and traffic flow data; the data preprocessing includes smoothing the traffic flow data using a moving average method, aggregating high-frequency data into low-frequency data, and normalizing the data.

3. The intelligent real-time traffic flow prediction method according to claim 1, characterized in that: In step 2, the hybrid feature network model framework includes connecting the input layer to the parallel multi-scale convolutional layer and long short-term memory layer, and then splicing the parallel outputs into one output through the splicing layer, and sequentially connecting them in series through the maximum pooling layer, multi-scale self-attention mechanism layer, random dropout layer, global pooling layer, fully connected layer and output layer.

4. The intelligent real-time traffic flow prediction method according to claim 1, characterized in that: In step 2, the hyperparameters include the number of filters in the convolutional layer, the learning rate, the random dropout rate, the L2 regularization strength, the number of units in the long short-term memory layer, and the number of heads in the multi-head attention mechanism.

Citation Information

Patent Citations

  • Integrated transmission device fault prediction algorithm based on ITSOBP

    CN117708771A

  • Soft measurement method of improved TSO optimized deep learning model

    CN118228613A