Skip to content
Closed
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
9 changes: 7 additions & 2 deletions flow/core/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def __init__(self,
seed=None,
restart_instance=False,
print_warnings=True,
teleport_time=-1):
teleport_time=-1,
num_clients=1):
"""Instantiate SumoParams.

Attributes
Expand Down Expand Up @@ -66,7 +67,10 @@ def __init__(self,
If set to false, this will silence sumo warnings on the stdout
teleport_time: int, optional
If negative, vehicles don't teleport in gridlock. If positive,
they teleport after teleport_time seconds
they teleport after teleport_time seconds.
num_clients: int, optional

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

FIXME: this blocks if >1 and only one client is connected

Number of clients SUMO expects to connect. Should be different from
one only in very rare situations.

"""
self.port = port
Expand All @@ -81,6 +85,7 @@ def __init__(self,
self.restart_instance = restart_instance
self.print_warnings = print_warnings
self.teleport_time = teleport_time
self.num_clients = num_clients


class EnvParams:
Expand Down
7 changes: 4 additions & 3 deletions flow/envs/base_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def start_sumo(self):
# command used to start sumo
sumo_call = [
self.sumo_params.sumo_binary, "-c", self.scenario.cfg,
"--remote-port",
str(port), "--step-length",
str(self.sim_step)
"--remote-port", str(port),
"--num-clients", str(self.sumo_params.num_clients),
"--step-length", str(self.sim_step)
]

# add step logs (if requested)
Expand Down Expand Up @@ -244,6 +244,7 @@ def start_sumo(self):
time.sleep(config.SUMO_SLEEP)

self.traci_connection = traci.connect(port, numRetries=100)
self.traci_connection.setOrder(0)

self.traci_connection.simulationStep()
return
Expand Down
9 changes: 5 additions & 4 deletions flow/visualize/visualizer_rllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import os

import ray
from ray.rllib.agent import get_agent_class
from ray.tune.registry import get_registry, register_env
from ray.rllib.agents.agent import get_agent_class
from ray.tune.registry import register_env

from flow.utils.registry import make_create_env
from flow.utils.rllib import get_flow_params
Expand Down Expand Up @@ -85,7 +85,7 @@
register_env(env_name, create_env)

agent_cls = get_agent_class(args.run)
agent = agent_cls(env=env_name, registry=get_registry(), config=config)
agent = agent_cls(env=env_name, config=config)
checkpoint = result_dir + '/checkpoint-' + args.checkpoint_num
agent._restore(checkpoint)

Expand All @@ -112,8 +112,9 @@
env_class = getattr(module, flow_params["env_name"])
env_params = flow_params['env']
sumo_params = flow_params['sumo']
sumo_params.sumo_binary = "sumo-gui"
sumo_params.sumo_binary = "sumo"
sumo_params.emission_path = "./test_time_rollout/"
sumo_params.num_clients = 2

env = env_class(
env_params=env_params, sumo_params=sumo_params, scenario=scenario)
Expand Down