Skip to content

Commit

Permalink
fix bug where pre-normalized actions are not clipped
Browse files Browse the repository at this point in the history
  • Loading branch information
ahalev committed Jun 13, 2023
1 parent 66e002a commit 4506d6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pymgrid/modules/base/base_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ def step(self, action, normalized=True):
this module provided to or absorbed from the microgrid.
"""

denormalized_action = self._action_space.denormalize(action) if normalized else action
if normalized:
denormalized_action = self._action_space.denormalize(action)
elif self._action_space.clip_vals:
denormalized_action = self._action_space.clip(action, normalized=False)
else:
denormalized_action = action

try:
denormalized_action = denormalized_action[self._energy_pos]
Expand Down
2 changes: 2 additions & 0 deletions src/pymgrid/modules/genset_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def step(self, action, normalized=True):
"""
if normalized:
denormalized = self._action_space.denormalize(action)
elif self._action_space.clip_vals:
denormalized = self._action_space.clip(action, normalized=False)
else:
denormalized = action

Expand Down

0 comments on commit 4506d6c

Please sign in to comment.