diff --git a/flow/core/params.py b/flow/core/params.py index 5a7467580..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) @@ -395,6 +398,7 @@ class SimParams(object): def __init__(self, sim_step=0.1, + scale=1.0, render=False, restart_instance=False, emission_path=None, @@ -405,6 +409,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 @@ -516,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 @@ -573,6 +581,7 @@ class SumoParams(SimParams): def __init__(self, port=None, sim_step=0.1, + scale=1.0, emission_path=None, lateral_resolution=None, no_step_log=True, @@ -592,9 +601,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 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',