Smarter commodity-context defaults and Commitment commodity field#2272
Conversation
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
…ontext Signed-off-by: F.N. Claessen <felix@seita.nl>
…formulation Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
…and map them to the respective group id Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
…chemas Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl> # Conflicts: # flexmeasures/data/models/planning/storage.py # flexmeasures/data/services/scheduling.py
…2274) Context: - PR #2072 added scheduling_result output to StorageScheduler.compute() when return_multiple=True, and added _compute_unresolved_targets. - In single-sensor mode (self.sensor is set), flex_model entries lack a "sensor" key, so _compute_unresolved_targets was skipping every device and returning empty unresolved/resolved lists. Changes: - storage.py: fall back to self.sensor in _compute_unresolved_targets when the flex_model entry has no "sensor" key (single-sensor mode) - test_commitments.py: update schedule-count assertions (+1 for the new scheduling_result entry added by PR #2072) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
…ulti-commodity-hardening
…nto feat/commodity-context-defaults # Conflicts: # documentation/changelog.rst
…t-defaults chore: update openapi-specs.json Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
nhoening
left a comment
There was a problem hiding this comment.
Very nice that we have this, another improvement to make flex-configuration have less unexplainable failures.
There might be new questions if things default to something, but at least we make it explicit, and this can also be read by LLMs which can hopefully offer useful answers.
…t-defaults # Conflicts: # .claude/agents/api-backward-compatibility-specialist.md # .claude/agents/architecture-domain-specialist.md # .claude/agents/coordinator.md # .claude/agents/data-time-semantics-specialist.md # .claude/agents/documentation-developer-experience-specialist.md # .claude/agents/performance-scalability-specialist.md # .claude/agents/test-specialist.md # .claude/agents/tooling-ci-specialist.md # .claude/agents/ui-specialist.md
- Give this PR its own concise changelog entry (pointing at the new commodity_context_defaults docs section) instead of only tagging the multi-commodity entry. - Reword the smart-defaults docs per review: prefer 'zero' over '0', clarify that zero prices refer to the usage (energy) prices, adopt the suggested 'Then, ...' phrasing in the per-case bullets, and state that giving all capacity fields is valid (directional capacities soft within the hard site-power-capacity limit). - Drop the redundant test-name prefix from a test docstring. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MLCUiSdXDqDBmg8GbYp1B
|
Interaction note with #2279: the smart defaults fill a zero 🤖 Generated with Claude Code |
…efaults After merging main's #2272 smart commodity-context defaults, a price-free commodity context (e.g. a bare {"commodity": "steam"}) gets a smart-defaulted zero consumption-price, which defeated #2289's priceless-commodity internal-node detection: the steam balance group vanished and the CHP dispatched incorrectly through the StorageScheduler. Record durably on each commodity context whether any price field was user-given (prices_are_defaulted) and treat a context whose prices were all defaulted (and which uses no price sensors) as an internal node. Ports the combo-branch fix upstream now that #2272 has landed on main. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MLCUiSdXDqDBmg8GbYp1B
Description
New in-scope features for the multi-commodity flex-context (follow-up to #2172, stacked on #2271) ahead of the v1 release.
Commitment schema
commodityfieldCommitmentSchemagets an undocumentedcommodityfield, defaulting toelectricity, for internal bookkeeping — matching a commitment to the device(s) sharing that commodity. Not the documented way for API users to associate a commitment with a commodity; that remains the multi-commoditycommoditieslist, one context per commodity.Smarter defaults for commodity contexts
A commodity context that omits grid-connection fields now gets sensible defaults instead of raising or leaving the grid unconstrained, based on which fields are explicitly given:
{"commodity": "gas"}, no grid connection): zero site-consumption-capacity and zero site-production-capacity as soft constraints, unlimited site-power-capacity.consumption-pricegiven: unlimited site-power-capacity and site-consumption-capacity, 0 site-production-capacity.production-pricegiven: unlimited site-power-capacity and site-production-capacity, 0 site-consumption-capacity.site-consumption-capacitygiven: unlimited site-power-capacity, that consumption capacity, 0 consumption-price, 0 site-production-capacity (and 0 production-price).site-production-capacitygiven: unlimited site-power-capacity, that production capacity, 0 production-price, 0 site-consumption-capacity (and 0 consumption-price).site-power-capacitygiven: hard constraint at that capacity; site-consumption/production-capacity equal to it; 0 consumption- and production-price.A
relax-constraints: Falsecontext that ends up with a smart-defaulted 0 hard capacity now logs a warning, since this can make the schedule infeasible.Correctness fix (found while implementing the above)
StorageScheduler.convert_to_commitmentsnow logs a warning when a commitment's commodity matches zero devices (aid for catching typos).Regression tests
7 parametrized DB-free cases for the 6 smart-default cases (+ a multi-field combination); price-free-context currency handling (top-level price sets currency, sibling context sets currency, nothing given anywhere falls back to EUR, genuine mismatches still 422).
documentation/changelog.rstHow to test
Related Items
Stacked on #2271; follow-up to #2172; prepares #1946 for release.