Repository navigation
Conversation
This was referenced Oct 4, 2026
…loses #163) p_departure per battery gives the probability the device leaves during each step. p_a then weighs s[t] by it instead of valuing s[-1] alone, so a charge that may be cut short is worth less than one already in. Optional, absent it reproduces the previous model.
Once the departure probabilities add up to one, the charge and discharge bounds of the later steps are zero. Without it the cost neutral tie break could put free surplus into a vehicle that is gone.
andig
force-pushed
the
feat/departure-risk
branch
from
October 8, 2026 15:33
d6fac37 to
1ce985a
Compare
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 #163
A vehicle may leave before the horizon ends. Today the schedule values only
s[-1], so a charge planned for tomorrow morning counts as much as one in the car now. One optional field per battery lets the schedule weigh that risk. Absent, the model is unchanged and every stored case solves as before.API
r_departure: per-step probability mass that the device leaves during that step, sum at most 1. The remainder is the chance it stays past the horizon. A mass, not a hazard or a CDF: it is the objective weight directly, it stays well defined with varyingdt(the first evcc step is a partial slot), and session-history histograms already come as masses. Validated: no negative entries, sum ≤ 1, length matchingdt, else 400.RDeparture.Model
p_avalues the expected state of charge at departure,sum_t r_t * s[t]with the remainder ons[-1], instead ofs[-1]alone (_soc_value_weights). One objective term, no new variables or rows._present). Without that the cost neutral tie break put free surplus into a gone vehicle (p_E = 0withcharge_before_export), and the bounded steps now leave the model in presolve.p_demandpast a certain departure is a conflicting request: the demand penalty wins and fills the vehicle before it leaves, at real cost. The caller cuts the demand where it cuts the presence.Measured,
tools/bench_departure.pyon the stored casesr_departureTests:
tests/test_risk.py(expected value accounting, certain departure stops charging, validation, length mismatch), stored case029-departure-risk-charges-early.Caller side: evcc-io/evcc#34422 builds
r_departurefrom the session history as a time of day hazard per weekday and weekend slot, blended with a 24 h half-life prior, and converts it to the per-step mass. On a real instance with 248 sessions of a daytime car that gives, plugged in on a Monday at 13:00, 33 % gone by 15:00 and 92 % by Tuesday 10:00; the raw history agrees (44 % of its midday plug-ins were gone by 15:00). Forecast uncertainty is the separate #185.🤖 Generated with Claude Code