Source-linked AI summary
Learning Traffic Flow Dynamics with Stochastic Physics-Informed Neural Cellular Automata
Federica Bragone, Matthieu Barreau
TL;DR
Learning local traffic rules from data while maintaining physically meaningful constraints remains challenging, especially for stochastic dynamics. The paper introduces a physics-informed neural cellular automaton and a stochastic extension, then evaluates them on traffic generated by NaSch and KKW models. PI-NCA is more accurate and physically consistent than the direct state prediction model, and its learned rules generalize across tested configurations.
Problem
Learning local traffic transition rules from data while preserving physical constraints remains challenging, and direct learning from trajectories has received less attention than using neural networks for prediction or classification.
Source: §1 · p. 3Method
PI-NCA predicts vehicle velocities and updates positions following the conservation law, while its stochastic extension predicts categorical distributions over possible next velocities.
Source: §1 · p. 4Results
PI-NCA provides more accurate and physically consistent predictions than the direct state prediction model, generalizes across tested configurations, and reproduces characteristic stochastic traffic behavior.
Source: §6 · p. 30Takeaways & Limitations
Combining learned local interaction rules with known physical structure is a promising approach for data-driven traffic modeling.
Source: §6 · p. 30The framework's future extensions include more realistic settings with higher and continuous velocities, open boundaries, and multi-lane and heterogeneous traffic.
Source: §6 · p. 30
Abstract
from arXiv · showhide
Traffic flow modeling is essential for understanding and predicting the collective dynamics of vehicles on road networks. Cellular automata provide a simple, interpretable yet powerful framework for representing these dynamics via local interaction rules, while retaining the ability to reproduce complex macroscopic traffic phenomena. However, learning local transition rules from data while preserving physically meaningful constraints remains challenging, particularly for stochastic models. In this work, we propose a physics-informed neural cellular automaton (PI-NCA) for data-driven traffic flow modeling. Building on the standard neural cellular automaton (NCA), we design a neural architecture that is physically consistent with the road topology and guarantees conservation of the total number of vehicles, thereby constraining the learned transition rules to physically admissible dynamics. We further extend this framework to stochastic dynamics by parameterizing probabilistic transition rules while preserving the same physics-informed constraints. We evaluate the proposed models on multiple traffic scenarios generated by the well-established Nagel-Schreckenberg and Kerner-Klenov-Wolf cellular automata. The results demonstrate that the PI-NCA successfully learns the dynamics of both traffic models and consistently outperforms a standard NCA, while the stochastic extension captures probabilistic transition rules without compromising the imposed physical constraints.
1. Introduction
Cellular automata offer a simple, efficient way to model microscopic traffic, but tuning their rules to match observations is difficult. The paper investigates learning local traffic rules directly from trajectories while preserving vehicle dynamics and testing deterministic and stochastic behavior.
1. Introduction
- Traffic cellular automata can reproduce behaviors including free flow, congestion, and wave dynamics through local, physics-inspired rules.The introduction highlights the Nagel–Schreckenberg and Kerner–Klenov–Wolf models as examples.Source: §1 · p. 2
- Traffic cellular automata use local transition rules, but faithfully reproducing observations requires complex tuning.Prior work combined learned components with traffic CAs, while direct learning of local transition rules from state trajectories received less attention.Source: §1 · pp. 2–3
- The paper investigates whether neural cellular automata can learn microscopic traffic rules from simulated trajectories and reproduce vehicle dynamics and macroscopic behavior.The stated open questions include vehicle conservation, generalization to unseen traffic conditions, and deterministic and stochastic behavior.Source: §1 · p. 3
- PI-NCA predicts vehicle velocities and updates positions through the conservation law, with a stochastic extension that predicts distributions over possible next velocities.The models are evaluated through autoregressive rollouts on NaSch and KKW-1 dynamics at microscopic and macroscopic levels.Source: §1 · p. 4
2. Preliminaries and Problem Statement
The preliminaries connect macroscopic density–flow descriptions with local cellular-automaton rules, whose repeated application can produce collective traffic patterns. The problem statement asks whether deterministic and stochastic local rules can be learned from simulated trajectories while preserving physical structure and vehicle conservation.
2.1. Traffic Flow Modelling
- Macroscopic traffic uses density, average velocity, and flow, with q = ρv; the closure q = Q(ρ) is limited because intermediate densities can support multiple flow states.The work considers a homogeneous single-lane road and distinguishes global traffic concentration from local spatial variation.Source: §2.1 · pp. 4–5
2.2.1. Traffic Cellular Automata
- Traffic cellular automata update a one-dimensional road lattice through shared local rules; repeated updates can generate macroscopic patterns, and this shared structure motivates convolutional learning.Occupied cells encode vehicle velocity and empty cells use −1; periodic boundaries make the road a ring and keep vehicle count constant.Source: §2.2.1 · pp. 6–7
- Stochastic traffic CA assign a categorical distribution over admissible vehicle velocities, so identical local conditions can yield different outcomes across realizations.After velocities are sampled, vehicles are displaced to form the next road configuration.Source: §2.2.1 · p. 8
2.2.2. Nagel–Schreckenberg Model
- NaSch updates vehicles through acceleration, collision avoidance, random deceleration, and movement, applied synchronously across occupied cells.The random-deceleration probability p = 0 makes the model deterministic.Source: §2.2.2 · pp. 8–9
- The NaSch diagrams show local traffic states spanning density and flow, while global flows rise then fall with density and differ between initializations at intermediate densities.At higher densities, the flows from the two initial configurations gradually converge.Source: §2.2.2 · pp. 9–10, Figure 3 · p. 10
2.3. Problem Formulation
- The learning problem is to infer deterministic local rules from trajectories without the rules, while retaining physical structure and vehicle conservation, and to explore learning stochastic dynamics.The stochastic objective includes learning uncertainty arising from stochastic vehicle behavior.Source: §2.3 · p. 11
3. Methodology
The methodology learns a shared local traffic transition rule with a one-dimensional CNN, then adds explicit vehicle movement to enforce conservation in PI-NCA. Its stochastic extension predicts velocity distributions while retaining that movement update.
3.1. Neural Cellular Automata
- The one-dimensional CNN learns a shared local transition rule from neighborhoods spanning cells i − vmax to i + vmax, reflecting the assumed local traffic interactions.Pointwise layers model the nonlinear rule applied across the road; circular padding preserves the simulated road’s periodicity.Source: §3.1 · pp. 11–12
3.2. Deterministic NCA Formulations
- PI-NCA predicts each occupied vehicle’s velocity and explicitly updates its position, conserving vehicle count when velocities are correctly computed.Unlike direct-state NCA, which predicts the complete next traffic state, PI-NCA constructs it through vehicle movement.Source: §3.2 · pp. 12, 14, 15
3.3. Stochastic PI-NCA Formulation
- Stochastic PI-NCA predicts a categorical distribution over admissible velocities, samples a velocity for each vehicle, and retains the explicit movement update and conservation structure.Repeated rollouts from the same initial state may therefore generate different trajectories.Source: §3.3 · pp. 15–17
4. Training and Evaluation
The experiments train and test NCA and PI-NCA on NaSch trajectories spanning structured and random initializations, then extend evaluation to KKW-1’s more complex local interactions. KKW-1 also requires a larger receptive field, and its simulations exhibit configuration-dependent global flow and varied local traffic states.
4.1. NaSch experiments
- NaSch training uses six structured-to-random initialization schemes, while testing also covers unseen road lengths and vehicle counts.For each vehicle count, 350 trajectories are generated; testing uses independently seeded trajectories and includes 10 per test configuration.Source: §4.1 · pp. 17–18
- Stochastic PI-NCA models are trained separately for NaSch stochasticity levels p = 0.1 to 0.9 and evaluated through autoregressive rollout.Stochastic evaluation includes standard prediction and conservation measures, total variation between predicted and reference next-velocity distributions, and relative L2 errors for global density–flow relations.Source: §4.1 · pp. 19–20
4.2. Extension to KKW-1 Dynamics
- KKW-1 adds a synchronization distance, making local interactions depend on both the available gap and the leading vehicle’s velocity.The model is adapted to the discrete road with vmax = 5 and periodic boundaries; its larger interaction range motivates an expanded convolutional receptive field.Source: §4.2 · pp. 20–21
- KKW-1 simulations show broad local traffic-state variation and configuration-dependent global flow at intermediate densities.The condensed and homogeneous initial configurations converge at higher densities.Source: §4.2 · pp. 20–21, Figure 7 · p. 20
5. Results
Across NaSch and KKW-1, PI-NCA outperforms direct state prediction, with especially consistent accuracy and vehicle conservation for KKW-1 across tested configurations. Its stochastic extension reproduces characteristic traffic evolution and local and global density–flow behavior during autoregressive rollouts.
5.1. Deterministic Prediction Performance
- PI-NCA consistently outperforms direct state NCA across reported metrics for NaSch and has a more pronounced advantage under KKW-1 dynamics, with near-zero conservation error.The comparison summarizes complete test sets and means and standard deviations over five independently trained models.Source: Table 4 · p. 21, §5.1 · p. 22
5.1.1. Generalization Across Initial Conditions
- For unseen traffic initializations, KKW-1 PI-NCA remains more accurate and consistent than NCA, whose errors increase for random configurations; PI-NCA conservation error stays near zero.Both models maintain small errors across tested NaSch initial conditions.Source: §5.1.1 · p. 23, Figure 9 · p. 24
5.1.2. Generalization Across Road Lengths
- For unseen road lengths L = 50 and L = 150, KKW-1 PI-NCA has lower MAE than NCA and near-zero conservation error across all tested lengths.NaSch prediction errors also remain low across all three tested road lengths.Source: §5.1.2 · p. 23, Figure 10 · p. 25
5.1.3. Generalization Across Vehicle Numbers
- For KKW-1, PI-NCA keeps MAE low and conservation error near zero across seen and unseen vehicle counts, while NCA errors rise with vehicle count.NaSch remains highly accurate across all tested vehicle counts.Source: §5.1.3 · p. 23, Figure 11 · p. 26
5.2. Stochastic Prediction Performance
- Stochastic evaluation examines space-time evolution, emergent local traffic behavior, and learned conditional velocity distributions.These assessments use autoregressive rollouts because identical initial states can produce different stochastic trajectories.Source: §5.2 · pp. 23–24
5.2.1. Stochastic Traffic Evolution
- Stochastic PI-NCA rollouts reproduce characteristic NaSch traffic waves and KKW-1 lower-velocity regions, even when individual NaSch states differ from the reference.The comparisons are qualitative and concern spatial and temporal characteristics.Source: §5.2.1 · pp. 24–25, Figure 12 · p. 27
5.2.2. Fundamental Diagram Analysis
- For both models, stochastic PI-NCA recovers local density–flow structure, including free-flow and congested regimes and coexistence of multiple velocities at one density.For KKW-1 it also recovers the broad traffic-state distribution and the binned local flow–density shape.Source: §5.2.2 · p. 28, Figure 13 · p. 29
- Global density–flow curves closely match reference behavior: NaSch relative L2 errors are 1.61% and 1.45%, while KKW-1 errors are 4.70% and 5.16% for condensed and homogeneous starts, respectively.The curves retain the initial-configuration separation around maximum flow and converge at higher densities.Source: §5.2.2 · pp. 28–29, Figure 13 · p. 29
6. Summary and Conclusions
The paper compares direct state prediction with PI-NCA, which predicts vehicle velocities and explicitly updates positions, on NaSch and KKW-1 traffic models. PI-NCA is more accurate and physically consistent, generalizes across tested configurations, and reproduces characteristic stochastic traffic behavior; future work targets more realistic settings.
6. Summary and Conclusions
- PI-NCA is more accurate and physically consistent than direct state prediction, with its largest improvements under KKW-1 and generalization to unseen initializations, road lengths, and vehicle counts.For stochastic dynamics, it reproduces characteristic local density–flow behavior and a shift from high-speed free flow to congestion as local density increases.Source: §6 · p. 30
- Future work should extend the framework to higher and continuous velocities, open boundaries, multi-lane roads, and heterogeneous traffic.Source: §6 · p. 30
Appendix A. Evaluation Metrics
Evaluation metrics are computed over complete rollout trajectories, with reference states, predictions, occupied cells, and vehicle counts defined at each time step. Metrics are then averaged across test trajectories and independent training runs.
Appendix A. Evaluation Metrics
- The evaluation defines the reference state, model prediction, occupied-cell set, and vehicle count at each rollout time step.The metrics are calculated over complete rollout trajectories and averaged over test trajectories and independent training runs.Source: Appendix A · p. 36
Mean Absolute Error
This section defines prediction-error, occupancy, vehicle-conservation, and probability-distribution metrics. The metrics evaluate cell values, occupied cells, vehicle counts, and next-velocity distributions.
Mean Absolute Error
- Mean Absolute Error (MAE) measures the average absolute difference between predicted and reference cell values.Source: Mean Absolute Error · p. 36
Mean Squared Error
- Mean Squared Error (MSE) is introduced as a separate metric.Source: Mean Squared Error · p. 36
Car Mean Absolute Error
- Car MAE is computed over occupied cells to evaluate prediction accuracy on vehicles.Source: Car Mean Absolute Error · p. 36
Occupancy Accuracy
- Occupancy Accuracy (OA) is the fraction of cells whose empty-or-occupied state is predicted correctly.Source: Occupancy Accuracy · p. 36
Conservation Error
- The Conservation Error (CE) quantifies deviations in the total number of vehicles.Source: Conservation Error · p. 37
Relative Conservation Error
- Relative Conservation Error (RCE) normalizes the conservation error by the reference vehicle count.Source: Relative Conservation Error · p. 37
Total Variation Distance
- Total Variation (TV) distance measures agreement between predicted and reference next-velocity probability distributions; it ranges from 0 to 1, with 0 indicating identical distributions.Source: Total Variation Distance · p. 37
Appendix A.1. Relative L2 Error
Relative L2 Error evaluates agreement between global fundamental diagrams for stochastic PI-NCA and the corresponding reference traffic model at matching global densities.
Appendix A.1. Relative L2 Error
- Relative L2 Error compares global flow curves for stochastic PI-NCA and the reference model at the same global densities.Source: Appendix A.1 · p. 37
Appendix B. KKW-1 Reference Dynamics
The appendix describes an adapted KKW-1 reference model used to test learning dynamics beyond NaSch. Its rules combine vehicle-gap and leader-velocity conditions with stochastic acceleration and deceleration.
Appendix B. KKW-1 Reference Dynamics
- The adapted KKW-1 model is included to evaluate whether the NCA formulations can learn dynamics beyond NaSch, using road discretization introduced in Section 4.2.Source: Appendix B · p. 38
- The synchronization parameter k sets the range over which a vehicle adapts to its leading vehicle, alongside safe-velocity and synchronization-distance quantities.Source: Appendix B · p. 38
- The control-velocity rule depends on whether the available gap exceeds the synchronization-distance threshold, using acceleration or the leader-versus-follower velocity difference.Source: Appendix B · p. 38
- Stochastic KKW-1 dynamics use ηt(i) for acceleration or deceleration, with outcomes determined by pb and pa and a uniformly sampled r.Source: Appendix B · pp. 38–39
- The adapted model specifies deceleration probabilities for stopped and moving vehicles and acceleration probabilities below and above threshold vp.Source: Appendix B · p. 39
- The appendix lists adapted KKW-1 experiment parameters in Table B.5.Source: Appendix B · p. 39, Table B.5 · p. 40
Appendix C. Additional Performance Tables
The appendix provides additional deterministic prediction results for NCA and PI-NCA on NaSch and KKW-1 test sets, including metrics and test-condition breakdowns.
Appendix C. Additional Performance Tables
- The additional results report mean and standard deviation over 5 independent training runs for deterministic NCA and PI-NCA predictions on both test sets.Source: Appendix C · p. 40, Table C.6 · p. 40
- Table C.6 reports overall prediction performance over the complete NaSch and KKW-1 test sets, including MSE, OA, and RCE metrics.Source: Appendix C · p. 40, Table C.6 · p. 40
- Tables C.7–C.9 provide MAE and CE results across initialization strategies, road lengths, and vehicle counts; road lengths L ∈{50, 150} are out-of-distribution.Source: Appendix C · p. 40, Table C.7 · p. 41, Table C.8 · p. 42
Appendix D. Learned Stochastic Behavior
The stochastic PI-NCA closely recovers the NaSch transition distributions across tested randomization probabilities. For both NaSch and KKW-1, its predicted velocity probabilities shift toward slower classes as local density increases.
- Across p = 0.1–0.9, stochastic PI-NCA distributions closely follow the NaSch reference, with mean total variation distance remaining small (Figures D.14–D.15).Figure D.14 compares probabilities assigned to next-velocity classes; Figure D.15 reports total variation distances across independent training runs.Source: Appendix D · p. 42, Figure D.14 · p. 43, Figure D.15 · p. 44
- The Figure D.16 probabilities come from the same single PI-NCA simulations used for the local fundamental diagrams, grouped by local density using matching detector locations and temporal windows.Source: Appendix D · pp. 42–43
- For both NaSch and KKW-1, increasing local density shifts predicted probability mass from higher to lower next-velocity classes (Figure D.16).The corresponding learned velocity distributions shift from faster to slower movement, reducing local flow.Source: Appendix D · p. 43, Figure D.16 · p. 44