CityBrainChallenge / KDDCup2021-CityBrainChallenge-starter-kit

75 stars 40 forks source link

Vehicles collision detected in `info` provided by `observations` #30

Open Yveh opened 3 years ago

Yveh commented 3 years ago

We assumed that, like CityFlow, vehicles have positive lengths. However, the following assertion failed when we ran the simulation:

for vid1, vinfo1 in info.items():
    lane_id1 = int(vinfo1["drivable"][0])
    dis1 = vinfo1['distance'][0]
    for vid2, vinfo2 in info.items():
        if vid1 == vid2:
            continue
        lane_id2 = int(vinfo2["drivable"][0])
        dis2 = vinfo2['distance'][0]
        if lane_id1 == lane_id2 and abs(dis1 - dis2) < 0.1:
            print(vinfo1)
            print(vinfo2)
            assert False

and the output is

{'distance': [13.88888888888889], 'drivable': [252401.0], 'road': [2524.0], 'route': [2524.0, 4819.0, 4798.0, 4899.0, 5665.0, 3395.0, 3385.0, 1783.0, 1413.0, 1281.0, 1265.0, 1264.0, 606.0, 3515.0, 1213.0, 1216.0, 4910.0], 'speed': [13.88888888888889], 'start_time': [130.0], 't_ff': [456.08699999999993]}
{'distance': [13.88888888888889], 'drivable': [252401.0], 'road': [2524.0], 'route': [2524.0, 4819.0, 4798.0, 4898.0, 5668.0, 5022.0, 3398.0, 1783.0, 1413.0, 1281.0, 1265.0, 1264.0, 604.0, 956.0, 582.0, 882.0, 630.0, 228.0, 444.0, 2536.0, 2109.0, 3773.0, 3882.0, 3745.0], 'speed': [13.88888888888889], 'start_time': [160.0], 't_ff': [727.8990000000001]}
Traceback (most recent call last):
  File "evaluate.py", line 506, in <module>
    scores = run_simulation(agent_spec, simulator_cfg_file, gym_cfg,metric_period,scores_dir,threshold)
  File "evaluate.py", line 332, in run_simulation
    actions = agent.act(all_info)
  File "agent/agent.py", line 241, in act
    get_vehicles_per_lane()
  File "agent/agent.py", line 133, in get_vehicles_per_lane
    assert False
AssertionError

in which we can find two different vehicles shares the same position.

Is it a bug, or intended to be so? In the latter case, how can we understand it? We can't find any clues in docs.

Thank you in advance!

huynhnhathao commented 3 years ago

I don't see that as an issue since it is not realistic to get the exact position of vehicles even in real-world situations.

fstqwq commented 3 years ago

I don't see that as an issue since it is not realistic to get the exact position of vehicles even in real-world situations.

That is indeed an issue, since in real world we can estimate the total capacity by the length of roads, and thus we can plan how vehicle moves. If vehicles can actually somehow flow into a road infinitely, the strategy may change a lot and the RL agents may even exploit the bug in the system.

Kanstarry9T commented 3 years ago

This case might happen when two consecutive vehicles entered the road network at the same location, but the location is congested and those two vehicles are waiting at the same position to enter the road network. This is an issue that we are trying to fix as soon as possible.