Skip to content

Commit

Permalink
scenarios -> networks [do not merge] (#698)
Browse files Browse the repository at this point in the history
* better file names for environments

* change base_scenario.py to base.py for consistency

* change WaveAttenuationMergePOEnv to MergePOEnv for consistency

* changed "loop" to "ring" in envs

* Renamed "loop" to "ring" in scenarios

* More rename "loop" to "ring"

* Final commit for "loop" to "merge"

* merge multiagent_envs into envs

* changed all apperance of green wave to traffic light grid

* Fixed names for scenarios so that they match the environments. Everything is uniform now

* moved scenario files to network and renamed Scenario->Network

* removed all non-aimsun mentioned of scenario

* added pending deprecation warning for scenario use

* Removing cooperative_merge (later we called it "TwoRingsOneMerge"

* pep8

* added deprecation warning for scenario to env input

* Refactoring new files that are added after pulling from master

* Change 'grid' to 'traffic_light_grid' across all files

* addressed flake8 issues

* PR fixes

* PR fix

* Fixed test_visualiszer.py errors

* bug fixes

* Remove data.json

* bug fix

* added deprecation support

- added a deprecation function for classes and functions
- renames deprecation_warning ->deprecated_attribute
- added deprecation warnings for all old names of environments
- updated version to 0.5.0.dev

* pep8

* pydocstyle

* added deprecation warnings to changed scenarios

* added deprecation warning for the multiagnet environments

* pydocstyle

* cleanup
  • Loading branch information
AboudyKreidieh committed Sep 12, 2019
1 parent f4ed943 commit bd49a78
Show file tree
Hide file tree
Showing 155 changed files with 5,191 additions and 5,026 deletions.
74 changes: 0 additions & 74 deletions README.md
Expand Up @@ -43,77 +43,3 @@ Vinitsky, E., Kreidieh, A., Le Flem, L., Kheterpal, N., Jang, K., Wu, F., ... &
# Contributors

Flow is supported by the [Mobile Sensing Lab](http://bayen.eecs.berkeley.edu/) at UC Berkeley and Amazon AWS Machine Learning research grants. The contributors are listed in [Flow Team Page](https://flow-project.github.io/team.html).


<!-- ## Getting Started
- TODO: Tutorial for visualization / plot generating scripts
Sumo Params:
- Port required, recommended set to 8873
- Timestep, recommended is 0.01, default is 1.0
- TODO: Same flags as SUMO Popen, make it more robust
Env Params:
- These will change based on the scenario
- Target Velocity
Net Params:
- For each environment, you should determine which net params are relevant.
- Used in Generator files that are specific to each scenario?
- "length" : length of the track
- "lanes" : number of lanes
- "speed_limit"
- "resolution" : number of nodes per edge, affects how 'circular' the track appears when visualized but doesn't affect performance [sic] (e.g. if you have 4 edges for a circle and resolution=2 it will display as 12 lines in the gui)
- "net_path" : path for the folder where the net XML files will be saved: edg.xml, .netccfg, nod.xml, typ.xml
- Suggestion: Direct control of naming of XML files
Configuration (Cfg) Params:
- "start_time" : 0
- "end_time" : When the simulation ends, so pick a reasonably large number
- TODO(cathywu) what are the units of start/end time?
- "cfg_path" : path for the folder where the cfg XML files will be saved: add.xml, gui.cfg, net.xml, rou.xml, sumo.cfg
Vehicle Params:
- Dictionary of car type tag -> (count, car following controller, lane changing controller) assignments, where controller is a method.
- Specifies number of cars for each type
- "Type" : (Number of cars, Car Following Model, Lane Changing Model)
- "rl": No car following model, action determined by RL algorithm
- All other types can have arbitrary names because their actions/updates are determined by the models (other functions in the tuple)
- Suggestion: instead of having "rl" be specific, we could have it such that None or a RL HOF are recognized as "rl vehicles"; Other suggestion: specifying controlled_vehicle_params and rl_params
- TODO(cathywu) include an example here
### Vehicle Params
Implemented car following models:
- Basic Car Following Model
- per [Horn 2013](http://ieeexplore.ieee.org/abstract/document/6728204/)
- Only considers vehicle ahead.
- Terms for desired velocity and headway gap
- Bilateral Control Model
- per [Horn 2013](http://ieeexplore.ieee.org/abstract/document/6728204/)
- Considers vehicle ahead and vehicle behind.
- Term for desired velocity. Another term to place self halfway between car ahead and car behind.
- Optimal Vehicle Model
- per [Jin & Gabor 2014](http://www-personal.umich.edu/~orosz/articles/CDC_2014_Jin.pdf)
- Only considers vehicle ahead.
- Desired velocity term is a function of headway. Also seeks to match velocity of car ahead.
Lane changing models:
- No lane changing
- Stochastic lane changer
Warnings:
====
All car controllers come equipped with a fail-safe rule wherein cars are not allowed to
move at a speed that would cause them to crash if the car in front of them suddenly started
breaking with max acceleration. If they attempt to do so, they will be reset to move at $$v_safe$$
where $$v_safe$$ is the speed such that the cars will come to rest at the same point. -->
2 changes: 1 addition & 1 deletion docs/setup.py.sumotools
Expand Up @@ -45,7 +45,7 @@ setup(
'continuous road traffic simulation package designed to '
'handle large road networks. It allows for intermodal '
'simulation including pedestrians and comes with a large set '
'of tools for scenario creation. http://sumo.dlr.de',
'of tools for network creation. http://sumo.dlr.de',

# This is an optional longer description of your project that represents
# the body of text which users will see when they visit PyPI.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples.rst
@@ -1,5 +1,5 @@
Built-in Traffic Scenarios
==========================
Built-in Traffic Networks
=========================

We provide a quick introduction to the traffic examples and tools that Flow comes pre-built with.
For further details, please examine the documentation provided in the examples folder.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/flow.core.kernel.rst
Expand Up @@ -9,10 +9,10 @@ flow.core.kernel module
:undoc-members:
:show-inheritance:

flow.core.kernel.scenario module
flow.core.kernel.network module
--------------------------------

.. automodule:: flow.core.kernel.scenario
.. automodule:: flow.core.kernel.network
:members:
:undoc-members:
:show-inheritance:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/flow.rst
Expand Up @@ -10,7 +10,7 @@ Subpackages
flow.controllers
flow.core
flow.envs
flow.scenarios
flow.networks
flow.utils
flow.visualize
flow.renderer
Expand Down
4 changes: 2 additions & 2 deletions docs/source/flow.scenarios.rst
@@ -1,7 +1,7 @@
flow.scenarios package
flow.networks package
======================

.. automodule:: flow.scenarios
.. automodule:: flow.networks
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions examples/aimsun/bottlenecks.py
Expand Up @@ -5,7 +5,7 @@
from flow.core.params import VehicleParams
from flow.core.params import TrafficLightParams

from flow.scenarios.bottleneck import BottleneckScenario
from flow.networks.bottleneck import BottleneckNetwork
from flow.envs.bottleneck import BottleneckEnv
from flow.core.experiment import Experiment

Expand Down Expand Up @@ -89,14 +89,14 @@ def bottleneck_example(flow_rate, horizon, restart_instance=False,
lanes_distribution=float("inf"),
edges_distribution=["2", "3", "4", "5"])

scenario = BottleneckScenario(
network = BottleneckNetwork(
name="bay_bridge_toll",
vehicles=vehicles,
net_params=net_params,
initial_config=initial_config,
traffic_lights=traffic_lights)

env = BottleneckEnv(env_params, sim_params, scenario, simulator='aimsun')
env = BottleneckEnv(env_params, sim_params, network, simulator='aimsun')

return Experiment(env)

Expand Down
8 changes: 4 additions & 4 deletions examples/aimsun/figure_eight.py
Expand Up @@ -9,7 +9,7 @@
from flow.core.params import AimsunParams, EnvParams, NetParams
from flow.core.params import VehicleParams
from flow.envs import TestEnv
from flow.scenarios.figure_eight import FigureEightScenario, ADDITIONAL_NET_PARAMS
from flow.networks.figure_eight import FigureEightNetwork, ADDITIONAL_NET_PARAMS


def figure_eight_example(render=None):
Expand Down Expand Up @@ -42,12 +42,12 @@ def figure_eight_example(render=None):
net_params = NetParams(
additional_params=ADDITIONAL_NET_PARAMS.copy())

scenario = FigureEightScenario(
name="FigureEight",
network = FigureEightNetwork(
name="figure8",
vehicles=vehicles,
net_params=net_params)

env = TestEnv(env_params, sim_params, scenario, simulator='aimsun')
env = TestEnv(env_params, sim_params, network, simulator='aimsun')

return Experiment(env)

Expand Down
6 changes: 3 additions & 3 deletions examples/aimsun/grid.py
Expand Up @@ -4,7 +4,7 @@
from flow.core.params import VehicleParams
from flow.core.params import TrafficLightParams
from flow.envs.ring.accel import AccelEnv, ADDITIONAL_ENV_PARAMS
from flow.scenarios.traffic_light_grid import TrafficLightGridScenario
from flow.networks import TrafficLightGridNetwork


def traffic_light_grid_example(render=None):
Expand Down Expand Up @@ -101,14 +101,14 @@ def traffic_light_grid_example(render=None):

initial_config = InitialConfig(spacing='custom')

scenario = TrafficLightGridScenario(
network = TrafficLightGridNetwork(
name="grid-intersection",
vehicles=vehicles,
net_params=net_params,
initial_config=initial_config,
traffic_lights=tl_logic)

env = AccelEnv(env_params, sim_params, scenario, simulator='aimsun')
env = AccelEnv(env_params, sim_params, network, simulator='aimsun')

return Experiment(env)

Expand Down
7 changes: 3 additions & 4 deletions examples/aimsun/merge.py
Expand Up @@ -7,7 +7,7 @@

import flow.core.params as params
from flow.core.experiment import Experiment
from flow.scenarios.merge import MergeScenario, ADDITIONAL_NET_PARAMS
from flow.networks.merge import MergeNetwork, ADDITIONAL_NET_PARAMS
from flow.controllers import IDMController
from flow.envs.merge import MergePOEnv, ADDITIONAL_ENV_PARAMS

Expand Down Expand Up @@ -77,14 +77,13 @@ def merge_example(render=None):

initial_config = params.InitialConfig()

scenario = MergeScenario(
network = MergeNetwork(
name="merge-baseline",
vehicles=vehicles,
net_params=net_params,
initial_config=initial_config)

env = MergePOEnv(
env_params, sim_params, scenario, simulator='aimsun')
env = MergePOEnv(env_params, sim_params, network, simulator='aimsun')

return Experiment(env)

Expand Down
6 changes: 3 additions & 3 deletions examples/aimsun/small_template.py
Expand Up @@ -4,7 +4,7 @@
from flow.core.params import AimsunParams, EnvParams, NetParams
from flow.core.params import VehicleParams
from flow.envs import TestEnv
from flow.scenarios.ring import Scenario
from flow.networks import Network
from flow.core.params import InFlows
import flow.config as config
import os
Expand All @@ -22,7 +22,7 @@
template_path = os.path.join(config.PROJECT_PATH,
"flow/utils/aimsun/small_template.ang")

scenario = Scenario(
network = Network(
name="aimsun_small_template",
vehicles=vehicles,
net_params=NetParams(
Expand All @@ -31,6 +31,6 @@
)
)

env = TestEnv(env_params, sim_params, scenario, simulator='aimsun')
env = TestEnv(env_params, sim_params, network, simulator='aimsun')
exp = Experiment(env)
exp.run(1, 3000)
6 changes: 3 additions & 3 deletions examples/aimsun/sugiyama.py
Expand Up @@ -8,7 +8,7 @@
from flow.core.params import AimsunParams, EnvParams, InitialConfig, NetParams
from flow.core.params import VehicleParams
from flow.envs import TestEnv
from flow.scenarios.ring import RingScenario, ADDITIONAL_NET_PARAMS
from flow.networks.ring import RingNetwork, ADDITIONAL_NET_PARAMS


def sugiyama_example(render=None):
Expand Down Expand Up @@ -43,13 +43,13 @@ def sugiyama_example(render=None):

initial_config = InitialConfig(bunching=20)

scenario = RingScenario(
network = RingNetwork(
name="sugiyama",
vehicles=vehicles,
net_params=net_params,
initial_config=initial_config)

env = TestEnv(env_params, sim_params, scenario, simulator='aimsun')
env = TestEnv(env_params, sim_params, network, simulator='aimsun')

return Experiment(env)

Expand Down
8 changes: 4 additions & 4 deletions examples/rllib/figure_eight.py
Expand Up @@ -16,7 +16,7 @@
SumoCarFollowingParams
from flow.core.params import VehicleParams
from flow.controllers import IDMController, ContinuousRouter, RLController
from flow.scenarios.figure_eight import ADDITIONAL_NET_PARAMS
from flow.networks.figure_eight import ADDITIONAL_NET_PARAMS

# time horizon of a single rollout
HORIZON = 1500
Expand Down Expand Up @@ -55,8 +55,8 @@
# name of the flow environment the experiment is running on
env_name='AccelEnv',

# name of the scenario class the experiment is running on
scenario='FigureEightScenario',
# name of the network class the experiment is running on
network='FigureEightNetwork',

# simulator that is used by the experiment
simulator='traci',
Expand All @@ -79,7 +79,7 @@
),

# network-related parameters (see flow.core.params.NetParams and the
# scenario's documentation or ADDITIONAL_NET_PARAMS component)
# network's documentation or ADDITIONAL_NET_PARAMS component)
net=NetParams(
additional_params=ADDITIONAL_NET_PARAMS.copy(),
),
Expand Down
8 changes: 4 additions & 4 deletions examples/rllib/multiagent_exps/multiagent_figure_eight.py
Expand Up @@ -29,7 +29,7 @@
from flow.core.params import SumoParams
from flow.core.params import SumoCarFollowingParams
from flow.core.params import VehicleParams
from flow.scenarios.figure_eight import ADDITIONAL_NET_PARAMS
from flow.networks.figure_eight import ADDITIONAL_NET_PARAMS
from flow.utils.registry import make_create_env
from flow.utils.rllib import FlowParamsEncoder

Expand Down Expand Up @@ -68,8 +68,8 @@
# name of the flow environment the experiment is running on
env_name='MultiAgentAccelEnv',

# name of the scenario class the experiment is running on
scenario='FigureEightScenario',
# name of the network class the experiment is running on
network='FigureEightNetwork',

# simulator that is used by the experiment
simulator='traci',
Expand All @@ -93,7 +93,7 @@
),

# network-related parameters (see flow.core.params.NetParams and the
# scenario's documentation or ADDITIONAL_NET_PARAMS component)
# network's documentation or ADDITIONAL_NET_PARAMS component)
net=NetParams(
additional_params=deepcopy(ADDITIONAL_NET_PARAMS),
),
Expand Down
8 changes: 4 additions & 4 deletions examples/rllib/multiagent_exps/multiagent_highway.py
@@ -1,7 +1,7 @@
"""Multi-agent highway with ramps example.
Trains a non-constant number of agents, all sharing the same policy, on the
highway with ramps scenario.
highway with ramps network.
"""
import json
import ray
Expand All @@ -23,7 +23,7 @@
from flow.utils.rllib import FlowParamsEncoder

from flow.envs.ring.accel import ADDITIONAL_ENV_PARAMS
from flow.scenarios.highway_ramps import ADDITIONAL_NET_PARAMS
from flow.networks.highway_ramps import ADDITIONAL_NET_PARAMS


# SET UP PARAMETERS FOR THE SIMULATION
Expand All @@ -45,7 +45,7 @@
PENETRATION_RATE = 20


# SET UP PARAMETERS FOR THE SCENARIO
# SET UP PARAMETERS FOR THE NETWORK

additional_net_params = ADDITIONAL_NET_PARAMS.copy()
additional_net_params.update({
Expand Down Expand Up @@ -135,7 +135,7 @@
flow_params = dict(
exp_tag='multiagent_highway',
env_name='MultiAgentHighwayPOEnv',
scenario='HighwayRampsScenario',
network='HighwayRampsNetwork',
simulator='traci',

env=EnvParams(
Expand Down
Expand Up @@ -60,8 +60,8 @@
# name of the flow environment the experiment is running on
env_name='MultiWaveAttenuationPOEnv',

# name of the scenario class the experiment is running on
scenario='MultiRingScenario',
# name of the network class the experiment is running on
network='MultiRingNetwork',

# simulator that is used by the experiment
simulator='traci',
Expand All @@ -85,7 +85,7 @@
),

# network-related parameters (see flow.core.params.NetParams and the
# scenario's documentation or ADDITIONAL_NET_PARAMS component)
# network's documentation or ADDITIONAL_NET_PARAMS component)
net=NetParams(
additional_params={
'length': 230,
Expand Down

0 comments on commit bd49a78

Please sign in to comment.