Waves, not cars - modelling traffic as a fluid
By Mats Vermeeren
Summary
Topics Covered
- Traffic Waves Move Backward Against Traffic Flow
- Track Density Waves, Not Individual Cars
- Traffic Jams Are Mathematically Inevitable
- Speed Limits Prevent Congestion Before It Exists
Full Transcript
On British motorways, temporary speed limits are often imposed to avoid congestion.
This seems a bit counterintuitive. You think that either there's no queue and the speed limit inconveniences everyone, or there is a queue and all traffic is going much slower than the speed limit. Anyway, what's not so obvious is that the speed limit can help avoid the queue in the first
limit. Anyway, what's not so obvious is that the speed limit can help avoid the queue in the first place. This video explores a simple mathematical model of traffic flow which we can use to explore
place. This video explores a simple mathematical model of traffic flow which we can use to explore this phenomenon. An interesting way to think about traffic on a large scale is as a fluid. To model
this phenomenon. An interesting way to think about traffic on a large scale is as a fluid. To model
a fluid, we don't usually think of individual molecules, but rather of macroscopic properties such as its density. In the same spirit, we can plot the density of the traffic and disregard the position of the individual cars. So, let's draw a plot of the traffic density, which we
denote by the Greek letter rho. As the cars move along the road, the plot of the density will change shape. Can we predict how it will change over time without modelling the actual cars?
change shape. Can we predict how it will change over time without modelling the actual cars?
Put differently, how do we model traffic if all we know is its density? A first step is to estimate how fast a car would be driving depending on the density of the traffic it's in. A fair assumption is that the denser the traffic is, the slower the cars will be. When traffic is very light, cars
drive at their maximum speed, v_max. When there is some traffic, cars drive at some slower speed. And
when traffic is bumper to bumper, the cars don't move at all. So the graph of speed over density may look like this or like this or different still. For now, let's take the simplest possible option, a linear relation. The graph is a straight line connecting a certain maximum speed when
the density is zero to a speed of zero when the density is maximum. Let's normalize density and speed. This means we choose units of density and speeds such that the maximum density and maximum
speed. This means we choose units of density and speeds such that the maximum density and maximum speed are both equal to one. This will simplify the formulas a little. When analyzing road traffic, a key quantity is the flow. The amount of cars passing a fixed point in a unit of time.
The flow is equal to the traffic density times the speed of the cars. In our model, the flow is a quadratic function of density. Rho minus rho squared. Its graph is a parabola which reaches its maximum at half of the maximum density. To turn these graphs of speed and flow into an equation
for how the density evolves, all we need to do is to look at the conservation of the number of cars.
Our model should not create or remove cars. From this, we can derive an equation for traffic flow.
If you prefer to look at the visuals first, you can skip to the next section of the video. To start the derivation, consider a short stretch of road,
video. To start the derivation, consider a short stretch of road, say between coordinates x and x plus epsilon. The total number of cars in this interval is approximately given by the length of the interval, which is epsilon times the density
rho at x. The number of cars going into this interval per unit time is given by the flow q at x. And the number of cars leaving the interval in the same unit of time is the flow q at x plus
at x. And the number of cars leaving the interval in the same unit of time is the flow q at x plus epsilon. So the change in the number of cars N over time is given by the difference in flow at
epsilon. So the change in the number of cars N over time is given by the difference in flow at x and at x plus epsilon. On the left hand side we can plug in the formula for the number of cars.
Now let's divide by epsilon and bring everything over to the left hand side.
Letting epsilon tend to zero, we recognise the derivative of q with respect to x. So we
find that the time derivative of row plus the space derivative of q equals zero.
With the chain rule that turns into this equation relating the time derivative of rho to its space derivative. In our model where q is rho minus rho squared, the factor d q / d rho is equal to 1 - 2
derivative. In our model where q is rho minus rho squared, the factor d q / d rho is equal to 1 - 2 rho. Equations like this are called partial differential equations. The word differential
rho. Equations like this are called partial differential equations. The word differential indicates that they involve derivatives. The word partial that there are derivatives with respect to several variables, here t and x. There is no general method to solve partial differential
equations. But this one allows a nice trick known as the method of characteristics. The inspiration
equations. But this one allows a nice trick known as the method of characteristics. The inspiration
for this method comes from looking at a nearly constant traffic density with a small disturbance.
We see that this small bump in the density moves at a constant speed and this speed is smaller than the speed of the cars. In heavy traffic, the bump even moves backwards against the direction of traffic. This suggests that we should not be tracking how individual cars move,
but how waves of constant density move. Imagine a helicopter flying over the densest bit of traffic. It does not follow an individual car. It follows a wave in traffic.
A space-time plot of the helicopter's trajectory is called a characteristic.
It is a line formed of points in space-time which all have the same traffic density.
Let's draw many different characteristics so that the space-time plot is almost filled with them. If
we want to know the traffic density at a certain point with space-time coordinates x and t, all we have to do is to find a characteristic that goes through the point (x,t) and the density at that point will be equal to the density at time zero at a point where the characteristic originated.
Now, how do we know what the slope of a characteristic should be? Or put differently, what speed the helicopter should be doing to make sure it sees the same density at all time. Suppose
the helicopter is flying at a certain speed c. The change it will observe in the traffic density rho is made up of two parts. One part is how rho itself is changing through time. The other part is due to the helicopter's motion. It's given by the helicopter's speed c times how rho is changing in
space. We want the helicopter to see a constant density. So we want this total change to be zero.
space. We want the helicopter to see a constant density. So we want this total change to be zero.
If we compare this to the partial differential equation for the traffic density, we see that the equations are almost the same. In particular, if c is equal to d q / d rho, then the helicopter will see no change in density. And this is exactly what we want. So this is the formula for the speed
of the helicopter or in more abstract terms for the slope of a characteristic. Recall that in our model, the flow q is a quadratic function of the traffic density rho. And we find that the slope
of the characteristic is 1 - 2 rho. Note that in light traffic, when rho is less than half, c is positive so the characteristics slope forward. But in heavy traffic, when rho is greater than half,
c is negative so the characteristics slope in the opposite direction. Conversely, if we see the plot of characteristics, we can tell by their slope what traffic density they correspond to. Suppose
we want to reconstruct the plot of density at a certain time. First, we draw the horizontal line corresponding to this time in the space-time plot. Then for each x-coordinate we look at the slope c of the characteristic intersecting our line at that x and from its slope we know the density.
Sloping backwards means high density sloping forwards means low density. This way we can read off the density profile at a certain time from the plot of the characteristics. When the initial traffic density is decreasing along the road like this, the characteristics will fan out. The gaps
between characteristics are not a problem because mathematically there are infinitely many of them.
The gaps are there because we chose to draw only a few. So if we find that a gap is getting too big, we can simply draw an additional characteristic in the gap. Or if you prefer, we could have drawn these extra characteristics from the start. If the initial traffic density increases from left
to right, the characteristics slope towards each other. At some point, they will intersect. Now,
if we have several characteristics going through the same point, we will find several different values when we try to reconstruct the density curve. So instead of the graph of a function, we get a meaningless S-shaped curve. So we cannot have intersecting characteristics! Instead,
when characteristics meet, they form a shock. This corresponds to a jump in the graph of density over x. The speed of the shock will have to be somewhere between the speeds of the intersecting
over x. The speed of the shock will have to be somewhere between the speeds of the intersecting characteristics. If you're wondering about the exact speed of the shock, this is determined by
characteristics. If you're wondering about the exact speed of the shock, this is determined by the fact that the flow into the shock should be the same as the flow out of the shock. But
this is not the absolute flow q, but the flow as observed by someone moving with the shock.
You can pause here to see a derivation of the speed of the shock. Now we have all the tools to solve the traffic equation with the method of characteristics. Let's look at a few examples.
First, let's consider a big lump of traffic on an otherwise nearly empty road. We see that a shock forms at the tail end of the queue. Initially, it moves backwards quite quickly, but then it slows down and the size of the jump in density starts to go down as well. In real traffic,
a shock is not concentrated in a single point like on our graph, but slightly spread out over a section of roads. Furthermore, our model does not take into account that good drivers look far ahead to anticipate what will happen and adjust their driving accordingly. This will also help
smooth out traffic compared to what we simulate in this model. But on a large scale, our model often gives a good indication. Next, let's look at a lump of denser traffic on a road that already has heavy traffic. Remember that heavy traffic means that the density is more than half the
maximum density and that the characteristics slope backwards. Again, the shock that is formed moves backwards and now it keeps going backwards and the peak in density stays large. This is the situation when on a busy motorway, traffic can be flowing nicely one moment, but the next instant you see
a wall of brake lights moving towards you. Let's go back to light traffic with a region of somewhat denser traffic but remaining less than half the maximal density. Maybe you'd expect the lump to be smoothed out without issue, but a shock is still formed. However, in light traffic like this,
shocks move forward just like the characteristics. This means that from the perspective of a driver, the relative speed at which you approach the shock is much lower than in heavy traffic. Combine this
with the fact that real life shocks will be a smoother version of what we simulate here, and it seems plausible that a shock in light traffic may not even be noticeable to the drivers.
In any case, it will be a much gentler affair than a shock in heavy traffic. Next,
let's look at a traffic light. When the light is on red, our model doesn't really apply to what is beyond the traffic light. But since no traffic can go past the red light, we could imagine the rest of the road to be completely full, with characteristics sloping backwards.
After all, a completely full road is also a way of modelling traffic that isn't moving forwards.
Unsurprisingly, a shock forms at the back of the growing queue. When the light finally goes green, the initial traffic density is at its maximum on the left and zero on the right. This gives
us the most extreme version of characteristics fanning out. The corresponding density plot after some time is a linear interpolation between bumper-to-bumper traffic on the left and an empty road on the right. Note that the distances from the traffic light to the regions with full or zero
density are the same. So if you imagine traffic going both ways, this would mean that the car in the queue starts moving exactly when the first car going the other direction drives past it. Our
model is way too simple to accurately capture such details of real life traffic. But still,
when you're stopped at a pedestrian crossing, it does seem that often you start moving around the same time that the cars going the other way start coming past. Let's return to the motorway where now the traffic density is half the maximum density on average but fluctuates quite a lot.
We see that many shocks are formed and only very slowly do they decrease in size. It takes a very long time for the density to approach a uniform one. However, in real life, sooner or later, a careless driver will force another to slam on the brakes, creating new fluctuations,
which then lead to new shocks. Is there anything the authorities could do to minimize the effect of such fluctuations on a fairly busy road? There is, but it's a measure that isn't always welcomed by drivers. They could impose a speed limit. Let's go back to the basics of our model. So far, we
drivers. They could impose a speed limit. Let's go back to the basics of our model. So far, we assumed that the speed of the traffic is a linear function of traffic density. But if we impose a speed limit, then the graph changes to look like this. Here the speed limit we chose is the speed
cars with two at half the maximum traffic density. The graph of traffic flow that is density time speed now changes from a parabola to something that has a straight line as its first half. This
is notable because the slope of this graph is what determines the slope of the characteristics.
So with a speed limit, all characteristics corresponding to light traffic (less than half the density) will have the same slope. Indeed, if traffic is light everywhere, the density profile now just moves to the right. Since all cars are driving the speed limit, the shape of the
graph does not change. It just moves to the right uniformly. But if we look back at the fluctuating traffic density from earlier, the shocks are dissipated much more quickly if the speed
limit is imposed and the traffic uniformises to a density of half the maximum density quite quickly.
Compare this to the situation we showed earlier with the same initial traffic density and no speed limit. On the same time scale, there are still several shocks, many places where the traffic has to slam on the brakes.
So when there is a temporary speed limit on the motorway, when there is no obstruction and traffic is flowing nicely, it's likely that the traffic density is such that big shocks would be forming if a speed limit wasn't imposed. So it's not that the speed limit is unnecessary because there's no
congestion. The speed limit has done its job and prevented cues from forming. Of course,
congestion. The speed limit has done its job and prevented cues from forming. Of course,
to the road user, it may appear as a useless speed limit. There's no glory in prevention. Or,
maybe, someone in a Birmingham office pressed the wrong button, causing a single gantry on an empty A1M to show a 40 mph speed limit. Who knows?
Loading video analysis...