Skip to main content

Parallelized differentiable IDM computation layer for traffic simulation

Project description

DiffIDM [Arxiv]

This is the official code of our paper "Gradient-based Trajectory Optimization with Parallelized Traffic Simulation", which has been accepted to ICRA 2025. Here we provide the code for parallelized differentiable IDM computation layer, which could be easily adopted for larger scale traffic simulators. The computation layer can handle upto 2 million vehicles in real time using either CPU or GPU. We also provide our experiment code for filtering vehicle trajectories in NGSim dataset using our simulator. Please see our paper for more details.

Parallelization scheme

Install

You need to install pytorch to use our computation layer. Then, you can install our computation layer using pip.

pip install diffidm

After installation, you can use the computation layer as follows.

import torch
from diffidm.layer import IDMLayer

num_vehicles = int(1e6)   # 1M vehicles

### randomly generate IDM variables
a_max = th.

Usage: Trajectory filtering for NGSIM dataset

As demonstrated in our paper, we can use our computation layer to filter physically unrealistic vehicle motions from their trajectories captured in real-world. We tested our filtering algorithm on NGSIM dataset. To run the algorithm, first download the dataset (1.53GB) from this page to data directory, under the name of ngsim.csv. Then, preprocess the data with the following command.

python ngsim_preprocess.py

This preprocessing step generates input data for our filtering algorithm, which would be saved in input/. Then, we can use the following command to filter the NGSIM trajectories in us-101 category using our computation layer. Please see ngsim_filter.py for the details abour arguments.

CUDA_VISIBLE_DEVICES=0 OMP_NUM_THREADS=1 python ngsim_filter.py --token=us-101 --device=cuda 

The filtered trajectories and related optimization results (e.g. IDM parameters for each trip) are stored under output/ directory. Finally, we can evaluate the filtered trajectories by comparing them with the ground truth data and generate the experimental results in the paper with following command. Also see ngsim_eval.py for the details about arguments.

python ngsim_eval.py --token=us-101 --render-traj-id=1000

The evaluation results are saved in eval/.

Citation

If you found our work to be useful, please consider citing our work.

@article{son2024gradient,
  title={Gradient-based Trajectory Optimization with Parallelized Differentiable Traffic Simulation},
  author={Son, Sanghyun and Zheng, Laura and Clipp, Brian and Greenwell, Connor and Philip, Sujin and Lin, Ming C},
  journal={arXiv preprint arXiv:2412.16750},
  year={2024}
}

Acknowledgement

We used Wei Ma's NGSIM interface code for preprocessing NGSIM dataset. We appreciate this great work.

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

diffidm-0.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

diffidm-0.0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file diffidm-0.0.1.tar.gz.

File metadata

  • Download URL: diffidm-0.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for diffidm-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1ca750b82c86d730281a62b41d65fb9362441f342c803f4c73d27e9cac2fb2fb
MD5 9881831aadf3a360a009efcca8ae7cd9
BLAKE2b-256 7c45251d98b959344e9f63b3d14dd3ce26d694d2d557b14941d556bd57ed4b72

See more details on using hashes here.

File details

Details for the file diffidm-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: diffidm-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for diffidm-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ff99086362541b2fee2c0a9252f91736f78618c076eaf7574bcebdf248193327
MD5 96dcd7a6204fab076762e996fbd754b7
BLAKE2b-256 392e929cf38c6b31b1a45d6424f9d86c35afffd3bd0bcb0e57cc485cfcd2f1d0

See more details on using hashes here.

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