DI-smartcross - Decision Intelligence Platform for Traffic Crossing Signal Control

Overview

DI-smartcross

icon

DI-smartcross - Decision Intelligence Platform for Traffic Crossing Signal Control.

DI-smartcross is application platform under OpenDILab

Instruction

DI-smartcross is an open-source traffic crossing signal control platform. DI-smartcross applies several Reinforcement Learning policies training & evaluation for traffic signal control system in provided road nets.

DI-smartcross uses DI-engine, a Reinforcement Learning platform to build RL experiments. DI-smartcross uses SUMO (Simulation of Urban MObility) traffic simulator package to run signal control simulation.

DI-smartcross supports:

  • Single-Agent and Multi-Agent Reinforcement Learning
  • Synthetic and Real roadnet, Arterial and Grid network shape
  • Customizable observation, action and reward types
  • Easily achieve Multi-Environment Parallel, Actor-Learner Asynchronous Parallel when training with DI-engine

Installation

DI-smartcross supports SUMO version >= 1.6.0. Here we show an easy guide of installation with SUMO 1.8.0 on Linux.

Install sumo

  1. install required libraries and dependencies
sudo apt-get install cmake python g++ libxerces-c-dev libfox-1.6-dev libgdal-dev libproj-dev libgl2ps-dev swig
  1. download and unzip the installation package
tar xzf sumo-src-1.8.0.tar.gz
cd sumo-1.8.0
pwd 
  1. compile sumo
mkdir build/cmake-build
cd build/cmake-build
cmake ../..
make -j $(nproc)
  1. environment variables
echo 'export PATH=$HOME/sumo-1.8.0/bin:$PATH
export SUMO_HOME=$HOME/sumo-1.8.0' | tee -a $HOME/.bashrc
source ~/.bashrc
  1. check install
sumo

If success, the following message will be shown in the shell.

Eclipse SUMO sumo Version 1.8.0
  Build features: Linux-3.10.0-957.el7.x86_64 x86_64 GNU 5.3.1 Release Proj GUI SWIG GDAL GL2PS
  Copyright (C) 2001-2020 German Aerospace Center (DLR) and others; https://sumo.dlr.de
  License EPL-2.0: Eclipse Public License Version 2 <https://eclipse.org/legal/epl-v20.html>
  Use --help to get the list of options.

Install DI-smartcross

To install DI-smartcross, simply run pip install in the root folder of this repository. This will automatically insall DI-engine as well.

pip install -e . --user

Quick Start

Run training and evaluation

DI-smartcross supports DQN, Off-policy PPO and Rainbow DQN RL methods with multi-discrete actions for each crossing. A set of default DI-engine configs is provided for each policy. You can check the document of DI-engine to get detail instructions of these configs.

  • train RL policies
usage: sumo_train [-h] -d DING_CFG -e ENV_CFG [-s SEED] [--dynamic-flow]
                  [-cn COLLECT_ENV_NUM] [-en EVALUATE_ENV_NUM]
                  [--exp-name EXP_NAME]

DI-smartcross training script

optional arguments:
  -h, --help            show this help message and exit
  -d DING_CFG, --ding-cfg DING_CFG
                        DI-engine configuration path
  -e ENV_CFG, --env-cfg ENV_CFG
                        sumo environment configuration path
  -s SEED, --seed SEED  random seed for sumo
  --dynamic-flow        use dynamic route flow
  -cn COLLECT_ENV_NUM, --collect-env-num COLLECT_ENV_NUM
                        collector sumo env num for training
  -en EVALUATE_ENV_NUM, --evaluate-env-num EVALUATE_ENV_NUM
                        evaluator sumo env num for training
  --exp-name EXP_NAME   experiment name to save log and ckpt

Example of running DQN in wj3 env with default config.

sumo_train -e smartcross/envs/sumo_arterial_wj3_default_config.yaml -d entry/config/sumo_wj3_dqn_default_config.py
  • evaluate existing policies
usage: sumo_eval [-h] [-d DING_CFG] -e ENV_CFG [-s SEED]
                 [-p {random,fix,dqn,rainbow,ppo}] [--dynamic-flow]
                 [-n ENV_NUM] [--gui] [-c CKPT_PATH]

DI-smartcross training script

optional arguments:
  -h, --help            show this help message and exit
  -d DING_CFG, --ding-cfg DING_CFG
                        DI-engine configuration path
  -e ENV_CFG, --env-cfg ENV_CFG
                        sumo environment configuration path
  -s SEED, --seed SEED  random seed for sumo
  -p {random,fix,dqn,rainbow,ppo}, --policy-type {random,fix,dqn,rainbow,ppo}
                        RL policy type
  --dynamic-flow        use dynamic route flow
  -n ENV_NUM, --env-num ENV_NUM
                        sumo env num for evaluation
  --gui                 open gui for visualize
  -c CKPT_PATH, --ckpt-path CKPT_PATH
                        model ckpt path

Example of running random policy in wj3 env.

sumo_eval -p random -e smartcross/envs/sumo_arterial_wj3_default_config.yaml     

Environments

sumo env configuration

The configuration of sumo env is stored in a config .yaml file. You can take a look at the default config file to see how to modify env settings.

import yaml
from easy_dict import EasyDict
from smartcross.env import SumoEnv

with open('smartcross/envs/sumo_arterial_wj3_default_config.yaml') as f:
    cfg = yaml.safe_load(f)
cfg = EasyDict(cfg)
env = SumoEnv(config=cfg.env)

The env configuration consists of basic definition and observation\action\reward settings. The basic definition includes the cumo config file, episode length and light duration. The obs\action\reward define the detail setting of each contains.

env:
    sumocfg_path: 'arterial_wj3/rl_wj.sumocfg'
    max_episode_steps: 1500
    green_duration: 10
    yellow_duration: 3
    obs:
        ...
    action:
        ...
    reward:
        ...

Observation

We provide several types of observations of a traffic cross. If use_centrolized_obs is set True, the observation of each cross will be concatenated into one vector. The contents of observation can me modified by setting obs_type. The following observation is supported now.

  • phase: One-hot phase vector of current cross signal
  • lane_pos_vec: Lane occupancy in each grid position. The grid num can be set with lane_grid_num
  • traffic_volumn: Traffic volumn of each lane. Vehicle num / lane length * volumn ratio
  • queue_len: Vehicle waiting queue length of each lane. Waiting num / lane length * volumn ratio

Action

Sumo environment supports changing cross signal to target phase. The action space is set to multi-discrete for each cross to reduce action num.

Reward

Reward can be set with reward_type. Reward is calculated cross by cross. If use_centrolized_obs is set True, the reward of each cross will be summed up.

  • queue_len: Vehicle waiting queue num of each lane
  • wait_time: Wait time increment of vehicles in each lane
  • delay_time: Delay time of all vahicles in incomming and outgoing lanes
  • pressure: Pressure of a cross

Contributing

We appreciate all contributions to improve DI-smartcross, both algorithms and system designs.

License

DI-smartcross released under the Apache 2.0 license.

Citation

@misc{smartcross,
    title={{DI-smartcross: OpenDILab} Decision Intelligence platform for Traffic Crossing Signal Control},
    author={DI-smartcross Contributors},
    publisher = {GitHub},
    howpublished = {\url{`https://github.com/opendilab/DI-smartcross`}},
    year={2021},
}
Comments
  • style(hus): update email address

    style(hus): update email address

    Description

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by TuTuHuss 0
  • update and fix typo in docs

    update and fix typo in docs

    Description

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by RobinC94 0
  • update envs, docs and actions

    update envs, docs and actions

    Description

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by RobinC94 0
  • Dev

    Dev

    Description

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by RobinC94 0
  • Merge branch 'main' into dev

    Merge branch 'main' into dev

    Description

    None

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by RobinC94 0
  • update readme

    update readme

    Description

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by RobinC94 0
  • suit for 0.3.0

    suit for 0.3.0

    Description

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by RobinC94 0
  • v0.1.0 update

    v0.1.0 update

    Description

    add cityflow env suit ding 0.3

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by RobinC94 0
  • Dev: Version 0.0.1

    Dev: Version 0.0.1

    Description

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by RobinC94 0
  • Dev: update obs helper, mappo; update configs

    Dev: update obs helper, mappo; update configs

    Description

    update obs helper, mappo; add arterial7; update configs

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by RobinC94 0
  • add different settings for ppo

    add different settings for ppo

    Description

    Related Issue

    TODO

    Check List

    • [ ] merge the latest version source branch/repo, and resolve all the conflicts
    • [ ] pass style check
    • [ ] pass all the tests
    opened by kxzxvbk 0
Releases(v0.1.0)
Owner
OpenDILab
Open sourced Decision Intelligence (DI)
OpenDILab
YOLOV4运行在嵌入式设备上

在嵌入式设备上实现YOLO V4 tiny 在嵌入式设备上实现YOLO V4 tiny 目录结构 目录结构 |-- YOLO V4 tiny |-- .gitignore |-- LICENSE |-- README.md |-- test.txt |-- t

Liu-Wei 6 Sep 09, 2021
Code for the paper One Thing One Click: A Self-Training Approach for Weakly Supervised 3D Semantic Segmentation, CVPR 2021.

One Thing One Click One Thing One Click: A Self-Training Approach for Weakly Supervised 3D Semantic Segmentation (CVPR2021) Code for the paper One Thi

44 Dec 12, 2022
Super Pix Adv - Offical implemention of Robust Superpixel-Guided Attentional Adversarial Attack (CVPR2020)

Super_Pix_Adv Offical implemention of Robust Superpixel-Guided Attentional Adver

DLight 8 Oct 26, 2022
ONNX Runtime Web demo is an interactive demo portal showing real use cases running ONNX Runtime Web in VueJS.

ONNX Runtime Web demo is an interactive demo portal showing real use cases running ONNX Runtime Web in VueJS. It currently supports four examples for you to quickly experience the power of ONNX Runti

Microsoft 58 Dec 18, 2022
This repository contains code to train and render Mixture of Volumetric Primitives (MVP) models

Mixture of Volumetric Primitives -- Training and Evaluation This repository contains code to train and render Mixture of Volumetric Primitives (MVP) m

Meta Research 125 Dec 29, 2022
A minimal yet resourceful implementation of diffusion models (along with pretrained models + synthetic images for nine datasets)

A minimal yet resourceful implementation of diffusion models (along with pretrained models + synthetic images for nine datasets)

Vikash Sehwag 65 Dec 19, 2022
Conformer: Local Features Coupling Global Representations for Visual Recognition

Conformer: Local Features Coupling Global Representations for Visual Recognition (arxiv) This repository is built upon DeiT and timm Usage First, inst

Zhiliang Peng 378 Jan 08, 2023
Snscrape-jsonl-urls-extractor - Extracts urls from jsonl produced by snscrape

snscrape-jsonl-urls-extractor extracts urls from jsonl produced by snscrape Usag

1 Feb 26, 2022
This is the winning solution of the Endocv-2021 grand challange.

Endocv2021-winner [Paper] This is the winning solution of the Endocv-2021 grand challange. Dependencies pytorch # tested with 1.7 and 1.8 torchvision

Vajira Thambawita 14 Dec 03, 2022
AI Face Mesh: This is a simple face mesh detection program based on Artificial intelligence.

AI Face Mesh: This is a simple face mesh detection program based on Artificial Intelligence which made with Python. It's able to detect 468 different

Md. Rakibul Islam 1 Jan 13, 2022
Neural Reprojection Error: Merging Feature Learning and Camera Pose Estimation

Neural Reprojection Error: Merging Feature Learning and Camera Pose Estimation This is the official repository for our paper Neural Reprojection Error

Hugo Germain 78 Dec 01, 2022
PromptDet: Expand Your Detector Vocabulary with Uncurated Images

PromptDet: Expand Your Detector Vocabulary with Uncurated Images Paper Website Introduction The goal of this work is to establish a scalable pipeline

103 Dec 20, 2022
An introduction to satellite image analysis using Python + OpenCV and JavaScript + Google Earth Engine

A Gentle Introduction to Satellite Image Processing Welcome to this introductory course on Satellite Image Analysis! Satellite imagery has become a pr

Edward Oughton 32 Jan 03, 2023
Build upon neural radiance fields to create a scene-specific implicit 3D semantic representation, Semantic-NeRF

Semantic-NeRF: Semantic Neural Radiance Fields Project Page | Video | Paper | Data In-Place Scene Labelling and Understanding with Implicit Scene Repr

Shuaifeng Zhi 243 Jan 07, 2023
This is the official source code of "BiCAT: Bi-Chronological Augmentation of Transformer for Sequential Recommendation".

BiCAT This is our TensorFlow implementation for the paper: "BiCAT: Sequential Recommendation with Bidirectional Chronological Augmentation of Transfor

John 15 Dec 06, 2022
Graph Analysis From Scratch

Graph Analysis From Scratch Goal In this notebook we wanted to implement some functionalities to analyze a weighted graph only by using algorithms imp

Arturo Ghinassi 0 Sep 17, 2022
Learning Pixel-level Semantic Affinity with Image-level Supervision for Weakly Supervised Semantic Segmentation, CVPR 2018

Learning Pixel-level Semantic Affinity with Image-level Supervision This code is deprecated. Please see https://github.com/jiwoon-ahn/irn instead. Int

Jiwoon Ahn 337 Dec 15, 2022
Supplementary materials to "Spin-optomechanical quantum interface enabled by an ultrasmall mechanical and optical mode volume cavity" by H. Raniwala, S. Krastanov, M. Eichenfield, and D. R. Englund, 2022

Supplementary materials to "Spin-optomechanical quantum interface enabled by an ultrasmall mechanical and optical mode volume cavity" by H. Raniwala,

Stefan Krastanov 1 Jan 17, 2022
Pytorch implementation of Make-A-Scene: Scene-Based Text-to-Image Generation with Human Priors

Make-A-Scene - PyTorch Pytorch implementation (inofficial) of Make-A-Scene: Scene-Based Text-to-Image Generation with Human Priors (https://arxiv.org/

Casual GAN Papers 259 Dec 28, 2022
Learning to Disambiguate Strongly Interacting Hands via Probabilistic Per-Pixel Part Segmentation [3DV 2021 Oral]

Learning to Disambiguate Strongly Interacting Hands via Probabilistic Per-Pixel Part Segmentation [3DV 2021 Oral] Learning to Disambiguate Strongly In

Zicong Fan 40 Dec 22, 2022