Suppose from distance $d$, while driving at speed $v\_0$, I notice that there's a red traffic light in front of me. Suppose that there are no other vehicles, my vehicle has perfect brakes, my maximum acceleration is $a$ and the red light will turn green according to some $\mu$ distribution. My goal is to get to my final destination as soon as possible, i.e., to minimize my estimated time of arrival (ETA), and suppose that the rest of the road has some speed limit $L$.



> 
> With what speed should I approach the red light to minimize my ETA?
> 
> 
> 


Of course, the answer will depend on the parameters; I'm interested in any non-trivial results.
As essentially the same problem has been raised earlier [here](https://terrytao.wordpress.com/2008/12/09/an-airport-inspired-puzzle/#comment-33878) and [here](https://mathoverflow.net/questions/1108/easy-probability-diff-eq-question) (thanks for the links!), but apparently without any solution, let me be more specific.



> 
> Is there any non-trivial set of parameters for which we know the solution?
> 
> 
> 


ps. I'm not interested in reducing milage, but feel free to add comments in this direction, if you wish. 



What is the optimal speed to approach a red light?
Similar to the linked variants on this problem, the optimal strategy takes the form of a function $v(t)$, which corresponds to the strategy in which you travel at velocity $v(t)$ until the light turns green, then you slam on the accelerator and accelerate at $a$ until you reach the speed limit $L$.


If $T$ is the time when the light turns green, we will be at $D=\int\_0^Tdt\;v(t)$ traveling at $V=v(T)$, and the velocity function for $t\ge T$ is $v'(t)=\min(V+a(t-T),L)$. We want to maximize, for $t\gg T$:


$$K:=\int\_0^tdt\; v'(t)=D-\frac{(L-V)^2}{2a}-LT+Lt$$


The leading term $Lt$ only depends on the chosen time $t$ to measure our distance, so we can ignore it, and similarly with $LT$ which depends only on $T$ which is not under our control. For the rest, we see a quadratic penalty to slowing below top speed.


The constraint of not running the red light is expressed as $P[\int\_0^Tdt\;v(t)\le d]=1$, which amounts to just $\int\_0^xdt\;v(t)\le d$ for all $x$ such that $\mu([x,\infty))>0$. In fact we can just go ahead and assume $\int\_0^xdt\;v(t)\le d$ for all $x$ because the strategy is irrelevant once the light is green.


So we are looking at:


$$E[K]=E\left[\int\_0^Tdt\;v(t)-\frac{(L-v(T))^2}{2a}\right]$$


where $T$ is drawn from the distribution $\mu$, and we wish to choose $v$ maximizing $E[K]$. I don't think much more can be done in this generality, so let me focus on the case $\mu$ uniform on $[0,\alpha]$.


In this case the expected value becomes (up to a factor $1/\alpha$ which doesn't affect the result)


$$\int\_0^\alpha dT\left[\int\_0^Tdt\;v(t)-\frac{(L-v(T))^2}{2a}\right]=$$
$$\int\_0^\alpha dt\left[(\alpha-t)\;v(t)-\frac1{2a}(L-v(t))^2\right].$$


We can add in a Lagrange multiplier to account for the constraint (which will almost certainly turn out to be extremal) $\int\_0^\alpha dt\; v(t)=d$, and solve this using calculus of variations:


$$\mathcal{L}(t,v,\lambda)=(\alpha-t)\;v-\frac1{2a}(L-v)^2+\lambda v$$


$$\frac{\partial\mathcal{L}}{\partial v}=0\implies v(t)=L+a(\alpha+\lambda)-at$$


Here $\lambda$ is a free constant which should be chosen to maintain the constraint $\int\_0^\alpha dt\; v(t)\le d$, which I'll leave to you since the story is more interesting: This says you should *decelerate* at $a$ starting from an appropriate speed. (Here the appropriate speed is so that you come to a stop at the light, unless this puts the initial speed above $L$, in which case obviously you should drive at the speed limit until you get close enough.)




---


Let's try another simple and reasonable distribution: the exponential distribution with mean $\beta=\alpha^{-1}$. In this case the expectation works out to:


$$\int\_0^\infty dT\;e^{-\alpha T}\left[\int\_0^Tdt\;v(t)-\frac{(L-v(T))^2}{2a}\right]=$$
$$\int\_0^\infty dt\;e^{-\alpha t}\left[\beta v(t)-\frac1{2a}(L-v(t))^2\right].$$


As with the uniform distribution case, we add a Lagrange multiplier and solve the Euler-Lagrange equation:


$$\mathcal{L}(t,v,\lambda)=e^{-\alpha t}\left[\beta v-\frac1{2a}(L-v)^2\right]+\lambda v$$


$$\frac{\partial\mathcal{L}}{\partial v}=0\implies v(t)=L+a(\beta+\lambda e^{\alpha t})$$


Unfortunately, this solution is formally problematic, since the integral of the velocity doesn't converge for large $t$. This solution is still correct before we hit the discontinuity, but we need to add the constraint in differently.


Let's explicitly consider a velocity curve that is zero after a certain fixed time, i.e. we approach the light and come to a stop. For a fixed chosen time $t^\*$ to stop at, the functional is the same, and so the solution is the same: exponential deceleration away from the unreachable "steady state" velocity $L+a\beta$. But when we hit the light, we use our magic brakes to stop, and continue after the light from a full stop.


$$E[K]=\int\_0^{t^\*} dT\;e^{-\alpha T}\left[\int\_0^Tdt\;v(t)-\frac{(L-v(T))^2}{2a}\right]+\underset{c(t^\*)}{\underbrace{\int\_{t^\*}^\infty dT\;e^{-\alpha T}\left[d-\frac{L^2}{2a}\right]}}$$
$$=\int\_0^{t^\*} dt\left[\int\_t^{t^\*}dT\;e^{-\alpha T}\;v(t)-\frac{e^{-\alpha t}}{2a}(L-v(t))^2\right]+c(t^\*).$$
$$=\int\_0^{t^\*} dt\left[\beta(e^{-\alpha t}-e^{-\alpha t^\*})\;v(t)-\frac{e^{-\alpha t}}{2a}(L-v(t))^2\right]+c(t^\*).$$


The parts that depend on $t^\*$ don't affect the variational analysis:


$$\mathcal{L}(t,v,\lambda)=\beta(e^{-\alpha t}-e^{-\alpha t^\*})\;v-\frac{e^{-\alpha t}}{2a}(L-v)^2+\lambda v$$


$$\frac{\partial\mathcal{L}}{\partial v}=0\implies v(t)=L+a(\beta(1-e^{\alpha(t-t^\*)})+\lambda e^{\alpha t})$$


This time we should really solve for $\lambda$ since we need to ensure that $\int\_0^{t^\*}dt\;v(t)=d$. I'll spare the details as the algebra gets worse, but after putting $\lambda$ back in the equation, we have a one-dimensional optimization for $E[K]$ as a function of $t^\*$, which can't be solved with elementary functions, but from numerical simulations it looks like the best option is still the extremal one: Wait until the last moment at the top speed, then execute the exponential deceleration maneuver $v(t)=L+a\beta(1-e^{\alpha t})$ and stop when $v(t)=0$, at $t=\beta\log(1+\frac L{a\beta})$.


PS: I don't recommend these maneuvers. They strike me as mildly suicidal.


