The green a signal cannot hold forever
Adaptive signal control in the digital twin is four lines of arithmetic and two constants. The constants are the interesting part.
Source: src/features/vector/twin/engine.ts.
The twin has a toggle marked adaptive. With it off, every junction runs a fixed eight-second green and the grid behaves like signal timing from 1960. With it on, the junction decides. The decision is this:
serving = queue on the approach that currently has green
waiting = queue on the approach that does not
if waiting > serving: switch phase, green = clamp(waiting * 1.6, 4, 16)
else: hold phase, green = clamp(serving * 1.4, 4, 16)That is the whole controller. No model, no learning, no lookahead — give the green to whichever approach is actually waiting, and scale how long you give it to how many are waiting.
The constants are the design§
The arithmetic is obvious. The two bounds are where the actual engineering is.
A green is never shorter than four seconds and never longer than sixteen. Remove the upper bound and the controller is strictly better at the thing it is measured on: it will hold a green on the busy axis for as long as the queue keeps arriving, and throughput on that axis goes up. The cross street never moves again.
A signal that can hold a green indefinitely is not adaptive. It is stuck, and it is stuck in a way that looks like success on the metric you were watching.
The lower bound is the same argument from the other end. Without it, a junction with one car on each approach flickers — a green so short nothing clears it, which costs the startup delay of a phase change and buys nothing.
The multipliers differ, and that asymmetry is deliberate: 1.6 for switching, 1.4 for holding. Changing phase costs everyone a moment of lost time while the junction clears, so a switch has to be worth more than a hold to justify itself.
Why the queues are counted rather than modelled§
queueNS and queueEW are sampled every tick by counting stopped vehicles on the
approach. Not estimated from arrival rates, not smoothed, not predicted. The
controller reads what is actually there.
This matters for the honesty of the demonstration. The throughput and delay figures the interface reports are computed from vehicles that actually queued and actually cleared, so switching the toggle moves numbers that were not decided in advance. A scripted animation would produce a better-looking result and prove nothing.
What this is not§
This is a simulation of adaptive control, not a deployment of it. It runs in a browser on a seven-by-seven grid with Manhattan routing and a single turn per vehicle. It has no detector hardware, no signal controller protocol, and no safety case.
What it demonstrates is narrow and real: that queue-responsive timing beats fixed timing on a grid under uneven load, and that the bounds preventing starvation cost measurable throughput. Both of those are visible by watching the numbers move.