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

add sumo option of traffic scale in visualizing #898

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion flow/core/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -395,6 +398,7 @@ class SimParams(object):

def __init__(self,
sim_step=0.1,
scale=1.0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, could you add an explanation of what this does to the docstring?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, done :)

render=False,
restart_instance=False,
emission_path=None,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -573,6 +581,7 @@ class SumoParams(SimParams):
def __init__(self,
port=None,
sim_step=0.1,
scale=1.0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done:)

emission_path=None,
lateral_resolution=None,
no_step_log=True,
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions flow/visualize/visualizer_rllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down Expand Up @@ -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',
Expand Down