Skip to content

Commit

Permalink
Merge pull request #517 from flow-project/time_space_diagram
Browse files Browse the repository at this point in the history
Time space diagram

- added a method for plotting time-space diagrams
- using the time-space diagrams to modify the vehicle parameters in the simulations to match expected behaviors in new sumo (more on this to come)
- tests for the new time-space diagram plotter
  • Loading branch information
AboudyKreidieh committed Jun 11, 2019
2 parents 3bfe67e + 748a67b commit c8ea2b0
Show file tree
Hide file tree
Showing 17 changed files with 1,404 additions and 11 deletions.
2 changes: 2 additions & 0 deletions examples/rllab/figure_eight.py
Expand Up @@ -27,6 +27,7 @@ def run_task(*_):
routing_controller=(ContinuousRouter, {}),
car_following_params=SumoCarFollowingParams(
speed_mode="obey_safe_speed",
decel=1.5,
),
num_vehicles=1)
vehicles.add(
Expand All @@ -37,6 +38,7 @@ def run_task(*_):
routing_controller=(ContinuousRouter, {}),
car_following_params=SumoCarFollowingParams(
speed_mode="obey_safe_speed",
decel=1.5,
),
num_vehicles=13)

Expand Down
2 changes: 2 additions & 0 deletions examples/rllib/figure_eight.py
Expand Up @@ -35,6 +35,7 @@
routing_controller=(ContinuousRouter, {}),
car_following_params=SumoCarFollowingParams(
speed_mode="obey_safe_speed",
decel=1.5,
),
num_vehicles=13)
vehicles.add(
Expand All @@ -43,6 +44,7 @@
routing_controller=(ContinuousRouter, {}),
car_following_params=SumoCarFollowingParams(
speed_mode="obey_safe_speed",
decel=1.5,
),
num_vehicles=1)

Expand Down
1 change: 1 addition & 0 deletions examples/sumo/figure_eight.py
Expand Up @@ -41,6 +41,7 @@ def figure_eight_example(render=None):
routing_controller=(ContinuousRouter, {}),
car_following_params=SumoCarFollowingParams(
speed_mode="obey_safe_speed",
decel=1.5,
),
initial_speed=0,
num_vehicles=14)
Expand Down
1 change: 1 addition & 0 deletions flow/benchmarks/figureeight0.py
Expand Up @@ -29,6 +29,7 @@
routing_controller=(ContinuousRouter, {}),
car_following_params=SumoCarFollowingParams(
speed_mode="obey_safe_speed",
decel=1.5,
),
num_vehicles=13)
vehicles.add(
Expand Down
1 change: 1 addition & 0 deletions flow/benchmarks/figureeight1.py
Expand Up @@ -30,6 +30,7 @@
routing_controller=(ContinuousRouter, {}),
car_following_params=SumoCarFollowingParams(
speed_mode="obey_safe_speed",
decel=1.5,
),
num_vehicles=1)
vehicles.add(
Expand Down
11 changes: 6 additions & 5 deletions flow/scenarios/merge.py
Expand Up @@ -99,7 +99,8 @@ def specify_nodes(self, net_params):
{
"id": "center",
"y": 0,
"x": premerge
"x": premerge,
"radius": 10
},
{
"id": "right",
Expand Down Expand Up @@ -196,11 +197,11 @@ def specify_edge_starts(self):
postmerge = self.net_params.additional_params["post_merge_length"]

edgestarts = [("inflow_highway", 0), ("left", INFLOW_EDGE_LEN + 0.1),
("center", INFLOW_EDGE_LEN + premerge + 8.1),
("center", INFLOW_EDGE_LEN + premerge + 22.6),
("inflow_merge",
INFLOW_EDGE_LEN + premerge + postmerge + 8.1),
INFLOW_EDGE_LEN + premerge + postmerge + 22.6),
("bottom",
2 * INFLOW_EDGE_LEN + premerge + postmerge + 8.2)]
2 * INFLOW_EDGE_LEN + premerge + postmerge + 22.7)]

return edgestarts

Expand All @@ -212,7 +213,7 @@ def specify_internal_edge_starts(self):
internal_edgestarts = [
(":left", INFLOW_EDGE_LEN), (":center",
INFLOW_EDGE_LEN + premerge + 0.1),
(":bottom", 2 * INFLOW_EDGE_LEN + premerge + postmerge + 8.1)
(":bottom", 2 * INFLOW_EDGE_LEN + premerge + postmerge + 22.6)
]

return internal_edgestarts
1 change: 1 addition & 0 deletions flow/utils/registry.py
Expand Up @@ -32,6 +32,7 @@ def make_create_env(params, version=0, render=None):
- exp_tag: name of the experiment
- env_name: name of the flow environment the experiment is running on
- scenario: name of the scenario class the experiment uses
- simulator: simulator that is used by the experiment (e.g. aimsun)
- sim: simulation-related parameters (see flow.core.params.SimParams)
- env: environment related parameters (see flow.core.params.EnvParams)
- net: network-related parameters (see flow.core.params.NetParams and
Expand Down
30 changes: 25 additions & 5 deletions flow/utils/rllib.py
Expand Up @@ -57,17 +57,37 @@ def get_flow_params(config):
Parameters
----------
config : dict
stored RLlib configuration dict
config : dict < dict > or str
May be one of two things:
* If it is a dict, then it is the stored RLlib configuration dict.
* If it is a string, then it is the path to a flow_params json file.
Returns
-------
dict
Dict of flow parameters, like net_params, env_params, vehicle
characteristics, etc
flow-related parameters, consisting of the following keys:
* exp_tag: name of the experiment
* env_name: name of the flow environment the experiment is running on
* scenario: name of the scenario class the experiment uses
* simulator: simulator that is used by the experiment (e.g. aimsun)
* sim: simulation-related parameters (see flow.core.params.SimParams)
* env: environment related parameters (see flow.core.params.EnvParams)
* net: network-related parameters (see flow.core.params.NetParams and
the scenario's documentation or ADDITIONAL_NET_PARAMS component)
* veh: vehicles to be placed in the network at the start of a rollout
(see flow.core.params.VehicleParams)
* initial: parameters affecting the positioning of vehicles upon
initialization/reset (see flow.core.params.InitialConfig)
* tls: traffic lights to be introduced to specific nodes (see
flow.core.params.TrafficLightParams)
"""
# collect all data from the json file
flow_params = json.loads(config['env_config']['flow_params'])
if type(config) == dict:
flow_params = json.loads(config['env_config']['flow_params'])
else:
flow_params = json.load(open(config, 'r'))

# reinitialize the vehicles class from stored data
veh = VehicleParams()
Expand Down
2 changes: 1 addition & 1 deletion flow/version.py
@@ -1,3 +1,3 @@
"""Specifies the current version number of Flow."""

__version__ = "0.3.0"
__version__ = "0.3.1"

0 comments on commit c8ea2b0

Please sign in to comment.