The prediction of traffic flow is essential for improving navigation efficiency. Traffic flow is influenced by the complex and changeable behavior of traffic participants. Consequently, traffic flows have stochastic properties. Traffic flow prediction involves finding patterns in the historical data and, thus, predicting the traffic flow situation in the future.
In this paper, we have implemented a short-term traffic flow prediction model using support vector regression (SVR). We have combined the genetic algorithm (GA) and particle swarm optimization (PSO) to choose parameters for SVR. The provided GA and PSO (GAPSO)-SVR achieves accurate prediction results of traffic flow as well as fast convergence speed.
5.1. Traffic Flow Prediction Based on Support Vector Regression
SVR is a regression prediction algorithm based on the support vector machine (SVM) theory. It is a supervised machine learning algorithm used to deal with classification problems. In dealing with small samples, high dimensions, and nonlinear problems, SVR has a strong ability. It has been widely used in the related fields of stock forecasting, wind forecasting, traffic flow forecasting, and so on.
The structure of an SVM can be divided into the input layer, intermediate node layer, and output layer. A general structure of an SVM is shown in
Figure 1. By introducing an insensitive loss function and corresponding kernel functions, an SVM can be extended and applied to regression estimation problems, that is, SVR [
38].
The most important thing for traffic flow prediction is to minimize the prediction error of the future traffic flow. In this paper, we chose the average of squared residuals (ASR) to be the objective function, considering that the ASR is preferable in massive data calculation. The smaller the ASR is, the fewer discrepancies there would be. Thus, the objective function is designed as:
where
N represents the number of samples,
represents the actual traffic flow value,
represents the predicted traffic flow value, and
represents the prediction error. The goal of traffic flow prediction is to minimize the
.
The main steps of establishing the traffic flow prediction model based on SVR are as follows:
Data Preparation: Extract historical data from the database. Construct a road map, calibrate coordinates, and transform historical data into traffic flow data. Normalize the data and divide them into a training set and a test set.
Data Analysis: Analyze the characteristics of the data, choose parameters of SVR, and obtain the decision function.
Model Construction: Build the SVR model with the training set. Evaluate the forecasting results using the test set. Finally, apply the model to real-time traffic flow data for real-time forecasting.
There are three kinds of parameters that are important for the SVR prediction model:
Penalty coefficient C: It adjusts the proportion between empirical risk and expected risk so as to make the model get the best generalization ability.
Insensitivity coefficient : It affects the number of support vectors, thus affecting the generalization ability of the model.
Kernel function parameters : It influences the distribution of input samples in the feature space and the correlation between support vectors.
Some existing studies set those coefficients by experience, . However, this method is not adaptive because using the same parameters can not guarantee to achieve the best training effect for different types of problems and different data characteristics.
5.2. GAPSO-Enhanced SVR
As we said before, the penalty coefficient, insensitivity coefficient, and kernel function parameters have a decisive impact on the prediction results. We need to find a way to optimize those parameters for SVR.
The PSO algorithm has the advantages of fast convergence speed, simple operation process, and easy implementation. However, the PSO algorithm cannot be guaranteed to get the optimal value. While the GA has strong global optimization ability, its implementation process is more complicated and the convergence speed is slow. Therefore, if the two can be combined, we can achieve a better model.
The decision variables of the PSO algorithm are inertial weight and learning factors . The details of the setting of those parameters are discussion below.
(1) Inertial weight: Inertial weight
controls the effect of the previous state on the current state.
can balance the global search ability and local search ability of the algorithm. The inertial weight
affects the searching ability of the algorithm. The bigger the
is, the stronger the global optimization ability is, but the convergence would be slower. The smaller the
is, the faster the convergence process is, but this would also narrow the scope of the optimization. In this paper, the linear recursive method is used to update the
so that the algorithm has strong global searchability in the early stage. In the later period, a fine search can be carried out locally. The
updating formula is as follows:
where
represents the maximum number of iterations of the algorithm and
k represents the current iteration number.
represents the starting value, and
represents the ending value.
(2) Learning factor: The learning factor is used to adjust the proportion of individual particle experience and group experience in its flight. Learning factors
also affect the searchability of the algorithm. Smaller learning factors will let the particles wander in the range away from the target area, while larger learning factors will fly particles as soon as possible to the target area to converge [
39]. In this paper, the non-linear symmetry method is used to update the learning factors
. The formula is as follows:
where
and
represent the starting and ending values of
, and
and
represent the starting and ending values of
. The range of variation of
is [2.5,1] and the range of
is [2.75, 1.5].
The decision variables of the GA algorithm are crossover probability and mutation probability . We apply the following steps to obtain the genetic evolution of particles. The genetic evolution of the particles mainly includes the selection, crossover, and mutation operations.
(1) Selection: We use the best reservation and the worst elimination mechanism. First, the particles are sorted according to their fitness. The best particle enters the next generation directly with their genes. The worst particles are unconditionally mutated.
(2) Crossover: The probability of crossover is
. In an engineering implementation, the general range of crossover probability is [0.45, 0.99]. We assume that the particles to be crossed are
. The particles’ location updating formulas are:
The speed updating formulas are:
where
are two random numbers with the range [0, 1]. We propose an adaptive crossover probability formula:
where
are constant values, which are set to 0.9 and 0.6, respectively, according to our evaluation.
is the fitness value of the two individuals under the crossover operation.
is the fitness value of the whole particle group, and
represents the optimal fitness in the current particle swarm.
(3) Mutation: In order to make the direction of mutation beneficial to the evolution of the particle swarm, we choose to mutate the position of the selected particle under probability
. In an engineering implementation, the general range of mutation probability is [0.001, 0.5]. Suppose that the
dimension of
is
.
is applied by the strategy of random perturbation. The perturbation
obeys the normal distribution, whose mean value is 0, and the variance is 1. The formula is as follows:
The probability of mutation also has an important influence on the effect of the algorithm. If
is too small, the ability to generate new individuals will become weak. If
is too large, then the search algorithm is not conducive to convergence. Therefore, this paper presents an adaptive mutation probability formula as follows:
where
and
are constant values, which are set to 0.1 and 0.001, respectively, according to our evaluation.
f is the fitness value of the particle under mutation. It can be seen from the formula that the probability of mutation will be dynamically adjusted with respect to the current particle and the particle swarm’s optimizing situation.
Figure 2 illustrates the flow of the GAPSO algorithm. The termination condition of our algorithm is that the maximum iteration number is reached.
Finally, we apply GAPSO to optimize the parameters of SVR and obtain the SVR model for traffic flow prediction.