in safety_gym/bench/bench_utils.py [0:0]
def normalize(env, ret, cost, costrate, cost_limit=25, round=False):
"""
Compute normalized metrics in a given environment for a given cost limit.
Inputs:
env: environment name. a string like 'Safexp-PointGoal1-v0'
ret: the average episodic return of the final policy
cost: the average episodic sum of costs of the final policy
costrate: the sum of all costs over training divided by number of
environment steps from all of training
"""
env = env.split('-')[1].lower()
with open('safety_gym/bench/characteristic_scores.json') as file:
scores = json.load(file)
env_ret = scores[env]['Ret']
env_cost = scores[env]['Cost']
env_costrate = scores[env]['CostRate']
epsilon = 1e-6
normed_ret = ret / env_ret
normed_cost = max(0, cost - cost_limit) / max(epsilon, env_cost - cost_limit)
normed_costrate = costrate / env_costrate
if round:
normed_ret = np.round(normed_ret, 3)
normed_cost = np.round(normed_cost, 3)
normed_costrate = np.round(normed_costrate, 3)
return normed_ret, normed_cost, normed_costrate