This repo provide necessary code for running SUMO with DQN and its variants.
Now it supports:
- DQN
- Double DQN
- Dueling DQN
- Double Dueling DQN (D3QN)
You can refer to sumo_rl or follow these instructions to install dependencies:
git clone https://github.com/hienhayho/sumo_TSC.git
cd sumo_TSC/
conda create -n rl python=3.10 -y
conda activate rl
chmod +x install.sh
bash ./install.sh
echo 'export SUMO_HOME="/usr/share/sumo"' >> ~/.bashrc
source ~/.bashrc
conda activate rl
If it shows: Permission denied, run:
sudo bash ./install.sh
There are 4 agents available, you can implement more agents and import it to sumo_rl/agents/_init_.py. Make sure you add it to build_model
function as well.
model_name
: name of-name
flag in tools/train.pynet_type
: type of core network. There are two available networks in sumo_rl/agents/base_net.py, you can implement your own networks and add tobuild_net
function.
To add new reward function, please refer to sumo_rl/environment/traffic_signal.py.
This work is automatically run with single intersection environment in SUMO, you can refer to here to change environments.
For training, you can refer to tools/train.py.
- Here an example for traing
dqn
withdiff-waiting-time
reward function:
CUDA_VISIBLE_DEVICES=0 python tools/train.py -name dqn -s 10000
- Training AIO (all in one):
apt-get install make -y
make train
If it shows: Permission denied, run:
sudo apt-get install make -y
Model and logs is at outputs/<model_name>/<reward_fn>_<time>
CUDA_VISIBLE_DEVICES=0 python tools/play.py -name <model_name> -r <reward_fn> -model <model_path>
Example:
CUDA_VISIBLE_DEVICES=0 python tools/play.py -name dqn -r diff-waiting-time -model outputs/dqn/diff-waiting-time_2024_
5EA6
05_28_20_10_14/model_20240528.pth
This code is developed from sumo_rl by hienhayho
.