About TrafficTwin
Urban Traffic Simulation with Cellular Automata
What is TrafficTwin?
TrafficTwin is an urban traffic simulation platform built on the Nagel-Schreckenberg cellular automata model. It provides a realistic representation of traffic flow dynamics on a configurable grid-based road network.
The simulator models individual vehicles following four fundamental rules: acceleration, gap-based slowing, random braking (to simulate human behavior), and movement. Traffic lights at intersections cycle through green, yellow, and red phases with configurable durations.
Technology Stack
- Backend: Python / FastAPI
- Database: SQLite / SQLAlchemy
- Templates: Jinja2
- Visualization: HTML5 Canvas
- Styling: Custom CSS (urban dark theme)
- Testing: pytest / httpx
The Nagel-Schreckenberg Model
The NaSch model is a theoretical model for highway traffic simulation. At each time step, every vehicle follows these rules:
- Acceleration: If the vehicle's speed is less than the maximum, increase by 1.
- Slowing: If the gap to the next vehicle ahead is less than the current speed, reduce speed to gap size.
- Random Braking: With probability p, reduce speed by 1 (simulates unpredictable driver behavior).
- Movement: Move forward by the current speed.
Version Info
Version: 1.0.0
License: MIT
Author: TrafficTwin Contributors