Skip to content

Commit

Permalink
Switch order of charging fallback policy to prioritize approaching SO…
Browse files Browse the repository at this point in the history
…C targets above staying within SOC constraints (#270)

Signed-off-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x committed Dec 10, 2021
1 parent 38c3726 commit 50e1c2d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions flexmeasures/data/models/planning/utils.py
Expand Up @@ -140,18 +140,6 @@ def fallback_charging_policy(
charge_schedule = initialize_series(charge_power, start, end, resolution)
discharge_schedule = initialize_series(discharge_power, start, end, resolution)
idle_schedule = initialize_series(0, start, end, resolution)
if (
device_constraints["max"].first_valid_index() is not None
and device_constraints["max"][device_constraints["max"].first_valid_index()] < 0
):
# start discharging to try and bring back the soc below the next max constraint
return discharge_schedule
if (
device_constraints["min"].first_valid_index() is not None
and device_constraints["min"][device_constraints["min"].first_valid_index()] > 0
):
# start charging to try and bring back the soc above the next min constraint
return charge_schedule
if (
device_constraints["equals"].first_valid_index() is not None
and device_constraints["equals"][
Expand All @@ -170,5 +158,17 @@ def fallback_charging_policy(
):
# start discharging to get as close as possible to the next target
return discharge_schedule
if (
device_constraints["max"].first_valid_index() is not None
and device_constraints["max"][device_constraints["max"].first_valid_index()] < 0
):
# start discharging to try and bring back the soc below the next max constraint
return discharge_schedule
if (
device_constraints["min"].first_valid_index() is not None
and device_constraints["min"][device_constraints["min"].first_valid_index()] > 0
):
# start charging to try and bring back the soc above the next min constraint
return charge_schedule
# stand idle
return idle_schedule

0 comments on commit 50e1c2d

Please sign in to comment.