/trafficRL

Adaptive Traffic Control System Using Reinforcement Learning

Primary LanguagePython

trafficRL

Adaptive Traffic Control System Using Reinforcment Learning

Run

Setup

  1. Install SUMO: http://sumo.dlr.de/wiki/Downloads

  2. Install MongoDB: Follow the official instructions at:

    https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ (for ubuntu) https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/ (for windows)

    Check mongo is installed by starting the server from the command line:

    For Ubuntu: mongod

    For Windows: C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe

  3. Clone the project using git and cd into it:

     git clone https://github.com/codemerlin19/trafficRL.git
    
     cd trafficRL
    
  4. (Optionally) Install Virtual Env

     pip3 install virtualenv
     virtualenv .venv
     source .venv/bin/activate
    
  5. Install requirements

     pip3 install -r requirements.txt
    
  6. Run project

     python runner.py
    

Usage: runner.py [options]

    -h, --help          show this help message and exit
    --nogui             run the commandline version of sumo
    -C NUM, --cars=NUM  specify the number of cars generated for simulation
    --bracket=BRACKET   specify the number with which to partition the range of
                            queue length/cumulative delay
    --learning=NUM      specify learning method (1 = Q-Learning, 2 = SARSA)
    --state=NUM         specify traffic state representation to be used (1 =
                            Queue Length, 2 = Cumulative Delay)
    --phasing=NUM       specify phasing scheme (1 = Fixed Phasing, 2 = Variable
                            Phasing)
    --action=NUM        specify action selection method (1 = epsilon greedy, 2 =
                            softmax)
NOTE: Ensure that SUMO_HOME path is defined in environment variables

Uses

Last tested with Eclipse SUMO Version 1.6.0.

Mongo

Currently it expects mongo on localhost on the default port without any authentication.

Development

Linting

For auto fixes use autopep8:

python -m pip install autopep8
autopep8 --in-place --aggressive  --exclude "__pycache__,.venv"  ./*.py