Skip to content

Commit e7ec8f0

Browse files
committed
fix a broken behaviour with hard overflow at the initial steps - they should be simulated
Signed-off-by: DONNOT Benjamin <[email protected]>
1 parent 012d310 commit e7ec8f0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

grid2op/Backend/backend.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ def next_grid_state(self,
14551455
infos = []
14561456
disconnected_during_cf = np.full(type(self).n_line, fill_value=-1, dtype=dt_int)
14571457
conv_ = self._runpf_with_diverging_exception(is_dc)
1458-
if env._no_overflow_disconnection or env._called_from_reset or conv_ is not None:
1458+
if env._no_overflow_disconnection or conv_ is not None:
14591459
return disconnected_during_cf, infos, conv_
14601460

14611461
# the environment disconnect some powerlines
@@ -1474,8 +1474,12 @@ def next_grid_state(self,
14741474
) & lines_status
14751475

14761476
# b) deals with soft overflow (disconnect them if lines still connected)
1477-
mask_inc = (lines_flows >= thermal_limits) & lines_status
1478-
mask_inc[counter_increased] = False
1477+
if env._called_from_reset:
1478+
# no soft overflow after a reset
1479+
mask_inc = np.zeros_like(thermal_limits, dtype=dt_bool)
1480+
else:
1481+
mask_inc = (lines_flows >= thermal_limits) & lines_status
1482+
mask_inc[counter_increased] = False
14791483
init_time_step_overflow[mask_inc] += 1
14801484
counter_increased[mask_inc] = True
14811485
to_disc[

0 commit comments

Comments
 (0)