Skip to content

Commit

Permalink
Merge pull request berkeleyflow#25 from berkeleyflow/rllib_tutorial
Browse files Browse the repository at this point in the history
Draft RLlib tutorial
  • Loading branch information
AboudyKreidieh authored Jun 16, 2018
2 parents 3ef12fc + b987d3a commit a351c4d
Show file tree
Hide file tree
Showing 5 changed files with 614 additions and 60 deletions.
2 changes: 1 addition & 1 deletion flow/scenarios/base_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, name, generator_class, vehicles, net_params,
if Serializable is not object:
Serializable.quick_init(self, locals())

self.orig_name = name
self.orig_name = name # To avoid repeated concatenation upon reset
self.name = name + str(time.time())

self.generator_class = generator_class
Expand Down
2 changes: 1 addition & 1 deletion flow/utils/rllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def make_create_env(params, version=0, sumo_binary=None):
configuration files
- sumo: sumo-related parameters (see flow.core.params.SumoParams)
- env: environment related parameters (see flow.core.params.EnvParams)
- net: #network-related parameters (see flow.core.params.NetParams and
- 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.vehicles.Vehicles)
Expand Down
68 changes: 20 additions & 48 deletions tutorials/exercises/exercise01_sumo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.scenarios.loop.loop_scenario import LoopScenario"
Expand All @@ -49,9 +47,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"name = \"ring_example\""
Expand All @@ -68,9 +64,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.scenarios.loop.gen import CircleGenerator"
Expand All @@ -89,9 +83,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.core.vehicles import Vehicles\n",
Expand All @@ -111,9 +103,7 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.controllers.car_following_models import IDMController"
Expand All @@ -129,9 +119,7 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.controllers.routing_controllers import ContinuousRouter"
Expand All @@ -147,9 +135,7 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"vehicles.add(\"human\",\n",
Expand All @@ -176,7 +162,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"{'resolution': 40, 'length': 230, 'lanes': 1, 'speed_limit': 30}\n"
"{'length': 230, 'speed_limit': 30, 'resolution': 40, 'lanes': 1}\n"
]
}
],
Expand Down Expand Up @@ -204,9 +190,7 @@
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.core.params import NetParams\n",
Expand All @@ -226,9 +210,7 @@
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.core.params import InitialConfig\n",
Expand All @@ -248,9 +230,7 @@
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.core.traffic_lights import TrafficLights\n",
Expand All @@ -270,12 +250,10 @@
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.envs.loop_accel import AccelEnv"
"from flow.envs.loop.loop_accel import AccelEnv"
]
},
{
Expand All @@ -296,9 +274,7 @@
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.core.params import SumoParams\n",
Expand All @@ -324,12 +300,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"{'target_velocity': 10}\n"
"{'target_velocity': 10, 'max_decel': 3, 'max_accel': 3}\n"
]
}
],
"source": [
"from flow.envs.loop_accel import ADDITIONAL_ENV_PARAMS\n",
"from flow.envs.loop.loop_accel import ADDITIONAL_ENV_PARAMS\n",
"\n",
"print(ADDITIONAL_ENV_PARAMS)"
]
Expand All @@ -344,9 +320,7 @@
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.core.params import EnvParams\n",
Expand All @@ -365,9 +339,7 @@
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from flow.core.experiment import SumoExperiment"
Expand All @@ -391,8 +363,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Round 0, return: 36079.41102186679\n",
"Average Return 36079.41102186679\n"
"Round 0, return: 841.1536320457072\n",
"Average Return 841.1536320457072\n"
]
}
],
Expand Down
Loading

0 comments on commit a351c4d

Please sign in to comment.