Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done fix #955

Open
wants to merge 104 commits into
base: i210_dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
2c85838
Added QMIX but its hella slow right now
eugenevinitsky Mar 28, 2020
ea470a3
Speedup
eugenevinitsky Mar 28, 2020
58f357c
Replace QMIX reward w global reward
eugenevinitsky Mar 28, 2020
99f6c09
Disable RNN
eugenevinitsky Mar 28, 2020
942fe56
Add an option for a local reward that just computes speed of the AV a…
eugenevinitsky Mar 29, 2020
562bb0f
Merge branch 'i210_dev_fix' into i210_qmix
eugenevinitsky Mar 29, 2020
5c165fe
Make speed square of rewards
eugenevinitsky Apr 6, 2020
29d16bb
Add QMIX and MADDPG
eugenevinitsky Apr 7, 2020
0edfec6
Turn on RNN
eugenevinitsky Apr 7, 2020
9d6344f
Increase inflow in i210 subnetwork
eugenevinitsky Apr 7, 2020
f3e7ce8
Add option to reroute exiting vehicles back into the network
eugenevinitsky Apr 30, 2020
3600357
Change the position at which vehicles are rerouted so tall the vehicl…
eugenevinitsky Apr 30, 2020
fe05dcd
Add single agent case
eugenevinitsky May 3, 2020
72f8459
Address comments
eugenevinitsky May 8, 2020
304fcfc
Merge branch 'i210_dev' of github.com:flow-project/flow into rerouting
eugenevinitsky May 8, 2020
b80d441
Pydoc style
eugenevinitsky May 8, 2020
a93bf29
Merge branch 'i210_qmix' into flow_maddpg
eugenevinitsky May 9, 2020
6c1ef8a
MADDPG is running but not training
eugenevinitsky May 9, 2020
73fe421
Minor
eugenevinitsky May 10, 2020
ff2ca54
But what if we just catch and ignore the exception
eugenevinitsky May 10, 2020
7d0dafa
Merge branch 'master' of github.com:flow-project/flow into flow_maddpg
eugenevinitsky May 10, 2020
adfde0e
Minor change to AMI to get sUMO version 1.1.0
eugenevinitsky May 10, 2020
0556175
Add MPG reward
eugenevinitsky May 10, 2020
1861051
Commit for local reward tests
eugenevinitsky May 10, 2020
2cd6329
Add a centralized critic
eugenevinitsky May 11, 2020
9a2a4a6
Add curricula over speed and headway
eugenevinitsky May 11, 2020
f1abcfe
add timing, remove adaptive KL from PPO
eugenevinitsky May 11, 2020
f9e573d
Minor fixes to KL
eugenevinitsky May 11, 2020
5605ec2
switch back to old AMI for testing purposes
eugenevinitsky May 11, 2020
e5437d3
Disable custom PPO for a sec
eugenevinitsky May 11, 2020
083aaee
Minor changes to centralized PPO to upgrade it to 0.9.0
eugenevinitsky May 12, 2020
ba3210f
Visuallizer rllib fixes for centralized PPO
eugenevinitsky May 12, 2020
3f4da91
Add the ability to look back in the platoon for the MPG reward
eugenevinitsky May 12, 2020
ad694c5
Minor
eugenevinitsky May 13, 2020
429df10
Add MPG reward
eugenevinitsky May 13, 2020
da5c054
Merge branch 'i210_dev' into mpg_reward2
eugenevinitsky May 13, 2020
76707c1
Flake8
eugenevinitsky May 13, 2020
4b615b4
Minor
eugenevinitsky May 13, 2020
ac8e206
Minor
eugenevinitsky May 14, 2020
2f823d8
Flake8
eugenevinitsky May 14, 2020
91f1498
Pydoc style
eugenevinitsky May 14, 2020
c783b09
Merge branch 'mpg_reward' into mpg_reward2
eugenevinitsky May 14, 2020
44d682c
Minor
eugenevinitsky May 14, 2020
1b3172e
Fix none condition handling
eugenevinitsky May 14, 2020
01cf922
Merge branch 'mpg_reward' into mpg_reward2
eugenevinitsky May 14, 2020
6d37f15
Minor
eugenevinitsky May 14, 2020
12c0f36
Downgrade to 0.8.0
eugenevinitsky May 15, 2020
d3e45b0
Merge branch 'mpg_reward2' into flow_maddpg
eugenevinitsky May 15, 2020
de4b21d
removed sweep
AboudyKreidieh May 16, 2020
62afe9c
added updated single lane highway network config
AboudyKreidieh May 16, 2020
b52d90a
added i210 xml files with downstream edge
AboudyKreidieh May 16, 2020
c370460
added I210Router
AboudyKreidieh May 16, 2020
4525a7a
added updated i210 features
AboudyKreidieh May 16, 2020
ed8506a
minor cleanup
AboudyKreidieh May 16, 2020
6c90517
better parameters based on when congestion propagates
AboudyKreidieh May 18, 2020
be0eb25
bug fixes
AboudyKreidieh May 18, 2020
bdcfb96
bug fixes
AboudyKreidieh May 18, 2020
34acd0b
Merge branch 'i210-highway-updated' of https://github.com/flow-projec…
AboudyKreidieh May 18, 2020
2892a80
more bug fixes
AboudyKreidieh May 18, 2020
c7567b6
Fix gain on MPG
eugenevinitsky May 18, 2020
ba892f3
Merge straight road changes to multiagent straight road
eugenevinitsky May 19, 2020
20c24ed
Merge branch 'i210_dev' of github.com:flow-project/flow into ev_i210_…
eugenevinitsky May 19, 2020
c331817
Merge branch 'ev_i210_highway_updated' into flow_maddpg
eugenevinitsky May 19, 2020
00f114c
Add ability to control which lengths the control is applied on
eugenevinitsky May 20, 2020
231f04f
Move training iterations
eugenevinitsky May 21, 2020
c5a251e
Turn off mpj reward
eugenevinitsky May 21, 2020
5fb28b8
Minorg
eugenevinitsky May 21, 2020
1895c4f
MPG w/ curriculum test
eugenevinitsky May 21, 2020
7772dfe
Add stop penalty
eugenevinitsky May 21, 2020
5c79a8a
Add accel_penalty
eugenevinitsky May 22, 2020
45a8e0a
Fix to space time diagram to update to new highway network
eugenevinitsky May 24, 2020
cf579bf
Import georges I210 fixes
eugenevinitsky May 24, 2020
a43bf81
Merge branch 'ev/george_fixes' into flow_maddpg
eugenevinitsky May 24, 2020
9a5b532
Add ghost cell template with correct priorities
eugenevinitsky May 26, 2020
e6f7ef8
Update I210 to new model
eugenevinitsky May 26, 2020
2dfffc6
Add missing file
eugenevinitsky May 26, 2020
ce5710f
Merge branch 'master' of github.com:flow-project/flow into flow_maddpg
eugenevinitsky May 27, 2020
e400a38
Add handling of too many vehicles trying to reroute at once
eugenevinitsky May 27, 2020
3d95f2d
Minor
eugenevinitsky May 27, 2020
d4b76b1
Shorten curriculum iters
eugenevinitsky May 27, 2020
72eda14
Put back long curriculum
eugenevinitsky May 27, 2020
ca6a567
Remove MADDPG, QMIX
eugenevinitsky May 27, 2020
82a29fc
Merge branch 'i210_dev' into network_update
eugenevinitsky May 27, 2020
9d468d8
Switch V_DES to 5.0
eugenevinitsky May 27, 2020
f678286
Bug fix for lead_obs false
eugenevinitsky May 27, 2020
bbb16ff
Address comments
eugenevinitsky May 28, 2020
c311bf5
Merge branch 'network_update' of github.com:flow-project/flow into ne…
eugenevinitsky May 28, 2020
c69b763
Add logging of number of cars
eugenevinitsky May 28, 2020
bb37992
Remove clipping so failsafes can be applied
eugenevinitsky May 28, 2020
36e3619
add logging of accel variation
eugenevinitsky May 28, 2020
c6949bc
Fix imports
eugenevinitsky May 28, 2020
3dd87d0
Fix on-ramp code
eugenevinitsky May 28, 2020
620ddd3
Add scaling for stop and accel penalties, turn off reroute on exit
eugenevinitsky May 28, 2020
89e8ae2
Increase lookback length to 10
eugenevinitsky May 28, 2020
6333099
Exp 11 with lookback length of 5
eugenevinitsky May 28, 2020
71e175f
Set lb length to 10
eugenevinitsky May 28, 2020
659b55c
Add done conditions so vehicles that exit are done if reroute on exit…
eugenevinitsky May 28, 2020
7ce4f07
Merge branch 'network_update' into flow_maddpg
eugenevinitsky May 29, 2020
67dc121
Update lane change mode (#948)
Yasharzf Jun 11, 2020
9e3e719
Merge branch 'i210_dev' of github.com:flow-project/flow into done_fix
eugenevinitsky Jun 11, 2020
eb4b485
Flake8
eugenevinitsky Jun 11, 2020
8950d69
Pydoc fixes
eugenevinitsky Jun 11, 2020
7ce615e
Visualizer tests fixes
akashvelu Jun 11, 2020
6b9bea9
Merge branch 'akash-visualize-test-bug' of github.com:flow-project/fl…
eugenevinitsky Jun 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/exp_configs/non_rl/bay_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
lc_pushy=0.8,
lc_speed_gain=4.0,
model="LC2013",
lane_change_mode="no_lat_collide",
lane_change_mode="no_lc_safe",
# lcKeepRight=0.8
),
num_vehicles=1400)
Expand Down
2 changes: 1 addition & 1 deletion examples/exp_configs/non_rl/bay_bridge_toll.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
model="LC2013",
lcCooperative=0.2,
lcSpeedGain=15,
lane_change_mode="no_lat_collide",
lane_change_mode="no_lc_safe",
),
num_vehicles=50)

Expand Down
7 changes: 0 additions & 7 deletions examples/exp_configs/non_rl/i210_subnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@

if WANT_GHOST_CELL:
from flow.networks.i210_subnetwork_ghost_cell import I210SubNetworkGhostCell, EDGES_DISTRIBUTION

highway_start_edge = 'ghost0'
else:
from flow.networks.i210_subnetwork import I210SubNetwork, EDGES_DISTRIBUTION

highway_start_edge = "119257914"

vehicles = VehicleParams()
Expand Down Expand Up @@ -255,11 +253,6 @@ def valid_ids(env, veh_ids):
env.k.vehicle.get_speed(valid_ids(env, env.k.vehicle.get_ids())))),
"avg_outflow": lambda env: np.nan_to_num(
env.k.vehicle.get_outflow_rate(120)),
# # we multiply by 5 to account for the vehicle length and by 1000 to convert
# # into veh/km
# "avg_density": lambda env: 5 * 1000 * len(env.k.vehicle.get_ids_by_edge(
# edge_id)) / (env.k.network.edge_length(edge_id)
# * env.k.network.num_lanes(edge_id)),
"mpg": lambda env: miles_per_gallon(env, valid_ids(env, env.k.vehicle.get_ids()), gain=1.0),
"mpj": lambda env: miles_per_megajoule(env, valid_ids(env, env.k.vehicle.get_ids()), gain=1.0),
}
2 changes: 1 addition & 1 deletion examples/exp_configs/non_rl/minicity.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
speed_mode=1,
),
lane_change_params=SumoLaneChangeParams(
lane_change_mode="no_lat_collide",
lane_change_mode="no_lc_safe",
),
initial_speed=0,
num_vehicles=90)
Expand Down
17 changes: 9 additions & 8 deletions examples/exp_configs/rl/multiagent/multiagent_i210.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# WANT_DOWNSTREAM_BOUNDARY = True
ON_RAMP = False
PENETRATION_RATE = 0.10
V_DES = 7.0
V_DES = 5.0
HORIZON = 1000
WARMUP_STEPS = 600

Expand Down Expand Up @@ -64,11 +64,11 @@
"mpg_reward": False,
# whether to use the MPJ reward. Otherwise, defaults to a target velocity reward
"mpj_reward": False,
# how many vehicles to look back for the MPG reward
"look_back_length": 1,
# how many vehicles to look back for any reward
"look_back_length": 10,
# whether to reroute vehicles once they have exited
"reroute_on_exit": True,
'target_velocity': 8.0,
"reroute_on_exit": False,
'target_velocity': 5.0,
# how many AVs there can be at once (this is only for centralized critics)
"max_num_agents": 10,
# which edges we shouldn't apply control on
Expand All @@ -91,9 +91,10 @@
"speed_reward_gain": 0.5,
# penalize stopped vehicles
"penalize_stops": True,

"stop_penalty": 0.05,
# penalize accels
"penalize_accel": True
"penalize_accel": True,
"accel_penalty": 0.05
})

# CREATE VEHICLE TYPES AND INFLOWS
Expand Down Expand Up @@ -264,7 +265,7 @@
sims_per_step=3,
warmup_steps=WARMUP_STEPS,
additional_params=additional_env_params,
done_at_exit=False
done_at_exit=not additional_env_params["reroute_on_exit"]
),

# network-related parameters (see flow.core.params.NetParams and the
Expand Down
21 changes: 16 additions & 5 deletions examples/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def run_model_stablebaseline(flow_params,
"""
from stable_baselines.common.vec_env import DummyVecEnv, SubprocVecEnv
from stable_baselines import PPO2

if num_cpus == 1:
constructor = env_constructor(params=flow_params, version=0)()
# The algorithms require a vectorized environment to run
Expand Down Expand Up @@ -218,8 +217,8 @@ def setup_exps_rllib(flow_params,
config["lr"] = tune.grid_search([5e-4, 5e-5])

elif alg_run == "TD3":
agent_cls = get_agent_class(alg_run)
config = deepcopy(agent_cls._default_config)
alg_run = get_agent_class(alg_run)
config = deepcopy(alg_run._default_config)

config["num_workers"] = n_cpus
config["horizon"] = horizon
Expand All @@ -242,6 +241,9 @@ def on_episode_start(info):
episode.user_data["avg_energy"] = []
episode.user_data["avg_mpg"] = []
episode.user_data["avg_mpj"] = []
episode.user_data["num_cars"] = []
episode.user_data["avg_accel_human"] = []
episode.user_data["avg_accel_avs"] = []

def on_episode_step(info):
episode = info["episode"]
Expand Down Expand Up @@ -271,6 +273,15 @@ def on_episode_step(info):
episode.user_data["avg_speed_avs"].append(av_speed)
episode.user_data["avg_mpg"].append(miles_per_gallon(env, veh_ids, gain=1.0))
episode.user_data["avg_mpj"].append(miles_per_megajoule(env, veh_ids, gain=1.0))
episode.user_data["num_cars"].append(len(env.k.vehicle.get_ids()))
episode.user_data["avg_accel_human"].append(np.nan_to_num(np.mean(
[np.abs((env.k.vehicle.get_speed(veh_id) - env.k.vehicle.get_previous_speed(veh_id))/env.sim_step) for
veh_id in veh_ids if veh_id in env.k.vehicle.previous_speeds.keys()]
)))
episode.user_data["avg_accel_avs"].append(np.nan_to_num(np.mean(
[np.abs((env.k.vehicle.get_speed(veh_id) - env.k.vehicle.get_previous_speed(veh_id))/env.sim_step) for
veh_id in rl_ids if veh_id in env.k.vehicle.previous_speeds.keys()]
)))

def on_episode_end(info):
episode = info["episode"]
Expand All @@ -281,9 +292,10 @@ def on_episode_end(info):
episode.custom_metrics["avg_energy_per_veh"] = np.mean(episode.user_data["avg_energy"])
episode.custom_metrics["avg_mpg_per_veh"] = np.mean(episode.user_data["avg_mpg"])
episode.custom_metrics["avg_mpj_per_veh"] = np.mean(episode.user_data["avg_mpj"])
episode.custom_metrics["num_cars"] = np.mean(episode.user_data["num_cars"])

def on_train_result(info):
"""Store the mean score of the episode, and adjust the number of adversaries."""
"""Store the mean score of the episode, and increment or decrement the iteration number for curriculum."""
trainer = info["trainer"]
trainer.workers.foreach_worker(
lambda ev: ev.foreach_env(
Expand Down Expand Up @@ -468,7 +480,6 @@ def train_stable_baselines(submodule, flags):
"""Train policies using the PPO algorithm in stable-baselines."""
from stable_baselines.common.vec_env import DummyVecEnv
from stable_baselines import PPO2

flow_params = submodule.flow_params
# Path to the saved files
exp_tag = flow_params['exp_tag']
Expand Down
Loading