Skip to main content

MObility Simulation System

Project description

MOSS: MObility Simulation System

Upload Python Package

A GPU-accelerated Large-scale Open Microscopic Traffic Simulation System

Website: https://moss.fiblab.net

Documentation: https://moss.fiblab.net/docs/introduction

API Reference: https://docs.fiblab.net/moss

Features

  • Efficient: MOSS adopts GPU as the computational engine, which accelerates 100 times compared to existing microscopic traffic simulators, allowing rapid simulation of large-scale urban road networks.
  • Realistic: MOSS provides the cutting-edge AIGC method to generate globally available realistic OD matrices for travel demand generation and allows the user to quickly calibrate the simulation parameters to obtain realistic simulation results.
  • Open: The simulator, toolchain, and sample programs will be open-sourced on Github for community access, and we hope that more people will join in the development and application of MOSS.

Awesome MOSS

The related repositories of MOSS are as follows:

  • cityproto: The protobuf-driven data structure definition for all city simulation projects of FIBLAB, URL. The project provides C/C++, Golang, Python, and Javascript/Typescript interfaces to access the data structure. (match python-moss>=1.0.0)
  • mosstool: The toolchain for MOSS, URL. The project is a Python packages that includes map building, traffic demand generation, SUMO format conversion, and some format conversion utilities. It is the key to build the input of MOSS. (match python-moss>=1.0.0)
  • routing: A gRPC-powered routing service with A* shortest path algorithm, URL. The project is the necessary service for mosstool when generating traffic demand or just calling pre_route functions to compute the routes of people. (match python-moss>=1.0.0)
  • moss-replay: A internal JS/TS package for building web-based UI to visualize the simulation results, URL. (match python-moss>=1.0.0)
  • moss-webui-frontend: A web UI to visualize the PostgreSQL output of the MOSS project, URL. The project is only a frontend built on moss-replay and provide a simple 2D visualization for debugging. Users can choose the backend URL in the web settings to connect to their backend and databases. (match python-moss>=1.0.0)
  • moss-webui-backend: A web backend to provide HTTP Restful API for the database output of the MOSS project, URL. The project provides Docker images to allow users to deploy the backend easily. (match python-moss>=1.0.0)
  • moss-ui: A simple UI to visualize the AVRO output of the MOSS project by adapting moss-replay to the AVRO output, URL. The project is a desktop application using web technologies, but it now faces performance challenges to manage data without a database. (match python-moss>=1.0.0, unstable)
  • MOSS based transportation optimization benchmark: A benchmark for large-scale transportation optimization benchmark based on MOSS, URL. The project includes simulation performance evaluation, traffic signal control optimization, dynamic lane control optimization, tidal lane control optimization, congestion pricing optimization, and road planning optimization. (match python-moss>=0.3.3,<1.0.0, will be updated)
  • sample programs: The sample programs for MOSS, URL. The project includes the showcases of MOSS for traffic signal control optimization. (match python-moss==0.2.0, deprecated)

Installation

Prerequisites

  • Linux
  • CUDA 11.8
  • Python >= 3.9

Install

pip install python-moss

Very Simple Demo

We assume that you have the map input map.pb and the person input person.pb generated by mosstool. The following code is a simple demo to run the simulation.

from moss import Engine, Verbosity
from moss.export import DBRecorder

e = Engine(
    "name",
    "data/map.pb",
    "data/person.pb",
    0,
    1,
    output_dir="output", # AVRO output, local directory
    speed_stat_interval=300, # open road status statistics
    verbose_level=Verbosity.ALL,
)
recorder = DBRecorder(
    e,
    "postgres://user:password@url:port/simulation",
    "map_db.map_coll", # map collection used for webui-backend
    "name",
) # used for PostgreSQL output
for _ in range(3600):
    e.next_step(1)
    recorder.record()
    # YOU CAN DO SOMETHING HERE
    # persons = e.fetch_persons()
    # ...
# save the simulation results to the database
recorder.flush()

FAQ

Q1: How to resolve the error ImportError: /.../libstdc++.so.6: version 'GLIBCXX_3.4.30' not found?

A1: Run conda install -c conda-forge libstdcxx-ng=12 in the current conda environment.

Development

If you are interested in the development of MOSS, you can follow the instructions below.

Prequsites

  • Linux
  • CUDA 11.8 or higher
  • CMake >= 3.18
  • Python >= 3.9
  • Network that can access the GitHub repository

Compile and Build

  1. Install Boost
wget -O boost_1_86_0.tar.gz https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.gz
tar -zxvf boost_1_86_0.tar.gz
cd boost_1_86_0
./bootstrap.sh --with-libraries=filesystem,iostreams,program_options,regex,system --prefix=/usr/local  # avro dependency
./b2 install
cd ..
rm -r boost_1_86_0
rm boost_1_86_0.tar.gz
  1. Build MOSS
mkdir build
cd build
cmake ..
make -j
  1. Test MOSS: You can use the compiled MOSS executable to run the simulation to skip the python package installation.
./build/bin/moss -h

Usage: Moss [--help] [--version] --name VAR --config VAR [--gpu VAR] [--quiet]

Optional arguments:
  -h, --help     shows help message and exits 
  -v, --version  prints version information and exits 
  -n, --name     name of the simulation [required]
  -c, --config   path to config file [required]
  --gpu          GPU device ID [nargs=0..1] [default: 0]
  -q, --quiet

The config file is a YAML file that contains the simulation parameters. You can refer to the ConfigFile in the repository. The meanings of the parameters can be found in the python package Engine's docstring in engine.py.

  1. Install Python Package
pip install . -v
  1. You can submit a pull request to the repository to contribute to the project.

Version History

v1.1

  • We apply a CUDA memory arena to do dynamic memory allocation in the GPU memory, which make the project been seen as a right CUDA project.
  • Based on the memory arena, we implement the checkpoint mechanism to save the simulation state to CPU memory and restore it from CPU memory.
  • More efficient database recorder with incompatible APIs.
  • Some bug fixes, performance improvements and more Python API.

From v0.4 to v1.0

That is what we change and why we change it.

  • Focus on the microscopic traffic simulation only (vehicle and pedestrian), no crowd in AOI, no bus for more clear code to support community contribution.
  • No overlap in junction to avoid deadlock following CBLab's design.
  • Can output files with widely-used data format for visualization (visualization is the first for the user to understand the simulation). We choose AVRO as the output format.
  • AOI is just as a marker of the starting/ending point of vehicles/pedestrians, no other functions for more clear code.
  • clear code structure and documentation written in English.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

python_moss-1.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

python_moss-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

python_moss-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

python_moss-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file python_moss-1.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_moss-1.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0585fa0ae60c45d081874e706c25e93e0907b8494ea655742c7eae761da53a48
MD5 6fec7ba224ab04e1f1fd50ada2386bd4
BLAKE2b-256 22831fb26211245942271fac3f459beee4838550050e37c43dad240d69283045

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_moss-1.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on tsinghua-fib-lab/moss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_moss-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_moss-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 760378f5933f26feca6e21e4df56971aba8414ea14323ab01778100d2be9b478
MD5 1160aedf7d7ebf99ccb4cad59917826f
BLAKE2b-256 dba6936281db7e8da008dcd14ede310271fa86d381ed83d024dfffe7a61ff08c

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_moss-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on tsinghua-fib-lab/moss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_moss-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_moss-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 99abb5ed5f78369a7555dbfe16f71bd62a04f4c49d0a4068682328cfd9853eca
MD5 3016f1fb9954331f4c3dc37484c2f6f2
BLAKE2b-256 777189c8be37e858b0ba85492f62a260ba2530e156ff278703448473f21ac308

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_moss-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on tsinghua-fib-lab/moss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_moss-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_moss-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0737f8da441c8d8927c0224de3bdb352b3103eb51e0a773f5934edf6b3dd045c
MD5 389bcb8c337c932d76d5df8cf08299e5
BLAKE2b-256 a37949b03cdd139a6b29c70dc89d9225cdb3953157ffd5f7c9d7e0604014e54d

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_moss-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on tsinghua-fib-lab/moss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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