Freeway ramp metering based on PSO-PID control

Ramp metering on freeway is one of the effective methods to alleviate traffic congestion. This paper advances the field of freeway ramp metering by introducing an application to the on-ramp, capitalizing on the macro traffic follow theory and improved the freeway traffic flow. The Particle Swarm Optimization (PSO) based on Proportional Integral Derivative (PID) controller is further developed to single ramp metering as well as to optimize the PID parameters. The approach is applied to a case study of the Changyi Freeway(G5513) in Hunan, China. The simulation is conducted by applying the actual profile traffic data to PID controller to adjust the entering traffic flow on the freeway on-ramp. The results show that the PSO-PID controller tends to converge in about 80 minutes, and the density tends to be stable after 240 iterations. The system has smaller oscillation, more accurate adjustment of ramp regulation rate, and more ideal expected traffic flow density. The traffic congestion on mainline is effectively slowed down, traffic efficiency is improved, and travel time and cost are reduced. The nonlinear processing ability of PSO-PID controller overcomes the defects of the traditional manual closing ramp, and can be successfully applied in the field of intelligent ramp metering.


Introduction
The aim of freeway on-ramp metering is to control the traffic demand. According to the traffic state of the main line, the ramp entering rate can be adjusted to support the traffic flow distribution of main line more regular, and the traffic capacity can be maximized. On-ramp metering includes ramp metering and ramp closure. According to the traffic information report of Changyi Freeway in March and April of 2018, it can be seen that the days of traffic congestion in March was 19 days, and the times of traffic control was 16. Most of the time in China, the treatment of freeway congestion is to close the ramp through traffic control, and the closing time is usually very long. Ramp closure will not only affect journeys for travelers, but also may trigger accidents. Only relying on the observation and feedback of the road operation state and closing the ramp cannot completely solve the problem of freeway congestion. Therefore, it is necessary to develop the intelligent control of freeway ramp metering.

PLOS ONE
PLOS ONE | https://doi.org/10.1371/journal.pone.0260977 December 9, 2021 1 / 14 a1111111111 a1111111111 a1111111111 a1111111111 a1111111111 In this paper, according to the nonlinear and time-varying characteristics of freeway traffic system, we take the measure of leveraging on a fuzzy automatic particle swarm optimization (PSO) based PID controller to improve the on-ramp entering flow rate to main line. The main contribution of this study lies in proposing the traffic flow state model according to the macro traffic flow theory, and developing the fuzzy automatic PID controller to optimize the traffic flow for ramp metering. The ramp regulation rate is determined by the controller, and the parameters are adjusted by fuzzy logic according to the density tracking error and the change of error. Combined with the nonlinear feedback theory, a fuzzy PSO-PID ramp controller is designed to deal with the expressway traffic flow density problem of the macro traffic flow model. According to the real-time traffic state, the parameters are dynamically adjusted by PSO method to obtain the minimum density tracking error. The principle of PID control system is simple, and has high robustness and good adaptability in nonlinear control. This method has the functions of self-organization, evolution, and memory. The control quality is obviously better than the traditional PID controller, and the response speed is obviously faster than the BP neural network based PID controller. The PSO-PID control provides a scientific strategy for the freeway on-ramp metering.
This remainder of the paper is organized as follows. Section 2 reviews relevant papers in the literature and highlights the research gap. Section 3 provides a quantitative way to estimate the traffic state by using profile data, and develops the optimized PID framework based on PSO algorithm. A case study simulation based on Changyi Freeway (G5513) is conducted in Section 4. Finally, Section 5 draws discussion and conclusion, as well as suggests future research directions.

Literature review
The basic principle of ramp metering is to effectively regulate the upstream and downstream traffic volume of the main line at the on-ramp by limiting the traffic flow into the freeway, so as to ensure that the traffic demand on the main line does not exceed its traffic capacity. According to the control range, ramp control can be divided into local / isolated metering and coordinated metering; according to the real-time response, ramp control can be divided into fixed-time strategies and responsive control [1]. The basic idea of the on-ramp timing control method proposed by Watleworth in 1965 is to estimate the fixed mediation rate of different time periods based on historical traffic data [2]. Its disadvantage is that it does not consider the time-varying characteristics of traffic conditions and cannot adjust the ramp inflow rate according to the real-time traffic. Inductive ramp control is based on the real-time parameters, with a certain control parameter kept near the optimal value as the goal, to calculate the onramp mediation rate. Early control algorithms include demand-capacity control and occupancy control. These methods belong to open-loop control, which is sensitive to external disturbance and has poor robustness [3]. In 1990s, Papageorgiou proposed ALINEA method, which is a feedback control method based on classical automatic control theory. The ramp metering is regarded as a state regulator by comparing the difference between the detection state and the target state, the ramp inflow rate is adjusted to maintain the density / occupancy rate of the downstream mainline at an ideal state. This is a typical single local ramp metering strategy, which is widely used in engineering because of its simple, flexible and effective characteristics. Papageorgiou proposed the METALINE method later for the overall control of freeway on-ramp, which is the extension of ALINEA method. These algorithms can make timely response to traffic conditions, and the control effect is improved compared with the timing algorithm, but the learning robustness is still insufficient [4][5][6][7]. Meanwhile, the traditional ramp metering method requires that the nonlinear partial differential equation model be simplified into a linear difference equation model, which will affect the control performance. Therefore, some researchers turn to use fuzzy control, artificial neural network and expert system to design intelligent controller. Taylor C (1997) and Zhang (1998) applied heuristic algorithms such as fuzzy control and artificial neural network to single dynamic ramp metering, and achieved certain results [8,9]. Liang (2005) et al. presented a nonlinear method to design the feedback controller of freeway on-ramp. The nonlinear feedback controller consists of freeway traffic flow model and proportional-integral regulator. However, the parameters cannot be adjusted online [10][11][12][13][14][15]. Bellemansa (2006) et al. proposed a ramp metering predictive method based on real traffic data [16]. Compared with the classical ALI-NEA, the results show that the model performs better than the ALINEA during the early peak period. Zeng (2007) studied the RBF neural network tuning PID controller parameters, and applied to the freeway on-ramp control. The simulation results showed that the controller has excellent dynamic and steady performance [17]. Loannis (2010) et al. proposed a feedback control strategy HERO (Heuristic Ramp-metering Coordination) [18]. The control strategy of single ramp uses ALINEA, while the coordinated control of multi-ramp is coordinated by the control center. Fares A. (2014) et al. proposed an intelligent Q-learning algorithm based on Markov model for freeway congestion control [19][20][21][22]. This algorithm has reward and evaluate function by collecting and analyzing past data. In the view of certain limitations to ramp metering, Meshkat (2015) et al. applied a prioritized control strategy to distribute traffic flow more rationally across the entire road network [23]. For the current difficulties in controlling discrete partial differential equation systems, Belletti (2017) et al. designed a new multi-intelligent parametric-free control algorithm, and showed how to realize parametric-free control based on BP neural network [24][25][26][27]. In addition, a more accurate BeATS simulator is adopted by researchers, which is the most advanced parameter control system compared with ALINEA, and achieved comparable control effect. Traffic estimation and simulation are the basis of freeway ramp metering, on this issue, Long (2018, 2019) and Gao (2019) et al. conducted traffic estimation and prediction of traffic operating efficiency using the multiple source data [28][29][30][31][32][33][34][35][36][37][38].
Basically, for a single ramp, on-ramp control can be divided into two categories: timing control and traffic sensing control. The timing control is based on the historical traffic volume data according to the preset regulation rate, so it cannot respond to the random changes of traffic volume, and it is difficult to eliminate traffic congestion. Traffic sensing control is based on the real-time traffic volume detection data to determine the ramp adjustment rate. It is superior to timing control in preventing and reducing traffic jams. The existing control strategies and methods seem to be very systematic and comprehensive, which can solve the problems of the whole system, but in fact they are very idealized. When the acquisition data is incomplete, part of the detector does not work, or the detection data is missing, those models that need to rely on complete data acquisition have limited control effect on the system. Furthermore, freeway traffic flow is a complex system, due to the traffic flow detector is limited and sparse, it is unable to obtain the parameters of traffic and state, not only the complete state in space, but also the complete information in parameters. The changeable traffic state leads to the traffic flow fluctuation and emergency events, which makes it very difficult to predict.
In this paper, a nonlinear feedback method is proposed to design an on-ramp traffic sensing controller, and the controller is simulated. To this end, this research will analyze the real profile traffic data, and provide the proper ramp metering method to Chinese freeway.

Introduction of profile traffic data
The detection of profile traffic flow is the main method currently used in China's freeways. The main technical approach of collecting traffic data is usually through various detection devices, such as loop detector, microwave detector, video detector, etc. The detection frequency can be 30 seconds, 1 minute, 5 minutes and 15 minutes. Through the collection of real-time data, such as density, speed, traffic volume, and travel time, these data are sent to the background system for storage and analysis. Thus, the road traffic status can be judged, predicted and timely processed. The data collected in this paper comes from the Changyi Freeway (G5513), mainly includes the data of main line and toll station. The main line contains the traffic flow data on different lanes, vehicle type, and location of detection points in every 5 minutes. These data can be used to estimate the traffic flow state of the main line. The toll station data covers the detailed running data of each ramp toll station, including date, vehicle license number, ramp number of entry and exit, time of entry and exit, etc. The number of vehicles entering and leaving the main line through the ramp can be counted through such information. Therefore, the travel time and travel route can be estimated according to the vehicle license and the access time.
Most of the traffic flow data are collected from the ramp of Changyi Freeway. The closed ramp flow data between different interchanges can be counted by classifying the data in March according to the number of toll station. It can be seen that the Ningxiang toll station near the city end is indeed a key section of the expressway flow based on the data analysis. This is consistent with the freeway blocking information from traffic police for closing ramp with high frequency on holidays and daily peak hours.

Macro traffic flow model at freeway on-ramp
The macro traffic flow model regards the traffic flow as a compressible continuous fluid medium composed of massive vehicles, and studies the average behavior of vehicle groups from the perspective of Hydrodynamics. It is usually focus on the overall state of traffic flow, density, and speed. The data collected by Changyi Freeway conform to the macro traffic flow model indexes. Therefore, this paper applies the macro traffic flow model to analyze the traffic state of the freeway. Fig 1 is a freeway weave section with on/off ramp schematic diagram.
According to the flow conservation principle, it is known that: Nðt þ 1Þ ¼ NðtÞ þ yDt½Q in ðtÞ À Q out ðtÞ� þ Dt½R in ðtÞ À S out ðtÞ� ð1Þ Here, Q in (t) is entering traffic flow on road section at time t; Q out (t) is outgoing traffic flow; R in (t) is entering traffic flow on-ramp; S out (t) is outgoing traffic flow on-ramp; θ is number of lanes; and ΔL is section length. N(t+1) is traffic flow in the ΔL section at time (t+1); N(t) is traffic flow in the ΔL section at the previous time. According to the definition of density: Bring Eq 2 into Eq 1: From the flow-density relation, it can be seen that: Bring Eq 4 into Eq 5: Here, Dt DL is the constant; Q in (t) is obtained by road detector; Δt is monitoring duration; V f is free-flow speed; ρ(t) is the state variable; ρ jam is jamming density. Eq 5 describes the traffic flow process of a freeway section, the initial state density of the system can be set and iteratively calculated in the control system. Therefore, Eq 5 can only be considered as a function of density and ramp entrance adjustment rate. In the following section 3.3, this model will be applied into the PID controller.

Single Ramp metering based on PSO-PID control
a. Objective of ramp control. According to the traffic flow theory, traffic density is the key parameter to reflect the traffic congestion level. If the traffic density exceeds the critical density, the traffic will become very crowded. Although the on-ramp flow is reduced, the congestion still needs a long time to return to normal. Therefore, the goal of ramp metering is to guarantee the traffic density not exceed the critical density, and generally maintain the density in the negative neighborhood of the critical density, that is, ρ d = ρ c -ε, where ρ d is the expected density, ρ c is the critical density, and ε is an appropriate small positive number.
b. Design of PSO-PID controller. Nowadays, with the rapid development of computer technology, many new control methods have emerged, but the classical closed-loop control theory of PID is still widely used in engineering field at present because of its simple principle and good adaptability. The PID control is a kind of feedback control, which is based on the input and output control of traffic flow. Although it cannot have a very clear grasp of all sections and spaces of the whole expressway, it can control the relationship between their input and output according to the state of some important sections, such as the merging point of on-ramp, the diverging point of off ramp and some important sections. The PID control is concerned with the variables and compared to the expected values to correct and control the system response. It has a complete set of parameters setting and design rules, which can be easily mastered by freeway policemen.
However, the parameters of PID cannot be adjusted in real time. Particle swarm optimization (PSO) is a method to achieve the optimal solution by interacting information within the population, and it provides a new idea to control the traffic demand. According the macro traffic flow theory, the freeway traffic flow estimation method based on profile data is proposed. The intelligent adaptive PSO-PID controller for freeway on-ramp is introduced into the ramp metering.
The traditional PID control method needs the accumulation of all the errors in the calculation, and the calculation is massive and complicated. Therefore, the PID control method applied in this paper is the incremental PID control based on PSO algorithm. It is a kind of on-line adaptive PID controller with good adaptability and robustness. The output of incremental PID control is Δu(k). With regard to the above formula subtraction, the incremental expression is obtained: Different with the positional PID control, the incremental PID control does not need to accumulate e(k), the state is only related to the previous state, and has little action error, so a better control effect can be achieved in control. When PSO generates a particle swarm, the particles in the group are assigned to the parameters K p , K i , and K d in the PID controller at once, so the density performance index is obtained by running the system. Transfers the difference between output density and expected density to PSO as the adaptive value of the particles, and finally judges whether the algorithm can be exited. The specific process of PSO-PID control system is shown in Fig 2 flow chart of PSO-PID control system. As can be seen from Fig 2 above, the PID control system is a closed loop feedback regulation system. In the initial state, the density is assigned to expected densityρ d (k), and the P, I, and D parameters are determined by the PSO optimization algorithm. e(k) is the error signal, when the error occurs, the controller will take effect immediately to reduce the error and meet the requirements. The PID control output is increment Δr(k) which is converted into control variable ramp regulation rate r(k), and put r(k) into the macro traffic flow model. The input flow q in (t) is known as external disturbance variable, and the output variable is state densityρ(k +1) according to the road detector. Z is the transfer function. This density then be fed back to the controller and compared with the expected density in order to re-adjust the PID controller parameters. The process cycles back and off until it converges. After optimization in the program, the input of PID controller is as follows: xð2Þ ¼ errorðkÞ ð9Þ Here, error _ 1 and error _ 2 respectively represent the difference error in the state of k-1 and k-2. The output of the incremental PID controller is: In the control system shown in Fig 2, the actual traffic flow density can track the desired traffic flow density by adjusting the on-ramp regulation rate. This feedback control can suppress the model error and disturbance input noise of expressway.
Assuming a population composed of N particles in a D-dimensional search space, in which the i particle represents a D-dimensional vector X i = (X i1 , X i2 ,� � �,X iD ) T and represents a potential solution of the problem. The fitness value corresponding to the position X i of each particle can be determined by the objective function. The velocity of particle i is (V i1 , V i2 ,� � �,V iD ) T , the individual extreme value is P i = (P i1 , P i2 ,� � �,P iD ) T , and the population extreme value is P g = (P g1 , P g2 ,� � �,P gD ) T . In the iterative cycle process, the particle updates the velocity and position information through its extreme values P i and P g , that is: Here, ω is the inertia weight; d = 1,2,3. . .D; i = 1,2,3. . .n; k is the current number of iterations; V kþ1 id is the velocity of particles under the current number of iterations; C 1 , C 2 is the acceleration factor, and C 1 , C 2 2R + ; R 1 , R 2 is a random number distributed in the interval [0,1]. According to main line data of traffic station investigation and every 5 minutes running data from toll station in April, the 13 hours traffic data from 5: 00 A.M. to 17: 00 P.M. during the Qingming Festival on April 5 are analyzed, as shown in Table 1 below:

Single ramp metering control simulation
The simulation parameters in the model are set as follows: number of lanes is λ = 2, freeflow speed is V f = 97.3km/h, jam density is ρ jam = 74 vehicles/km/lane, critical density is ρ cr = 36.14 vehicles/km/lane, and simulation time step is set as Δt = 20 seconds.   In the absence of control measures, after about 300 minutes, the main line density rises steadily and forms a long period congestion. If there is no intervention, the congestion will inevitably increase and spread to the upstream. The overall control system tends to converge at approximately 80 minutes after 240 iterations. Due to the large traffic flow input, the parameters need to be preliminarily iterated, which will cause density shake obviously and make the ramp control system in an unstable state in the initial stage of ramp metering. Due to the large traffic flow input, the parameters need to be preliminarily iterated, which will cause density shake obviously and make the ramp control system in an unstable state in the initial stage of ramp metering. However, with the real-time control and traffic flow adjustment, the input is more and more stable, the PID control parameters are gradually stable, as well as the freeway traffic flow. The ramp entry rate can be controlled in real time based on the real-time upstream traffic flow data. Meanwhile, by learning from PSO algorithm, the PID parameters are changing in real time, which reflects the significance of intelligent traffic management in freeway ramp metering. The result shows that the PSO-PID ramp metering has a good effect on the density control.
The PSO is compared with the BP neural network in order to show the advantages of PSO. The dimension of the input and output layer in BP neural network is completely determined according to the operators' requirements. The three parameters are the output of on-ramp metering, so the output layer will have three nodes. The control quantity, i.e., the regulation rate of the on-ramp, is obtained through progressive propulsion. It should be noted that the input quantity must be detected and has a great impact on the output quantity. In addition, it is also required that each input variable has an independent relationship with each other. The parameters adopted here are the same input flow data and system parameters.  It can be seen that the PID ramp metering system using BP neural network tend to converge in about 150 minutes after 450 iterations. Compared with PSO, the convergence speed of BP neural network is 70 minutes slower, and the number of iterations is 210 times more. The density with PSO is closer to the given ideal density, and the oscillation degree is obviously less than that of BP neural network.

Conclusion
According to the running data collected by toll station and profile detectors, the intelligent PID control is proposed based on macro traffic flow model, and it is optimized by the PSO for the single ramp metering. It can achieve the control goal of smooth traffic flow on main line section near on-ramp and keep the density near the expected value all the time. An example simulation experiment based on the MATLAB is carried out in the Youren Interchange of Changyi Freeway. The results show that the PSO-PID control system has rapid convergence speed and better effect. With the PSO-PID control of ramp traffic flow, the main traffic flow becomes stable, and the freeway tends to be stable simultaneously. As a comparison, the paper uses BP neural network to optimize the PID control parameters in the same simulation, the result shows that the convergence speed of PSO-PID control is faster than the BP neural network-PID, but there is little difference in convergence accuracy. The service level and actual density of the freeway main line and on ramp can keep in an ideal range by adopting the PSO--PID control. Moreover, the traffic flow rate and traffic safety of expressway can be improved, and the total travel time and the accident rate during peak period can be reduced. Furthermore, the ramp control not only can optimize the travel efficiency of the main sections, but also for the connecting urban roads at the exit ramp.
The most obvious practical difficulty in implementing our approach is the data accuracy issue for freeway operators since it is often the case that the detectors on the mainline are spares and the data collection usually takes a long-time interval. To solving this problem, the transportation authority could take the lead and make the real time data collection possible. For future research, we are interested in extending the developed model to integrate both single and multi-ramp metering in order to obtain an optimal traffic flow input allocation during the holidays and peak hours.