Giter Club home page Giter Club logo

gym-traffic's Introduction

gym-traffic

OpenAI Gym Environment for Traffic Control

Installation

git clone https://github.com/bstriner/gym-traffic.git
cd gym-traffic
python setup.py install

##Environments

###Simple Environment Traffic-Simple-cli-v0 and Traffic-Simple-gui-v0 model a simple intersection with North-South, South-North, East-West, and West-East traffic.

CLI runs sumo and GUI runs sumo-gui. GUI is slower but required if you want to render video.

Agent has 4 available actions, corresponding to traffic light phases:

  • Green N-S Red E-W
  • Yellow N-S Red E-W
  • Red N-S Green E-W
  • Red N-S Yellow E-W

Simple Environment

##Agents

A simple DQN agent is provided, written in Keras.

##Questions?

Feel free to create issues, pull requests, or email me.

gym-traffic's People

Contributors

bstriner avatar github-bot-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gym-traffic's Issues

'nvec (counts) have to be positive'

I changed some of you code in init.py since there are problems on finding the module.
Right now, I get the problem "'nvec (counts) have to be positive'".
I have no idea to fix it.

I'm using python3 and IDE is VScode.

here are my command and log from running on terminal.
python examples/example_gym_traffic_random.py
Traceback (most recent call last):
File "examples/example_gym_traffic_random.py", line 9, in
env = gym.make('Traffic-Simple-cli-v0')
File "c:\users\user\desktop\gym\gym\envs\registration.py", line 145, in make
return registry.make(id, **kwargs)
File "c:\users\user\desktop\gym\gym\envs\registration.py", line 90, in make
env = spec.make(kwargs)
File "c:\users\user\desktop\gym\gym\envs\registration.py", line 60, in make
env = cls(
_kwargs)
File "c:\users\user\downloads\gym-traffic-first\gym-traffic-first\gym_traffic\envs\traffic_env_simple.py", line 23, in init
super(TrafficEnvSimple, self).init(mode=mode, lights=lights, netfile=netfile, routefile=routefile,
File "c:\users\user\downloads\gym-traffic-first\gym-traffic-first\gym_traffic\envs\traffic_env.py", line 53, in init
spaces.MultiDiscrete([[0, len(light.actions) - 1 ] for light in self.lights]), 'all')
File "c:\users\user\desktop\gym\gym\spaces\multi_discrete.py", line 30, in init
assert (np.array(nvec) > 0).all(), 'nvec (counts) have to be positive'
AssertionError: nvec (counts) have to be positive

And, I also changed the code in the statement in traffic_env. I think the problem is cause from that statement. But, if I did not change the method, it will show me the error of "AttributeError: module 'gym.spaces' has no attribute 'DiscreteToMultiDiscrete'"
the old one:
self.action_space = spaces.DiscreteToMultiDiscrete(
spaces.MultiDiscrete([[0, len(light.actions) - 1] for light in self.lights]), 'all')
I changed to this:
self.action_space = spaces.multi_discrete(
spaces.MultiDiscrete([[0, len(light.actions) - 1 ] for light in self.lights]), 'all')

ImportError: No module named traci

I want to play around with the tool, but when I run the example: python examples/example_gym_traffic_dqn.py I get an error saying python cannot find the traci module.

I've been going through the installations steps mentioned by this repo readme before running the file, but I can't seem to figure out how to fix this.

What can I do from here?

No module named 'dqn'

whenever I try to run the examples I get the following error.
No module named 'dqn'

Gym versions

Dear Ben,

In my case, I had several errors. What kind of Gym version did you use ?

I used the following packages.

gym (0.8.2)
gym-pull (0.1.7)
tensorflow (1.0.1)
keras-rl (0.3.0)
sumo(0.29.0)

I got errors below.

Lee~/Downloads/Transportation/bstriner_Ben/gym-traffic-master/examples$ python example_gym_traffic_dqn.py
Using TensorFlow backend.
[2017-05-09 09:31:14,954] Making new env: Traffic-Simple-gui-v0
Traceback (most recent call last):
File "example_gym_traffic_dqn.py", line 51, in
main(sys.argv[1:])
File "example_gym_traffic_dqn.py", line 47, in main
example(args.gui)
File "example_gym_traffic_dqn.py", line 23, in example
train_env = gym.make('Traffic-Simple-gui-v0')
File "/usr/local/lib/python2.7/site-packages/gym/envs/registration.py", line 161, in make
return registry.make(id)
File "/usr/local/lib/python2.7/site-packages/gym/envs/registration.py", line 119, in make
env = spec.make()
File "/usr/local/lib/python2.7/site-packages/gym/envs/registration.py", line 86, in make
env = cls(**self._kwargs)
File "/Users/Lee/Downloads/Transportation/bstriner_Ben/gym-traffic-master/gym_traffic/envs/traffic_env_simple.py", line 19, in init
lanes=lanes, exitloops=exitloops)
File "/Users/Lee/Downloads/Transportation/bstriner_Ben/gym-traffic-master/gym_traffic/envs/traffic_env.py", line 53, in init
self.action_space = spaces.DiscreteToMultiDiscrete(
AttributeError: 'module' object has no attribute 'DiscreteToMultiDiscrete'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/site-packages/gym/utils/closer.py", line 67, in close
closeable.close()
File "/usr/local/lib/python2.7/site-packages/gym/core.py", line 167, in close
self.render(close=True)
File "/usr/local/lib/python2.7/site-packages/gym/core.py", line 153, in render
return self._render(mode=mode, close=close)
File "/Users/Lee/Downloads/Transportation/bstriner_Ben/gym-traffic-master/gym_traffic/envs/traffic_env.py", line 151, in _render
if self.viewer is not None:
AttributeError: 'TrafficEnvSimple' object has no attribute 'viewer'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/site-packages/gym/utils/closer.py", line 67, in close
closeable.close()
File "/usr/local/lib/python2.7/site-packages/gym/core.py", line 167, in close
self.render(close=True)
File "/usr/local/lib/python2.7/site-packages/gym/core.py", line 153, in render
return self._render(mode=mode, close=close)
File "/Users/Lee/Downloads/Transportation/bstriner_Ben/gym-traffic-master/gym_traffic/envs/traffic_env.py", line 151, in _render
if self.viewer is not None:
AttributeError: 'TrafficEnvSimple' object has no attribute 'viewer'
Lee~/Downloads/Transportation/bstriner_Ben/gym-traffic-master/examples$

__init__() got an unexpected keyword argument 'tags' with python 3.6.8

I have the next error, in the example: "example_gym_traffic_dqn". Could you help me?

Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

RESTART: C:\Python3.6.8\scripts\gym-traffic-master\examples\example_gym_traffic_dqn.py
Traceback (most recent call last):
File "C:\Python3.6.8\scripts\gym-traffic-master\examples\example_gym_traffic_dqn.py", line 4, in
from gym_traffic.agents import DQN, EpsilonExplorer
File "C:\Users\RICARDO\AppData\Local\Programs\Python\Python36\lib\site-packages\gym_traffic-0.0.1-py3.6.egg\gym_traffic_init_.py", line 8, in
nondeterministic=True
File "C:\Users\RICARDO\AppData\Local\Programs\Python\Python36\lib\site-packages\gym\envs\registration.py", line 139, in register
return registry.register(id, **kwargs)
File "C:\Users\RICARDO\AppData\Local\Programs\Python\Python36\lib\site-packages\gym\envs\registration.py", line 133, in register
self.env_specs[id] = EnvSpec(id, **kwargs)
TypeError: init() got an unexpected keyword argument 'tags'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.