Skip to content

Fix: scheduling none soc mixed assets#2108

Merged
Flix6x merged 5 commits intomainfrom
fix/scheduling-none-soc-mixed-assets
Apr 14, 2026
Merged

Fix: scheduling none soc mixed assets#2108
Flix6x merged 5 commits intomainfrom
fix/scheduling-none-soc-mixed-assets

Conversation

@BelhsanHmida
Copy link
Copy Markdown
Contributor

@BelhsanHmida BelhsanHmida commented Apr 14, 2026

Description

  • Fix a mixed-device scheduling regression in StorageScheduler where non-storage devices such as PV were incorrectly processed by the new SoC-based "prefer full storage sooner" logic.
  • Only create the StockCommitment for devices that actually define both soc_max and soc_at_start.
  • Add test covering a mixed battery + PV schedule so scheduling computes instead of failing with TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'.
  • add a changelog entry

Context

This issue first surfaced through the HEMS example scheduling phase, where the worker failed with TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'. The issue comes from PR #2023 (Feat: full SoC preference), which moved the tie-breaking preference into a SoC-based StockCommitment and assumed each preferred device had soc_max and soc_at_start. That assumption is valid for storage devices, but not for non-storage devices such as PV that can still appear in mixed-device schedules.

How to test

  • Run the regression test in flexmeasures/data/models/planning/tests/test_solver.py
  • Reproduce a mixed-device scheduling request with a storage device and a non-storage device such as PV in the same flex-model; for example, by running the HEMS script
  • Confirm scheduling no longer crashes in StorageScheduler._prepare(...)

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

Context:
- PR #2023 introduced a StockCommitment that assumes each preferred device has soc_max and soc_at_start.
- Mixed-device schedules can include non-storage devices such as PV, which do not have state-of-charge values.
Change:
- Guard the full-SoC preference so it only applies when both soc_max and soc_at_start are defined.
- Prevent mixed-device scheduling from crashing on NoneType subtraction.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context:
- The scheduler regression was exposed by HEMS-style mixed-device flex-models that combine storage with PV.
Change:
- Add a regression test covering a mixed battery plus PV schedule.
- Verify scheduling computes without applying SoC-only preferences to the PV device.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida BelhsanHmida self-assigned this Apr 14, 2026
@BelhsanHmida BelhsanHmida added the bug Something isn't working label Apr 14, 2026
Context:
- PR #2108 fixes a mixed-device scheduling regression in StorageScheduler.
Change:
- Document the fix in the unreleased v0.32.0 bugfixes section.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented Apr 14, 2026

Documentation build overview

📚 flexmeasures | 🛠️ Build #32259221 | 📁 Comparing bfda69c against latest (48a0829)

  🔍 Preview build  

2 files changed
± changelog.html
± api/v3_0.html

@BelhsanHmida BelhsanHmida requested a review from Flix6x April 14, 2026 15:12
@nhoening nhoening added this to the 0.32.0 milestone Apr 14, 2026
Flix6x added 2 commits April 14, 2026 17:43
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Copy link
Copy Markdown
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

🐛 🐦

@Flix6x Flix6x merged commit f3008b2 into main Apr 14, 2026
12 of 13 checks passed
@Flix6x Flix6x deleted the fix/scheduling-none-soc-mixed-assets branch April 14, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants