fix(mpc): give Energyplan 1.5 s when a car is plugged in - #1515
Merged
Merged
Conversation
On the home Pi 4, two plans with the car came back 11% above the proven optimum at Core's 0.5 s budget. On the same requests the planner reaches the optimum with about 0.6-0.7 s of Pi time, so 0.5 s sat just below the point where it can improve its first plan. Requests with an active loadpoint now get 1.5 s; battery-only requests keep 0.5 s, and fleet, demand-charge and curtailment requests keep 5 s. The remaining time of the first slot still caps every budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Codex Review SummaryThis 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
Core gives the Energyplan planner 0.5 s unless the model is large, demand charges apply or PV curtailment is active. Since #1440 most homes with one car fall under 0.5 s. On the home Pi 4 that sits just below the point where the planner can improve on its first plan for the car.
Two plans with the car on the home box (v0.139.3-dev test build with Energyplan 0.5.0, 3 Oct, 112-113 slots) came back about 11% above the proven HiGHS optimum: 6 800.21 against 6 115.16 öre and 6 770.17 against 6 098.44 öre. Replaying the same requests on a laptop, the planner reaches the optimum at about 30-35 ms there, which is about 0.6-0.7 s on the Pi. Below that it returns its first plan.
Change
Requests with an active loadpoint get 1.5 s (
energyplanEVBudget). Battery-only requests keep 0.5 s; large fleet, demand-charge and curtailment requests keep 5 s. The remaining time of the first slot still caps every budget, as before.Evidence
Known limitation
The same morning request showed a case where more time does not lower the bill: a car 253 Wh short of its target, less than one five-minute run at the lowest step. With more time the planner proves that a plan without a short run exists and then requires one, and the search found such a plan at 924 öre where the optimum is -116.89 öre. With less time it returned -110.8 öre with a 191 s short run. The charging-period preference ranks above cost by design, and v0.4.10 behaves the same. Whether a need smaller than one minimum run should count as met is an open product decision for Energyplan.
Verification
TestEVGetsLongerBudgetThanBatteryAlone(new) andTestBatterylessEVBudgetDoesNotInventStorage(updated) fail without the change and pass with it.make native-solver-testandmake verifypass.v0.139.3-dev.c33c2c4a(same change on top of chore(optimizer): bundle Energyplan 0.5.0 #1512).Checklist
go/internal/mpc/energyplan.go.patch), or the change is exempt.🤖 Generated with Claude Code