Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions examples/exp_configs/non_rl/i210_subnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@
# whether to include the downstream slow-down edge in the network
WANT_DOWNSTREAM_BOUNDARY = True
# whether to include vehicles on the on-ramp
ON_RAMP = True
ON_RAMP = False
# the inflow rate of vehicles (in veh/hr)
INFLOW_RATE = 5 * 2215
INFLOW_RATE = 2050
# the speed of inflowing vehicles from the main edge (in m/s)
INFLOW_SPEED = 24.1
INFLOW_SPEED = 25.5
# horizon over which to run the env
HORIZON = 1500
# steps to run before follower-stopper is allowed to take control
WARMUP_STEPS = 600

# =========================================================================== #
# Specify the path to the network template. #
Expand Down Expand Up @@ -75,12 +79,13 @@

inflow = InFlows()
# main highway
inflow.add(
veh_type="human",
edge="ghost0" if WANT_GHOST_CELL else "119257914",
vehs_per_hour=INFLOW_RATE,
departLane="best",
departSpeed=INFLOW_SPEED)
for lane in [0, 1, 2, 3, 4]:
inflow.add(
veh_type="human",
edge="ghost0" if WANT_GHOST_CELL else "119257914",
vehs_per_hour=INFLOW_RATE,
departLane=lane,
departSpeed=INFLOW_SPEED)
# on ramp
if ON_RAMP:
inflow.add(
Expand Down Expand Up @@ -123,7 +128,9 @@

# environment related parameters (see flow.core.params.EnvParams)
env=EnvParams(
horizon=10000,
horizon=HORIZON,
warmup_steps=WARMUP_STEPS,
sims_per_step=3
),

# network-related parameters (see flow.core.params.NetParams and the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3501,11 +3501,11 @@
</lane>
</edge>
<edge id="ghost0" from="gneJ0" to="300944378" priority="1" spreadType="center">
<lane id="ghost0_0" index="0" speed="13.89" length="573.08" shape="-17.02,1355.30 478.76,1067.86"/>
<lane id="ghost0_1" index="1" speed="13.89" length="573.08" shape="-15.36,1358.16 480.42,1070.71"/>
<lane id="ghost0_2" index="2" speed="13.89" length="573.08" shape="-13.71,1361.01 482.07,1073.56"/>
<lane id="ghost0_3" index="3" speed="13.89" length="573.08" shape="-12.05,1363.86 483.73,1076.42"/>
<lane id="ghost0_4" index="4" speed="13.89" length="573.08" shape="-10.40,1366.72 485.38,1079.27"/>
<lane id="ghost0_0" index="0" speed="30" length="573.08" shape="-17.02,1355.30 478.76,1067.86"/>
<lane id="ghost0_1" index="1" speed="30" length="573.08" shape="-15.36,1358.16 480.42,1070.71"/>
<lane id="ghost0_2" index="2" speed="30" length="573.08" shape="-13.71,1361.01 482.07,1073.56"/>
<lane id="ghost0_3" index="3" speed="30" length="573.08" shape="-12.05,1363.86 483.73,1076.42"/>
<lane id="ghost0_4" index="4" speed="30" length="573.08" shape="-10.40,1366.72 485.38,1079.27"/>
</edge>

<tlLogic id="122684743" type="static" programID="0" offset="0">
Expand Down Expand Up @@ -4727,8 +4727,8 @@
<connection from="119257908#1-AddedOffRampEdge" to="119257908#2" fromLane="3" toLane="2" via=":1686591010_1_2" dir="s" state="M"/>
<connection from="119257908#1-AddedOffRampEdge" to="119257908#2" fromLane="4" toLane="3" via=":1686591010_1_3" dir="s" state="M"/>
<connection from="119257908#1-AddedOffRampEdge" to="119257908#2" fromLane="5" toLane="4" via=":1686591010_1_4" dir="s" state="M"/>
<connection from="119257908#1-AddedOnRampEdge" to="119257908#1" fromLane="0" toLane="0" via=":119257908#1-AddedOnRampNode_0_0" dir="s" state="M"/>
<connection from="119257908#1-AddedOnRampEdge" to="119257908#1" fromLane="1" toLane="0" via=":119257908#1-AddedOnRampNode_0_1" dir="s" state="m"/>
<connection from="119257908#1-AddedOnRampEdge" to="119257908#1" fromLane="0" toLane="0" via=":119257908#1-AddedOnRampNode_0_0" dir="s" state="m"/>
<connection from="119257908#1-AddedOnRampEdge" to="119257908#1" fromLane="1" toLane="0" via=":119257908#1-AddedOnRampNode_0_1" dir="s" state="M"/>
<connection from="119257908#1-AddedOnRampEdge" to="119257908#1" fromLane="2" toLane="1" via=":119257908#1-AddedOnRampNode_0_2" dir="s" state="M"/>
<connection from="119257908#1-AddedOnRampEdge" to="119257908#1" fromLane="3" toLane="2" via=":119257908#1-AddedOnRampNode_0_3" dir="s" state="M"/>
<connection from="119257908#1-AddedOnRampEdge" to="119257908#1" fromLane="4" toLane="3" via=":119257908#1-AddedOnRampNode_0_4" dir="s" state="M"/>
Expand Down
88 changes: 88 additions & 0 deletions flow/networks/i210_subnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ def __init__(self,
if p not in net_params.additional_params:
raise KeyError('Network parameter "{}" not supplied'.format(p))

# The length of each edge and junction is a fixed term that can be
# found in the xml file.
self.length_with_ghost_edge = [
("ghost0", 573.08),
(":300944378_0", 0.30),
("119257914", 61.28),
(":300944379_0", 0.31),
("119257908#0", 696.97),
(":300944436_0", 2.87),
("119257908#1-AddedOnRampEdge", 97.20),
(":119257908#1-AddedOnRampNode_0", 3.24),
("119257908#1", 239.68),
(":119257908#1-AddedOffRampNode_0", 3.24),
("119257908#1-AddedOffRampEdge", 98.50),
(":1686591010_1", 5.46),
("119257908#2", 576.61),
(":1842086610_1", 4.53),
("119257908#3", 17.49),
]

super(I210SubNetwork, self).__init__(
name=name,
vehicles=vehicles,
Expand Down Expand Up @@ -196,3 +216,71 @@ def specify_routes(self, net_params):
})

return rts

def specify_edge_starts(self):
"""See parent class."""
if self.net_params.additional_params["ghost_edge"]:
# Collect the names of all the edges.
edge_names = [
e[0] for e in self.length_with_ghost_edge
if not e[0].startswith(":")
]

edge_starts = []
for edge in edge_names:
# Find the position of the edge in the list of tuples.
edge_pos = next(
i for i in range(len(self.length_with_ghost_edge))
if self.length_with_ghost_edge[i][0] == edge
)

# Sum of lengths until the edge is reached to compute the
# starting position of the edge.
edge_starts.append((
edge,
sum(e[1] for e in self.length_with_ghost_edge[:edge_pos])
))

elif self.net_params.additional_params["on_ramp"]:
# TODO: this will incorporated in the future, if needed.
edge_starts = []

else:
# TODO: this will incorporated in the future, if needed.
edge_starts = []

return edge_starts

def specify_internal_edge_starts(self):
"""See parent class."""
if self.net_params.additional_params["ghost_edge"]:
# Collect the names of all the junctions.
edge_names = [
e[0] for e in self.length_with_ghost_edge
if e[0].startswith(":")
]

edge_starts = []
for edge in edge_names:
# Find the position of the edge in the list of tuples.
edge_pos = next(
i for i in range(len(self.length_with_ghost_edge))
if self.length_with_ghost_edge[i][0] == edge
)

# Sum of lengths until the edge is reached to compute the
# starting position of the edge.
edge_starts.append((
edge,
sum(e[1] for e in self.length_with_ghost_edge[:edge_pos])
))

elif self.net_params.additional_params["on_ramp"]:
# TODO: this will incorporated in the future, if needed.
edge_starts = []

else:
# TODO: this will incorporated in the future, if needed.
edge_starts = []

return edge_starts