Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy independent model on the network #202

Open
Kunal-Kumar-Sahoo opened this issue May 28, 2024 · 5 comments
Open

Deploy independent model on the network #202

Kunal-Kumar-Sahoo opened this issue May 28, 2024 · 5 comments

Comments

@Kunal-Kumar-Sahoo
Copy link

Given a traffic network with multiple intersections, I want to deploy a single DQN to all the individual traffic light signal. How can I do that?

@LucasAlegre
Copy link
Owner

SUMO-RL provides environments with the PettingZoo API. You can use any RL library that supports it. See https://pettingzoo.farama.org/tutorials/sb3/ for examples of how to use different libraries with PettingZoo environments, both for independent and centralized agents.

@Kunal-Kumar-Sahoo
Copy link
Author

While implementing the example sumo_rl/experiments/sb3_grid4x4.py I get the following error:

Using libsumo as traci as requested by environment variable.
/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/pettingzoo/utils/conversions.py:132: UserWarning: The base environment `sumo_rl_v0` does not have a `render_mode` defined.
  warnings.warn(
Traceback (most recent call last):
  File "/home/kunalkumarsahoo/Playground/CiSTUP/research_internship/multi_agent/agent.py", line 22, in <module>
    env = ss.pettingzoo_env_to_vec_env_v1(env)
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/supersuit/vector/vector_constructors.py", line 89, in pettingzoo_env_to_vec_env_v1
    return MarkovVectorEnv(parallel_env)
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/supersuit/vector/markov_vector_wrapper.py", line 20, in __init__
    self.render_mode = par_env.unwrapped.render_mode
AttributeError: 'SumoEnvironmentPZ' object has no attribute 'render_mode'

Upon checking these files where the error has occurred I could not find SumoEnvironmentPZ class. How can I resolve this issue?

@LucasAlegre
Copy link
Owner

Thanks for spotting this. I fixed in the last commit: 2a8b6e5

@Kunal-Kumar-Sahoo
Copy link
Author

Now I get this error:

Traceback (most recent call last):
  File "/home/kunalkumarsahoo/Playground/CiSTUP/research_internship/multi_agent/agent.py", line 50, in <module>
    model.learn(total_timesteps=50000)
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/stable_baselines3/ppo/ppo.py", line 315, in learn
    return super().learn(
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/stable_baselines3/common/on_policy_algorithm.py", line 287, in learn
    total_timesteps, callback = self._setup_learn(
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/stable_baselines3/common/base_class.py", line 423, in _setup_learn
    self._last_obs = self.env.reset()  # type: ignore[assignment]
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/stable_baselines3/common/vec_env/vec_monitor.py", line 70, in reset
    obs = self.venv.reset()
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/supersuit/vector/sb3_vector_wrapper.py", line 22, in reset
    observations, self.reset_infos = self.venv.reset()
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/supersuit/vector/concat_vec_env.py", line 45, in reset
    _obs, _info = self.vec_envs[i].reset(options=options)
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/supersuit/vector/markov_vector_wrapper.py", line 57, in reset
    _observations, infos = self.par_env.reset(seed=seed, options=options)
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/pettingzoo/utils/conversions.py", line 179, in reset
    self.aec_env.reset(seed=seed, options=options)
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/pettingzoo/utils/wrappers/order_enforcing.py", line 118, in reset
    super().reset(seed=seed, options=options)
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/pettingzoo/utils/wrappers/base.py", line 38, in reset
    self.env.reset(seed=seed, options=options)
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/pettingzoo/utils/wrappers/base.py", line 38, in reset
    self.env.reset(seed=seed, options=options)
  File "/home/kunalkumarsahoo/Playground/CiSTUP/sumo-rl/sumo_rl/environment/env.py", line 542, in reset
    self.env.reset(seed=seed, options=options)
  File "/home/kunalkumarsahoo/Playground/CiSTUP/sumo-rl/sumo_rl/environment/env.py", line 255, in reset
    self._start_simulation()
  File "/home/kunalkumarsahoo/Playground/CiSTUP/sumo-rl/sumo_rl/environment/env.py", line 241, in _start_simulation
    self.sumo.gui.setSchema(traci.gui.DEFAULT_VIEW, "real world")
  File "/home/kunalkumarsahoo/mambaforge/envs/cistup/lib/python3.10/site-packages/libsumo/libsumo.py", line 2060, in setSchema
    return _libsumo.gui_setSchema(viewID, schemeName)
libsumo.libsumo.TraCIException: View 'View #0' is not known

@LucasAlegre
Copy link
Owner

This seems to be a problem with the GUI. Are you running in a cluster or something without a screen monitor? Try running without the GUI rendering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants