Skip to content

Fix: soc min does not need to be mandatory#2221

Merged
Flix6x merged 16 commits into
mainfrom
fix/soc-min-does-not-need-to-be-mandatory
Jun 17, 2026
Merged

Fix: soc min does not need to be mandatory#2221
Flix6x merged 16 commits into
mainfrom
fix/soc-min-does-not-need-to-be-mandatory

Conversation

@BelhsanHmida

Copy link
Copy Markdown
Contributor

Description

  • Let storage scheduling continue when a flex-model omits soc-min.
  • Treat missing soc-min as no global lower state-of-charge boundary, rather than defaulting it to zero.
  • Preserve timed soc-minima constraints without filling gaps with an implied global lower bound.
  • Clarified the scheduling metadata for optional soc-min.
  • Added changelog entry

Look & Feel

N/A. This is scheduler behavior and documentation only.

How to test

pytests:

pytest -k "add_storage_constraints_skips_global_minimum_when_soc_min_is_missing or add_storage_constraints_with_soc_minima_and_missing_soc_min_has_gaps"

Manual check:

  • Called add_storage_constraints(..., soc_min=None) directly.
  • Confirmed no TypeError is raised.
  • Confirmed the generated global min column remains empty.
  • Confirmed validate_storage_constraints(...) returns no violations.

Related Items

Closes SeitaBV/ems#211


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

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida BelhsanHmida self-assigned this Jun 4, 2026
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida BelhsanHmida requested a review from Flix6x June 4, 2026 01:32
@Flix6x Flix6x added this to the 1.0.0 milestone Jun 4, 2026

@Flix6x Flix6x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I think we may need the same for soc-max. It would be interesting to extend the new tests to a case where soc-min is defined, but soc-max is missing (or both are missing).

Comment thread flexmeasures/data/schemas/scheduling/metadata.py Outdated
Comment thread flexmeasures/data/models/planning/tests/test_solver.py Outdated
Comment thread flexmeasures/data/models/planning/tests/test_solver.py Outdated
Comment thread flexmeasures/data/models/planning/storage.py Outdated
@Flix6x Flix6x mentioned this pull request Jun 4, 2026
6 tasks
BelhsanHmida and others added 6 commits June 4, 2026 21:55
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida

Copy link
Copy Markdown
Contributor Author

Nice. I think we may need the same for soc-max. It would be interesting to extend the new tests to a case where soc-min is defined, but soc-max is missing (or both are missing).

Yes, this is now covered. I added tests for soc-min defined with missing soc-max, both bounds missing, and soc-maxima with gaps. I also added preprocessing coverage so missing soc-max no longer raises before constraints are built.

@BelhsanHmida BelhsanHmida requested a review from Flix6x June 4, 2026 21:19
BelhsanHmida and others added 5 commits June 17, 2026 12:47
Signed-off-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com>
…e without hard constraints on the SoC

Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…need-to-be-mandatory

# Conflicts:
#	documentation/changelog.rst
…mandatory' into fix/soc-min-does-not-need-to-be-mandatory
if soc_max_asset is not None:
self.flex_model["soc-max"] = soc_max_asset
else:
# Lacking information about the battery's nominal capacity, we use the highest target value as the maximum state of charge

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this at length. I now think we should not use ensure_soc_min_max anymore at all. It was only used for the old sensor schedule trigger anyway. I now removed it. This means we no longer try to infer the soc-min or soc-max if they are not passed. The function originally:

  1. Tried to get the soc-min/max from the asset. By now this already happens in collect_flex_config, for all fields, so this became redundant.
  2. Assumed 0 as the soc-min. Not a good assumption if SoC is used as a proxy for temperature.
  3. Tried to get the soc-max from the soc-targets field. Not a good assumption of the soc-max lies below soc-at-start.

The greater contribution of this PR is allowing constraint validation to pass for devices without soc-min or soc-max. That means the StorageScheduler is becoming a more generic DeviceScheduler. I'm not ready to rename it yet, but this is where I feel we are heading.

@Flix6x Flix6x merged commit 98980ca into main Jun 17, 2026
12 checks passed
@Flix6x Flix6x deleted the fix/soc-min-does-not-need-to-be-mandatory branch June 17, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants