Skip to content

Commit

Permalink
Fix sim_params in the tutorials (#807)
Browse files Browse the repository at this point in the history
* Update tutorials

* Update all tutorials

* Apply suggestions from code review

Co-authored-by: Aboudy Kreidieh <akreidieh@gmail.com>
  • Loading branch information
ashkan-software and AboudyKreidieh committed Jan 5, 2020
1 parent d2cd893 commit 824c613
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 24 deletions.
26 changes: 22 additions & 4 deletions tutorials/tutorial01_sumo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,30 @@
"source": [
"Although we will not be training any autonomous agents in this tutorial, the use of an environment allows us to view the cumulative reward simulation rollouts receive in the absence of autonomy.\n",
"\n",
"Envrionments in Flow are parametrized by three components:\n",
"* `EnvParams`\n",
"Although we will not be training any autonomous agents in this exercise, the use of an environment allows us to view the cumulative reward simulation rollouts receive in the absence of autonomy.\n",
"\n",
"Envrionments in Flow are parametrized by several components, including the following attributes:\n",
"* `sim_params`\n",
"* `env_params`\n",
"* `network`\n",
"* `net_params`\n",
"* `initial_config`\n",
"* `network`\n",
"* `simulator`\n",
"\n",
"where `sim_params`, `env_params`, and `network` are the primary parameters of an environment. For the full list of attributes, please check `class Env` in `flow/envs/base.py`.\n",
"\n",
"Sumo envrionments in Flow are parametrized by three components:\n",
"* `SumoParams`\n",
"* `EnvParams`\n",
"* `Network`\n",
"\n",
"### 3.1 SumoParams\n",
"`SumoParams` specifies simulation-specific variables (e.g. `SumoParams` and `AimsunParams` are the variables related to SUMO and Aimsun simulator, respectively). These variables maay include the length a simulation step (in seconds), whether to render the GUI when running the experiment, and other variables. For this example, we consider a SUMO simulation, step length of 0.1s, and activate the GUI.\n",
"\n",
"Another useful parameter is `emission_path`, which is used to specify the path where the emissions output will be generated. They contain a lot of information about the simulation, for instance the position and speed of each car at each time step. If you do not specify any emission path, the emission file will not be generated. More on this in Section 5.\n",
"\n",
"### 3.1 SumoParams\n",
"`SumoParams` specifies simulation-specific variables. These variables include the length a simulation step (in seconds) and whether to render the GUI when running the experiment. For this example, we consider a simulation step length of 0.1s and activate the GUI.\n",
"\n",
"Another useful parameter is `emission_path`, which is used to specify the path where the emissions output will be generated. They contain a lot of information about the simulation, for instance the position and speed of each car at each time step. If you do not specify any emission path, the emission file will not be generated. More on this in Section 5."
Expand All @@ -255,7 +273,7 @@
"source": [
"from flow.core.params import SumoParams\n",
"\n",
"sumo_params = SumoParams(sim_step=0.1, render=True, emission_path='data')"
"sim_params = SumoParams(sim_step=0.1, render=True, emission_path='data')"
]
},
{
Expand Down Expand Up @@ -336,7 +354,7 @@
" traffic_lights=traffic_lights)\n",
"\n",
"# create the environment object\n",
"env = AccelEnv(env_params, sumo_params, network)\n",
"env = AccelEnv(env_params, sim_params, network)\n",
"\n",
"flow_params = dict(\n",
" exp_tag='ring_example',\n",
Expand Down
17 changes: 14 additions & 3 deletions tutorials/tutorial02_aimsun.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,24 @@
"source": [
"Although we will not be training any autonomous agents in this tutorial, the use of an environment allows us to view the cumulative reward simulation rollouts receive in the absence of autonomy.\n",
"\n",
"Envrionments in Flow are parametrized by three components:\n",
"* `EnvParams`\n",
"Envrionments in Flow are parametrized by several components, including the following attributes:\n",
"* `sim_params`\n",
"* `env_params`\n",
"* `network`\n",
"* `net_params`\n",
"* `initial_config`\n",
"* `network`\n",
"* `simulator`\n",
"\n",
"where `sim_params`, `env_params`, and `network` the are primary parameters of an environment. For the full list of attributes, please check `class Env` in `flow/envs/base.py`.\n",
"\n",
"Aimsun envrionments in Flow are parametrized by three components:\n",
"* `AimsunParams`\n",
"* `EnvParams`\n",
"* `Network`\n",
"\n",
"### 3.1 AimsunParams\n",
"`AimsunParams` specifies simulation-specific variables. These variables include the length a simulation step (in seconds) and whether to render the GUI when running the experiment. For this example, we consider a simulation step length of 0.1s and set `render` within the simulation params to be True in order for vehicles to appear on the GUI during the simulation."
"`AimsunParams` specifies simulation-specific variables. These variables include the length a simulation step (in seconds) and whether to render the GUI when running the experiment. For this example, we set `render` within the simulation params to be True in order for vehicles to appear on the GUI during the simulation."
]
},
{
Expand Down
16 changes: 8 additions & 8 deletions tutorials/tutorial03_rllib.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@
"\n",
"Several environments in Flow exist to train RL agents of different forms (e.g. autonomous vehicles, traffic lights) to perform a variety of different tasks. The use of an environment allows us to view the cumulative reward simulation rollouts receive, along with to specify the state/action spaces.\n",
"\n",
"Envrionments in Flow are parametrized by three components:\n",
"* env_params\n",
"* sumo_params\n",
"* network\n",
"Sumo envrionments in Flow are parametrized by three components:\n",
"* `SumoParams`\n",
"* `EnvParams`\n",
"* `Network`\n",
"\n",
"### 3.1 SumoParams\n",
"`SumoParams` specifies simulation-specific variables. These variables include the length of any simulation step and whether to render the GUI when running the experiment. For this example, we consider a simulation step length of 0.1s and activate the GUI. \n",
"`SumoParams` specifies simulation-specific variables. These variables include the length of any simulation step and whether to render the GUI when running the experiment. For this example, we consider a simulation step length of 0.1s and deactivate the GUI. \n",
"\n",
"**Note** For training purposes, it is highly recommanded to deactivate the GUI in order to avoid global slow down. In such case, one just needs to specify the following: `render=False`"
]
Expand All @@ -181,7 +181,7 @@
"source": [
"from flow.core.params import SumoParams\n",
"\n",
"sumo_params = SumoParams(sim_step=0.1, render=False)"
"sim_params = SumoParams(sim_step=0.1, render=False)"
]
},
{
Expand Down Expand Up @@ -287,8 +287,8 @@
" network=network_name,\n",
" # simulator that is used by the experiment\n",
" simulator='traci',\n",
" # sumo-related parameters (see flow.core.params.SumoParams)\n",
" sim=sumo_params,\n",
" # simulation-related parameters\n",
" sim=sim_params,\n",
" # environment related parameters (see flow.core.params.EnvParams)\n",
" env=env_params,\n",
" # network-related parameters (see flow.core.params.NetParams and\n",
Expand Down
2 changes: 1 addition & 1 deletion tutorials/tutorial04_visualize.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"source": [
"from flow.core.params import SumoParams\n",
"\n",
"sumo_params = SumoParams(sim_step=0.1, render=True, emission_path='data')"
"sim_params = SumoParams(sim_step=0.1, render=True, emission_path='data')"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions tutorials/tutorial05_networks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@
" routing_controller=(ContinuousRouter, {}),\n",
" num_vehicles=22)\n",
"\n",
"sumo_params = SumoParams(sim_step=0.1, render=True)\n",
"sim_params = SumoParams(sim_step=0.1, render=True)\n",
"\n",
"initial_config = InitialConfig(bunching=40)"
]
Expand Down Expand Up @@ -454,7 +454,7 @@
")\n",
"\n",
"# AccelEnv allows us to test any newly generated network quickly\n",
"env = AccelEnv(env_params, sumo_params, network)\n",
"env = AccelEnv(env_params, sim_params, network)\n",
"\n",
"flow_params = dict(\n",
" exp_tag='test_network',\n",
Expand Down
8 changes: 4 additions & 4 deletions tutorials/tutorial08_environments.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
"from flow.core.params import VehicleParams\n",
"from flow.networks.ring import RingNetwork, ADDITIONAL_NET_PARAMS\n",
"\n",
"sumo_params = SumoParams(sim_step=0.1, render=True)\n",
"sim_params = SumoParams(sim_step=0.1, render=True)\n",
"\n",
"vehicles = VehicleParams()\n",
"vehicles.add(veh_id=\"idm\",\n",
Expand All @@ -300,7 +300,7 @@
"#############################################################\n",
"######## using my new environment for the simulation ########\n",
"#############################################################\n",
"env = myEnv(env_params, sumo_params, network)\n",
"env = myEnv(env_params, sim_params, network)\n",
"#############################################################\n",
"\n",
"flow_params = dict(\n",
Expand Down Expand Up @@ -374,7 +374,7 @@
"\n",
"\n",
"def run_task(*_):\n",
" sumo_params = SumoParams(sim_step=0.1, render=False)\n",
" sim_params = SumoParams(sim_step=0.1, render=False)\n",
"\n",
" vehicles = VehicleParams()\n",
" vehicles.add(veh_id=\"rl\",\n",
Expand Down Expand Up @@ -404,7 +404,7 @@
" #######################################################\n",
" env_name = \"myEnv\"\n",
" #######################################################\n",
" pass_params = (env_name, sumo_params, vehicles, env_params, net_params,\n",
" pass_params = (env_name, sim_params, vehicles, env_params, net_params,\n",
" initial_config, network)\n",
"\n",
" env = GymEnv(env_name, record_video=False, register_params=pass_params)\n",
Expand Down
4 changes: 2 additions & 2 deletions tutorials/tutorial11_inflows.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"from flow.envs.ring.accel import AccelEnv, ADDITIONAL_ENV_PARAMS\n",
"from flow.core.experiment import Experiment\n",
"\n",
"sumo_params = SumoParams(render=True,\n",
"sim_params = SumoParams(render=True,\n",
" sim_step=0.2)\n",
"\n",
"env_params = EnvParams(additional_params=ADDITIONAL_ENV_PARAMS)\n",
Expand All @@ -233,7 +233,7 @@
" net_params=net_params,\n",
" initial_config=initial_config)\n",
"\n",
"env = AccelEnv(env_params, sumo_params, network)\n",
"env = AccelEnv(env_params, sim_params, network)\n",
"\n",
"flow_params = dict(\n",
" exp_tag='merge-example',\n",
Expand Down

0 comments on commit 824c613

Please sign in to comment.