fix: never pass an empty feed-in forecast to the optimizer#98
Open
bvweerd wants to merge 1 commit into
Open
Conversation
When the feed-in sensor publishes at a finer interval than the grid price sensor and has less than one full grid-price period of data left (e.g. 30 min of 15-min feed-in entries against hourly grid prices), resample_forecast() returns an empty list. The empty list bypassed the padding logic and reached the optimizer, where every step fell back to the grid buy price and the terminal value of stored energy became 0 — exactly the fallback the feed-in invariant forbids, making PV arbitrage look unprofitable for that run. Fall back to the fixed feed-in price when resampling yields an empty series, the same fallback used for an unavailable feed-in sensor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XWQRQEJXUxbp2CGFS18U9i
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When the feed-in sensor publishes at a finer interval than the grid price sensor and has less than one full grid-price period of data left (e.g. two remaining 15-min feed-in entries against hourly grid prices),
resample_forecast()computestarget_steps = 30 // 60 = 0and returns[].That empty list slipped through: the padding block is guarded by
if resampled_feed_in and len(...) < n_steps, so an empty series was neither padded nor replaced, and reachedoptimize_battery_scheduleas[]. Inside the DP an empty (non-None) feed-in list means every step falls back to the grid buy price andterminal_pricebecomes 0 — precisely the fallback the project's feed-in invariant forbids (CLAUDE.md: "Never return None to optimizer — falls back toCONF_FIXED_FEED_IN_PRICE"), making PV arbitrage look unprofitable and dumping the terminal value of stored energy for that run.Fix: when resampling yields an empty series, fall back to
[fixed_feed_in_price] * len(resampled_prices)— the same fallback already used for an unavailable feed-in sensor.Type of change
fix:Bug fix (patch version bump)feat:New feature (minor version bump)feat!:/BREAKING CHANGE:Breaking change (major version bump)chore:/docs:/ci:Maintenance or documentation (no version bump)Checklist
feat:,fix:,chore:, etc.)devbranch (notmain, unless this is a hotfix)Screenshots / Logs (optional)
New test:
test_feed_in_forecast_empty_after_resample_uses_fixed_price.🤖 Generated with Claude Code
https://claude.ai/code/session_01XWQRQEJXUxbp2CGFS18U9i
Generated by Claude Code