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
138 changes: 0 additions & 138 deletions examples/rllab/bottlenecks.py

This file was deleted.

36 changes: 23 additions & 13 deletions examples/rllab/cooperative_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
SumoCarFollowingParams, SumoLaneChangeParams
from flow.core.vehicles import Vehicles
from flow.scenarios.loop_merge.gen import TwoLoopOneMergingGenerator
from flow.scenarios.loop_merge.scenario import TwoLoopsOneMergingScenario
from flow.scenarios.loop_merge.scenario import TwoLoopsOneMergingScenario, \
ADDITIONAL_NET_PARAMS

HORIZON = 300


def run_task(*_):
sumo_params = SumoParams(sim_step=0.2, sumo_binary="sumo")
sumo_params = SumoParams(sim_step=0.2, sumo_binary="sumo-gui")

# note that the vehicles are added sequentially by the generator,
# so place the merging vehicles after the vehicles in the ring
Expand Down Expand Up @@ -65,22 +66,31 @@ def run_task(*_):
),
sumo_lc_params=SumoLaneChangeParams())

additional_env_params = {"target_velocity": 20, "max-deacc": -1.5,
"max-acc": 1}
env_params = EnvParams(horizon=HORIZON,
additional_params=additional_env_params)
env_params = EnvParams(
horizon=HORIZON,
additional_params={
"max_accel": 3,
"max_decel": 3,
"target_velocity": 10,
"n_preceding": 2,
"n_following": 2,
"n_merging_in": 2,
}
)

additional_net_params = {"ring_radius": 50, "lanes": 1,
"lane_length": 75, "speed_limit": 30,
"resolution": 40}
additional_net_params = ADDITIONAL_NET_PARAMS.copy()
additional_net_params["ring_radius"] = 50
additional_net_params["inner_lanes"] = 1
additional_net_params["outer_lanes"] = 1
additional_net_params["lane_length"] = 75
net_params = NetParams(
no_internal_links=False,
additional_params=additional_net_params
)

initial_config = InitialConfig(
x0=50,
spacing="custom",
spacing="uniform",
additional_params={"merge_bunching": 0}
)

Expand Down Expand Up @@ -123,17 +133,17 @@ def run_task(*_):

exp_tag = "cooperative_merge_example" # experiment prefix

for seed in [1, 5, 10, 56]: # , 1, 5, 10, 73]:
for seed in [1]: # , 5, 10, 56, 73]:
run_experiment_lite(
run_task,
# Number of parallel workers for sampling
n_parallel=8,
n_parallel=1,
# Only keep the snapshot parameters for the last iteration
snapshot_mode="all",
# Specifies the seed for the experiment. If this is not provided, a
# random seed will be used
seed=seed,
mode="ec2",
mode="local", # "ec2"
exp_prefix=exp_tag,
# plot=True,
)
2 changes: 1 addition & 1 deletion examples/rllab/figure_eight.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def run_task(*_):
sumo_params = SumoParams(sim_step=0.1,
sumo_binary="sumo")
sumo_binary="sumo-gui")

vehicles = Vehicles()
vehicles.add(veh_id="rl",
Expand Down
18 changes: 11 additions & 7 deletions examples/rllib/cooperative_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
exp_tag="cooperative_merge",

# name of the flow environment the experiment is running on
env_name="TwoLoopsMergeEnv",
env_name="TwoLoopsMergePOEnv",

# name of the scenario class the experiment is running on
scenario="TwoLoopsOneMergingScenario",
Expand All @@ -91,9 +91,12 @@
env=EnvParams(
horizon=HORIZON,
additional_params={
"target_velocity": 20,
"max_accel": 1,
"max_decel": 1.5,
"max_accel": 3,
"max_decel": 3,
"target_velocity": 10,
"n_preceding": 2,
"n_following": 2,
"n_merging_in": 2,
},
),

Expand All @@ -103,22 +106,23 @@
no_internal_links=False,
additional_params={
"ring_radius": 50,
"lanes": 1,
"lane_length": 75,
"inner_lanes": 1,
"outer_lanes": 1,
"speed_limit": 30,
"resolution": 40,
},
),

# vehicles to be placed in the network at the start of a rollout (see
# vehicles to be placed in the network at the start of a rollout (see
# flow.core.vehicles.Vehicles)
veh=vehicles,

# parameters specifying the positioning of vehicles upon initialization/
# reset (see flow.core.params.InitialConfig)
initial=InitialConfig(
x0=50,
spacing="custom",
spacing="uniform",
additional_params={
"merge_bunching": 0,
},
Expand Down
2 changes: 1 addition & 1 deletion examples/rllib/stabilizing_highway.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
# sumo-related parameters (see flow.core.params.SumoParams)
sumo=SumoParams(
sim_step=0.2,
sumo_binary="sumo-gui",
sumo_binary="sumo",
),

# environment related parameters (see flow.core.params.EnvParams)
Expand Down
3 changes: 2 additions & 1 deletion examples/rllib/velocity_bottleneck.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"reset_inflow": False,
"lane_change_duration": 5,
"max_accel": 3,
"max_decel": 3
"max_decel": 3,
"inflow_range": [1000, 2000]
}

# flow rate
Expand Down
2 changes: 2 additions & 0 deletions examples/sumo/bay_bridge_toll.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ def bay_bridge_bottleneck_example(sumo_binary=None,
Performs a non-RL simulation of the bottleneck portion of the Oakland-San
Francisco Bay Bridge. This consists of the toll booth and sections of the
road leading up to it.

Parameters
----------
sumo_binary: bool, optional
specifies whether to use sumo's gui during execution
use_traffic_lights: bool, optional
whether to activate the traffic lights in the scenario

Note
----
Unlike the bay_bridge_example, inflows are always activated here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
from flow.scenarios.loop_merge.gen import TwoLoopOneMergingGenerator


def two_loops_merge_straight_example(sumo_binary=None):
sumo_params = SumoParams(sim_step=0.1, emission_path="./data/",
def loop_merge_example(sumo_binary=None):
sumo_params = SumoParams(sim_step=0.1,
emission_path="./data/",
sumo_binary="sumo-gui")

if sumo_binary is not None:
Expand All @@ -29,6 +30,7 @@ def two_loops_merge_straight_example(sumo_binary=None):
lane_change_controller=(SumoLaneChangeController, {}),
routing_controller=(ContinuousRouter, {}),
num_vehicles=7,
speed_mode="no_collide",
sumo_car_following_params=SumoCarFollowingParams(
minGap=0.0, tau=0.5),
sumo_lc_params=SumoLaneChangeParams())
Expand All @@ -37,6 +39,7 @@ def two_loops_merge_straight_example(sumo_binary=None):
lane_change_controller=(SumoLaneChangeController, {}),
routing_controller=(ContinuousRouter, {}),
num_vehicles=10,
speed_mode="no_collide",
sumo_car_following_params=SumoCarFollowingParams(
minGap=0.01, tau=0.5),
sumo_lc_params=SumoLaneChangeParams())
Expand Down Expand Up @@ -74,7 +77,7 @@ def two_loops_merge_straight_example(sumo_binary=None):

if __name__ == "__main__":
# import the experiment variable
exp = two_loops_merge_straight_example()
exp = loop_merge_example()

# run for a set number of rollouts / time steps
exp.run(1, 1500, convert_to_csv=True)
4 changes: 2 additions & 2 deletions flow/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
from flow.envs.loop.lane_changing import LaneChangeAccelEnv, \
LaneChangeAccelPOEnv
from flow.envs.loop.loop_accel import AccelEnv
from flow.envs.loop.loop_merges import TwoLoopsMergeEnv
from flow.envs.loop.loop_merges import TwoLoopsMergePOEnv
from flow.envs.loop.wave_attenuation import WaveAttenuationEnv, \
WaveAttenuationPOEnv
from flow.envs.merge import WaveAttenuationMergePOEnv
from flow.envs.test import TestEnv

__all__ = ["Env", "AccelEnv", "LaneChangeAccelEnv", "LaneChangeAccelPOEnv",
"GreenWaveTestEnv", "GreenWaveTestEnv", "WaveAttenuationMergePOEnv",
"TwoLoopsMergeEnv", "BottleneckEnv", "BottleNeckAccelEnv",
"TwoLoopsMergePOEnv", "BottleneckEnv", "BottleNeckAccelEnv",
"WaveAttenuationEnv", "WaveAttenuationPOEnv", "TrafficLightGridEnv",
"PO_TrafficLightGridEnv", "DesiredVelocityEnv", "TestEnv",
"BayBridgeEnv"]
6 changes: 3 additions & 3 deletions flow/envs/loop/loop_merges.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
}


class TwoLoopsMergeEnv(Env):
"""Environment for training cooperative merging behavior in a closed loop
merge scenario.
class TwoLoopsMergePOEnv(Env):
"""Environment for training cooperative merging behavior in a partially
observable closed loop merge scenario.

WARNING: only supports 1 RL vehicle

Expand Down
Loading