How hard should you brake?
One of my favorite amusements while driving is to try and time my braking when approaching a red light so as to preserve as much speed as possible. Coasting in an open lane past a car waiting at a red light thanks to hitting the light change perfectly is one of those quotidian moments of joy that make life worth living. Pulling off this timing exploit is most possible on short routes that I drive frequently and know well, but it’s also occasionally possible to look at cross-traffic patterns and make an educated guess about green-light timing on roads you aren’t familiar with.Nothing in this post should be taken as driving advice.
While the conditions for light timing require a lot of metis, the execution is more amenable to techne. In particular, the technical problem I want to think about today (and for several follow-up posts) is as follows:
Suppose that I’m traveling at speed towards a red light a distance away. I have some prior waiting-time distribution on for when the light will change. What should my braking profile look like?I’ve often wondered about this problem while driving, but every time I have wondered I’ve concluded that it’s too difficult to sort out completely (at least while driving). So let’s take some time and actually work it out!
None of this post was written while driving.
For starters, this is a problem in optimal control theory: we’ve got some state functions (the position and velocity of our car as functions of time) that are influenced by a control function (our braking force as a function of time) via a differential equation (Newton’s second law), some constraints (we can’t run the red light), and we want to extremize some objective functional (unspecified in our informal description, but on which more below below).
Because the waiting time is only known as a distribution, this is actually a problem in stochastic optimal control. It’s a pretty unusual setup for a stochastic optimal control problem, however, because there’s no noise or uncertainty in the control system: we observe the state perfectly, and the state responds deterministically to our control input. Instead, the uncertainty is entirely concentrated in the time horizon.
A formal setup
Let’s get started by setting up the problem a little more formally, borrowing the usual language and notation of optimal control theory. We’ll make some simplifying assumptions throughout: no frictionExcept for our brakes!
, no drag, no height variation along the road, and no mass loss due to gas consumption.
- Controls and the state equation: Our only control input will be our braking acceleration . Our state is simply our position and velocity , which is governed by the standard (frictionless) dynamical state equation
- Endpoint constraints: Our endpoint constraints are pretty simple: we only have endpoint constraints at time . There we require that and . It would also be possible to add the endpoint constraint , but it turns out to be more natural to have this requirement as a path constraint for all times since is a random variable.
-
Path constraints: Our path constraints fall into two categories: constraints on the state, and constraints on the control.
- Constraints on the state: It’s pretty hard to brake so forcefully that your car starts moving backwards, so we’ll require . (We can derive the path constraint from this constraint, so we don’t explicitly add it.) We also need to not run the red light, so we require .
-
Constraints on the control: We’re going to deliberately assume that we don’t hit the gas before the light changes: i.e., that our acceleration is always nonpositive. We could derive the path constraint from this assumption and our state equation, but it’s unnecessary to add this. In real life, this isn’t a good assumption: it can be correct (say with respect to the objective of maximizing kinetic energy) to accelerate towards a red light if you’ve got the timing down really well, or are quite far away and traveling slowly. But assuming no forward acceleration will make our analysis a fair bit simpler, so we’ll impose this constraint.
There are two natural choices for an additional constraint on our braking acceleration . One choice is to assume that there is no maximum deceleration. This choice has the advantage of making all our control problems solvable: we can just slam on the brakes as hard as needed so that we don’t run the red light. It has the downside of making our control domain (i.e., the set of possible values of ) noncompact, however.
Another natural choice is to impose some maximum deceleration . This makes our control domain compact, which is a useful assumption in optimal control theory.This is essentially because a continuous real-valued function on a compact set must attain its maximum.It makes some problems unsolvable, however. Thankfully, the solvability criterion is pretty simple: we just need the restriction on the support of that since is the minimum distance we can stop in. We’ll always state which of these two choices we’re making.
-
The objective functional: I’ve deliberately left unspecified the objective in the problem description. I think the most natural objective is to maximize the expected remaining kinetic energyWe’ll always ignore the mass constant.when the light changes—i.e., —which (in the spirit of hypermiling) also roughly minimizes fuel consumption. There are other reasonable objective functionals: perhaps you really dislike being stopped at a red light and want to minimize the expected time you’re stopped, for example. But this is the one we’ll work with throughout our analysis.
The non-stochastic problem
For today, I want to start with the non-stochastic version of our problem, which corresponds to being a point mass at time . We’ll assume no maximum deceleration. In this case there’s a physically-obvious solution, which is to immediately brake to speed and then coast. This solution preserves expected kinetic energy. The argument that this solution is optimal is straightforward. Any solution must have . Since , is monotone decreasing, so that with equality iff is constant. Note that in this no-maximum-deceleration setup, it’s somehow more intuitive to think of the velocity as our control. Formally this is difficult, however, because of the requirement that velocity be monotone decreasing.I don’t know of instances in optimal control theory where path constraints involving derivatives of the control function are imposed. Such a requirement would be hard to reconcile with non-differentiable velocity inputs like those we’ll see below.
The barely-stochastic problem
The second and final problem that we’ll consider today is what happens when we introduce the tiniest-possible amount of stochasticity into the problem. Specifically, we’ll consider the setup where i.e., where the light turns green with probability at time and with probability at time . We have a valid solution with as in the non-stochastic problem above, with expected kinetic energy . Can we do better? As it turns out, yes—but not always! One trick to develop intuition for this case is to reason from an extreme limiting case, when is very close to 1 and when . In other words, we have a tiny probability of having to wait a very long time. In this limiting case, we can do better by immediately braking to speed at time , then rolling up to the stoplight at time and immediately braking to speed zero if the light does not change. We have kinetic energy if the light changes and kinetic energy zero otherwise, for an expected kinetic energy of . Can we do better than this? Let’s consider the approach where we travel at some constant velocity on the time interval and some constant velocity on the time interval . At time , we have remaining distance . Hence by the non-stochastic analysis above we know that the optimal (given some choice of ) is given by . So our maximum expected remaining kinetic energy is The expression to maximize is a quadratic function of , and the quadratic coefficient is Hence the kinetic-energy expression is a convex function of , so it attains its maximum at one of the endpointsThis is really convenient, because the kinetic-energy expressions at the endpoints are very clean but the kinetic-energy expression at the critical point is quite messy.
or . A little bit of algebra tells us that the maximum expected kinetic energy is thus where we should take if and otherwise.
The constant-velocity argument
To finish the analysis of the barely-stochastic problem, we need to argue why this two-constant-velocities approach is optimal. The argument here is a pretty straightforward generalization of the constant-velocity argument in the non-stochastic problem above. To start, our velocity should clearly be constant on the interval , because at this point we’ve completely reduced to the non-stochastic analysis. Now notice that regardless of whether or , our kinetic energy functional is an increasing function of and hence a decreasing function of . Because is monotone decreasing, is minimized for a given precisely when is constant on the interval .A concrete example
To illustrate this analysis, let’s suppose that we’re driving towards a red light which we know will turn green either one minute from now (with probability ) or two minutes from now (with probability ). Then the breakpoint is at , and we should- if : brake to speed immediately and coast until the light changes;
- if : brake to speed and slam on the brakes if the light does not change.
For next time
Next time we’ll fully solve the no-maximum-deceleration case when is a discrete distribution with finite support, i.e. with , , and positiveNote that if , then the only feasible solution is to immediately decelerate completely: i.e., for all .
and increasing. A good motivational exercise for next week is to consider how to use the solution above in the analysis.
<!–
References:
https://mathoverflow.net/questions/33312/what-braking-strategy-is-most-fuel-efficient
https://mathoverflow.net/questions/1108/easy-probability-diff-eq-question
https://mathoverflow.net/questions/284114/what-is-the-optimal-speed-to-approach-a-red-light
https://arxiv.org/pdf/2511.09530
>