Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore old metric keep method #1736

Merged
merged 3 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import asyncio
import json

THIS_VERSION = "v8.8.7"
THIS_VERSION = "v8.8.8"

# fmt: off
PREDBAT_FILES = ["predbat.py", "config.py", "prediction.py", "gecloud.py","utils.py", "inverter.py", "ha.py", "download.py", "unit_test.py", "web.py", "predheat.py", "futurerate.py", "octopus.py", "solcast.py","execute.py", "plan.py", "fetch.py", "output.py", "userinterface.py"]
Expand Down
8 changes: 4 additions & 4 deletions apps/predbat/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,12 +808,12 @@ def run_prediction(self, charge_limit, charge_window, export_window, export_limi
diff = get_diff(battery_draw, pv_dc, pv_ac, load_yesterday, inverter_loss)

# Metric keep - pretend the battery is empty and you have to import instead of using the battery
if soc < self.best_soc_keep and battery_draw > 0:
if soc < self.best_soc_keep:
# Apply keep as a percentage of the time in the future so it gets stronger over an 4 hour period
# Weight to 50% chance of the scenario
# keep_diff = max(get_diff(0, 0, pv_now, load_yesterday, inverter_loss), battery_draw)
# if keep_diff > 0:
metric_keep += rate_import[minute_absolute] * battery_draw * keep_minute_scaling
keep_diff = max(get_diff(0, 0, pv_now, load_yesterday, inverter_loss), battery_draw)
if keep_diff > 0:
metric_keep += rate_import[minute_absolute] * keep_diff * keep_minute_scaling
if diff > 0:
# Import
# All imports must go to home (no inverter loss) or to the battery (inverter loss accounted before above)
Expand Down
16 changes: 8 additions & 8 deletions apps/predbat/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,8 @@ def run_execute_test(
def run_single_debug(my_predbat, debug_file):
print("**** Running debug test {} ****\n".format(debug_file))
re_do_rates = True
reset_load_model = True
load_override = 0.2
reset_load_model = False
load_override = 1.0

reset_inverter(my_predbat)
my_predbat.read_debug_yaml(debug_file)
Expand All @@ -907,10 +907,10 @@ def run_single_debug(my_predbat, debug_file):
my_predbat.fetch_config_options()

# Force off combine export XXX:
print("Combined export slots {}".format(my_predbat.combine_export_slots))
print("Combined export slots {} min_improvement_export {}".format(my_predbat.combine_export_slots, my_predbat.metric_min_improvement_export))
# my_predbat.combine_export_slots = False
# my_predbat.best_soc_keep = 1.0
my_predbat.metric_min_improvement_export = 5
# my_predbat.metric_min_improvement_export = 5

if re_do_rates:
# Set rate thresholds
Expand Down Expand Up @@ -3392,7 +3392,7 @@ def run_model_tests(my_predbat):
with_battery=True,
discharge=0,
battery_soc=10,
assert_keep=1 * import_rate * KEEP_SCALE,
assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE,
keep=1.0,
)
failed |= simple_scenario(
Expand All @@ -3405,7 +3405,7 @@ def run_model_tests(my_predbat):
with_battery=True,
discharge=0,
battery_soc=10,
assert_keep=1 * import_rate * KEEP_SCALE,
assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE,
keep=1.0,
save="test",
)
Expand All @@ -3419,7 +3419,7 @@ def run_model_tests(my_predbat):
with_battery=True,
discharge=0,
battery_soc=10,
assert_keep=1 * import_rate * KEEP_SCALE,
assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE,
keep=1.0,
save="none",
)
Expand Down Expand Up @@ -4064,7 +4064,7 @@ def run_model_tests(my_predbat):
battery_size=10,
keep=1.0,
assert_final_iboost=0,
assert_keep=import_rate * 1 * KEEP_SCALE,
assert_keep=import_rate * 14 * 0.5 * KEEP_SCALE + import_rate * 1 * KEEP_SCALE,
)

# Alternating high/low rates
Expand Down
Loading