Skip to content

Commit

Permalink
update genset slack
Browse files Browse the repository at this point in the history
  • Loading branch information
ahalev committed Oct 3, 2023
1 parent 81a8522 commit 0ccd191
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/pymgrid/envs/continuous/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,19 @@ def add_slack(self, action, net_load):
if self._slack_module is None:
return action

slack_action = np.ones(self._slack_module_ref.action_space.shape)
current_prod = sum([act[-1] for act_list in action.values() for act in act_list])
remaining_net_load = net_load - current_prod

if remaining_net_load > 0:
slack_action = np.ones(self._slack_module_ref.action_space.shape)
else:
# Genset off. Ignored in all other slack modules; overwritten below.
slack_action = np.zeros(self._slack_module_ref.action_space.shape)

slack_action[-1] = remaining_net_load



module_name, module_num = self._slack_module

try:
Expand Down

0 comments on commit 0ccd191

Please sign in to comment.