Repository navigation
Restore the soc-min default of 0 for storage - #2884
Conversation
Since #2221 (v1.0.0), a storage flex-model without soc-min had no lower bound, so a battery could be scheduled into a negative state of charge. The default now lives in default_soc_min(), which issue #2847 can make unit-aware: 0 is a physical floor for energy stocks, but not for fill levels in, say, degrees Celsius. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc Signed-off-by: F.N. Claessen <claessen@seita.nl>
The toy account's battery set soc-max but no soc-min, so scheduling it without a soc-min in the request let it discharge into a negative state of charge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc Signed-off-by: F.N. Claessen <claessen@seita.nl>
📖 82 files changed · 5 added · 77 modified
Preview · build overview · flexmeasures · built Dec. 2, 2026, 2:05 p.m. UTC |
The fix is to be backported to the 1.0.x branch, so list it under the oldest release that will ship it, as was done for v1.0.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc Signed-off-by: F.N. Claessen <claessen@seita.nl>
Flix6x
left a comment
There was a problem hiding this comment.
A self-review of #2884, at its head 34adcfe and merged into today's main (4bdcf55; a local trial merge, where only the API changelog conflicts).
The fix holds on main: the test battery, scheduled from 2.5 MWh with soc-max 4.5 MWh and no soc-min anywhere, goes down to −45.5 MWh on main, and stops at 0 with #2884. An explicit soc-min (0.5 MWh) is unchanged. The new test fails on main and passes with #2884 merged; the planning tests, the scheduling schema, the schedule API and the toy-account CLI tests pass there too (821 passed, 3 xfailed).
For the changelog: flex-models without a soc-min now behave like an explicit soc-min: 0 again. That includes a soc-usage beyond what the stock holds: it used to run into a negative state of charge, and is now left out at the soc-delta-breach-price (as #2920 already does for an explicit soc-min; 2.3 MWh of 4.8 MWh in the probe), or, with relax-soc-constraints off, makes the schedule infeasible, as before v1.0.0.
Before merging, we'll push these to the branch ourselves:
- The conflict in
documentation/api/change_log.rst: the entry is under v3.0-35 (released November 11); it moves to v3.0-38. - The changelog entry opens a new "v1.0.3 | November xx" section, but v1.0.3 was released on November 23 without this fix (it would merge silently as a second v1.0.3 section). It moves to v1.0.4, the milestone, with the line on the
soc-usagebehaviour above. - The OpenAPI
versionbump to 1.1.1 is moot now:mainalready has it, so we takemain's side. - The
soc-mindescription (SOC_MINinflexmeasures/data/schemas/scheduling/metadata.py, and the OpenAPI spec) will say the default applies to energy units only, so it doesn't over-promise once non-energy SoC units arrive (#2847): "If omitted, it defaults to 0 for storage whose state of charge is known and measured in energy units (kWh, MWh), since an energy stock cannot hold less than nothing."
For the backport: the code changes apply cleanly to 1.0.x and 1.1.x; only the changelogs and the OpenAPI spec conflict there. 1.1.x has #2920; 1.0.x doesn't, so on 1.0.4 such a soc-usage makes the schedule fail as infeasible rather than run into a negative state of charge. That is the pre-v1.0.0 behaviour, and the right one physically, but worth a line in the 1.0.4 changelog.
…ero-followups # Conflicts: # documentation/api/change_log.rst
…tion to v1.0.4 v1.0.3 was released on November 23 without this fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… beyond the stock Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
So the description does not over-promise once a state of charge may come in other units (#2847). The OpenAPI spec is regenerated, keeping its version at 1.1.1, as on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
As announced in the review, we pushed the follow-ups to this branch (merged with
Left for the 1.0.x backport (it does not exist yet): its v1.0.4 entry should keep only the infeasible half of item 3, since 1.0.x has no #2920 ( Planning tests and |
… of charge once Signed-off-by: F.N. Claessen <claessen@seita.nl>
|
Follow-ups of the re-check, done after the review:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
* Restore the soc-min default of 0 for storage (#2884) * fix: default soc-min to 0 for storage whose state of charge is known Since #2221 (v1.0.0), a storage flex-model without soc-min had no lower bound, so a battery could be scheduled into a negative state of charge. The default now lives in default_soc_min(), which issue #2847 can make unit-aware: 0 is a physical floor for energy stocks, but not for fill levels in, say, degrees Celsius. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc Signed-off-by: F.N. Claessen <claessen@seita.nl> * fix: give the toy battery a soc-min of 0 kWh The toy account's battery set soc-max but no soc-min, so scheduling it without a soc-min in the request let it discharge into a negative state of charge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc Signed-off-by: F.N. Claessen <claessen@seita.nl> * docs: changelog entries for PR #2884 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc Signed-off-by: F.N. Claessen <claessen@seita.nl> * docs: move the PR #2884 changelog entry to a new v1.0.3 section The fix is to be backported to the 1.0.x branch, so list it under the oldest release that will ship it, as was done for v1.0.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc Signed-off-by: F.N. Claessen <claessen@seita.nl> * docs: move the PR #2884 changelog entry from an unreleased v1.0.3 section to v1.0.4 v1.0.3 was released on November 23 without this fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: say in the PR #2884 changelog entry what happens to a soc-usage beyond the stock Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: say the soc-min default of 0 applies to energy units only So the description does not over-promise once a state of charge may come in other units (#2847). The OpenAPI spec is regenerated, keeping its version at 1.1.1, as on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: say the PR #2884 changelog entry's point about a negative state of charge once Signed-off-by: F.N. Claessen <claessen@seita.nl> --------- Signed-off-by: F.N. Claessen <claessen@seita.nl> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2429a0d) Signed-off-by: F.N. Claessen <claessen@seita.nl> * docs: say "as before v1.0.0" once in the PR #2884 changelog entry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl> --------- Signed-off-by: F.N. Claessen <claessen@seita.nl> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ach-price, v1.1.4 does (#2954) The v1.0.4 entry now reads as on the 1.0.x branch (#2952), where a soc-usage beyond the stock makes the schedule infeasible. The main wording moves to a new v1.1.4 section, for the 1.1.x backport (#2951), which has #2920. Signed-off-by: F.N. Claessen <claessen@seita.nl> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix: default soc-min to 0 for storage whose state of charge is known Since #2221 (v1.0.0), a storage flex-model without soc-min had no lower bound, so a battery could be scheduled into a negative state of charge. The default now lives in default_soc_min(), which issue #2847 can make unit-aware: 0 is a physical floor for energy stocks, but not for fill levels in, say, degrees Celsius. Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc * fix: give the toy battery a soc-min of 0 kWh The toy account's battery set soc-max but no soc-min, so scheduling it without a soc-min in the request let it discharge into a negative state of charge. Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc * docs: changelog entries for PR #2884 Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc * docs: move the PR #2884 changelog entry to a new v1.0.3 section The fix is to be backported to the 1.0.x branch, so list it under the oldest release that will ship it, as was done for v1.0.2. Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc * docs: move the PR #2884 changelog entry from an unreleased v1.0.3 section to v1.0.4 v1.0.3 was released on November 23 without this fix. * docs: say in the PR #2884 changelog entry what happens to a soc-usage beyond the stock * docs: say the soc-min default of 0 applies to energy units only So the description does not over-promise once a state of charge may come in other units (#2847). The OpenAPI spec is regenerated, keeping its version at 1.1.1, as on main. * docs: say the PR #2884 changelog entry's point about a negative state of charge once --------- (cherry picked from commit 2429a0d) Signed-off-by: F.N. Claessen <claessen@seita.nl> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Description
Until v1.0.0, a storage flex-model without
soc-mingot a lower bound of 0 ("can't drain the storage by more than it contains").#2221 removed
ensure_soc_min_max()to makesoc-maxoptional, and thesoc-mindefault went with it.Since then, a battery scheduled without
soc-minhas no lower bound and can be scheduled into a negative state of charge.A community user hit this with the toy battery:
flexmeasures add toy-accountgives itsoc-max: 450 kWhbut nosoc-min, so a schedule request withoutsoc-mindischarged at the full 500 kW for the whole window.soc-minto 0 for any stock whose state of charge is known, in both single- and multi-device flex-models.The default lives in the new
default_soc_min()in the scheduler, soadd_storage_constraints()stays unit-neutral and Fix: soc min does not need to be mandatory #2221's tests of it still hold."soc-min": "0 kWh"to the toy battery's flex-model, so the tutorial doesn't depend on the default.soc-minfield description (and so the OpenAPI spec).soc-maxstays optional.Why a function, and not a schema default
#2847 plans to allow arbitrary fill-level units, such as degrees Celsius for a freezer.
0 is a physical floor for energy and percentage stocks, but not for temperatures, so
default_soc_min()is where that issue can returnNonefor non-energy units.For now all stocks are converted to MWh, so it always returns 0.
How to test
pytest flexmeasures/data/models/planning/tests/test_solver.py -k defaults_soc_min_to_zeroThe new test schedules day 2 (8 expensive hours first) with no
soc-minin either the request or the asset's flex-model, and checks the state of charge bottoms out at 0.It fails on main: the state of charge goes negative.
The planning, schema, CLI and schedule-API suites pass locally (1147 passed, 4 xfailed).
Further notes
versionfrom 1.1.0 to 1.1.1 (its next-version guess fromgit describe, which givesv1.1.0-20). Drop that line if 1.2.0 is preferred.🤖 Generated with Claude Code
https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc