1

我想在网格例子上模拟一个堵塞模拟,所以我尝试增加行数和列数或增加num_cars_left/nums_cars_right/nums_cars_top/nums_cars_bot的数量。例如:

n_rows = 5
n_columns = 5
num_cars_left = 50
num_cars_right = 50
num_cars_top = 50
num_cars_bot = 50

所以,然后通过命令运行它,有一个错误:

Loading configuration... done.
Success.
Loading configuration... done.
Traceback (most recent call last):
  File "examples/sumo/grid.py", line 237, in <module>
    exp.run(1, 1500)
  File "/home/dnl/flow/flow/core/experiment.py", line 118, in run
    state = self.env.reset()
  File "/home/dnl/flow/flow/envs/loop/loop_accel.py", line 167, in reset
    obs = super().reset()
  File "/home/dnl/flow/flow/envs/base_env.py", line 520, in reset
    raise FatalFlowError(msg=msg)
flow.utils.exceptions.FatalFlowError: 
Not enough vehicles have spawned! Bad start?
Missing vehicles / initial state:
- human_994: ('human', 'bot4_0', 0, 446, 0)
- human_546: ('human', 'top0_5', 0, 466, 0)
- human_886: ('human', 'bot3_0', 0, 366, 0)
- human_689: ('human', 'bot1_0', 0, 396, 0)
.....

然后我检查了 'flow/flow/envs/base_env.py' 有一个描述:

# check to make sure all vehicles have been spawned
        if len(self.initial_ids) > len(initial_ids):
            missing_vehicles = list(set(self.initial_ids) - set(initial_ids))
            msg = '\nNot enough vehicles have spawned! Bad start?\n' \
                  'Missing vehicles / initial state:\n'
            for veh_id in missing_vehicles:
                msg += '- {}: {}\n'.format(veh_id, self.initial_state[veh_id])
            raise FatalFlowError(msg=msg)

所以,我的问题是:如果我想在网格上模拟堵车,如果行数、列数、nums_cars_left(right/bot/top) 有限制,该怎么办?

4

1 回答 1

0

默认情况下,网格示例examples/sumo/grid.py不使用流入,而是直接在输入边上生成车辆。因此,如果您增加车辆的数量,则必须增加它们生成的边缘的大小。我试过你的例子,这个设置对我有用:

    inner_length = 300
    long_length = 500
    short_length = 500
    n_rows = 5
    n_columns = 5
    num_cars_left = 50
    num_cars_right = 50
    num_cars_top = 50
    num_cars_bot = 50

载具生成的边的长度是short_length,如果载具没有足够的空间来添加,这是您想要增加的长度。

此外,更改行数和列数并不会改变任何内容,因为每行将添加 50 辆车;所以在这种情况下,每 50 辆车有 20 个输入边,总共 1000 辆车,这将是相当滞后的。


如果您想使用连续流入而不是一次性生成,请查看use_inflowsingrid_example函数中的参数examples/sumo/grid.py,以及该参数设置为 True 时的作用。

于 2019-07-23T11:44:03.430 回答