Repository navigation
fix(mpc): plan an out-of-band battery from the band edge for every planner - #2045
Merged
Merged
Conversation
…anner Core clamped a start below soc_min (or above soc_max) onto the band edge only when Core DP was the planner. Energyplan got the real start. On a v0.164.0-beta.1 site a Pixii settled at 0.097 under a 0.10 floor, with a car in the plan; Energyplan's fleet MILP published an idle battery for 28 h although cheap night power made charging pay. A replay of that request with the start on the floor charges 17.8 kWh at night, on both bundled workers (847936a and 7ea7d998). And when the worker failed in that state, Core kept the previous plan, since its DP could not model the out-of-band start. Replan now clamps for every planner and records the real reading in InitialSoCUnclamped, as it did for Core DP. The recovery-only branches go: shadows, baselines and the Core fallback run as for any start. A site Core DP cannot model, such as two storages, still keeps its previous plan when the worker fails. Refs #2043. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Problem
A support file from v0.164.0-beta.1 (#2043) shows a 20 kWh battery that Energyplan kept idle for a whole 115-slot horizon, 28 h. Night power cost about 104–133 öre/kWh and the next day 243–282 öre/kWh, so charging at night clearly paid. The battery had settled at SoC 0.097, under its 0.10 floor, and a car was in the plan.
Core clamps such a start onto the band edge, but only when Core DP is the planner (
s.Optimizer == nil). Energyplan got the real start, and its fleet MILP never beat the idle seed.A local replay of the exact request the box sent ran the shipped Linux worker in a container:
The results are the same on 847936a (in the beta) and on 7ea7d998 (on master). A longer budget (60 s) does not help. The same thing happened on the site on the night of 11–12 Nov. The replay data stays local.
There is a second gap. When the worker failed in that state, Core kept the previous plan, because its DP "cannot model operating-bound recovery". A battery that dips under its floor should never stop planning.
Change
Replanclamps an out-of-band start onto the band edge for every planner, through the existingclampParamsIntoOperatingBand. It records the real reading inInitialSoCUnclamped.clampParamsIntoOperatingBandexplains why clamping beats refusing.Tests
TestReplanGivesTheWorkerAnInBandStartcovers three starts: 0.097, 0.01, and a fleet member at 0.05.TestReplanFallsBackToCoreWhenTheWorkerFailsBelowTheFloorcovers 0.097 and 0.01, with a failing worker.&& s.Optimizer == nil). An independent reviewer checked this too.TestNativeEnergyplanPlansFromTheBandEdge(was…RecoveryKeepsRealBatteryEnergy)TestNativeEnergyplanEVRecoveryFallbackFaultsTestImportCeilingWorkerPlanOverrunsAnHour: a battery below its floor now gets Core's plan inside the import hour, not the worker's overrun with a warningTestNativeImportCeilingBelowTheFloormake verifypassed.go test ./internal/mpc/passed.go test -race ./internal/mpc/ -run 'Replan|Recovery|Band|ImportCeiling'passed, per the reviewer.Native*test passed against the bundled arm64 worker, run in a local Linux container (FTW_NATIVE_SOLVERwrapper).Refs #2043.
🤖 Generated with Claude Code