Skip to content

Commit

Permalink
add standardization shaper
Browse files Browse the repository at this point in the history
  • Loading branch information
ahalev committed Apr 6, 2024
1 parent 50bf067 commit 8cd007d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/pymgrid/microgrid/reward_shaping/standardization_shaper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pymgrid.microgrid.reward_shaping.base import BaseRewardShaper
from pymgrid.utils.running_mean_std import RunningMeanStd


class StandardizationShaper(BaseRewardShaper):
yaml_tag = u'StandardizationShaper'

def __init__(self):
self.reward_running_mean_std = RunningMeanStd()

def __call__(self, original_reward, step_info, cost_info):
self.reward_running_mean_std.update(original_reward)
return (original_reward - self.reward_running_mean_std.mean) / self.reward_running_mean_std.var

0 comments on commit 8cd007d

Please sign in to comment.