TorchGRL is the source code for our paper Graph Convolution-Based Deep Reinforcement Learning for Multi-Agent Decision-Making in Mixed Traffic Environments for IV 2022.

Related tags

Deep LearningTorchGRL
Overview

TorchGRL

TorchGRL is the source code for our paper Graph Convolution-Based Deep Reinforcement Learning for Multi-Agent Decision-Making in Mixed Traffic Environments for IV 2022.TorchGRL is a modular simulation framework that integrates different GRL algorithms and SUMO simulation platform to realize the simulation of multi-agents decision-making algorithms in mixed traffic environment. You can adjust the test scenarios and the implemented GRL algorithm according to your needs.


Preparation

Before starting to carry out some relevant works on our framework, some preparations are required to be done.

Hardware

Our framework is developed based on a laptop, and the specific configuration is as follows:

  • Operating system: Ubuntu 20.04
  • RAM: 32 GB
  • CPU: Intel (R) Core (TM) i9-10980HK CPU @ 2.40GHz
  • GPU: RTX 2070

It should be noted that our program must be reproduced under the Ubuntu 20.04 operating system, and we strongly recommend using GPU for training.

Development Environment

Before compiling the code of our framework, you need to install the following development environment:

  • Ubuntu 20.04 with latest GPU driver
  • Pycharm
  • Anaconda
  • CUDA 11.1
  • cudnn-11.1, 8.0.5.39

Installation

Please download our GRL framework repository first:

git clone https://github.com/Jacklinkk/TorchGRL.git

Then enter the root directory of TorchGRL:

cd TorchGRL

and please be sure to run the below commands from /path/to/TorchGRL.

Installation of FLOW

The FLOW library will be firstly installed.

Firstly, enter the flow directory:

cd flow

Then, create a conda environment from flow library:

conda env create -f environment.yml

Activate conda environment:

conda activate TorchGCQ

Install flow from source code:

python setup.py develop

Installation of SUMO

SUMO simulation platform will be installed. Please make sure to run the below commands in the "TorchGRL" virtual environment.

Install via pip:

pip install eclipse-sumo

Setting in Pycharm:

In order to adopt SUMO correctly, you need to define the environment variable of SUMO_HOME in Pycharm. The specific directory is:

/home/…/.conda/envs/TorchGCQ/lib/python3.7/site-packages/sumo

Setting in Ubuntu:

At first, run:

gedit ~/.bashrc

then copy the path name of SUMO_HOME to “~/.bashrc”:

export SUMO_HOME=“/home/…/.conda/envs/TorchGCQ/lib/python3.7/site-packages/sumo”

Finally, run:

source ~/.bashrc

Installation of Pytorch and related libraries

Please make sure to run the below commands in the "TorchGRL" virtual environment.

Installation of Pytorch:

We use Pytorch version 1.9.0 for development under a specific version of CUDA and cudnn.

pip3 install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

Installation of pytorch geometric:

Pytorch geometric is a Graph Neural Network (GNN) library upon Pytorch

pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.9.0+cu111.html

Installation of pfrl library

Please make sure to run the below commands in the "TorchGRL" virtual environment.

pfrl is a deep reinforcement learning library that implements various algorithms in Python using PyTorch.

Firstly, enter the pfrl directory:

cd pfrl

Then install from source code:

python setup.py develop

Instruction

flow folder

The flow folder is the root directory of the library after the FLOW library is installed through source code, including interface-related programs between DRL algorithms and SUMO platform.

Flow_Test folder

The Flow_Test folder includes the related programs of the test environment configuration; specifically, T_01.py is the core python program. If the program runs successfully, the environment configuration is successful.

pfrl folder

The pfrl folder is the root directory of the library after the deep reinforcement learning pfrl library is installed through source code, including all DRL related programs. The source program can be modified as needed.

GRLNet folder

The GRLNet folder contains the GRL neural network built in the Pytorch environment. You can modify the source code as needed or add your own neural network.

  • Pytorch_GRL.py constructs the fundamental neural network of GRL algorithms
  • Pytorch_GRL_Dueling.py constructs the dueling network of GRL algorithms

GRL_utils folder

The GRL_utils folder contains basic functions such as model training and testing, data storage, and curve drawing.

  • Train_and_Test.py contains the training and testing functions for the GRL model.
  • Data_Plot_Train.py is the function to plot the training data curve.
  • Data_Process_Test.py is the function to process the test data.
  • Fig folder stores the training data curve.
  • Logging_Training folder stores the training data generated by different GRL algorithms.
  • Logging_Test folder stores the testing data generated by different GRL algorithms.

GRL_Simulation folder

The GRL_Simulation folder is the core of our framework, which contains the core simulation program and some related functional programs.

  • main.py is the main program, containing the definition of FLOW parameters, as well as the controlling (start and end) of the simulation.
  • controller.py is the definition of vehicle control model based on FLOW library.
  • environment.py is the core program to build and initialize the simulation environment of SUMO.
  • network.py defines the road network.
  • registry_custom.py registers the simulation environment of SUMO to the gym library to realize the connection with GRL algorithms.
  • specific_environment.py defines the elements in MDPs, including state representation, action space and reward function.
  • Experiment folder is the core program of co-simulation under different GRL algorithms, including the initialization of the simulation environment, the initialization of the neural network, the training and testing of GRL algorithms, and the preservation of the training and testing results.
  • GRL_Trained_Models folder stores the trained GRL model when the training process ends.

Tutorial

You can simply run "main.py" in Pycharm to simulate the GRL algorithm, and observe the simulation process in SUMO platform. You can generate training plot such as Reward curve:

Verification of other algorithms

If you want to verify other algorithms, you can develop the source code as needed under the "Experiment folder", and don't forget to change the imported python script in "main.py". In addition, you can also construct your own network in GRLNet folder.

Verification of other traffic scenario

If you want to verify other traffic scenario, you can define a new scenario in "network.py". You can refer to the documentation of SUMO for more details .

Owner
XXQQ
XXQQ
🚀 An end-to-end ML applications using PyTorch, W&B, FastAPI, Docker, Streamlit and Heroku

🚀 An end-to-end ML applications using PyTorch, W&B, FastAPI, Docker, Streamlit and Heroku

Made With ML 82 Jun 26, 2022
Contrastive Learning for Metagenomic Binning

CLMB A simple framework for CLMB - a novel deep Contrastive Learningfor Metagenomic Binning Created by Pengfei Zhang, senior of Department of Computer

1 Sep 14, 2022
TrTr: Visual Tracking with Transformer

TrTr: Visual Tracking with Transformer We propose a novel tracker network based on a powerful attention mechanism called Transformer encoder-decoder a

趙 漠居(Zhao, Moju) 66 Dec 27, 2022
The source codes for ACL 2021 paper 'BoB: BERT Over BERT for Training Persona-based Dialogue Models from Limited Personalized Data'

BoB: BERT Over BERT for Training Persona-based Dialogue Models from Limited Personalized Data This repository provides the implementation details for

124 Dec 27, 2022
OpenMMLab Text Detection, Recognition and Understanding Toolbox

Introduction English | 简体中文 MMOCR is an open-source toolbox based on PyTorch and mmdetection for text detection, text recognition, and the correspondi

OpenMMLab 3k Jan 07, 2023
Open-source python package for the extraction of Radiomics features from 2D and 3D images and binary masks.

pyradiomics v3.0.1 Build Status Linux macOS Windows Radiomics feature extraction in Python This is an open-source python package for the extraction of

Artificial Intelligence in Medicine (AIM) Program 842 Dec 28, 2022
Unoffical implementation about Image Super-Resolution via Iterative Refinement by Pytorch

Image Super-Resolution via Iterative Refinement Paper | Project Brief This is a unoffical implementation about Image Super-Resolution via Iterative Re

LiangWei Jiang 2.5k Jan 02, 2023
Transfer Learning Shootout for PyTorch's model zoo (torchvision)

pytorch-retraining Transfer Learning shootout for PyTorch's model zoo (torchvision). Load any pretrained model with custom final layer (num_classes) f

Alexander Hirner 169 Jun 29, 2022
A PyTorch implementation of DenseNet.

A PyTorch Implementation of DenseNet This is a PyTorch implementation of the DenseNet-BC architecture as described in the paper Densely Connected Conv

Brandon Amos 771 Dec 15, 2022
PyTorch code to run synthetic experiments.

Code repository for Invariant Risk Minimization Source code for the paper: @article{InvariantRiskMinimization, title={Invariant Risk Minimization}

Facebook Research 345 Dec 12, 2022
Main Results on ImageNet with Pretrained Models

This repository contains Pytorch evaluation code, training code and pretrained models for the following projects: SPACH (A Battle of Network Structure

Microsoft 151 Dec 14, 2022
Code for the CVPR2022 paper "Frequency-driven Imperceptible Adversarial Attack on Semantic Similarity"

Introduction This is an official release of the paper "Frequency-driven Imperceptible Adversarial Attack on Semantic Similarity" (arxiv link). Abstrac

Leo 21 Nov 23, 2022
Repository for the COLING 2020 paper "Explainable Automated Fact-Checking: A Survey."

Explainable Fact Checking: A Survey This repository and the accompanying webpage contain resources for the paper "Explainable Fact Checking: A Survey"

Neema Kotonya 42 Nov 17, 2022
Pytorch implementation for "Large-Scale Long-Tailed Recognition in an Open World" (CVPR 2019 ORAL)

Large-Scale Long-Tailed Recognition in an Open World [Project] [Paper] [Blog] Overview Open Long-Tailed Recognition (OLTR) is the author's re-implemen

Zhongqi Miao 761 Dec 26, 2022
LSSY量化交易系统

LSSY量化交易系统 该项目是本人3年来研究量化慢慢积累开发的一套系统,属于早期作品慢慢修改而来,仅供学习研究,回测分析,实盘交易部分未公开

55 Oct 04, 2022
Anomaly detection analysis and labeling tool, specifically for multiple time series (one time series per category)

taganomaly Anomaly detection labeling tool, specifically for multiple time series (one time series per category). Taganomaly is a tool for creating la

Microsoft 272 Dec 17, 2022
Sparse Physics-based and Interpretable Neural Networks

Sparse Physics-based and Interpretable Neural Networks for PDEs This repository contains the code and manuscript for research done on Sparse Physics-b

28 Jan 03, 2023
N-gram models- Unsmoothed, Laplace, Deleted Interpolation

N-gram models- Unsmoothed, Laplace, Deleted Interpolation

Ravika Nagpal 1 Jan 04, 2022
Sharing of contents on mitochondrial encounter networks

mito-network-sharing Sharing of contents on mitochondrial encounter networks Required: R with igraph, brainGraph, ggplot2, and XML libraries; igraph l

Stochastic Biology Group 0 Oct 01, 2021
PyTorch implementation for Stochastic Fine-grained Labeling of Multi-state Sign Glosses for Continuous Sign Language Recognition.

Stochastic CSLR This is the PyTorch implementation for the ECCV 2020 paper: Stochastic Fine-grained Labeling of Multi-state Sign Glosses for Continuou

Zhe Niu 28 Dec 19, 2022