Repository navigation
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
Open
Flix6x wants to merge 25 commits into
Conversation
The reaction rules need the hard and breach-priced site capacities also where the plan does not sit at them, so their parsing moves out of `_intended_connection_power` into `_site_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>
…g device's reach Off the price kink, a reacting device's band only kept the kink's side of the plan, so a deviation pushing the connection away from the kink was not absorbed, even where a site capacity (hard or breach-priced) lay just beyond the plan. Where such a capacity, per commodity, is closer to the planned connection power than the device could still move against a deviation in that direction within its band, the band now keeps both sides, and the device reacts against the same reference, holding the planned connection power both ways. It then also absorbs deviations that would not have crossed the capacity; the drift gate and retrigger handle the resulting drift. A charger whose plan the modes keep just below a hard fuse now defends that fuse. 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>
…nd an off-kink plan 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>
…thin reach 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>
…ing devices A site capacity beyond an off-kink plan was defended only where a single device could reach it. Since reacting devices act in series, each taking what the devices before it could not, the chain of reacting devices of a commodity can defend a capacity that no single device can reach. So "within reach" now compares the distance to the capacity with the room of all reacting devices of the commodity together, and every reacting device with room to move against a deviation towards the capacity keeps its whole band and reacts, also where no kink is within its own reach. 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>
|
📖 6 files modified
Preview · build overview · flexmeasures · built Dec. 6, 2026, 2:34 p.m. UTC |
…e kink Where consumption and production are priced the same and above zero, there is no price kink, and a device used to get react 0 unless a site capacity bound. A site capacity within the combined reach of the reacting devices, on either side of the plan, is now defended there too: the devices with room to move against a deviation towards it get react 1, their whole band, and the forecast as reference. On symmetric prices, this also makes a battery react in slots where it plans to export well within the site's export limit, as long as that limit is within its reach; two existing tests are updated accordingly. 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>
…adroom Each reaction rule now carries a headroom, the range (low, high) of deviations the device lets pass. On the kink it is 0 on both sides; off the kink it is 0 towards a price kink within the device's reach, and the distance to the nearest site capacity (hard or breach-priced) away from it, or on both sides without a price kink. The band is left as the device's feasibility, no longer cut to the kink's side, and the "within reach" guard is dropped: with the headroom, a far site capacity costs no reaction until a deviation would cross it. 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>
…sign convention of its values Each reaction object gains a headroom [low, high], null on a side where the device never reacts. A production-positive sign convention swaps its sides, a coarser sensor keeps it only where the sub-slots agree, and rules stored without one are served with [0, 0], so they keep their meaning. 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>
… direction 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>
…ay, the same for every device Each side of the headroom is now the distance from the planned connection power to the nearest kink in that direction, the price kink or a site capacity, whichever is nearer, so a deviation that keeps the connection between its neighbouring kinks passes. The per-device reach of the price kink is dropped: every reacting device gets the same site-level headroom, its band limits what it can do, and the chain passes the rest on. 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>
…deviation within it causes no drift 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>
… must take from its planned mode A device that must cross a hole between its operation modes to absorb towards the price kink, such as an idle charger that charges from 1.4 kW, gets that side of the headroom shrunk by the hole's width, floored at 0, where the price kink is the nearest kink on that side, so it is in its next mode by the time the connection would cross the kink, rather than only after crossing it by the whole step. 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>
…rice kink starts that much earlier 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>
3 tasks done
…tion reference The client subtracts only the power of the devices that get reaction rules from the meter, so a flexible device without react is uncontrolled as the client sees it. Leaving its plan out of the reference made a client see its planned power as a deviation. 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>
…out react, and the client subtracts the planned power of a device that does not react in a slot 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>
… with the installation's own protection and load balancing 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>
…limit it defends 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>
…nd, rather than holding the connection 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>
7 tasks done
…he scheduling job's result A client learns from the job it already waits for which devices to subtract from the meter and where it stands in the series, also for devices whose react was set in a flex-model stored on the asset. 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>
…, from the job's reaction-sensors 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>
…es order, from the job's reaction-sensors" This reverts commit d2a366b: the list of reacting devices waits for a design of a central schedule response. 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>
…er, in the scheduling job's result" This reverts commit 087fa8f: the list of reacting devices waits for a design of a central schedule response. 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>
…hose set on the asset among the job's outputs 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>
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
Stacked on #2963 (breach-priced site capacities as kinks), and follows #2905 (reaction rules).
The gap. Off the price kink, a reacting device's band only extended from the plan to the side that absorbs deviations towards the kink. A site capacity just beyond the plan, away from the kink, therefore got no reaction. For example: a plan importing 11.36 kW against a breach-priced import limit of 12 kW, an EV at its 11 kW maximum (react 0), and a battery with band
[[-1.137, 5]]kW and react 1. A 2 kW rise in base load takes the site to about 13.4 kW, and nothing reacts. The same holds with a hard site capacity, so this is not specific to soft limits.The change: a headroom per direction. Each rule gains a
headroom,[low, high]in the schedule's unit and sign convention: the deviations the device lets pass. The client absorbs only the excess outside it:[0, 0]: the rule is unchanged.nullon a side without one, where the device never reacts. Between two kinks the connection's cost is linear, so absorbing there gains nothing._site_capacities, shared by_intended_connection_powerand the reaction rules.react, and their order; wherereactis set in a flex-model stored on the asset, it finds them among the job'soutputs, as the sensors whose schedule comes with areactionarray.[0, 0].reactare now part of thereference, which was only the inflexible forecast. The client subtracts only the power of the devices that get reaction rules from the meter, so such a device is uncontrolled as the client sees it; before, a client following the docs saw its whole planned power as a deviation (an EV charging at 11 kW as planned made the battery discharge against it). A departure from its plan still counts as a deviation. A device that setreactbut has react 0 in a slot is subtracted at its planned power, so its departure from plan counts as a deviation too; the docs now say so.reactionfield and the 1.2.0 changelog entry are extended (no entry of their own, since reaction rules are unreleased).Backwards compatibility. Reaction rules are unreleased, so nothing released changes. A client that finds no
headroomuses[0, 0], which gives the rule as served by #2905.What it buys. On a synthetic replay against a site capacity 637 W beyond the plan, the headroom absorbs what would cross the capacity as well as holding the plan both ways does, at a lower cost. Without a reaction to it, 37.55 kWh crosses the capacity; both ways of reacting to it cut that to 0.07 kWh, the part the battery's band cannot cover. Holding the plan both ways makes the battery absorb 96.4 kWh to get there, with 147 drift retriggers; the headroom 37.5 kWh, with 74. The difference is energy absorbed from deviations that would never have crossed the capacity: it only moves the state of charge away from the plan. A deviation within the headroom is not absorbed, so it causes no state-of-charge drift and no retrigger.
Behaviour change in an existing test. A charger whose plan the operation modes keep 0.35 kW below a hard 5.75 kW fuse, at its 7.4 kW limit, used to get react 0 (band a single point). It now reacts to what would cross the fuse; the test is renamed to
test_plan_just_below_the_fuse_absorbs_what_would_cross_it.Look & Feel
For the example above, the battery's rule for that slot gets band
[[-5, 5]]kW, react 1, the reference unchanged, and a headroom of 11.363 kW towards the price kink and 0.637 kW towards the limit. A +2 kW base-load swing then takes the site to the 12 kW limit and no further; a +0.5 kW swing passes unabsorbed.How to test
pytest flexmeasures/data/models/planning/tests/test_reaction.py flexmeasures/api/v3_0/tests/test_reaction_response.py, under both solver backends. Among others:test_site_capacity_beyond_the_plan_absorbs_beyond_the_headroom,test_far_site_capacity_absorbs_only_beyond_its_distance,test_big_battery_lets_a_far_site_capacity_pass.test_chain_absorbs_what_would_cross_a_site_capacity,test_chain_absorbs_what_would_cross_a_site_capacity_beyond_each_battery: what no single battery could absorb, the chain absorbs together.test_absorbs_what_would_cross_a_site_capacity_without_a_price_kink.test_off_the_kink_importing_absorbs_what_crosses_the_kinkand its exporting twin.test_idle_charger_starts_charging_before_the_connection_crosses_the_kink,test_step_towards,test_headroom_per_side,test_headroom_without_capacities.test_flexible_device_without_react_is_part_of_the_reference: an EV withoutreactnext to a reacting battery; the reference holds the EV's plan, the battery follows its plan with the house as forecast, absorbs what a load rise would take across the limit, and lets the EV stopping pass. It fails without the reference change.test_reaction_response.py: the headroom is served in the schedule's unit and sign convention, withnullfor a side without a kink.Further Improvements
Related Items
Stacked on #2963; follows #2905. The client side is FlexMeasures/flexmeasures-client#299, which documents that only devices with reaction rules enter the meter subtraction and its
residuals.Sign-off
🤖 Generated with Claude Code
https://claude.ai/code/session_01WGt2vUmJ4goxUYxexuArDE