Skip to content

Commit 86c2e4c

Browse files
I210 highway updated (#934)
* removed sweep * added updated single lane highway network config * added i210 xml files with downstream edge * added I210Router * added updated i210 features * minor cleanup * better parameters based on when congestion propagates * bug fixes * bug fixes * more bug fixes * bug fixes * minor * broader tests for scenario * added tests for specify_routes * PR fixes
1 parent 5b38dc4 commit 86c2e4c

File tree

14 files changed

+11945
-321
lines changed

14 files changed

+11945
-321
lines changed

examples/exp_configs/non_rl/highway_single.py

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
"""Multi-agent highway with ramps example.
2-
3-
Trains a non-constant number of agents, all sharing the same policy, on the
4-
highway with ramps network.
5-
"""
6-
from flow.controllers import BandoFTLController
1+
"""Example of an open network with human-driven vehicles."""
2+
from flow.controllers import IDMController
73
from flow.core.params import EnvParams
84
from flow.core.params import NetParams
95
from flow.core.params import InitialConfig
106
from flow.core.params import InFlows
117
from flow.core.params import VehicleParams
128
from flow.core.params import SumoParams
139
from flow.core.params import SumoLaneChangeParams
10+
from flow.core.params import SumoCarFollowingParams
1411
from flow.networks import HighwayNetwork
1512
from flow.envs import TestEnv
1613
from flow.networks.highway import ADDITIONAL_NET_PARAMS
1714

18-
TRAFFIC_SPEED = 11
19-
END_SPEED = 16
20-
TRAFFIC_FLOW = 2056
21-
HORIZON = 3600
22-
INCLUDE_NOISE = False
15+
# the speed of vehicles entering the network
16+
TRAFFIC_SPEED = 24.1
17+
# the maximum speed at the downstream boundary edge
18+
END_SPEED = 6.0
19+
# the inflow rate of vehicles
20+
TRAFFIC_FLOW = 2215
21+
# the simulation time horizon (in steps)
22+
HORIZON = 1500
23+
# whether to include noise in the car-following models
24+
INCLUDE_NOISE = True
2325

2426
additional_net_params = ADDITIONAL_NET_PARAMS.copy()
2527
additional_net_params.update({
@@ -31,28 +33,30 @@
3133
"speed_limit": 30,
3234
# number of edges to divide the highway into
3335
"num_edges": 2,
34-
# whether to include a ghost edge of length 500m. This edge is provided a
35-
# different speed limit.
36+
# whether to include a ghost edge. This edge is provided a different speed
37+
# limit.
3638
"use_ghost_edge": True,
3739
# speed limit for the ghost edge
38-
"ghost_speed_limit": END_SPEED
40+
"ghost_speed_limit": END_SPEED,
41+
# length of the downstream ghost edge with the reduced speed limit
42+
"boundary_cell_length": 300,
3943
})
4044

4145
vehicles = VehicleParams()
4246
vehicles.add(
4347
"human",
44-
num_vehicles=0,
48+
acceleration_controller=(IDMController, {
49+
'a': 1.3,
50+
'b': 2.0,
51+
'noise': 0.3 if INCLUDE_NOISE else 0.0
52+
}),
53+
car_following_params=SumoCarFollowingParams(
54+
min_gap=0.5
55+
),
4556
lane_change_params=SumoLaneChangeParams(
46-
lane_change_mode="strategic",
57+
model="SL2015",
58+
lc_sublane=2.0,
4759
),
48-
acceleration_controller=(BandoFTLController, {
49-
'alpha': .5,
50-
'beta': 20.0,
51-
'h_st': 12.0,
52-
'h_go': 50.0,
53-
'v_max': 30.0,
54-
'noise': 1.0 if INCLUDE_NOISE else 0.0,
55-
}),
5660
)
5761

5862
inflows = InFlows()
@@ -64,8 +68,6 @@
6468
depart_speed=TRAFFIC_SPEED,
6569
name="idm_highway_inflow")
6670

67-
# SET UP FLOW PARAMETERS
68-
6971
flow_params = dict(
7072
# name of the experiment
7173
exp_tag='highway-single',
@@ -82,14 +84,15 @@
8284
# environment related parameters (see flow.core.params.EnvParams)
8385
env=EnvParams(
8486
horizon=HORIZON,
85-
warmup_steps=0,
86-
sims_per_step=1,
87+
warmup_steps=500,
88+
sims_per_step=3,
8789
),
8890

8991
# sumo-related parameters (see flow.core.params.SumoParams)
9092
sim=SumoParams(
91-
sim_step=0.5,
93+
sim_step=0.4,
9294
render=False,
95+
use_ballistic=True,
9396
restart_instance=False
9497
),
9598

examples/exp_configs/non_rl/i210_subnetwork.py

Lines changed: 82 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""I-210 subnetwork example."""
22
import os
3-
43
import numpy as np
54

6-
from flow.controllers.car_following_models import IDMController
5+
from flow.controllers import IDMController
6+
from flow.controllers import I210Router
77
from flow.core.params import SumoParams
88
from flow.core.params import EnvParams
99
from flow.core.params import NetParams
@@ -15,7 +15,49 @@
1515
from flow.envs import TestEnv
1616
from flow.networks.i210_subnetwork import I210SubNetwork, EDGES_DISTRIBUTION
1717

18-
# create the base vehicle type that will be used for inflows
18+
# =========================================================================== #
19+
# Specify some configurable constants. #
20+
# =========================================================================== #
21+
22+
# whether to include the upstream ghost edge in the network
23+
WANT_GHOST_CELL = True
24+
# whether to include the downstream slow-down edge in the network
25+
WANT_DOWNSTREAM_BOUNDARY = True
26+
# whether to include vehicles on the on-ramp
27+
ON_RAMP = True
28+
# the inflow rate of vehicles (in veh/hr)
29+
INFLOW_RATE = 5 * 2215
30+
# the speed of inflowing vehicles from the main edge (in m/s)
31+
INFLOW_SPEED = 24.1
32+
33+
# =========================================================================== #
34+
# Specify the path to the network template. #
35+
# =========================================================================== #
36+
37+
if WANT_DOWNSTREAM_BOUNDARY:
38+
NET_TEMPLATE = os.path.join(
39+
config.PROJECT_PATH,
40+
"examples/exp_configs/templates/sumo/i210_with_ghost_cell_with_"
41+
"downstream.xml")
42+
elif WANT_GHOST_CELL:
43+
NET_TEMPLATE = os.path.join(
44+
config.PROJECT_PATH,
45+
"examples/exp_configs/templates/sumo/i210_with_ghost_cell.xml")
46+
else:
47+
NET_TEMPLATE = os.path.join(
48+
config.PROJECT_PATH,
49+
"examples/exp_configs/templates/sumo/test2.net.xml")
50+
51+
# If the ghost cell is not being used, remove it from the initial edges that
52+
# vehicles can be placed on.
53+
edges_distribution = EDGES_DISTRIBUTION.copy()
54+
if not WANT_GHOST_CELL:
55+
edges_distribution.remove("ghost0")
56+
57+
# =========================================================================== #
58+
# Specify vehicle-specific information and inflows. #
59+
# =========================================================================== #
60+
1961
vehicles = VehicleParams()
2062
vehicles.add(
2163
"human",
@@ -24,35 +66,39 @@
2466
lane_change_mode="strategic",
2567
),
2668
acceleration_controller=(IDMController, {
27-
"a": 0.3, "b": 2.0, "noise": 0.5
69+
"a": 1.3,
70+
"b": 2.0,
71+
"noise": 0.3,
2872
}),
73+
routing_controller=(I210Router, {}) if ON_RAMP else None,
2974
)
3075

3176
inflow = InFlows()
3277
# main highway
3378
inflow.add(
3479
veh_type="human",
35-
edge="119257914",
36-
vehs_per_hour=8378,
37-
departLane="random",
38-
departSpeed=23)
80+
edge="ghost0" if WANT_GHOST_CELL else "119257914",
81+
vehs_per_hour=INFLOW_RATE,
82+
departLane="best",
83+
departSpeed=INFLOW_SPEED)
3984
# on ramp
40-
# inflow.add(
41-
# veh_type="human",
42-
# edge="27414345",
43-
# vehs_per_hour=321,
44-
# departLane="random",
45-
# departSpeed=20)
46-
# inflow.add(
47-
# veh_type="human",
48-
# edge="27414342#0",
49-
# vehs_per_hour=421,
50-
# departLane="random",
51-
# departSpeed=20)
52-
53-
NET_TEMPLATE = os.path.join(
54-
config.PROJECT_PATH,
55-
"examples/exp_configs/templates/sumo/test2.net.xml")
85+
if ON_RAMP:
86+
inflow.add(
87+
veh_type="human",
88+
edge="27414345",
89+
vehs_per_hour=500,
90+
departLane="random",
91+
departSpeed=10)
92+
inflow.add(
93+
veh_type="human",
94+
edge="27414342#0",
95+
vehs_per_hour=500,
96+
departLane="random",
97+
departSpeed=10)
98+
99+
# =========================================================================== #
100+
# Generate the flow_params dict with all relevant simulation information. #
101+
# =========================================================================== #
56102

57103
flow_params = dict(
58104
# name of the experiment
@@ -69,22 +115,26 @@
69115

70116
# simulation-related parameters
71117
sim=SumoParams(
72-
sim_step=0.5,
118+
sim_step=0.4,
73119
render=False,
74120
color_by_speed=True,
75121
use_ballistic=True
76122
),
77123

78124
# environment related parameters (see flow.core.params.EnvParams)
79125
env=EnvParams(
80-
horizon=4500,
126+
horizon=10000,
81127
),
82128

83129
# network-related parameters (see flow.core.params.NetParams and the
84130
# network's documentation or ADDITIONAL_NET_PARAMS component)
85131
net=NetParams(
86132
inflows=inflow,
87-
template=NET_TEMPLATE
133+
template=NET_TEMPLATE,
134+
additional_params={
135+
"on_ramp": ON_RAMP,
136+
"ghost_edge": WANT_GHOST_CELL,
137+
}
88138
),
89139

90140
# vehicles to be placed in the network at the start of a rollout (see
@@ -94,10 +144,14 @@
94144
# parameters specifying the positioning of vehicles upon initialization/
95145
# reset (see flow.core.params.InitialConfig)
96146
initial=InitialConfig(
97-
edges_distribution=EDGES_DISTRIBUTION,
147+
edges_distribution=edges_distribution,
98148
),
99149
)
100150

151+
# =========================================================================== #
152+
# Specify custom callable that is logged during simulation runtime. #
153+
# =========================================================================== #
154+
101155
edge_id = "119257908#1-AddedOnRampEdge"
102156
custom_callables = {
103157
"avg_merge_speed": lambda env: np.nan_to_num(np.mean(

0 commit comments

Comments
 (0)