Skip to content

Commit

Permalink
Merge branch 'master' into tune_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AboudyKreidieh authored Jun 9, 2018
2 parents 5c289d2 + 4f365b1 commit 0a25686
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion flow/utils/rllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
from flow.core.traffic_lights import TrafficLights
from flow.core.vehicles import Vehicles

import sumolib
import time
from copy import deepcopy


def make_create_env(params, version=0, sumo_binary=None):
"""Creates a parametrized flow environment compatible with RLlib.
Expand Down Expand Up @@ -71,7 +75,6 @@ def make_create_env(params, version=0, sumo_binary=None):
module = __import__("flow.scenarios", fromlist=[params["generator"]])
generator_class = getattr(module, params["generator"])

sumo_params = params['sumo']
env_params = params['env']
net_params = params['net']
vehicles = params['veh']
Expand All @@ -90,6 +93,13 @@ def create_env(*_):
initial_config=initial_config,
traffic_lights=traffic_lights,
)

sumo_params = deepcopy(params['sumo'])
if sumo_params.port is None:
time_stamp = ''.join(str(time.time()).split('.'))
time.sleep(2.0 * int(time_stamp[-6:]) / 1e6)
sumo_params.port = sumolib.miscutils.getFreeSocketPort()

register(
id=env_name,
entry_point='flow.envs:' + params["env_name"],
Expand Down

0 comments on commit 0a25686

Please sign in to comment.