1

when I run the flow/envs/ring/lane_change_accel,there is an error:

Traceback (most recent call last):
      File "/home/vcdc/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/vcdc/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/vcdc/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.train() (pid=5690, ip=192.168.6.112)
      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/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 444, in train
        raise e
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 433, in train
        result = Trainable.train(self)
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/tune/trainable.py", line 176, in train
        result = self._train()
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/agents/trainer_template.py", line 129, in _train
        fetches = self.optimizer.step()
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/optimizers/multi_gpu_optimizer.py", line 140, in step
        self.num_envs_per_worker, self.train_batch_size)
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/optimizers/rollout.py", line 29, in collect_samples
        next_sample = ray_get_and_free(fut_sample)
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/utils/memory.py", line 33, in ray_get_and_free
        result = ray.get(object_ids)
    ray.exceptions.RayTaskError(IndexError): ray::RolloutWorker.sample() (pid=5766, ip=192.168.6.112)
      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/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/evaluation/rollout_worker.py", line 471, in sample
        batches = [self.input_reader.next()]
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/evaluation/sampler.py", line 56, in next
        batches = [self.get_data()]
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/evaluation/sampler.py", line 99, in get_data
        item = next(self.rollout_provider)
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/evaluation/sampler.py", line 340, in _env_runner
        base_env.send_actions(actions_to_send)
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/env/base_env.py", line 332, in send_actions
        self.vector_env.vector_step(action_vector)
      File "/home/vcdc/anaconda3/envs/flow/lib/python3.7/site-packages/ray/rllib/env/vector_env.py", line 110, in vector_step
        obs, r, done, info = self.envs[i].step(actions[i])
      File "/home/vcdc/flow/flow/envs/base.py", line 364, in step
        self.apply_rl_actions(rl_actions)
      File "/home/vcdc/flow/flow/envs/base.py", line 616, in apply_rl_actions
        self._apply_rl_actions(rl_clipped)
      File "/home/vcdc/flow/flow/envs/ring/lane_change_accel.py", line 151, in _apply_rl_actions
        np.array([0] * sum(non_lane_changing_veh))
    IndexError: boolean index did not match indexed array along dimension 0; dimension is 0 but corresponding boolean dimension is 1

i do not know what the code(

non_lane_changing_veh = \
            [self.time_counter <=
             self.env_params.additional_params["lane_change_duration"]
             + self.k.vehicle.get_last_lc(veh_id)
             for veh_id in sorted_rl_ids]

) means,because non_lane_changing_veh does not look like an integer. Anybody tell me what is wrong, I think the code is not correct

  • `non_lane_changing_veh` is a list containing bool values. Depending on the version of numpy, this will produce an `IndexError` (what you see) OR a `VisibleDeprecationWarning`. You may be able to avoid the error by changing numpy version. More info: https://stackoverflow.com/questions/45207650/indexerror-boolean-index-did-not-match-indexed-array-along-dimension-0 – Ghoti Jul 28 '21 at 02:07
  • I am using `numpy==1.16.4` and was not able to reproduce an error. Tried different bool values and list length within `non_lane_changing_veh`. – Ghoti Jul 28 '21 at 02:10
  • enmm,I change my numpy version as 1.16.4 , but still reproduce the error,so I am so depressed – liw17150934 Jul 28 '21 at 06:06

0 Answers0