RUST · TRAFFIC SIMULATION

sumo-rs — Microscopic Urban Traffic Simulation (IDM, Krauss & MOBIL) in Pure Rust

sumo-rs is a high-performance Rust port of the SUMO microscopic traffic simulator that models individual vehicle acceleration, lane changing, and signalized intersections. It implements the Intelligent Driver Model (IDM), Krauss stochastic car-following, and MOBIL lane-change incentives with zero heap allocations per tick.

$ cargo add sumo-rs
GitHub ↗
MODEL: IDM + MOBIL
ACTIVE VEHICLES: 18
AVG SPEED: 84.2 km/h
LANE CHANGES: 0
COLLISIONS: 0 (VERIFIED)
INSPECTING VEHICLE #-- Lane: -- Speed: -- Acc: -- Net Gap: -- Lead Headway: -- MOBIL Incentive: --
CURRENT PHASE: N/S GREEN (STRAIGHT + RIGHT)
PHASE TIMER: 14.2s
CONFLICT ZONE: CLEAR
JUNCTION THROUGHPUT: 0 vehicles
SUMO C++ Direct Translations

Core Microscopic Traffic Algorithms

Strictly verified against Eclipse SUMO dynamics with full mathematical proofs, guaranteeing realistic car-following and zero runtime collisions.

∇

Krauss Safe Speed Model

Implements the Krauss (1998) collision-free car-following model. Dynamically determines safe following speed \(v_{safe}\) considering driver reaction time \(\tau\), deceleration limits \(b\), and driver dawdling imperfection \(\sigma\).

\(v_{safe} = -g\tau + \sqrt{(g\tau)^2 + v_l^2 + 2bg}\)
Dawdling σ Zero Collision Invariant Continuous Velocity
Δ

Intelligent Driver Model (IDM)

Treiber, Hennecke, & Helbing (2000) non-linear continuous acceleration model. Produces human-like smooth acceleration curves, dynamic equilibrium time headways \(T\), and realistic emergency braking under acute approach rates.

\(\dot{v} = a [ 1 - (v/v_0)^\delta - (s^*(v, \Delta v)/s)^2 ]\)
Desired Gap s* Exponent δ = 4.0 Comfort Deceleration
↔

MOBIL Lane-Changing Model

Minimizing Overall Braking Induced by Lane changes (Kesting et al.). Arbitrates lane changes by calculating net collective acceleration gain weighted by driver politeness \(p\), enforcing follower safety braking boundaries \(b_{safe}\) and asymmetric keep-right bias.

\(a_{new} - a_{curr} + p(a_{new,f} - a_{curr,f} + \dots) > \Delta a_{th} \pm a_{bias}\)
Politeness Factor p Oscillation Filtering Safety Criterion
⊕

Intersection SPaT & Conflict Zones

NTCIP / SAE J2735 compliant Signal Phase & Timing (SPaT) multi-stage controllers. Supports unprotected left-turn yielding to oncoming straight trajectories, all-way stop FIFO arrival arbitration, and continuous spatial-temporal conflict zone reservations.

\([t_{enter} - t_{buffer}, t_{exit} + t_{buffer}] \cap \mathcal{R}_{conflict} = \emptyset\)
SPaT Multi-Phase Left Turn Yielding FIFO Stop Signs
§

Road Network Graph Topology

Geometric graph topology with high-precision polyline lanes, internal intersection connection links, and neighbor connectivity matrices. Includes built-in Dijkstra routing across complex arbitrary networks.

\(G = (V, E) \implies \text{Node} \to \text{Edge} \to \text{Lane} \to \text{Connection}\)
Dijkstra Routing Sub-lane Geometry Graph Serialization
⧉

Bevy 3D Game Engine Integration

Seamlessly translates 2D road lane coordinates and headings into 3D world transforms (`Vec3`, `Quat`) for Bevy entities. Perfect for open-world traffic in autonomous vehicle simulation, digital twins, and urban video games.

\(\text{vehicle\_to\_bevy\_transform}(veh, net, z) \to \text{Transform}\)
Bevy 0.15 glam 0.29 Zero-Copy Transform
Mathematical Rigor

Algorithmic Formulations

Exact governing equations implemented in pure Rust, ensuring microscopic physical consistency.

Krauss Safe Velocity & Dawdling

Calculates the absolute maximum safe speed to guarantee avoiding rear-end impact with leading vehicle \(l\):

\[v_{safe} = -g\tau + \sqrt{(g\tau)^2 + v_l^2 + 2bg}\]

Where \(g = \max(0, \text{gap} - s_0)\), with driver reaction headway \(\tau\). Stochastic driver imperfection is injected via:

\[v(t + \Delta t) = \max(0, v_{des} - \sigma \min(a\Delta t, v_{des})\eta), \quad \eta \sim \mathcal{U}(0,1)\]

IDM Acceleration & Dynamic Gap

Continuous acceleration balancing free-flow cruising acceleration against braking distance:

\[\dot{v} = a \left[ 1 - \left(\frac{v}{v_0}\right)^\delta - \left(\frac{s^*(v, \Delta v)}{s}\right)^2 \right]\]

The dynamic desired gap accounts for current speed and approaching velocity \(\Delta v = v - v_l\):

\[s^*(v, \Delta v) = s_0 + v T + \frac{v \cdot \Delta v}{2\sqrt{ab}}\]

MOBIL Incentive & Safety

Ego vehicle only changes lanes if collective acceleration improves without causing excessive follower braking:

\[\underbrace{a_{new} - a_{curr}}_{\text{Ego Gain}} + p \Big[ \underbrace{(a_{new,f} - a_{curr,f})}_{\text{New Follower}} + \underbrace{(a_{new,of} - a_{curr,of})}_{\text{Old Follower}} \Big] > \Delta a_{th} \pm a_{bias}\]

Follower deceleration is strictly guarded by the safety criterion:

\[a_{new,f} \ge -b_{safe} \quad \wedge \quad a_{new} \ge -b_{safe}\]
Deterministic Verification & Benchmarks

Microsecond Microscopic Traffic vs. Eclipse SUMO (C++)

Extensive integration test suite and native benchmarks comparing pure Rust against upstream Eclipse SUMO. Read Full BENCHMARKS.md →

Test Suite Status 23 / 23 PASSED

accuracy_test::idm_equilibrium_&_krauss_bounds
3 / 3 OK
car_following_tests::krauss_safe_speed
6 / 6 OK
intersection_tests::spat_cycle_&_left_yield
4 / 4 OK
lane_changing_tests::mobil_incentive_&_politeness
3 / 3 OK
network_tests::dijkstra_routing_&_interpolation
3 / 3 OK
simulation_tests::highway_mobil_&_platoon
4 / 4 OK

Engine Performance vs. Eclipse SUMO BENCHMARK

100 Vehicles Step Latency 360 µs (2,778 steps/s)
MOBIL Lane-Changing Decisions 4.69M /s (213 ns/eval)
Dijkstra Routing Queries 201,380 routes/s (4.97 µs)
Memory Overhead vs C++ SUMO 16–19× Lower RAM (8.6 MB vs 145 MB)
Developer Quickstart

Integrate sumo-rs in Seconds

Add to Cargo.toml and simulate multi-lane highways or signalized intersections with a few lines of Rust.

[dependencies]
sumo-rs = "0.1"
glam = "0.29"