UXsim: traffic flow simulator
Project description
UXsim: Network traffic flow simulator in pure Python
(日本語の説明書はこちら/Japanese readme is here)
UXsim is a free, open-source macroscopic and mesoscopic network traffic flow simulator developed in Python. It is suitable for simulating large-scale (e.g., city-scale) vehicular transportation. It computes dynamic traffic flow in a network by using traffic flow models commonly utilized by transportation research. UXsim would be especially useful for scientific and educational purposes because of its simple, lightweight, and customizable features; but of course users are free to use UXsim for any purpose.
Main Features
- Dynamic network traffic simulation with a given network and time-dependent OD demand (i.e., dynamic traffic assignment). Specifically, the following models are used jointly:
- Newell's simplified car-following model (X-Model)
- Lagrangian Incremental Node Model
- Dynamic User Optimum-type Route Choice Model (with inertia)
- Implementation of traffic management schemes (e.g., traffic signals, inflow control, route guidance, congestion pricing).
- Basic analysis of simulation results (e.g., trip completion rate, total travel time, delay), and their export to pandas.DataFrame and CSV files.
- Visualization of simulation results (e.g., time-space diagram, MFD, network traffic animation).
- Can be flexibly customized by users thanks to pure Python implementation.
- Can also be directly integrated with other Python-based frameworks, such as PyTorch for deep reinforcement learning traffic control.
Main files
uxsim
directory: UXsim main packageuxsim/uxsim.py
: UXsim main codeuxsim/utils.py
: UXsim utilities codeuxsim/utils
directory: UXsim utilities files
demos_and_examples
directory: Tutorials and examples of UXsimdat
directory: Sample scenario files
Usage
First, install UXsim package using pip:
pip install uxsim
or download the uxsim
directory from this Github repo and place it to your local directory.
The former is required if you want to customize UXsim’s internal logic.
Then import the module using:
from uxsim import *
The Jupyter Notebook Demo summarizes the basic usage and features. For the further details, please see demos_and_examples and UXsim technical documentation.
Simulation Example
Large-scale scenario
Belows are simulation result where approximately 60000 vehicles pass through a 10km x 10km grid network in 2 hours. The computation time was about 30 seconds on a standard desktop PC.
Visualization of link traffic states (thicker lines mean more vehicles, darker colors mean slower speeds) and some vehicle trajectories:
Vehicle trajectory diagram on a corridor of the above network:
Deep reinforcement learning signal control using PyTorch
Traffic signal controller is trained by deep reinforcement learning (DRL) of PyTorch. The left is no control scenario with fixed signal timing; the traffic demand exceeds the network capacity with naive signal setting, and a gridlock occurs. The right is with DRL control scenario, where traffic signal can be changed by observing queue length; although the demand level is the same, traffic is smoothly flowing. Jupyter Notebook of this example is available.
Terms of Use & License
UXsim is released under the MIT License. You are free to use it as long as the source is acknowledged.
When publishing works based on from UXsim, please cite:
- Toru Seo. Macroscopic Traffic Simulation: Fundamental Mathematical Theory and Python Implementation. Corona Publishing Co., Ltd., 2023.
- Toru Seo. UXsim: An open source macroscopic and mesoscopic traffic simulator in Python-a technical overview. arXiv preprint arXiv: 2309.17114, 2023
Related Links
- Toru Seo (Author)
- Collection of related simulators by Seo
- Japanese book "Macroscopic Traffic Simulation: Fundamental Mathematical Theory and Python Implementation" (Author: Toru Seo, Publisher: Corona Publishing Co., Ltd.): UXsim is a significant expansion of the traffic flow simulator UroborosX described in this book.
- Seo Laboratory, Tokyo Institute of Technology
- Interactive Traffic Flow Simulator that Runs on a Web Browser: Play with the same link traffic flow model used in this simulator interactively, and learn the basics of traffic flow and its simulation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.