Home > Computer science essays > Traffic Simulation Using Cellular Automaton Model for Closed Loops

Essay: Traffic Simulation Using Cellular Automaton Model for Closed Loops

Essay details and download:

  • Subject area(s): Computer science essays
  • Reading time: 14 minutes
  • Price: Free download
  • Published: 26 March 2022*
  • Last Modified: 29 September 2024
  • File format: Text
  • Words: 4,006 (approx)
  • Number of pages: 17 (approx)

Text preview of this essay:

This page of the essay has 4,006 words.

Abstract

The project aims to demonstrate the use cellular automaton model to describe vehicular traffic on a freeway for a one lane and two-lane road. Properties of the system like the flow, critical density, average car speed and congestions have been represented under some constraints and analysed. The phenomena of stop-start waves have also been observed. The programming language chosen was Python, for its strong power in graphical representation which is critical for the project.

1. Introduction

Drivers spend many hours of their lives stuck in traffic congestion, some large jams can have no obvious cause. In London, commuters spend more than 3 days a year in congestions [1]. Scientists, from as early as the 1930s [2], has been in the conquest of modelling the problem to explain its emergence and effective methods to deal with it. The problem is of special interest to statistical physicists who develop computer simulations with only indispensable constraints, allowing a clear representation of some properties of real complex traffic. Theoretically, there are two fundamental skeletons followed to approach the problem: (1) Macroscopic: treat the system as a compressible fluid focusing on overall features and (2) Microscopic: treat the system as a chain of cells, focusing on individual elements behaviours [3]. Traffic Cellular Automata (TCA) approach, as replicated in this project, is a microscopic model. The introduction of the approach was on the hands of Kai Nagel and Michael Schreckenberg in 1992, whose basic, probabilistic model for a single lane highway (called NaSch model) served as the basis for all other TCA extensions that followed [4].The approach used four very simple but crucial ordered steps and was the first to reproduce the effect of human behaviour on traffic and generate results mimicking real traffic data [5]. Additionally, in 1996, Nagel, Schreckenberg, Rickert and Latourd, published an extended model allowing two lanes of cars, where cars can change lanes when necessary, under certain additional safety rules [6].

2. The Model

Generally, TCA are ideal, discretised models; Variables like position (x), speed (v), acceleration (a) and time (t) vary in discrete integer steps existing in distinct states. The models are generally deterministic but can be made stochastic using simple procedures.

Furthermore, the basis for the TCA models is to reflect macroscopic quantities using very basic microscopic dynamics. This is done through building a big enough system of cars such that the abnormalities of individual elements (cars) cancel out on average and, overall, familiar effects are mimicked, like spontaneous congestions; A phenomenon explained by the concepts of fluid dynamics [7].

When producing most plots, it was common to see fluctuations and deviations in quantities (e.g. flow), one had to take the average of such quantities. A choice was made between averaging over a long time (time average) or averaging over many copies of the system (ensemble average) to use the latter. The reason is the number of iterations needed to produce the same smoothing effect was significantly more for the former than the latter; This consumed huge computer power and took longer time, hence, less efficient. Any averages mentioned below are ensemble averages.

2.1 One Lane Model

The single lane model (SLM) assumes an array of (L) sites (or ‘cells’), each either containing one car or being vacant. After initial random distribution of cars over sites, if a car (i) is present at a given site (x_i), it is randomly assigned an integer velocity (v_i) between (0) and a maximum (v_max) as shown in figure (1). The system is taken to have periodic boundary conditions, meaning the total number of cars in the array is constant and a car at the final site moves back to the first site after a step of time as if in a single loop. Initially, sites are randomly filled with cars and assigned random velocities within the appropriate range. In one time step (t→t+1), the system undergoes an ‘update’ of information (i.e. its velocity and position change).

This update is defined by a set of four rules, applied in order, simultaneously for all cells. If gap between cars is given by (s_i = x_(i+1)- x_i) at a time (t), the steps mathematically read:

Acceleration: If v_i

Deceleration: If s_i≤v_i ,〖 v〗_i→s_i-1

Randomization: With a probability (p), v_i→v_(i-1)

General Motion: x_i→x_i+v_i for all cars simultaneously.

The rules above are very sensible as they provide the bare minimum to sustain a realistic model of human behaviour on a freeway. The account for human decision-making effect is observed in the first rule, reflecting the driver’s will to move as fast as possible. The second rule is a safety measure, there to avoid accidents when drivers accelerate by specifying a minimum distance between a car and its neighbour in following cell. The third rule, which implies that occasionally the driver might slow down for external reasons, is at the heart of why spontaneous congestions arise. The final step puts system in dynamic motion [5].

To convert the arbitrary units of this report into real life units, the speed limit (v_max=5) was taken to be the UK national speed limit (70 mph=30 ms^(-1)), giving each velocity unit to be (6 ms^(-1)). At the most extreme case, the stopping distance, due to drivers’ reaction time and breaking time, for a car breaking from the national speed limit to rest would be (96 m) [8]. However, to make the distances between cars realistic, each time step is equivalent to (2s) and the length of one site is (12 m).

A space-time diagram of the situation traffic lane can be plotted. Figure (2) compares real traffic data with the data simulated. Both are in agreement, showing similar main features like the spontaneous congestions moving backwards relative to cars, proving the model’s capability of demonstrating the phenomenon.

In the plot, the cars enter from the left-hand side, and time moves in the downwards axis direction. The jams are shown as light grey regions with a steep positive gradient whereas the flow lines (with a colour gradient shown in figure) have a slight negative inclination.

The vehicles with higher velocities slow down to enter the jams and remain there with only slow advances. The vehicles regain their speeds by accelerating once reaching end of the congestion. Such behaviour, seen in Figure (2), is called a ‘start-stop wave’, but colloquially know by many names such as phantom jams or ‘Jamitons’ (!source x2), as the driver can find no obvious cause such as accident or breakdown [5]. Such waves of congestion move backwards relative to the road; They are phenomenon that can be explained by studying the system using concepts of fluid dynamics by looking at the evolution of continuous quantities (e.g. velocity) of the system not individual cars.

The traffic flow is not much different from that of a classical fluid; The boundary conditions conserve the number of cars, leading to a continuity equation, relating the density with the velocity of the whole system and an additional partial differential equation (PDE) describing the evolution of velocity with time subject to factors affecting it [9]. These equations constitute ‘second order’ models, the base of which is the Payne-Whitam model, which acknowledged that applying the continuity equation alone to the system, assuming equilibrium, fails for light traffic [10]. The Aw-Rascale model addressed the main differences between a car traffic model and fluid flow, accounting for fact that cars only respond to incidents in front of them but not behind, unlike fluid particles responding to both [10]. Moreover, for large densities, the stability of the coupled PDEs linearly falls. Hence, if the array of cars is initially at constant separation, a small disruption to the system will lead to formation of a high-density wave of cars. The jamitons are stable waves and only passes by very cautious driving or decrease in densities. They also take the form of ‘detonation wave’, where there is a sever density rise one side then a smooth decay on the other side [11]. The reason why they move backwards relative to the flow is due to the speed of the traveling waves being always less than that of the whole car system [12]. Finally, jamitons can induce further disturbances later in the road, called jamitinos [11].

The important properties of the system, the constant density (ρ) and the global flow (F), are given by [13]:

ρ=(Number of cars on the road)/(Number of sites on the road)

and,

F=mean velocity × number of cars on the road

respectively.

Using these relations, one can plot what is known as the fundamental diagram, which plots the global flow against density. The fundamental diagram taken from real traffic data of a single lane and the fundamental diagram for the simulation of a single lane using the methods discussed above are shown in Figure (3). Both diagrams show a triangular-shaped curve with a transition point from positive to negative slope. The first part of the curve occurs for low densities where the cars barely interact with one another. Hence, all the cars will theoretically be moving at the maximum speed and flow of cars increases linearly as the density increases up to a maximum value. This flow for the linear part is called ‘Laminar’ flow. The density where the flow is a maximum, and the gradient is therefore zero, is called the critical density (ρ_criticial). After this point, in the region of the congestion densities, the flow starts dropping as density increases as start-stop waves start forming [14].

The fundamental diagram and () against density for varying speed limits is shown in figure (4). The critical values obtained from each graph matches for each maximum velocity. Before the critical density, the cars rarely interact with each other, so the mean velocity is constant at just below the speed limit. At the critical density, there is a sharp decrease in (). As the speed limit increases, the critical density decreases because in one-time step, the cars can move further in a time step, and can catch up to any slower cars ahead. Thus, the cars will start bunching up to form jams at smaller densities and hence lowering the critical density at which there is maximum flow. The critical density decreases with increasing (v_max), so at high densities, lower speeds can reduce traffic jams, even if the total flow is less.

Such behaviour, shown in Figure (4), implies that traffic moderators have a choice between maximising flux on a highway by increasing maximum allowed velocities or to maximise the number of cars that can still travel in the laminar region and hence reduce jams. Thus, increasing speed limits on freeways is not always the ideal solution to improve flux and can worsen congestions. The behaviour described encouraged the notion of smart motorways in the UK. Technology is used to monitor congestion levels and number of cars on the road, and the speed limit is adjusted accordingly. At busier times, the speed limit is set below the national limit, to reduce traffic jams [15].

Additionally, due to ‘particle-hole symmetry’, if (v_max=1), the fundamental curve is be symmetric about ρ = 0.5 [16]; While this is observed in this simulation, it does not however hold in real traffic and asymmetry is observed. Particle hole symmetry is a result of treating the array of cars as N indistinguishable particles (with density ρ) moving within a lattice [17]. Those particles will satisfy an exclusion principle that is two cars (particles) cannot occupy the same site at the same time. The parallel updating nature of NaSch model allows the treatment of a car (particle) moving into an empty site as an exchange between the particle and a hole in opposite direction. This means motion of the particles into holes with density ρ is equivalent to motion of the holes with the complement density. This holds only for (v_max=1) because the problem is binary with that limit; A car either moves or not.

The probability (p) of the driver decelerating due to external factors was then varied, as shown in Figure (5). As p increases, the flow decreases significantly. The velocity of each car more likely to decrease, and so the average velocity and hence flow will decrease. Additionally, this will in turn cause faster cars to get closer to the newly slowed down cars ones more often, have to slow down by the safety rules, and therefore the speed of the whole system drops at a smaller density. This decrease in speed is represented through the flow drop observed at smaller critical densities.

Figure 5: The Fundamental diagram showing flow against density for different values of the breaking probability (p) using v_max=5. The curve shows the expected behaviour, having a transition point at a particular critical density fir each (p) value. The critical point shifts to the left and down with increasing (p).

2.2 Two Lanes Model

In real roads, there are different types of cars moving at different speeds, leading to a fair number of faster cars following slower ones. If only one lane existed, faster cars will have to decelerate, and the maximum speed of the road would fall down to that of free-flow velocity of the slow cars [6]. Therefore, an appropriate extension to the model in Section 2.1 is needed to allow cars to move to another lane when they are obstructed by slower ones.

A two lanes simulation was produced based on the Rickert-Nagel-Schrecknberg-Latourd model (RNSLM), which appropriately extends the NaSch model by adding rules to the aforementioned steps, governing the transition of a car from one lane to another. The model still assumes periodic boundary conditions, but now with two parallel arrays of cells. The system modelled is symmetric, meaning that the cars have no preferred lane; They stay in their lane if there is no reason to switch. Symmetric roads are experienced within cities, where there is no ‘fast’ and ‘slow’ lanes. Most UK highways, however, will have asymmetric lane changing rules, drivers should aim to drive on the left-most lane when road ahead is clear. The symmetric rules are, nonetheless, more suitable for theoretical studies [6]. To show human behaviour, the model is stochastic meaning drivers can sometimes choose to not switch lane, even if they can.

The simulation assumes cars move horizontally between lanes. Although such assumption is far from real (cars cannot move in purely horizontal lines), it is made more acceptable when followed by parallel updating of both lanes independently, using the arrangement that resulted from horizontal movement, by applying the NaSch single lane steps.

Before introducing the new rules, new variables and parameters need to be defined. q is the probability of a driver choosing to switch lanes when they have the chance and ρ_2 is the density of the new lane, which is not necessarily the same as ρ for lane one. Additionally, the following new variables need to be initiated:

Number of free cells in front of a car in its own lane, g(i).

Number of free cells in front of the car in the other lane, g_new (i).

Number of free cells behind the car in the destination lane, g_(new,behind) (i).

Velocity of the closest car behind car (i) in the destination lane, v_(i,behind)

For a given car to be allowed to switch lanes, the following rules need to be satisfied:

g(i) g(i).

The site in destination lane, right next to the car, is empty.

g_new (i)>v_i.

g_(new,behind) (i) > v_(i,behind).

Nevertheless, to randomize the model, even if a car satisfies all the above conditions, it switches lane with a given probability q.

The first two rules are to determine whether it would benefit the car to change lane. If both satisfied, the car must abide by the safety rules (3) and (4). Rule (3) states a car cannot occupy a cell that is already occupied. Rule (4) states when a car switches lane, its velocity needs to be smaller than the gap in front of it so that when a time update takes place, they don’t collide. The final rule is to make sure the transition of the car does not obstruct cars behind it on the destination lane. Cars will follow all the rules and, if satisfied, will switch with a probability (q) to the new lane. The aforementioned NaSch rules are applied to each lane in parallel to move the system in time.

Figure (6) is the space-time diagram for each lane at the total critical density of !. Start-stop waves are observed at the same time and place for each lane- if there is a jam in one lane there will be a jam in the other lane, otherwise, cars would have moved to the emptier one. Do the density modelled, various jams are observed for both lanes as expected.

As before, the fundamental diagram for the two lanes can be produced for the total flow across both lanes as shown in Figure (7).

The simulation shows that there is an increase in maximum total flow in comparison to the single lane simulation, indeed more than twice. Two lane roads more efficient than two independent single lane roads, as demonstrated in the right-hand side of figure (7) through the rise in maximum flow for the (q=1) compared to the (q=0) curves by more than 10%.

This is attributed to cars moving to the emptier lane if it is beneficial to their speed, which contributes to the total flow of the system.

The left graph of Figure (8) compares the number of cars switching lanes against time. This shows that even for the extreme case of wildly different densities and low (q), the number of cars switching lanes is initially high. Very quickly, the lanes become similar densities and the only a few cars change due to the random fluctuations.

The right graph of Figure (8) shows the number of lane changes per cell and time step, as a function of density. The diagram shows a near quadratic up to relatively high densities, suggesting that the probability of change is proportional to square of density. This demonstrates the large density range over which the validity of an analytical mean field description of the system interactions holds [6]. It is also clear from Figure (8) that the maximum number of lane changes occurs at higher densities than ρ_criticial which is justified by the fact that cars will tend to change their lane more frequently when many congestions are forming, as happens after the critical density in the congestion region of the fundamental diagram. After this peak in the number of lane changes, the curve will show a negative gradient, explained by the fact that at very high densities, both lanes will be experiencing heavy traffic and a car would find it harder to meet the safety conditions to move to the new lane. The frequency of lane changes shows an expected rise as the value of (q) increases.

3. Analytical Methods and Improved Methods

Many approaches have been proposed to describe the NaSch model with approximate, analytic results. The analytical techniques for the RNSLM or other multiple lane models are quite complicated and not discussed here.

The simplest analytical technique is through mean-field theory (MF) [18]. The simplicity of the theory lies in the fact that correlation between different objects of a system it is describing, are ignored. In the case of TCA, this assumption means that two vehicles at neighbouring sites have no effect on one another. Since the model is microscopic, the theories used to approximate it are microscopic as well, including (MF).

However, the flow calculated is found to be an underestimate for parallel dynamics (where all cells are updated per time step in parallel). Thus, we can conclude that correlation between cars increase the flow and are not insignificant. This flow increase suggests a ‘particle-hole’ attraction, meaning that there is a bigger chance of finding a car near a vacant site [18].

Many improved MF theories that include correlation between cells are already in place, describing the behaviour of the fundamental diagram ever more accurately.

For example, cluster approximation provides accounts for short-range correlations; In n-cluster approximation, the array is grouped into clusters of length (n) sites that are self consistently coupled to the rest of the system [19] [18]. The 2-cluster method gives exact solutions for (v_max=1) and small clusters give spectacular overlap with simulations for speed limit of 2 [20]. Additionally, the mean field theory doesn’t take into account what is known as ‘paradisical sates’; States that are ‘dynamically forbidden’ and are only unreachable for parallel dynamics. Such a state would be the situation of a car of speed (v) following a car of speed (v+1) with no empty cells in between implies the presence of the two cars in the same cell in the NaSch model. Finding those states and getting rid of them then applying MF gives the paradisical mean field treatment, enhancing the results [20]. Finally, there is the car-oriented mean field approach, which treats takes the dynamic variable of the system to be the separation between cars rather than the site occupation which adds the effect of some long-range correlations [21]. The two last techniques give exact solutions for v_max=1.

The Nagel-Schrecknberg model is capable of showing stop-go waves and a qualitative shape of the fundamental diagram. However, it fails at it shows peculiar behaviour for large speed limits (as v_max→∞) and the deterministic limits (p=0 or 1) do not show some essential properties of the system [22]. As mentioned before, it is also a minimal model with many extensions that can be built on it by changing or adding to the steps in section 2.1 and it fails to show hysteresis and metastability effects found in the continuum limit of the cells (with discrete time steps) [7].

Some models branched out from NaSch by changing the deceleration rules, showing the desired effects. Cruise-control limit and self-organized criticality, the behaviour of the cruise-control option in cars keeping which fixes the speed at a chosen speed. The method applies same rules as NaSch except that vehicles travelling at (v_max) are not subject to noises by applying the randomization step only to cars with smaller velocities [23]. At particularly low densities, cars all move with their maximum speed in pure deterministic matters, only ever perturbed with very small rates giving them recovery time to the deterministic state separating the timescales for perturbations and responses [24]. A boundary condition is used that enables the system to find its maximum flux state; It exhibits ‘self-organized criticality’ [7] [24]. Other set of models add a slow-to-start rule to NaSch and come in three different variations [25]. One is by letting a car that is still at a given time with a vacant cell in front be allowed to accelerate only with a given probability while other cars accelerate deterministically then follows the rest of the NaSch steps for all cars [7]. Another variation is to add a rule after the acceleration step that all cars that had to break during an update will only be allowed to move when an opportunity comes with a given probability [25]. Finally, the Velocity-Dependent-Randomization (VDR) model adds a step (0) to NaSch which determines a speed-dependant parameter based on information from previous time step, which controls the randomization probability in step (3).

4. Conclusion

The models used in this report predict the nature of traffic to a high degree of accuracy on a macroscopic scale. However, by simulating cars to change lanes horizontally instead of diagonally. Stopping distances vary for different speeds, which has an effect on the probability of slowing down. Drivers will naturally slow down if they can see a traffic jam ahead and they are going at higher velocities, hence p is realistically a function of the speed of the car and the next few ahead.

The simulations and results discussed here are only hint of the many different extensions to the NaSch model. Indeed, more research into the effects of introducing traffic lights, breakdowns, bottlenecks or more lanes could be done. The models used in this report are important for designing new motorways and roads, in particular deciding the number of lanes and speed limits to maximise the flow based on how many cars are likely to be using it.

2018-4-29-1525008174

About this essay:

If you use part of this page in your own work, you need to provide a citation, as follows:

Essay Sauce, Traffic Simulation Using Cellular Automaton Model for Closed Loops. Available from:<https://www.essaysauce.com/computer-science-essays/traffic-simulation-using-cellular-automaton-model-for-closed-loops/> [Accessed 15-11-24].

These Computer science essays have been submitted to us by students in order to help you with your studies.

* This essay may have been previously published on EssaySauce.com and/or Essay.uk.com at an earlier date than indicated.