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

Benchmark fix #919

Merged
merged 3 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions flow/benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ inflow = 300 veh/hour/lane S=(915,), A=(25,), T=400.
this problem is to learn to avoid the *capacity drop* that is characteristic to
bottleneck structures in transportation networks, and maximize the total
outflow in a mixed-autonomy setting.
- `flow.benchmarks.bottleneck0` 4 lanes, inflow = 1900 veh/hour, 10% CAV
- `flow.benchmarks.bottleneck0` 4 lanes, inflow = 2500 veh/hour, 10% CAV
penetration, no vehicles are allowed to lane change, S=(141,), A=(20,), T=1000.
- `flow.benchmarks.bottleneck1` 4 lanes, inflow = 1900 veh/hour, 10% CAV
- `flow.benchmarks.bottleneck1` 4 lanes, inflow = 2500 veh/hour, 10% CAV
penetration, the human drivers follow the standard lane changing model in the
simulator, S=(141,), A=(20,), T=1000.
- `flow.benchmarks.bottleneck2` 8 lanes, inflow = 3800 veh/hour, 10% CAV
- `flow.benchmarks.bottleneck2` 8 lanes, inflow = 5000 veh/hour, 10% CAV
penetration, no vehicles are allowed to lane change, S=(281,), A=(40,), T=1000.

## Training on Custom Algorithms
Expand Down
2 changes: 1 addition & 1 deletion flow/benchmarks/bottleneck0.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
}

# flow rate
flow_rate = 2000 * SCALING
flow_rate = 2500 * SCALING

# percentage of flow coming out of each lane
inflow = InFlows()
Expand Down
2 changes: 1 addition & 1 deletion flow/benchmarks/bottleneck1.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
}

# flow rate
flow_rate = 2000 * SCALING
flow_rate = 2500 * SCALING

# percentage of flow coming out of each lane
inflow = InFlows()
Expand Down
2 changes: 1 addition & 1 deletion flow/benchmarks/bottleneck2.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
}

# flow rate
flow_rate = 2000 * SCALING
flow_rate = 2500 * SCALING

# percentage of flow coming out of each lane
inflow = InFlows()
Expand Down
4 changes: 2 additions & 2 deletions flow/benchmarks/grid0.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- **Observation Dimension**: (339, )
- **Horizon**: 400 steps
"""
from flow.envs import TrafficLightGridPOEnv
from flow.envs import TrafficLightGridBenchmarkEnv
from flow.networks import TrafficLightGridNetwork
from flow.core.params import SumoParams, EnvParams, InitialConfig, NetParams, \
InFlows, SumoCarFollowingParams
Expand Down Expand Up @@ -68,7 +68,7 @@
exp_tag="grid_0",

# name of the flow environment the experiment is running on
env_name=TrafficLightGridPOEnv,
env_name=TrafficLightGridBenchmarkEnv,

# name of the network class the experiment is running on
network=TrafficLightGridNetwork,
Expand Down
4 changes: 2 additions & 2 deletions flow/benchmarks/grid1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- **Observation Dimension**: (915, )
- **Horizon**: 400 steps
"""
from flow.envs import TrafficLightGridPOEnv
from flow.envs import TrafficLightGridBenchmarkEnv
from flow.networks import TrafficLightGridNetwork
from flow.core.params import SumoParams, EnvParams, InitialConfig, NetParams, \
InFlows, SumoCarFollowingParams
Expand Down Expand Up @@ -68,7 +68,7 @@
exp_tag="grid_1",

# name of the flow environment the experiment is running on
env_name=TrafficLightGridPOEnv,
env_name=TrafficLightGridBenchmarkEnv,

# name of the network class the experiment is running on
network=TrafficLightGridNetwork,
Expand Down
3 changes: 2 additions & 1 deletion flow/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flow.envs.bottleneck import BottleneckAccelEnv, BottleneckEnv, \
BottleneckDesiredVelocityEnv
from flow.envs.traffic_light_grid import TrafficLightGridEnv, \
TrafficLightGridPOEnv, TrafficLightGridTestEnv
TrafficLightGridPOEnv, TrafficLightGridTestEnv, TrafficLightGridBenchmarkEnv
from flow.envs.ring.lane_change_accel import LaneChangeAccelEnv, \
LaneChangeAccelPOEnv
from flow.envs.ring.accel import AccelEnv
Expand Down Expand Up @@ -33,6 +33,7 @@
'WaveAttenuationPOEnv',
'TrafficLightGridEnv',
'TrafficLightGridPOEnv',
'TrafficLightGridBenchmarkEnv',
'BottleneckDesiredVelocityEnv',
'TestEnv',
'BayBridgeEnv',
Expand Down
11 changes: 11 additions & 0 deletions flow/envs/traffic_light_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,17 @@ def additional_command(self):
[self.k.vehicle.set_observed(veh_id) for veh_id in self.observed_ids]


class TrafficLightGridBenchmarkEnv(TrafficLightGridPOEnv):
"""Class used for the benchmarks in `Benchmarks for reinforcement learning inmixed-autonomy traffic`."""

def compute_reward(self, rl_actions, **kwargs):
"""See class definition."""
if self.env_params.evaluate:
return - rewards.min_delay_unscaled(self)
else:
return rewards.desired_velocity(self)


class TrafficLightGridTestEnv(TrafficLightGridEnv):
"""
Class for use in testing.
Expand Down