Skip to content

Commit

Permalink
Add ballistic integration as an option (#873)
Browse files Browse the repository at this point in the history
* Add ballistic integration as an option

* bug fix

Co-authored-by: AboudyKreidieh <akreidieh@gmail.com>
  • Loading branch information
eugenevinitsky and AboudyKreidieh committed Mar 17, 2020
1 parent f72760b commit d3c5c83
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
5 changes: 3 additions & 2 deletions examples/exp_configs/non_rl/i210_subnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
lane_change_mode="strategic",
),
acceleration_controller=(IDMController, {
"a": 0.3, "b": 2.0, "noise": 0.45
"a": 0.3, "b": 2.0, "noise": 0.5
}),
)

Expand Down Expand Up @@ -69,9 +69,10 @@

# simulation-related parameters
sim=SumoParams(
sim_step=0.8,
sim_step=0.5,
render=False,
color_by_speed=True,
use_ballistic=True
),

# environment related parameters (see flow.core.params.EnvParams)
Expand Down
4 changes: 4 additions & 0 deletions flow/core/kernel/simulation/traci.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def start_simulation(self, network, sim_params):
"--step-length", str(sim_params.sim_step)
]

# use a ballistic integration step (if request)
if sim_params.use_ballistic:
sumo_call.append("--step-method.ballistic")

# add step logs (if requested)
if sim_params.no_step_log:
sumo_call.append("--no-step-log")
Expand Down
6 changes: 5 additions & 1 deletion flow/core/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ class SumoParams(SimParams):
color_by_speed : bool
whether to color the vehicles by the speed they are moving at the
current time step
use_ballistic: bool, optional
If true, use a ballistic integration step instead of an euler step
"""

def __init__(self,
Expand All @@ -586,7 +588,8 @@ def __init__(self,
print_warnings=True,
teleport_time=-1,
num_clients=1,
color_by_speed=False):
color_by_speed=False,
use_ballistic=False):
"""Instantiate SumoParams."""
super(SumoParams, self).__init__(
sim_step, render, restart_instance, emission_path, save_render,
Expand All @@ -600,6 +603,7 @@ def __init__(self,
self.teleport_time = teleport_time
self.num_clients = num_clients
self.color_by_speed = color_by_speed
self.use_ballistic = use_ballistic


class EnvParams:
Expand Down
4 changes: 4 additions & 0 deletions flow/visualize/visualizer_rllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def visualizer_rllib(args):
sim_params = flow_params['sim']
setattr(sim_params, 'num_clients', 1)

# for hacks for old pkl files TODO: remove eventually
if not hasattr(sim_params, 'use_ballistic'):
sim_params.use_ballistic = False

# Determine agent and checkpoint
config_run = config['env_config']['run'] if 'run' in config['env_config'] \
else None
Expand Down

0 comments on commit d3c5c83

Please sign in to comment.