Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render #136

Merged
merged 5 commits into from
Sep 17, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/rllab/cooperative_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

def run_task(*_):
"""Implement the run_task method needed to run experiments with rllab."""
sumo_params = SumoParams(sim_step=0.2, sumo_binary="sumo-gui")
sumo_params = SumoParams(sim_step=0.2, render=True)

# note that the vehicles are added sequentially by the generator,
# so place the merging vehicles after the vehicles in the ring
Expand Down
2 changes: 1 addition & 1 deletion examples/rllab/figure_eight.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def run_task(*_):
"""Implement the run_task method needed to run experiments with rllab."""
sumo_params = SumoParams(sim_step=0.1, sumo_binary="sumo-gui")
sumo_params = SumoParams(sim_step=0.1, render=True)

vehicles = Vehicles()
vehicles.add(
Expand Down
2 changes: 1 addition & 1 deletion examples/rllab/green_wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def run_task(*_):
"cars_bot": num_cars_bot
}

sumo_params = SumoParams(sim_step=1, sumo_binary="sumo-gui")
sumo_params = SumoParams(sim_step=1, render=True)

vehicles = Vehicles()
vehicles.add(
Expand Down
2 changes: 1 addition & 1 deletion examples/rllab/stabilizing_highway.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
def run_task(_):
"""Implement the run_task method needed to run experiments with rllab."""
sumo_params = SumoParams(
sumo_binary="sumo-gui", sim_step=0.2, restart_instance=True)
render=True, sim_step=0.2, restart_instance=True)

# RL vehicles constitute 5% of the total number of vehicles
vehicles = Vehicles()
Expand Down
2 changes: 1 addition & 1 deletion examples/rllab/stabilizing_the_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def run_task(*_):
"""Implement the run_task method needed to run experiments with rllab."""
sumo_params = SumoParams(sim_step=0.1, sumo_binary="sumo", seed=0)
sumo_params = SumoParams(sim_step=0.1, render=False, seed=0)

vehicles = Vehicles()
vehicles.add(
Expand Down
2 changes: 1 addition & 1 deletion examples/rllab/velocity_bottleneck.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
i = 0

sumo_params = SumoParams(
sim_step=0.5, sumo_binary="sumo", restart_instance=True)
sim_step=0.5, render=False, restart_instance=True)

vehicles = Vehicles()

Expand Down
2 changes: 1 addition & 1 deletion examples/rllib/cooperative_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
# sumo-related parameters (see flow.core.params.SumoParams)
sumo=SumoParams(
sim_step=0.1,
sumo_binary="sumo",
render=False,
),

# environment related parameters (see flow.core.params.EnvParams)
Expand Down
2 changes: 1 addition & 1 deletion examples/rllib/figure_eight.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# sumo-related parameters (see flow.core.params.SumoParams)
sumo=SumoParams(
sim_step=0.1,
sumo_binary="sumo",
render=False,
),

# environment related parameters (see flow.core.params.EnvParams)
Expand Down
2 changes: 1 addition & 1 deletion examples/rllib/green_wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def get_non_flow_params(enter_speed, additional_net_params):
# sumo-related parameters (see flow.core.params.SumoParams)
sumo=SumoParams(
sim_step=1,
sumo_binary="sumo-gui",
render=True,
),

# environment related parameters (see flow.core.params.EnvParams)
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 @@ -98,7 +98,7 @@
# sumo-related parameters (see flow.core.params.SumoParams)
sumo=SumoParams(
sim_step=0.2,
sumo_binary="sumo",
render=False,
),

# environment related parameters (see flow.core.params.EnvParams)
Expand Down
2 changes: 1 addition & 1 deletion examples/rllib/stabilizing_the_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# sumo-related parameters (see flow.core.params.SumoParams)
sumo=SumoParams(
sim_step=0.1,
sumo_binary="sumo",
render=False,
),

# environment related parameters (see flow.core.params.EnvParams)
Expand Down
2 changes: 1 addition & 1 deletion examples/rllib/velocity_bottleneck.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
# sumo-related parameters (see flow.core.params.SumoParams)
sumo=SumoParams(
sim_step=0.5,
sumo_binary="sumo",
render=False,
print_warnings=False,
restart_instance=True,
),
Expand Down
10 changes: 5 additions & 5 deletions examples/sumo/bay_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
os.path.dirname(os.path.abspath(__file__)), "bay_bridge.net.xml")


def bay_bridge_example(sumo_binary=None,
def bay_bridge_example(render=None,
use_inflows=False,
use_traffic_lights=False):
"""
Perform a simulation of vehicles on the Oakland-San Francisco Bay Bridge.

Parameters
----------
sumo_binary: bool, optional
render: bool, optional
specifies whether to use sumo's gui during execution
use_inflows: bool, optional
whether to activate inflows from the peripheries of the network
Expand All @@ -41,8 +41,8 @@ def bay_bridge_example(sumo_binary=None,
"""
sumo_params = SumoParams(sim_step=0.6, overtake_right=True)

if sumo_binary is not None:
sumo_params.sumo_binary = sumo_binary
if render is not None:
sumo_params.render = render

sumo_car_following_params = SumoCarFollowingParams(speedDev=0.2)
sumo_lc_params = SumoLaneChangeParams(
Expand Down Expand Up @@ -195,7 +195,7 @@ def bay_bridge_example(sumo_binary=None,
if __name__ == "__main__":
# import the experiment variable
exp = bay_bridge_example(
sumo_binary="sumo-gui", use_inflows=False, use_traffic_lights=False)
render=True, use_inflows=False, use_traffic_lights=False)

# run for a set number of rollouts / time steps
exp.run(1, 1500)
10 changes: 5 additions & 5 deletions examples/sumo/bay_bridge_toll.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
os.path.dirname(os.path.abspath(__file__)), "bottleneck.net.xml")


def bay_bridge_bottleneck_example(sumo_binary=None, use_traffic_lights=False):
def bay_bridge_bottleneck_example(render=None, use_traffic_lights=False):
"""Perform a simulation of the toll portion of the Bay Bridge.

This consists of the toll booth and sections of the road leading up to it.

Parameters
----------
sumo_binary: bool, optional
render : 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
Expand All @@ -35,8 +35,8 @@ def bay_bridge_bottleneck_example(sumo_binary=None, use_traffic_lights=False):
"""
sumo_params = SumoParams(sim_step=0.4, overtake_right=True)

if sumo_binary is not None:
sumo_params.sumo_binary = sumo_binary
if render is not None:
sumo_params.render = render

sumo_car_following_params = SumoCarFollowingParams(speedDev=0.2)
sumo_lc_params = SumoLaneChangeParams(
Expand Down Expand Up @@ -121,7 +121,7 @@ def bay_bridge_bottleneck_example(sumo_binary=None, use_traffic_lights=False):
if __name__ == "__main__":
# import the experiment variable
exp = bay_bridge_bottleneck_example(
sumo_binary="sumo-gui", use_traffic_lights=False)
render=True, use_traffic_lights=False)

# run for a set number of rollouts / time steps
exp.run(1, 1500)
13 changes: 7 additions & 6 deletions examples/sumo/bottleneck.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
INFLOW = 1800


def bottleneck_example(flow_rate, horizon, sumo_binary=None):
def bottleneck_example(flow_rate, horizon, render=None):
"""
Perform a simulation of vehicles on a bottleneck.

Expand All @@ -27,7 +27,7 @@ def bottleneck_example(flow_rate, horizon, sumo_binary=None):
total inflow rate of vehicles into the bottlneck
horizon : int
time horizon
sumo_binary: bool, optional
render: bool, optional
specifies whether to use sumo's gui during execution

Returns
Expand All @@ -36,11 +36,12 @@ def bottleneck_example(flow_rate, horizon, sumo_binary=None):
A non-rl experiment demonstrating the performance of human-driven
vehicles on a bottleneck.
"""
if sumo_binary is None:
sumo_binary = "sumo"
if render is None:
render = False

sumo_params = SumoParams(
sim_step=0.5,
sumo_binary=sumo_binary,
render=render,
overtake_right=False,
restart_instance=True)

Expand Down Expand Up @@ -108,5 +109,5 @@ def bottleneck_example(flow_rate, horizon, sumo_binary=None):
if __name__ == "__main__":
# import the experiment variable
# inflow, number of steps, binary
exp = bottleneck_example(INFLOW, 1000, sumo_binary="sumo-gui")
exp = bottleneck_example(INFLOW, 1000, render=True)
exp.run(5, 1000)
10 changes: 5 additions & 5 deletions examples/sumo/figure_eight.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from flow.scenarios.figure8.gen import Figure8Generator


def figure_eight_example(sumo_binary=None):
def figure_eight_example(render=None):
"""
Perform a simulation of vehicles on a figure eight.

Parameters
----------
sumo_binary: bool, optional
render: bool, optional
specifies whether to use sumo's gui during execution

Returns
Expand All @@ -29,10 +29,10 @@ def figure_eight_example(sumo_binary=None):
A non-rl experiment demonstrating the performance of human-driven
vehicles on a figure eight.
"""
sumo_params = SumoParams(sumo_binary="sumo-gui")
sumo_params = SumoParams(render=True)

if sumo_binary is not None:
sumo_params.sumo_binary = sumo_binary
if render is not None:
sumo_params.render = render

vehicles = Vehicles()
vehicles.add(
Expand Down
10 changes: 5 additions & 5 deletions examples/sumo/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from flow.scenarios.grid.grid_scenario import SimpleGridScenario


def grid_example(sumo_binary=None):
def grid_example(render=None):
"""
Perform a simulation of vehicles on a grid.

Parameters
----------
sumo_binary: bool, optional
render: bool, optional
specifies whether to use sumo's gui during execution

Returns
Expand Down Expand Up @@ -48,10 +48,10 @@ def grid_example(sumo_binary=None):
"cars_bot": num_cars_bot
}

sumo_params = SumoParams(sim_step=0.1, sumo_binary="sumo-gui")
sumo_params = SumoParams(sim_step=0.1, render=True)

if sumo_binary is not None:
sumo_params.sumo_binary = sumo_binary
if render is not None:
sumo_params.render = render

vehicles = Vehicles()
vehicles.add(
Expand Down
10 changes: 5 additions & 5 deletions examples/sumo/highway.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
ADDITIONAL_NET_PARAMS


def highway_example(sumo_binary=None):
def highway_example(render=None):
"""
Perform a simulation of vehicles on a highway.

Parameters
----------
sumo_binary: bool, optional
render : bool, optional
specifies whether to use sumo's gui during execution

Returns
Expand All @@ -26,10 +26,10 @@ def highway_example(sumo_binary=None):
A non-rl experiment demonstrating the performance of human-driven
vehicles on a figure eight.
"""
sumo_params = SumoParams(sumo_binary="sumo-gui")
sumo_params = SumoParams(render=True)

if sumo_binary is not None:
sumo_params.sumo_binary = sumo_binary
if render is not None:
sumo_params.render = render

vehicles = Vehicles()
vehicles.add(
Expand Down
10 changes: 5 additions & 5 deletions examples/sumo/loop_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
from flow.scenarios.loop_merge.gen import TwoLoopOneMergingGenerator


def loop_merge_example(sumo_binary=None):
def loop_merge_example(render=None):
"""
Perform a simulation of vehicles on a loop merge.

Parameters
----------
sumo_binary: bool, optional
render : bool, optional
specifies whether to use sumo's gui during execution

Returns
Expand All @@ -28,10 +28,10 @@ def loop_merge_example(sumo_binary=None):
vehicles on a loop merge.
"""
sumo_params = SumoParams(
sim_step=0.1, emission_path="./data/", sumo_binary="sumo-gui")
sim_step=0.1, emission_path="./data/", render=True)

if sumo_binary is not None:
sumo_params.sumo_binary = sumo_binary
if render is not None:
sumo_params.render = render

# note that the vehicles are added sequentially by the generator,
# so place the merging vehicles after the vehicles in the ring
Expand Down
10 changes: 5 additions & 5 deletions examples/sumo/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
FLOW_RATE = 2000


def merge_example(sumo_binary=None):
def merge_example(render=None):
"""
Perform a simulation of vehicles on a merge.

Parameters
----------
sumo_binary: bool, optional
render: bool, optional
specifies whether to use sumo's gui during execution

Returns
Expand All @@ -35,13 +35,13 @@ def merge_example(sumo_binary=None):
vehicles on a merge.
"""
sumo_params = SumoParams(
sumo_binary="sumo-gui",
render=True,
emission_path="./data/",
sim_step=0.2,
restart_instance=True)

if sumo_binary is not None:
sumo_params.sumo_binary = sumo_binary
if render is not None:
sumo_params.render = render

vehicles = Vehicles()
vehicles.add(
Expand Down