Traffic flow prediction method based on IGA-Bi-LSTM
Through improved adaptive genetic algorithms and Bi-LSTM models, the existing traffic flow prediction model has been solved, and more efficient and reliable traffic flow prediction is achieved, and more effective highway control is supported.
Patent Information
- Application Number
- CN202410832600.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2025-02-18
AI Technical Summary
The existing traffic flow prediction models have problems such as low prediction accuracy, slow efficiency, unobservable neural network learning process and difficult to explain results, which affect the reliability of the results.
Improved adaptive genetic algorithm (IGA) is used to adjust the hyperparameters of the Bi-LSTM model, and combined with bidirectional long-term and short-term neural network (Bi-LSTM) to predict traffic flow parameters to improve the accuracy and efficiency of prediction.
Through improved adaptive genetic algorithms and Bi-LSTM models, the accuracy and efficiency of traffic flow prediction are improved, the interpretability of the model is enhanced, and more effective highway control is supported.
Smart Images

Figure CN119479264A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent transportation technology, and in particular to a traffic flow prediction method based on IGA-Bi-LSTM. Background Art
[0002] Traffic flow forecasting is crucial in highway management. It provides key data support for managers, assists in formulating effective traffic management strategies, and improves the operational efficiency, safety, and sustainability of highway systems. Traffic flow forecasting can accurately predict future highway traffic conditions. Through historical data and real-time information analysis, managers can predict traffic flow, vehicle speed, and density in future time periods and sections, and take timely measures to alleviate congestion, reduce accident risks, and improve traffic efficiency. Forecasting supports highway planning and infrastructure construction. Accurately predicting future traffic demand helps to rationally plan expansion, reconstruction, and maintenance work, cope with traffic pressure, and avoid congestion and delays. Traffic flow forecasting optimizes operational management. By analyzing travel patterns and demand, the location and number of toll booths can be reasonably arranged, and lane configuration can be optimized to improve traffic efficiency and safety.
[0003] The research related to data prediction is divided into three categories, namely, machine learning methods, mathematical or traffic flow theory methods, and neural network algorithms. Traditional machine learning methods have achieved some results, but are relatively poor in dealing with nonlinear problems, and their interpretability is also weak. Mathematical methods have the problem of poor applicability due to the complex nonlinear relationship of traffic flow data, and the theory of a certain time point or time period. The advantages of neural network algorithms are strong learning ability and parallel distributed processing ability, associative memory function, and noise neural network has strong robustness, and nonlinear relationships can be represented. However, the neural network model requires a large number of parameters, such as network topology, weights and initial thresholds, and the efficiency and error accuracy of neural network parameter selection need to be improved. In order to solve the above problems, based on the previous research, the present invention proposes an improved adaptive genetic algorithm, which judges the degree of concentration and dispersion of the population according to the discrete degree of population fitness, so as to adaptively determine the genetic algorithm process and the values of crossover probability and mutation probability. And combining the advantages of the two models, the improved adaptive genetic algorithm is used to update the parameters, and then the Bi-LSTM model is input to predict the traffic flow parameters to improve the accuracy and efficiency.
[0004] The existing traffic flow prediction models have problems such as low prediction accuracy and slow optimization of traffic flow parameters. The neural network learning process cannot be observed, and its production results are difficult to explain, which affects the reliability of the results. The genetic algorithm has a certain degree of explainability for the model operation process. The technical problem to be solved by the present invention is to predict traffic flow by improving the genetic algorithm and the bidirectional long-short time neural network, so as to improve the accuracy and efficiency of traffic flow prediction, and then conduct more effective highway management and control. Summary of the invention
[0005] The technical problem to be solved by the present invention is to provide a traffic flow prediction method based on IGA-Bi-LSTM in view of the defects of poor traffic flow prediction accuracy and low efficiency in the prior art.
[0006] The technical solution adopted by the present invention to solve its technical problem is:
[0007] The present invention provides a traffic flow prediction method based on IGA-Bi-LSTM, which comprises the following steps:
[0008] Step 1: Collect traffic flow data, and perform data anomaly, data missing, and data filling processing operations on it. After completing the data update, complete traffic flow data is obtained;
[0009] Step 2: For the predicted road section, the complete traffic flow data and the traffic flow data of the adjacent lanes are divided into a training set and a test set according to a set ratio, and a sliding window is used to generate spatiotemporal correlations between the training set and the test set as input data for the prediction model;
[0010] Step 3: Establish an IGA-Bi-LSTM short-term traffic flow prediction model, which includes an adaptive genetic algorithm IGA for parameter adjustment and a bidirectional long-short-term neural network Bi-LSTM model for time series prediction;
[0011] Step 4: Based on the optimizer Adam, the IGA-Bi-LSTM short-term traffic flow prediction model is iteratively trained using the training set data;
[0012] Step 5: Use the trained IGA-Bi-LSTM short-term traffic flow prediction model to predict the short-term traffic flow of the test set, compare the prediction results with the actual values, use performance indicators for evaluation, and output the prediction model that meets the performance indicators.
[0013] Furthermore, the method of step 1 of the present invention comprises:
[0014] Step 1.1, collect traffic flow data, and delete abnormal data according to data quality marks or traffic flow theory knowledge;
[0015] Step 1.2: For the timestamp data, find the missing time bar data and add the corresponding timestamp;
[0016] Step 1.3: Divide the data into working day and non-working day data, and collect historical data where the statistics are missing. When the missing data is more than a certain threshold, use historical data for interpolation; when the missing data is less than a certain threshold, use linear interpolation to interpolate the data; after interpolation, obtain complete traffic flow data.
[0017] Furthermore, the method of step 2 of the present invention comprises:
[0018] Step 2.1, divide the lanes, and divide the lanes where the data is missing into the middle lane and the side lanes; when it is the middle lane, calculate the Pearson correlation coefficient between the left and right adjacent lanes; when it is the side lanes, calculate the correlation coefficient data of the left or right adjacent lanes; for the lanes where the predicted data is missing, select multiple data with strong correlation according to the correlation coefficient data, randomly combine them, and combine the weekly average historical data to fill the missing parts;
[0019] The complete traffic flow data and the traffic flow data of adjacent lanes are divided into a training set and a test set according to a set ratio;
[0020] Step 2.2, by sliding the time window with m steps as intervals, taking m as the number of input time steps and d as the number of relevant lanes, construct an m×d-order spatiotemporal correlation matrix as the input matrix of the prediction model;
[0021] Step 2.3: Normalize the constructed input matrix by calculating the ratio of the difference between the true value and the minimum value to the difference between the maximum and minimum values.
[0022] Furthermore, the method of step 3 of the present invention comprises:
[0023] Step 3.1, build a bidirectional long short time neural network Bi-LSTM model structure, including an input layer, a bidirectional LSTM layer, add a Dropout layer to reduce overfitting, then add another bidirectional LSTM layer, and finally add a fully connected layer as the output layer;
[0024] Step 3.2: Use the overflow layer to add regularization constraints to the model;
[0025] Step 3.3: Use the improved adaptive genetic algorithm IGA to determine the hyperparameters of the Bi-LSTM model.
[0026] Furthermore, the method of step 3.1 of the present invention comprises:
[0027] The LSTM model includes:
[0028] f t : The forget gate determines which information in the cell state of the previous moment will be forgotten;
[0029] i t : The input gate determines the impact of the newly input information on the cell state at the current moment;
[0030] o t: The output gate determines the hidden state h at the current moment t Which information will be output?
[0031] a t :represents the response of h at time t t-1 and x t Preliminary feature extraction of
[0032] Bidirectional LSTM accepts a sequence X = {x1, x2, ...x T}, where T is the length of the time series, and for each time step t, the input is calculated as follows:
[0033]
[0034]
[0035] Among them, i t 、f t , g t , o t are the gate vectors of input, forget, input gate and output gate respectively; σ is the sigmoid function; tanh is the hyperbolic tangent function; W and b are the weight matrix and bias vector;
[0036] The cell update and hidden state update are calculated as follows:
[0037]
[0038] Among them, ⊙ represents element-by-element multiplication;
[0039] The reverse LSTM is represented as The calculation of the reverse LSTM uses the reverse input sequence, concatenating the forward and reverse LSTM outputs of the final output of the bidirectional LSTM: Then make a prediction.
[0040] Further, the method of step 3.3 of the present invention comprises:
[0041] 1) Chromosome encoding and initial population generation;
[0042] 2) Calculate the fitness of the individual, and calculate the three-quarter and one-quarter quantile values and the maximum value of the fitness of the population;
[0043] 3) Adaptively determine the crossover probability and mutation probability for each individual, perform differential analysis on different individuals, and perform individual selection processing on the crossover probability and mutation probability. The calculation formula is as follows, where k1 and k2 are constants;
[0044]
[0045]
[0046] 4) Determine whether the population meets the convergence conditions. If so, output it. If not, continue to execute downward.
[0047] 5) Judgment Is it true? If true, it means that the average fitness value of the population is very close to the maximum fitness value of the population and is larger than π / 6. In this case, it is judged that the fitness value of the population is relatively concentrated. Therefore, the mutation operation is performed first to increase the diversity of the population, and then the crossover operation is performed, and finally the selection operation is performed. On the contrary, if it is not true, it means that the gap between the average fitness value of the population and the maximum fitness value of the population is large and smaller than π / 6. It shows that the fitness value of the population is relatively dispersed. In this case, the crossover operation is performed first to promote information exchange and gene recombination, and then the mutation operation is performed, and finally the selection operation is performed.
[0048] 6) Return to step 2).
[0049] Furthermore, the method of step 4 of the present invention comprises:
[0050] Step 4.1: Input the normalized traffic flow data of the training set into the long short-term memory neural network Bi-LSTM model, pass through the first bidirectional LSTM layer, temporarily discard some neurons during training through the dropout method, and output the first hidden layer result after passing through three control gates; use the output result as the input of the second long short-term memory neural network Bi-LSTM model hidden layer to obtain the output result of the second hidden layer; the result of the second long short-term memory neural network LSTM hidden layer is output after passing through the fully connected layer to obtain the traffic flow prediction value; calculate the MSE based on the predicted value and the actual value as the error objective function;
[0051] Step 4.2: Calculate the gradient of the loss function through the optimizer Adam, and back-propagate the gradient to update the weights of the model until the model reaches the minimum error or the maximum number of iterations, then stop updating the weights and end the training.
[0052] Furthermore, the method of step 5 of the present invention comprises:
[0053] Compare the prediction results of the test set with the actual values, and use the performance evaluation index to evaluate the performance of the Bi-LSTM short-term traffic flow prediction model. If it does not meet the requirements, re-adjust the parameters of the short-term traffic flow prediction model for training;
[0054] The performance evaluation indicators include mean square error (MSE), mean absolute error (MAE), and root mean square error (RMSE).
[0055] The present invention provides a traffic flow prediction method system based on IGA-Bi-LSTM, comprising:
[0056] a memory for storing executable computer programs;
[0057] The processor is used to implement the above-mentioned traffic flow prediction method based on IGA-Bi-LSTM when executing the executable computer program stored in the memory.
[0058] The present invention provides a computer-readable storage medium storing a computer program for implementing the above-mentioned traffic flow prediction method based on IGA-Bi-LSTM when executed by a processor.
[0059] The beneficial effects produced by the present invention are:
[0060] The present invention performs nonlinear adaptive determination on the mutation probability and the crossover probability, and then adaptively determines the genetic algorithm process of mutation, crossover and selection. Experiments show that the adaptive genetic algorithm has good results and certain application value. In view of the bidirectional temporal characteristics of data missing, the Bi-LSTM model is cited to meet actual needs, and a bidirectional LSTM layer, an overflow layer, a fully connected layer and the like are set for prediction. Finally, most of the existing studies are conducted on historical statistical data of longer time periods such as 5, 10 and 15 minutes. The present invention uses historical data of a shorter time period of 20 seconds for research. Experiments show that the traffic flow prediction proposed by the present invention has better effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:
[0062] Figure 1 A schematic diagram of the flow chart of the IGA-Bi-LSTM model traffic flow prediction model provided by the present invention;
[0063] Figure 2 A schematic diagram of the bidirectional long-short time neural network information transmission process provided by the present invention;
[0064] Figure 3 This is a schematic diagram of the improved adaptive genetic algorithm process provided by the present invention. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0066] Example 1
[0067] In view of the above technical deficiencies, the present invention proposes a traffic flow prediction model based on IGA-Bi-LSTM to solve the problems of poor accuracy and low efficiency of existing traffic flow prediction in the prior art.
[0068] The embodiment of the present invention provides a method for short-term traffic flow prediction, which mainly includes: improving the adaptive genetic algorithm and building a bidirectional long-short-term neural network model. Figure 1 shown.
[0069] The embodiment of the present invention provides the following sub-steps:
[0070] 1. Collect or find traffic flow data sets, and perform three-step operations on data anomalies, missing data items, and missing data based on data quality marks or relevant knowledge of traffic flow theory to complete data updates and obtain complete data;
[0071] 2. Divide the historical traffic data of the predicted section and the traffic data of the adjacent lanes into a training set and a test set, and use a sliding window to generate spatiotemporal correlations between the training set and the test set as input data for the prediction model;
[0072] 3. Establish an IGA-Bi-LSTM model, which includes an adaptive genetic algorithm IGA for parameter adjustment and a bidirectional long-short-time neural network Bi-LSTM model for time series prediction.
[0073] 4. Based on the optimizer Adam, the IGA-Bi-LSTM short-term traffic flow prediction model is iteratively trained using the training set data;
[0074] 5. Use the trained IGA-Bi-LSTM short-term traffic flow prediction model to perform short-term traffic flow prediction on the test set.
[0075] Example 2
[0076] In another specific embodiment of the present invention, the present invention comprises the following specific steps:
[0077] 1. Collect or find traffic flow data sets, and delete data anomalies based on data quality indicators or traffic flow theory knowledge to complete the first step of data update;
[0078] 2. For the timestamp data, find the missing time bar data, add the corresponding timestamp, and complete the second step of data update;
[0079] 3. Divide the data of working days and non-working days, and collect historical data where the statistics are missing. When there are many missing data, use historical data for interpolation. When there are few missing data, use linear interpolation to interpolate data. Complete the third step of data update and obtain complete data.
[0080] 4. Divide the lanes, and divide the lanes where data is missing into the middle lane and the side lanes. When it is the middle lane, calculate the Pearson correlation coefficient between the left and right adjacent lanes; when it is the side lanes, calculate the correlation coefficient data of the left or right adjacent lanes; and divide the relevant data into training sets and test sets, and the ratio can be divided according to 7:3;
[0081] Calculate the historical average data of a period of time at the data filling point. Take the data of one week as an example, and calculate the Pearson correlation coefficient with the left and right adjacent lanes respectively. Specifically, calculate the correlation coefficient between the data of each day of the week and the historical data of the data prediction lane for one week, and get a total of fourteen correlation coefficients, 7 for the left and right lanes respectively. Use this correlation coefficient to select the data with strong correlation on the left or right lanes, and select three days of data with strong correlation respectively, and get a total of six days of data on the left and right. Randomly combine them, and input the weekly average historical data of the combined data filling lane into the model as the input parameter of the model to predict the traffic flow.
[0082] 5. After dividing the historical traffic data of the predicted section and the traffic data of the adjacent lanes into the training set and the test set according to the set ratio, the training set is trained and the test set is tested by sliding the time window with m steps as the interval. That is, the first m time data are used to predict the next m time period data, and an m×d-order spatiotemporal correlation matrix is created as the input data of the prediction model.
[0083] 6. m is the number of input time steps, d is the number of relevant lanes, and the input data matrix is constructed.
[0084] 7. The constructed input matrix is normalized, wherein the specific method used is to calculate the ratio of the difference between the true value and the minimum value to the difference between the maximum and minimum values.
[0085] 8. The structure layer of the Bi-LSTM neural network mainly includes an input layer, a bidirectional LSTM layer, and then a Dropout layer is added to reduce overfitting, followed by another bidirectional LSTM layer, and finally a fully connected layer is added as the output layer. The model structure of the Bi-LSTM is as follows:
[0086] Construction of bidirectional long short-term neural network: After the above steps, the bidirectional neural network is combined with it. The long short term memory (LSTM) is a type of recurrent neural network (RNN). In practical applications, it is found that RNN has problems such as gradient disappearance, gradient explosion, and poor long-distance dependency information ability, so LSTM is introduced. The basic structure of LSTM is similar to RNN, but the main difference is that three gate structures are introduced in the hidden layer h, namely the forget gate, input gate, and output gate, and a hidden state is added. The principle of the LSTM hidden layer structure is as follows Figure 2 shown.
[0087] f t : The forget gate determines which information in the cell state at the previous moment will be forgotten.
[0088] i t : The input gate determines the impact of the new input information on the cell state at the current moment.
[0089] o t : The output gate determines the hidden state h at the current moment t Which information will be output.
[0090] a t :represents the response of h at time t t-1 and x t Initial feature extraction.
[0091] By introducing these gating structures, LSTM enables the network to more effectively capture and process long-term dependencies in time series data, thereby improving its performance in various tasks. T}, where T is the length of the time series, and for each time step t, the input is calculated as follows:
[0092]
[0093] Among them, i t 、f t , g t , o t are the gating vectors of input, forget, input gate and output gate respectively; σ is the sigmoid function; tanh is the hyperbolic tangent function; W and b are the weight matrix and bias vector.
[0094] The cell update and hidden state update are calculated as follows:
[0095]
[0096] Among them, ⊙ represents element-by-element multiplication.
[0097] Reverse LSTM (denoted as ) is similar to the forward LSTM, using the reverse input sequence. The forward and reverse LSTM outputs of the final output of the bidirectional LSTM are concatenated: Then make a prediction.
[0098] 9. Input the sequence with spatial features into the long short-term memory neural network LSTM, and predict the traffic flow at time t based on the historical traffic information in the time period [tk, t-1], where k represents the time step of the prediction interval.
[0099] 10. In order to prevent the model from overfitting, an overflow layer is used to add regularization constraints to the model.
[0100] 11. Since the neural network has many hyperparameters, it is necessary to determine the hyperparameters and then input them into the model. The following invention first improves the traditional genetic algorithm and establishes an adaptive genetic algorithm, which is described as follows:
[0101] Improved adaptive genetic algorithm (such as Figure 3 As shown in the figure): The traditional genetic algorithm realizes the evolution of the population from generation to generation in the order of gene selection-crossover-mutation. In this process, the crossover operator obtains individuals with excellent characteristics through gene recombination, while the mutation operator ensures the diversity of the population. However, this operation mode of crossover followed by mutation easily leads to excessive concentration of fitness of the population in the later stage, and at the same time, the mutation operator makes relatively small changes to the individuals, thus leading to local convergence. To solve this problem, based on the previous research, the present invention uses an adaptive algorithm flow to avoid the algorithm from falling into the local optimal solution.
[0102] 1) Chromosome encoding and initial population generation. (Chromosomes may include learning rate, overflow rate, number of neurons, etc. Each parameter represents a chromosome; all parameters constitute an individual, the collection of all individuals is called a population, and all initially generated individuals are called the initial population)
[0103] 2) Calculate the fitness of the individual, and calculate the three-quarter and one-quarter quantile values and the maximum value of the fitness of the population. (The present invention uses the error calculated by the individual as the individual fitness, and in order to avoid the situation where the degree of dispersion between the population is too large, the quantile value is used to avoid extreme situations.)
[0104] 3) Adaptively determine the crossover probability and mutation probability for each individual. Perform differential analysis on different individuals, and perform individual selection on the crossover probability and mutation probability. The calculation formula is as follows, where k1 and k2 are constants.
[0105]
[0106] 4) Determine whether the population meets the convergence conditions. If so, output it. If not, continue to execute downward.
[0107] 5) Judgment Is it true? If the above formula is true, it means that the average fitness value of the population is very close to the maximum fitness value of the population and is larger than π / 6. In this case, it can be judged that the fitness value of the population is relatively concentrated. Therefore, it is recommended to perform a mutation operation first to increase the diversity of the population, then perform a crossover operation, and finally perform a selection operation. On the contrary, if the above formula is not true, it means that the gap between the average fitness value of the population and the maximum fitness value of the population is large and smaller than π / 6. This shows that the fitness value of the population is relatively dispersed and maintains a large diversity. In this case, it is recommended to perform a crossover operation first to promote information exchange and gene recombination, then perform a mutation operation, and finally perform a selection operation. Such adjustments help maintain a large population difference and improve the global search performance of the algorithm.
[0108] 6) Return to step 2).
[0109] 12. After the above steps, a neural network layer with certain hyperparameters is obtained. The normalized traffic flow data of the training set is input into the Bi-LSTM short-term traffic flow prediction model. After passing through the first bidirectional LSTM layer, some neurons are temporarily discarded by the dropout method during training. After passing through three control gates, the first hidden layer result is output; the output result is used as the input of the second long short-term memory neural network Bi-LSTM hidden layer, and the steps are repeated to obtain the output result of the second hidden layer; the result of the second long short-term memory neural network LSTM hidden layer is output after passing through the fully connected layer to obtain the traffic flow prediction value; MSE is calculated based on the predicted value and the actual value as the error objective function;
[0110] 13. The optimizer Adam calculates the gradient of the loss function and backpropagates these gradients to update the weights of the model until the model reaches the minimum error or the maximum number of iterations, stops updating the weights and ends the training.
[0111] 14. Compare the prediction results of the test set with the actual values, and use performance evaluation indicators to evaluate the performance of the Bi-LSTM short-term traffic flow prediction model. If it does not meet the requirements, re-adjust the parameters of the short-term traffic flow prediction model for training.
[0112] 15. Performance evaluation indicators may include mean square error (MSE), mean absolute error (MAE), root mean square error (RMSE), etc.
[0113] Test Example
[0114] The preferred embodiments of the present invention are described in detail below, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0115] In order to realize the traffic flow prediction function of the present invention, the experimental data uses the PORTAL highway dataset provided by FHWA. The experimental data comes from the PORTAL highway dataset provided by FHWA, which contains 20 seconds of speed, flow and occupancy data obtained by double-ring detectors on lanes and ramps of main roads of Portland area highways from September 15, 2011 to November 15, 2011. Each detector in the dataset contains 4320 traffic data samples a day. In the experimental verification of the present invention, we selected data from the I-205 North Line section, which lasted for one month and only contained continuous data on non-holidays for experimental analysis.
[0116] Data prediction preprocessing:
[0117] First, in order to solve the abnormal values in traffic flow data caused by harsh environmental disturbances, data prediction preprocessing is required before data filling to improve data quality. In the process of data anomaly processing, the focus includes intelligent detection and elimination of abnormal data and duplicate values, and subsequent accurate processing of missing data. Data processing is judged based on traffic flow theory, data quality indicators, and common sense.
[0118] Then the present invention selects the historical data of the adjacent lanes on the left and right sides and the missing data, and then uses the Pearson correlation coefficient to calculate and select three related data with strong correlation, and calculates the average historical time data at the same time as the input of the model. For example, take the average of all the data at each time of every Friday of three weeks, and extract the spatial periodic characteristics and historical time characteristics of the data. The calculation formula is as follows, where x ij , are the value and average of the relevant data, respectively, x i , are the value and mean of the filled data, respectively.
[0119]
[0120] After the above data filling and preprocessing, the Pearson correlation coefficient is calculated. Taking Friday's data as an example, the correlation coefficient is shown in Table 1.
[0121] Table 1 Correlation coefficients of adjacent points
[0122]
[0123] Calculate the correlation coefficient, select the data corresponding to Friday, Thursday, and Tuesday for the left adjacent lane. Select the data corresponding to Friday, Thursday, and Tuesday for the right adjacent lane. Select the data corresponding to Friday, Wednesday, and Thursday for the time history data. Take the average value of the three columns of data with strong correlation to the historical data near the missing data.
[0124] Then the traffic flow data is normalized. The traffic flow data normalization formula is as follows:
[0125]
[0126] In the formula, q is the traffic flow, which can also be replaced by other traffic parameters such as Speed and Occupancy.
[0127] Bi-LSTM model settings:
[0128] 1. Parameter settings:
[0129] `num_units`(number of LSTM units): This is the parameter that determines the number of hidden units in the LSTM layer. It controls the capacity and complexity of the model, affecting the model's learning ability and expressiveness. More hidden units usually increase the capacity of the model, but also increase the risk of overfitting.
[0130] `learning_rate`(learning rate): The learning rate is a key parameter in the optimization algorithm, which determines the step size when the model updates the weights in each iteration. A larger learning rate may cause the weight updates to be too large and fail to converge, while a smaller learning rate may result in slow training.
[0131] `dropout_rate`(Dropout ratio): Dropout is a commonly used regularization technique to reduce overfitting of models. It specifies the proportion of neurons that are randomly dropped during training. A higher Dropout ratio increases the robustness of the model, but may reduce the training speed and performance of the model.
[0132] 2. Layer settings:
[0133] Bidirectional LSTM layer (`Bidirectional(LSTM(...))`): The bidirectional LSTM layer consists of two LSTM units in opposite directions, processing along the time series and in the reverse time series respectively. This helps capture the forward and reverse patterns in the sequence data, improving the model's ability to express and predict sequence data.
[0134] Dropout layer (`Dropout(...)`): The Dropout layer is used to randomly drop a certain proportion of neurons during training to reduce overfitting of the model. It can be added between LSTM layers or between LSTM layers and fully connected layers to help improve the generalization ability of the model.
[0135] Fully connected layer (`Dense(...)`): A fully connected layer is used to map the output of the LSTM layer to a single value prediction result. It can contain one or more neurons, depending on the complexity of the task and the dimensionality of the output.
[0136] 3. Create model function (`create_model()`):
[0137] This function is responsible for building the entire neural network model, including the bidirectional LSTM layer, the Dropout layer, and the fully connected layer.
[0138] In the function, first add a bidirectional LSTM layer, then add a Dropout layer to reduce overfitting, then add another bidirectional LSTM layer, and finally add a fully connected layer as the output layer.
[0139] 4. Evaluate model performance function (`evaluate_model(individual)`):
[0140] This function is used to evaluate the performance of the model for a given hyperparameter combination. It fits the model using the training data and calculates the mean squared error as the performance metric.
[0141] These parameters and layer settings constitute a Bi-LSTM model for time series data forecasting tasks. Genetic algorithms are used to optimize these hyperparameters so that the model performs best on the given dataset.
[0142] Model combination and experimental comparison:
[0143] K1 and K2 are set to 1 and 0.5 to determine the mutation probability and crossover probability, and the improved adaptive genetic algorithm is used to determine the model hyperparameters, which include the number of neurons, learning rate, and overflow rate. The population average error or the optimal individual error is used as an evaluation index to evaluate IGA, and the advantages and disadvantages of the unimproved genetic algorithm and the improved genetic algorithm are observed. The minimum error finally achieved by the two algorithms is better than that of the IGA algorithm.
[0144] The obtained model hyperparameters are input into the traffic flow model. Set the random seed, determine 5 random missing arrays, predict the traffic flow data, and calculate the evaluation index of each model according to the mse formula. The calculation results are shown in Table 2-2. Finally, other methods are selected for comparison. Other methods may include historical averaging, random forest, ARIMA, etc. The size is compared by calculating the mse formula. Experiments have proved that the IGA-LSTM proposed in this invention has smaller error and efficiency, and can better provide a theoretical basis for highway management.
[0145]
[0146] Table 2 MSE index comparison
[0147]
[0148] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0149] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all these improvements and changes should fall within the scope of protection of the appended claims of the present invention.
Claims
1. A traffic flow prediction method based on IGA-Bi-LSTM, characterized in that: The method comprises the following steps: Step 1: Collect traffic flow data, and perform data anomaly, data missing, and data missing processing operations on it. After completing the data update, complete traffic flow data is obtained; Step 2: For the predicted road section, the complete traffic flow data and the traffic flow data of the adjacent lanes are divided into a training set and a test set according to a set ratio, and a sliding window is used to generate spatiotemporal correlations between the training set and the test set as input data for the prediction model; Step 3: Establish an IGA-Bi-LSTM short-term traffic flow prediction model, which includes an adaptive genetic algorithm IGA for parameter adjustment and a bidirectional long-short-term neural network Bi-LSTM model for time series prediction; Step 4: Based on the optimizer Adam, the IGA-Bi-LSTM short-term traffic flow prediction model is iteratively trained using the training set data; Step 5: Use the trained IGA-Bi-LSTM short-term traffic flow prediction model to predict the short-term traffic flow of the test set, compare the prediction results with the actual values, use performance indicators for evaluation, and output the prediction model that meets the performance indicators.
2. The traffic flow prediction method based on IGA-Bi-LSTM according to claim 1, characterized in that: The method of step 1 comprises: Step 1.1, collect traffic flow data, and delete abnormal data according to data quality marks or traffic flow theory knowledge; Step 1.2: For the timestamp data, find the missing time bar data and add the corresponding timestamp; Step 1.3: Divide the data into working day and non-working day data, and collect historical data where the statistics are missing. When the missing data is more than a certain threshold, use historical data for interpolation; when the missing data is less than a certain threshold, use linear interpolation to interpolate the data; after interpolation, obtain complete traffic flow data.
3. The traffic flow prediction method based on IGA-Bi-LSTM according to claim 1, characterized in that: The method of step 2 comprises: Step 2.1, divide the lanes, and divide the lanes where the data is missing into the middle lane and the side lanes; when it is the middle lane, calculate the Pearson correlation coefficient between the left and right adjacent lanes; when it is the side lanes, calculate the correlation coefficient data of the left or right adjacent lanes; for the lanes where the predicted data is missing, select multiple data with strong correlation according to the correlation coefficient data, randomly combine them, and combine the weekly average historical data to fill the missing parts; The complete traffic flow data and the traffic flow data of adjacent lanes are divided into a training set and a test set according to a set ratio; Step 2.2, by sliding the time window with m steps as intervals, taking m as the number of input time steps and d as the number of relevant lanes, construct an m×d-order spatiotemporal correlation matrix as the input matrix of the prediction model; Step 2.3: Normalize the constructed input matrix by calculating the ratio of the difference between the true value and the minimum value to the difference between the maximum and minimum values.
4. The traffic flow prediction method based on IGA-Bi-LSTM according to claim 1, characterized in that: The method of step 3 comprises: Step 3.1, build a bidirectional long short time neural network Bi-LSTM model structure, including an input layer, a bidirectional LSTM layer, add a Dropout layer to reduce overfitting, then add another bidirectional LSTM layer, and finally add a fully connected layer as the output layer; Step 3.2: Use the overflow layer to add regularization constraints to the model; Step 3.3: Use the improved adaptive genetic algorithm IGA to determine the hyperparameters of the Bi-LSTM model.
5. The traffic flow prediction method based on IGA-Bi-LSTM according to claim 4 is characterized in that: The method of step 3.1 comprises: The LSTM model includes: f t : The forget gate determines which information in the cell state of the previous moment will be forgotten; i t : The input gate determines the impact of the newly input information on the cell state at the current moment; o t : The output gate determines the hidden state h at the current moment t Which information will be output? a t :represents the response of h at time t t-1 and x t Preliminary feature extraction of Bidirectional LSTM accepts a sequence X = {x1, x2, ...x T }, where T is the length of the time series, and for each time step t, the input is calculated as follows: Among them, i t 、f t , g t , o t are the gate vectors of input, forget, input gate and output gate respectively; σ is the sigmoid function; tanh is the hyperbolic tangent function; W and b are the weight matrix and bias vector; The cell update and hidden state update are calculated as follows: Among them, ⊙ represents element-by-element multiplication; The reverse LSTM is represented as The calculation of the reverse LSTM uses the reverse input sequence, concatenating the forward and reverse LSTM outputs of the final output of the bidirectional LSTM: Then make a prediction.
6. The traffic flow prediction method based on IGA-Bi-LSTM according to claim 4 is characterized in that: The method of step 3.3 comprises: 1) Chromosome encoding and initial population generation; 2) Calculate the fitness of the individual, and calculate the three-quarter and one-quarter quantile values and the maximum value of the fitness of the population; 3) Adaptively determine the crossover probability and mutation probability for each individual, perform differential analysis on different individuals, and perform individual selection processing on the crossover probability and mutation probability. The calculation formula is as follows, where k1 and k2 are constants; 4) Determine whether the population meets the convergence conditions. If so, output it. If not, continue to execute downward. 5) Judgment Is it true? If true, it means that the average fitness value of the population is very close to the maximum fitness value of the population and is larger than π / 6. In this case, it is judged that the fitness value of the population is relatively concentrated. Therefore, the mutation operation is performed first to increase the diversity of the population, and then the crossover operation is performed, and finally the selection operation is performed. On the contrary, if it is not true, it means that the gap between the average fitness value of the population and the maximum fitness value of the population is large and smaller than π / 6. It shows that the fitness value of the population is relatively dispersed. In this case, the crossover operation is performed first to promote information exchange and gene recombination, and then the mutation operation is performed, and finally the selection operation is performed. 6) Return to step 2).
7. The traffic flow prediction method based on IGA-Bi-LSTM according to claim 5, characterized in that: The method of step 4 comprises: Step 4.1: Input the normalized traffic flow data of the training set into the long short-term memory neural network Bi-LSTM model, pass through the first bidirectional LSTM layer, temporarily discard some neurons during training through the dropout method, and output the first hidden layer result after passing through three control gates; use the output result as the input of the second long short-term memory neural network Bi-LSTM model hidden layer to obtain the output result of the second hidden layer; the result of the second long short-term memory neural network LSTM hidden layer is output after passing through the fully connected layer to obtain the traffic flow prediction value; calculate the MSE based on the predicted value and the actual value as the error objective function; Step 4.2: Calculate the gradient of the loss function through the optimizer Adam, and back-propagate the gradient to update the weights of the model until the model reaches the minimum error or the maximum number of iterations, then stop updating the weights and end the training.
8. The traffic flow prediction method based on IGA-Bi-LSTM according to claim 1, characterized in that: The method of step 5 comprises: Compare the prediction results of the test set with the actual values, and use the performance evaluation index to evaluate the performance of the Bi-LSTM short-term traffic flow prediction model. If it does not meet the requirements, re-adjust the parameters of the short-term traffic flow prediction model for training; The performance evaluation indicators include mean square error (MSE), mean absolute error (MAE), and root mean square error (RMSE).
9. A traffic flow prediction method system based on IGA-Bi-LSTM, characterized in that: include: a memory for storing executable computer programs; A processor, configured to implement the traffic flow prediction method based on IGA-Bi-LSTM as described in any one of claims 1 to 8 when executing an executable computer program stored in a memory.
10. A computer-readable storage medium, characterized in that: A computer program is stored, which is used to implement the traffic flow prediction method based on IGA-Bi-LSTM as described in any one of claims 1 to 8 when executed by a processor.
Citation Information
Cited By
Photovoltaic power generation power prediction method based on Bi-LSTM
CN120146096A