From 7d610a165d64d701588c6256fade1ab0b81eeaea Mon Sep 17 00:00:00 2001 From: zpymyyn Date: Sun, 5 Apr 2020 14:26:37 +0300 Subject: [PATCH 1/4] add traffic scale option to running with sumo --- flow/core/params.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flow/core/params.py b/flow/core/params.py index 5a7467580..b0450067b 100755 --- a/flow/core/params.py +++ b/flow/core/params.py @@ -395,6 +395,7 @@ class SimParams(object): def __init__(self, sim_step=0.1, + scale=1, render=False, restart_instance=False, emission_path=None, @@ -405,6 +406,7 @@ def __init__(self, force_color_update=False): """Instantiate SimParams.""" self.sim_step = sim_step + self.scale = scale self.render = render self.restart_instance = restart_instance self.emission_path = emission_path @@ -573,6 +575,7 @@ class SumoParams(SimParams): def __init__(self, port=None, sim_step=0.1, + scale=1 emission_path=None, lateral_resolution=None, no_step_log=True, @@ -592,9 +595,10 @@ def __init__(self, use_ballistic=False): """Instantiate SumoParams.""" super(SumoParams, self).__init__( - sim_step, render, restart_instance, emission_path, save_render, + sim_step, scale, render, restart_instance, emission_path, save_render, sight_radius, show_radius, pxpm, force_color_update) self.port = port + self.scale = scale self.lateral_resolution = lateral_resolution self.no_step_log = no_step_log self.seed = seed From a8b51d19815569e964b0e6a6e7f7b8664291da80 Mon Sep 17 00:00:00 2001 From: zpymyyn Date: Sun, 5 Apr 2020 14:32:41 +0300 Subject: [PATCH 2/4] add sumo option of traffic scale --- flow/visualize/visualizer_rllib.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flow/visualize/visualizer_rllib.py b/flow/visualize/visualizer_rllib.py index 8c38a91c1..cc8b77d71 100644 --- a/flow/visualize/visualizer_rllib.py +++ b/flow/visualize/visualizer_rllib.py @@ -73,6 +73,7 @@ def visualizer_rllib(args): # TODO(ev) remove eventually sim_params = flow_params['sim'] setattr(sim_params, 'num_clients', 1) + setattr(sim_params, 'scale', 1) # for hacks for old pkl files TODO: remove eventually if not hasattr(sim_params, 'use_ballistic'): @@ -351,6 +352,11 @@ def create_parser(): type=int, default=1, help='The number of rollouts to visualize.') + parser.add_argument( + '--scale', + type=float, + default=1.0, + help='Scale demand by the given factor.') parser.add_argument( '--gen_emission', action='store_true', From 269f976b1f03a845a0e19e41730caf7f8ef4367b Mon Sep 17 00:00:00 2001 From: zpymyyn Date: Sun, 5 Apr 2020 14:35:08 +0300 Subject: [PATCH 3/4] Update params.py --- flow/core/params.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flow/core/params.py b/flow/core/params.py index b0450067b..1b83fad9a 100755 --- a/flow/core/params.py +++ b/flow/core/params.py @@ -395,7 +395,7 @@ class SimParams(object): def __init__(self, sim_step=0.1, - scale=1, + scale=1.0, render=False, restart_instance=False, emission_path=None, @@ -575,7 +575,7 @@ class SumoParams(SimParams): def __init__(self, port=None, sim_step=0.1, - scale=1 + scale=1.0, emission_path=None, lateral_resolution=None, no_step_log=True, From 0da267c4e056e541e1e707fd46fc2a2e2478a693 Mon Sep 17 00:00:00 2001 From: zpymyyn Date: Sun, 5 Apr 2020 23:09:21 +0300 Subject: [PATCH 4/4] add explanation of 'scale' in docstring --- flow/core/params.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flow/core/params.py b/flow/core/params.py index 1b83fad9a..6d1684731 100755 --- a/flow/core/params.py +++ b/flow/core/params.py @@ -363,6 +363,9 @@ class SimParams(object): ---------- sim_step : float optional seconds per simulation step; 0.1 by default + scale : float optional + scale demand by the given factor (by discarding or + duplicating vehicles); 1.0 by default render : str or bool, optional specifies whether to visualize the rollout(s) @@ -518,6 +521,9 @@ class SumoParams(SimParams): Port for Traci to connect to; finds an empty port by default sim_step : float optional seconds per simulation step; 0.1 by default + scale : float optional + scale demand by the given factor (by discarding or + duplicating vehicles); 1.0 by default emission_path : str, optional Path to the folder in which to create the emissions output. Emissions output is not generated if this value is not specified