Skip to content

Commit

Permalink
Revert the changes. Going to add this as a new PR
Browse files Browse the repository at this point in the history
  • Loading branch information
ashkan-software committed Jul 22, 2019
1 parent e45940e commit 3b36cc1
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions flow/core/rewards.py
Expand Up @@ -158,37 +158,6 @@ def min_delay_unscaled(env):
cost = time_step * sum((v_top - vel) / v_top)
return cost / (env.k.vehicle.num_vehicles + eps)

def avg_delay_specified_vehicles(env, veh_ids):
"""Calculates the average delay for a set of vehicles in the system
Parameters
----------
env: flow.envs.Env
the environment variable, which contains information on the current
state of the system.
veh_ids: a list of the ids of the vehicles, for which we are calculating
average delay
Returns
-------
float
average delay
"""

vel = np.array(env.k.vehicle.get_speed(veh_ids))

vel[vel < -1e-6] = 0

sum = 0
for edge in env.k.scenario.get_edge_list():
for veh_id in env.k.vehicle.get_ids_by_edge(edge):
v_top = env.k.scenario.speed_limit(edge)
sum += (v_top - env.k.vehicle.get_speed(veh_id)) / v_top
time_step = env.sim_step
try:
cost = time_step * sum
return cost / len(veh_ids)
except ZeroDivisionError:
return 0


def penalize_standstill(env, gain=1):
"""A reward function that penalizes vehicle standstill
Expand Down

0 comments on commit 3b36cc1

Please sign in to comment.