Skip to content

Reaction rules: treat breach-priced site capacities as capacity kinks - #2963

Open
Flix6x wants to merge 3 commits into
mainfrom
feat/reaction-soft-site-capacity-kink
Open

Flix6x wants to merge 3 commits into
mainfrom
feat/reaction-soft-site-capacity-kink

Conversation

@Flix6x

@Flix6x Flix6x commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

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_power found the capacity kink only from the hard site constraints (derivative max / derivative min of the commodity's EMS constraints).
But site-consumption-capacity and site-production-capacity are 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 (with site-power-capacity: 100 kW), curtailable PV with react (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 as site-power-capacity, it was already right.

  • _intended_connection_power now 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.
  • As for a binding hard capacity, the device then gets react 1 where it can reach the power that balances the connection at the limit, the reference stays the uncontrolled forecast (equal to the capacity minus the planned device power there), and the band extends over the device's full range.
  • Planned breaches: where the plan breaches a soft limit on purpose (net power beyond it), the kink is still at the limit. This follows how the hard capacity check is written (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.
  • Updated the "Reacting to deviations at the connection" section in documentation/concepts/flexibility-configuration.rst.
  • Extended the changelog entry of Serve per-slot reaction rules with storage schedules #2905 in 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):

p react reference band
before -6 1 1 (-8, -6)
after -6 1 1 (-8, 0)

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 with relax-site-capacity-constraints: false as 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 to test_planned_breach_of_a_site_capacity_absorbs_deviations_from_the_planned_connection_power.)

Proving the tests can fail:

  • On 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.
  • With the hard capacity kink assignments disabled, the four hard-limit controls fail.
  • With the soft kink restricted to "at the limit" (|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

  • The peak commitments (site-peak-consumption / site-peak-production with their prices) also bend the cost of the connection; they are not kinks for the reaction rules yet.
  • Group capacities (soft, with default breach prices) are not considered as kinks, just like hard group power capacities.

Related Items

Follows #2905.


Sign-off

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

🤖 Generated with Claude Code

https://claude.ai/code/session_01WGt2vUmJ4goxUYxexuArDE

Flix6x and others added 3 commits December 5, 2026 21:36
…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>
@Flix6x Flix6x added this to the 1.2.0 milestone Dec 5, 2026
@Flix6x Flix6x added Scheduling Feature A new feature labels Dec 5, 2026
@Flix6x Flix6x self-assigned this Dec 5, 2026
@read-the-docs-community

Copy link
Copy Markdown

📖 4 files modified


Preview · build overview · flexmeasures · built Dec. 5, 2026, 8:45 p.m. UTC

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant