Skip to content

Commit

Permalink
refactor: move statements to where they matter
Browse files Browse the repository at this point in the history
Signed-off-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x committed May 25, 2023
1 parent 97da1c9 commit fa49442
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions flexmeasures/data/models/planning/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,13 +694,10 @@ def validate_storage_constraints(
min_extended[storage_constraints.index[0] - resolution] = min_soc
min_extended = min_extended.sort_index()

# 3) min(t) - max(t-1) <= `derivative max`(t)
delta_min_max = min_extended - max_extended.shift(1)
delta_min_max = delta_min_max[1:]

delta_max_min = max_extended - min_extended.shift(1)
delta_max_min = delta_max_min[1:]

# 3) min(t) - max(t-1) <= `derivative max`(t)
condition3 = delta_min_max <= storage_constraints["derivative max"] * factor_w_wh
mask = ~condition3
time_condition_fails = storage_constraints.index[mask]
Expand All @@ -719,6 +716,9 @@ def validate_storage_constraints(
)

# 4) max(t) - min(t-1) >= `derivative min`(t)
delta_max_min = max_extended - min_extended.shift(1)
delta_max_min = delta_max_min[1:]

condition4 = delta_max_min >= storage_constraints["derivative min"] * factor_w_wh
mask = ~condition4
time_condition_fails = storage_constraints.index[mask]
Expand Down

0 comments on commit fa49442

Please sign in to comment.