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

Bug generating custom start position in TrafficLightGridNetwork #1041

Open
JoserraLP opened this issue Apr 13, 2021 · 0 comments
Open

Bug generating custom start position in TrafficLightGridNetwork #1041

JoserraLP opened this issue Apr 13, 2021 · 0 comments
Labels

Comments

@JoserraLP
Copy link

Bug Description

When trying to generate custom vehicles on each lanes in the TrafficLightGridNetwork, the start lane on the vertical lanes is always empty due to the fact the code which generates these positions is wrong.

Bug Resolution

I tried different things because I didn't notice what was the problem, but definitely I found that the code related to the method "gen_custom_start_pos" on the previously mentioned file, is wrong as the loop iterating on the rows calculates the vertical lanes with the number of cars heading the "left" and the "right" and it should be with the "top" and "bot" ones, resulting in the next code:

for i in range(row_num):
start_pos += [("top{}_{}".format(i, col_num), x0 + k * dx)
for k in range(cars_heading_top)]
start_pos += [("bot{}_0".format(i), x0 + k * dx)
for k in range(cars_heading_bot)]
vert_lanes = np.random.randint(low=0, high=net_params.additional_params["vertical_lanes"],
size=cars_heading_bot + cars_heading_top).tolist()

Note: the modified code is indicated as bold text.

Bug Reproduce

File in which the bug occurred: traffic_light_grid.py in /flow/networks folder.

The exact command that you did run that caused the bug:
python traffic_light_grid.py

Note: the simulation is made on a script developed by me which creates different vehicles routes on the edges indicated, for example on the "bot" edges.

Output Log

Full error output log:

2021-04-13 14:00:28,977 ERROR trial_runner.py:482 -- Error processing event.
Traceback (most recent call last):
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/tune/trial_runner.py", line 426, in _process_trial
    result = self.trial_executor.fetch_result(trial)
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/tune/ray_trial_executor.py", line 378, in fetch_result
    result = ray.get(trial_future[0], DEFAULT_GET_TIMEOUT)
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/worker.py", line 1457, in get
    raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(IndexError): ray::PPO.__init__() (pid=30225, ip=192.168.191.212)
  File "python/ray/_raylet.pyx", line 626, in ray._raylet.execute_task
  File "python/ray/_raylet.pyx", line 633, in ray._raylet.execute_task
  File "python/ray/_raylet.pyx", line 634, in ray._raylet.execute_task
  File "python/ray/_raylet.pyx", line 636, in ray._raylet.execute_task
  File "python/ray/_raylet.pyx", line 619, in ray._raylet.execute_task.function_executor
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/agents/trainer_template.py", line 90, in __init__
    Trainer.__init__(self, config, env, logger_creator)
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 398, in __init__
    Trainable.__init__(self, config, logger_creator)
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/tune/trainable.py", line 96, in __init__
    self._setup(copy.deepcopy(self.config))
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 523, in _setup
    self._init(self.config, self.env_creator)
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/agents/trainer_template.py", line 109, in _init
    self.config["num_workers"])
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 568, in _make_workers
    logdir=self.logdir)
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/evaluation/worker_set.py", line 64, in __init__
    RolloutWorker, env_creator, policy, 0, self._local_config)
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/evaluation/worker_set.py", line 220, in _make_worker
    _fake_sampler=config.get("_fake_sampler", False))
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/evaluation/rollout_worker.py", line 271, in __init__
    self.env = _validate_env(env_creator(env_context))
  File "/home/eclipse-sumo/flow/flow/utils/registry.py", line 130, in create_env
    return gym.envs.make(env_name)
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/gym/envs/registration.py", line 156, in make
    return registry.make(id, **kwargs)
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/gym/envs/registration.py", line 101, in make
    env = spec.make(**kwargs)
  File "/home/eclipse-sumo/anaconda3/envs/flow/lib/python3.7/site-packages/gym/envs/registration.py", line 73, in make
    env = cls(**_kwargs)
  File "/home/eclipse-sumo/flow/flow/envs/traffic_light_grid.py", line 618, in __init__
    super().__init__(env_params, sim_params, network, simulator)
  File "/home/eclipse-sumo/flow/flow/envs/traffic_light_grid.py", line 126, in __init__
    super().__init__(env_params, sim_params, network, simulator)
  File "/home/eclipse-sumo/flow/flow/envs/base.py", line 194, in __init__
    self.setup_initial_state()
  File "/home/eclipse-sumo/flow/flow/envs/base.py", line 289, in setup_initial_state
    lane = start_lanes[i]
IndexError: list index out of range

Versions

  • OS: Ubuntu 18.04 LTS
  • Flow version: 0.5.0 dev
  • Flow commit number: a511c41
@JoserraLP JoserraLP added the bug label Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant