Skip to content

Add multi‑commodity support to device scheduler#1946

Draft
Ahmad-Wahid wants to merge 47 commits intofeat/switching-between-gas-and-electricityfrom
feat/multi-commodity
Draft

Add multi‑commodity support to device scheduler#1946
Ahmad-Wahid wants to merge 47 commits intofeat/switching-between-gas-and-electricityfrom
feat/multi-commodity

Conversation

@Ahmad-Wahid
Copy link
Copy Markdown
Contributor

@Ahmad-Wahid Ahmad-Wahid commented Feb 3, 2026

This PR adds initial support for multi‑commodity commitments (e.g. gas and electricity) in the device_scheduler, building on the grouped‑devices functionality. Flow commitments can now be tagged with a commodity, and EMS‑level flow constraints are applied per commodity by aggregating the relevant devices.

TODO

  • Specify how commodity is encoded per device in the flex‑model
  • Exclude non‑matching commodities (e.g. gas devices) from EMS electricity commitments
  • Extend flex‑model schema with commodity metadata
  • add gas-price field to flex-context
  • set up gas commitment using gas-powered devices and gas-price
  • Update scheduling.rst
  • Add tutorial examples for multi‑commodity scheduling

closes https://github.com/SeitaBV/simulations/issues/987

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community bot commented Feb 3, 2026

Documentation build overview

📚 flexmeasures | 🛠️ Build #31957437 | 📁 Comparing de4981e against latest (d9840bf)


🔍 Preview build

Show files changed (6 files in total): 📝 4 modified | ➕ 2 added | ➖ 0 deleted
File Status
genindex.html 📝 modified
_autodoc/COMMODITY.html ➕ added
_autodoc/GAS_PRICE.html ➕ added
_autosummary/flexmeasures.data.models.planning.html 📝 modified
_autosummary/flexmeasures.data.models.planning.storage.html 📝 modified
api/v3_0.html 📝 modified

Ahmad-Wahid and others added 15 commits February 3, 2026 02:09
Signed-off-by: Ahmad-Wahid <[email protected]>
Signed-off-by: Ahmad-Wahid <[email protected]>
@Ahmad-Wahid Ahmad-Wahid requested a review from Flix6x February 16, 2026 11:51
@Ahmad-Wahid Ahmad-Wahid self-assigned this Feb 16, 2026
@Ahmad-Wahid Ahmad-Wahid added enhancement New feature or request Scheduling labels Feb 16, 2026
@Ahmad-Wahid
Copy link
Copy Markdown
Contributor Author

@Flix6x could you please suggest some assertions for both test cases?

@Flix6x
Copy link
Copy Markdown
Contributor

Flix6x commented Feb 19, 2026

Please comment on why the test suite is failing.

@Ahmad-Wahid
Copy link
Copy Markdown
Contributor Author

Please try to run these test cases: test_two_flexible_assets_with_commodity and test_mixed_gas_and_electricity_assets

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.

I reviewed the two tests.

Signed-off-by: F.N. Claessen <[email protected]>
Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 26, 2026

@Flix6x I've opened a new pull request, #1991, to work on those changes. Once the pull request is ready, I'll request review from you.

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.

We should look those failing tests, too.

@Ahmad-Wahid
Copy link
Copy Markdown
Contributor Author

Ahmad-Wahid commented Feb 27, 2026

Here are all the failed tests from the job, along with their failure reasons:

  • 1. flexmeasures/data/models/planning/tests/test_solver.py::test_battery_storage_different_units[power (kW)-MWh-kWh]

    • Reason: Assertion failed. The test expected (sum).0.25 == 0.9, but the sum was 0.0.
  • 2. flexmeasures/data/models/planning/tests/test_solver.py::test_unavoidable_capacity_breach

    • Reason: Assertion failed. The solver’s termination status was infeasibleOrUnbounded, but 'optimal' was expected.
  • 3. flexmeasures/data/models/planning/tests/test_solver.py::test_multiple_commitments_per_group

    • Reason: Assertion failed. The solver’s termination status was infeasibleOrUnbounded instead of 'optimal'.
  • 4. flexmeasures/data/models/planning/tests/test_solver.py::test_multiple_devices_simultaneous_scheduler

    • Reason: Assertion failed. The solver’s termination status was infeasibleOrUnbounded rather than 'optimal'.
  • 5. flexmeasures/data/models/planning/tests/test_solver.py::test_multiple_devices_sequential_scheduler

    • Reason: Assertion failed. The solver’s termination status was infeasibleOrUnbounded rather than 'optimal'.
  • 6. flexmeasures/data/models/planning/tests/test_storage.py::test_battery_solver_multi_commitment

    • Reason: KeyError for 'energy' during test execution.
  • 7. flexmeasures/data/tests/test_scheduling_simultaneous.py::test_create_simultaneous_jobs[True]

    • Reason: Assertion failed. EV cost was €2.3125 but the test expected €2.2375.
  • 8. flexmeasures/data/tests/test_scheduling_simultaneous.py::test_create_simultaneous_jobs[False]

    • Reason: Assertion failed. EV cost was €2.3125 but the test expected €2.2375.
  • 9. flexmeasures/ui/tests/test_utils.py::test_ui_flexcontext_schema

    • Reason: Assertion failed. Likely due to a new flex-context field added to the codebase without corresponding UI support. The set of keys did not match the reference set.
  • 10. flexmeasures/ui/tests/test_utils.py::test_ui_flexmodel_schema

    • Reason: Assertion failed. There are unexpected/extra items in the flexmodel schema output set compared to the reference set.

@Flix6x
Copy link
Copy Markdown
Contributor

Flix6x commented Mar 13, 2026

@Ahmad-Wahid Maybe we should move the preference to charge sooner (and discharge later) to a per-device StockCommitment instead of a per-device FlowCommitment. The StockCommitment should use a tiny negative up-price for SoC > 0, and no down-price, so it prefers being full over being empty, all else being equal.

Update: moved out to #2023

Flix6x and others added 8 commits March 19, 2026 12:24
…eat/multi-commodity

# Conflicts:
#	documentation/concepts/commitments.rst
#	flexmeasures/data/models/planning/__init__.py
#	flexmeasures/data/models/planning/storage.py
…lectricity' into feat/multi-commodity

# Conflicts:
#	flexmeasures/data/models/planning/tests/test_commitments.py
Signed-off-by: F.N. Claessen <[email protected]>
@nhoening nhoening added this to the 0.32.0 milestone Mar 20, 2026
@Flix6x Flix6x mentioned this pull request Mar 23, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Scheduling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants