Repository navigation
fix(pvmodel): gate Predict at clearSky<50 to suppress night-time phantom output - #135
Merged
Merged
Conversation
…tom output Closes #133. Model.Predict evaluates the learned RLS regression with a feature vector that includes an intercept term (x[0]=1.0). At night every other feature is zero (they all multiply clearSkyW=0), so the prediction collapses to trust*Beta[0]. RLS has no physical constraint forcing Beta[0] to zero — whenever the daytime training residual is minimized with a non-zero intercept, the model projects that intercept into every night slot. Operator report (2026-04-19): planner showed −1.1 kW of PV at Mon 02:00 local, feeding that into the MPC as the night-time generation input. The Update path already gates at clearSkyW<50 (same "no sun, no signal" threshold); mirror it on the Predict side. Pure physics — PV production is bounded below by zero and requires sun above the horizon. This masks the night-time symptom. The intercept still drifts during daytime training and biases daytime predictions by a constant Beta[0] offset; that's tracked separately in #134. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
4 of 5 tasks
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.
Closes #133.
Summary
Why
Operator report (2026-04-19): planner UI showed −1.1 kW of PV at Mon 02:00 local. The feature vector's intercept term (`x[0]=1`) collapses the learned prediction to `Beta[0]` at night; RLS is free to pick a non-zero `Beta[0]` when that minimises daytime residual, and nothing stops the intercept from leaking into night slots.
Followed by the planner's `selectPlannerPVW` (`mpc/service.go:832`) — at night `forecastPVW=0 < 200 W` so it falls back unreserved to the twin's prediction — the twin's phantom 1.1 kW became the MPC's sole PV input.
Hard gate at the model layer is the right place: physics lives there, the planner trusts the model.
Follow-up
#134 addresses the underlying intercept drift. This PR suppresses the night symptom; #134 will clean up the daytime bias.
Test plan
🤖 Generated with Claude Code