Skip to main content

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 package
    • uxsim/uxsim.py: UXsim main code
    • uxsim/utils.py: UXsim utilities code
    • uxsim/utils directory: UXsim utilities files
  • demos_and_examples directory: Tutorials and examples of UXsim
  • dat 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 Flow 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uxsim-1.0.4.tar.gz (69.5 kB view hashes)

Uploaded Source

Built Distribution

uxsim-1.0.4-py3-none-any.whl (66.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page