Repository navigation
Conversation
…on rules The reaction rules found the capacity kink only from the hard site constraints, so a site limit relaxed into a breach-priced soft constraint (the default for site-consumption-capacity and site-production-capacity) never was one. A device next to, for example, a DSO export limit sent as site-production-capacity then got a band that stopped at its planned power, and did not curtail when the uncontrolled load dropped. Now the soft site capacities of each commodity, taken from its breach commitments, are a capacity kink where the plan sits at them or beyond them, with the hard capacity taking precedence where it binds. Where the plan breaches a soft capacity on purpose, the kink stays at that capacity, so the device holds the planned connection power and a deviation does not add to the breach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGt2vUmJ4goxUYxexuArDE 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_01WGt2vUmJ4goxUYxexuArDE Signed-off-by: F.N. Claessen <claessen@seita.nl>
… capacities Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGt2vUmJ4goxUYxexuArDE Signed-off-by: F.N. Claessen <claessen@seita.nl>
|
📖 4 files modified
Preview · build overview · flexmeasures · built Dec. 5, 2026, 8:45 p.m. UTC |
13 tasks done
This branch has not been deployed
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.
Description
Extends the reaction rules of #2905 (unreleased) to breach-priced site limits: a soft site capacity that the plan sits at is now a capacity kink, as a hard one already was.
Until now,
StorageScheduler._intended_connection_powerfound the capacity kink only from the hard site constraints (derivative max/derivative minof the commodity's EMS constraints).But
site-consumption-capacityandsite-production-capacityare relaxed by default into breach-priced soft constraints, with the site power capacity as the hard limit.Such a limit was therefore never a kink for the reaction rules, although the docs already define the kink as including "a capacity that binds", and crossing a breach-priced limit costs the breach price.
Example: a DSO export limit sent as
site-production-capacity: 5 kW(withsite-power-capacity: 100 kW), curtailable PV withreact(production capacity from an 8 kW sun forecast), a 1 kW load, and feed-in that pays (50/30 EUR/MWh).The plan curtails the PV to 6 kW to hold the export at 5 kW, but the PV got react 1 with band (-8, -6) as if off the kink, rather than (-8, 0).
So when the load dropped by 2 kW, the site exported 7 kW and the PV did not curtail.
With
relax-site-capacity-constraints: false, or with the limit given assite-power-capacity, it was already right._intended_connection_powernow also reads each commodity's soft site capacities from its"<commodity> all consumption breaches"/"<commodity> all production breaches"commitments (only in slots where the breach price is positive), and puts the capacity kink there where the plan sits at the limit (within the existing tolerance). The hard capacity still takes precedence where it binds. Per-commodity contexts are handled as for the hard capacities and the net energy prices; group capacities (group ... breaches) are left out, as for the hard ones.net >= capacity - tolerance) and the docs' notion of a kink as the point where the cost bends. In practice the device then absorbs deviations from the planned connection power (the reaction rule always balances against the plan's reference): a deviation that would add to the breach is absorbed, within the device's band, which saves the breach price and keeps the breach (and the "any breach" peak price) from growing beyond what the plan accepted as far as the band allows, while a deviation that eases the breach lets the device take up the room the plan wanted, within its band. Where the device cannot reach the limit's balancing power (e.g. the uncontrolled power alone breaches it), the rules fall back to the price kink, as for an unreachable hard capacity.documentation/concepts/flexibility-configuration.rst.documentation/changelog.rst(no entry of its own, since the reaction rules are unreleased).Look & Feel
For the example above (one slot, powers in kW):
How to test
New tests in
flexmeasures/data/models/planning/tests/test_reaction.py, run under both solver backends like the rest of the module:test_site_capacity_is_a_kink_whether_breach_priced_or_hard, parametrized over production (curtailable PV under a site export limit) and consumption (curtailable load under a site import limit, at negative prices), each with the default breach-priced limit and withrelax-site-capacity-constraints: falseas the hard-limit control. Each checks the plan, react, reference and band, and that the client rule brings the connection back to the limit for a 2 kW deviation each way.test_planned_breach_of_a_site_capacity_holds_the_planned_connection_power: a cheap breach price makes the plan import 8 kW over a 5 kW limit; the load reacts with band (0, 6) and absorbs a rise of the uncontrolled load, bringing the import back to the planned 8 kW. (Renamed in Reaction rules: a headroom per direction, up to the nearest kink, so a device also absorbs what would cross a site capacity beyond the plan #2965 totest_planned_breach_of_a_site_capacity_absorbs_deviations_from_the_planned_connection_power.)Proving the tests can fail:
main(without the change), the four breach-priced cases and both planned-breach cases fail (band (-8, -6) for PV, react 0 for the load), while the four hard-limit controls pass.|net - capacity| <= tolerance) instead of "at or beyond", the planned-breach test fails, so it pins the planned-breach decision.The reaction and planning tests pass, and the full suite too.
Further Improvements
site-peak-consumption/site-peak-productionwith their prices) also bend the cost of the connection; they are not kinks for the reaction rules yet.Related Items
Follows #2905.
Sign-off
🤖 Generated with Claude Code
https://claude.ai/code/session_01WGt2vUmJ4goxUYxexuArDE