Echo

Hear the whole city in seconds.

Exactly the same answer. Up to 285,000× faster.

0 of 0 detectors firingframe 0 Vehicle Noise, deep blue fires Building Detector Firing, ringed

Hours of simulation.
Now seconds.

Vehicles drive through a city and their noise spreads along the streets, never through buildings. Detectors fire when the noise they hear adds up to a threshold. The original simulator rebuilt the whole noise map on every frame. Echo doesn't.

~42 horiginal simulator, busy city (projected)
0.53 sEcho, same city, one CPU core
0differences in the output

Listen where it matters.

Two observations remove almost all of the work: only detector cells need an answer, and a vehicle's noise changes only when it moves.

  1. Step 1

    Listen from the detectors.

    One distance search from each detector, out to the loudest vehicle's reach. Street distance is the same both ways, so the numbers match the simulator's exactly.

  2. Step 2

    Turn routes into segments.

    Each vehicle becomes "on this cell from frame a to frame b". A looping vehicle repeats its lap, so Echo builds one lap and shifts copies in time.

  3. Step 3

    Add up changes, not frames.

    Noise is added when a vehicle arrives near a detector and subtracted when it leaves. One cumulative sum gives every detector's exact noise on every frame.

The same route. Every time.

When two paths are equally short, the simulator's queue picks one in a set order. That order always gives the alphabetically first shortest path, reading moves as up, down, left, right. Echo measures distances from the goal once and walks straight there.

5,000random routes compared with the original
15,000route legs planned in a stress city
0routes that differ

Faster on every city.

Measured on one CPU core in a Linux container with a 4 GB memory cap.

CityBeforeWith EchoFaster
Busy city80 vehicles, 20 detectors~42 h0.53 s285,000×
Big city400×400 map, 2,000 detectors~6.5 h3.2 s7,300×
Long patrol12 vehicles, 6,000 detectors~6 h3.7 s5,800×
Sensor grid6 vehicles, 12,000 detectors~7 h6.7 s3,800×
Demo cityincluded in the repo12.2 s0.02 s600×

"Before" times marked ~ are projected from the original simulator's first 20 frames, because full runs take hours. The demo city's times are full measured runs that anyone can repeat.

Fast is easy.
Exact is the point.

Every change had to pass all of these before it was kept.

  • Reference cities

    Every example city gives a log identical to the original's, and frame-by-frame snapshots match on the small city.

  • 300 random cities

    Built to hit edge cases: walled-off regions, vehicles louder than the map, parked vehicles, waits, loops, runs cut short, thresholds from trivial to unreachable.

  • Broken on purpose

    Changing "at least the threshold" to "above the threshold" makes the tests fail. They also caught a real bug during development.

  • At the limits

    Spread-out cities with every limit at once, on one core with a hard 4 GB cap: 169 s and 277 s, under 1 GB of memory. One known limit: 20,000 detectors packed around 100 of the loudest cars takes about 16 minutes. That's next.

  • Reviewed independently

    A separate review compared 3,000 random cities and 174,762 routes with the original: identical. It also found two input edge cases, now fixed and tested.

Try it yourself.

Python 3.12 with numpy and pyyaml. The command line is the same as the original simulator's.

# install
pip install -r requirements.txt

# run the demo city: writes log.json
python -m citynoise run examples/demo.yaml

# make your own city
python tools/make_scenario.py examples/mine --vehicles 20 --detectors 500

# prove it matches the original
python -m pytest tests