Skip to content

Keep explicit zero directional capacity hard under relax-constraints#2345

Open
sankalpsthakur wants to merge 4 commits into
FlexMeasures:mainfrom
sankalpsthakur:fix-2323-explicit-zero-capacity-hard
Open

Keep explicit zero directional capacity hard under relax-constraints#2345
sankalpsthakur wants to merge 4 commits into
FlexMeasures:mainfrom
sankalpsthakur:fix-2323-explicit-zero-capacity-hard

Conversation

@sankalpsthakur

@sankalpsthakur sankalpsthakur commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

  • Treat an explicit all-zero production-capacity / consumption-capacity as a physical impossibility, not an economic limit
  • Under relax-constraints (or when breach prices are set), keep the hard derivative bound and do not create soft device capacity FlowCommitments for that direction
  • Non-zero directional capacities may still be softened via breach prices (unchanged; explicit regression)
  • Regression tests: hard bounds + no soft breach commitments for both directions; schedule never produces/consumes when that directional capacity is 0 with a directional breach price set
  • Changelog entry

Context

Fixes #2323

Impact

Severity: physically impossible schedules under default relax-constraints.

Observed (community co-sim, #2323): heat pump with explicit production-capacity: 0 kW scheduled −1.764 kW production when site capacity was tight and site breach prices (10 000 EUR/kW) dwarfed device breach prices (100 EUR/kW). The LP rationally breached a soft zero-capacity commitment.

Root cause: explicit zero was turned into a soft FlowCommitment; hard bound stayed at symmetric -power-capacity. Breach prices soften limits, not impossibilities (#2272 spirit).

Workaround before this fix: set is_strictly_non_positive on consumption-only sensors.

How to test

pytest \
  flexmeasures/data/models/planning/tests/test_solver.py::test_explicit_zero_directional_capacity_stays_hard_under_relax_constraints \
  flexmeasures/data/models/planning/tests/test_solver.py::test_non_zero_directional_capacity_still_softens_under_breach_price \
  flexmeasures/data/models/planning/tests/test_solver.py::test_explicit_zero_directional_capacity_not_breached_in_schedule \
  flexmeasures/data/models/planning/tests/test_solver.py::test_device_power_capacity_uses_directional_capacity_before_site_fallback \
  flexmeasures/data/models/planning/tests/test_solver.py::test_capacity \
  -v

Related Items


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
  • Added changelog item in documentation/changelog.rst

sankalpsthakur added a commit to sankalpsthakur/flexmeasures that referenced this pull request Jul 22, 2026
Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
@read-the-docs-community

read-the-docs-community Bot commented Jul 22, 2026

Copy link
Copy Markdown

@sankalpsthakur
sankalpsthakur force-pushed the fix-2323-explicit-zero-capacity-hard branch 2 times, most recently from 128c669 to 076a8d0 Compare July 22, 2026 18:18
With relax-constraints defaulting to True, an explicit
production-capacity: 0 (or consumption-capacity: 0) was turned into a
soft FlowCommitment whenever breach prices were present. The LP could
then schedule power in a physically impossible direction (e.g. produce
from a heat pump).

Treat an all-zero directional capacity as a physical impossibility:
keep the hard derivative bound and skip soft breach commitments.
Non-zero (economic) capacity limits may still be relaxed.

Fixes FlexMeasures#2323

Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
Companion regression for FlexMeasures#2323: only explicit zero stays hard; economic
non-zero production/consumption capacities must still create soft breach
commitments.

Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
Parametrize the end-to-end schedule regression so both production and
consumption explicit zeros stay hard under directional breach prices.

Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
@sankalpsthakur
sankalpsthakur force-pushed the fix-2323-explicit-zero-capacity-hard branch from 076a8d0 to 8ec7149 Compare July 22, 2026 19:03
…ression

Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicit zero directional capacity should stay a hard constraint under relax-constraints

1 participant