Skip to content

Comments

Add multi‑commodity support to device scheduler#1946

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

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

Conversation

@Ahmad-Wahid
Copy link
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

Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
@read-the-docs-community
Copy link

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

Documentation build overview

📚 flexmeasures | 🛠️ Build #31246494 | 📁 Comparing 1d63893 against latest (36400dd)


🔍 Preview build

Show files changed (13 files in total): 📝 11 modified | ➕ 1 added | ➖ 1 deleted
File Status
changelog.html 📝 modified
genindex.html 📝 modified
index.html 📝 modified
py-modindex.html 📝 modified
_autosummary/flexmeasures.data.models.planning.html 📝 modified
_autosummary/flexmeasures.data.services.scheduling.html 📝 modified
_autosummary/flexmeasures.utils.html 📝 modified
_autosummary/flexmeasures.utils.job_utils.html ➖ deleted
api/v3_0.html 📝 modified
cli/change_log.html 📝 modified
concepts/commitments.html ➕ added
concepts/device_scheduler.html 📝 modified
plugin/customisation.html 📝 modified

Ahmad-Wahid and others added 15 commits February 3, 2026 02:09
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
…chemas

Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
@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
Contributor Author

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

@Flix6x
Copy link
Contributor

Flix6x commented Feb 19, 2026

Please comment on why the test suite is failing.

@Ahmad-Wahid
Copy link
Contributor Author

Please try to run these test cases: test_two_flexible_assets_with_commodity and test_mixed_gas_and_electricity_assets

Copy link
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.

Comment on lines +413 to +415
# ---- assertions
assert isinstance(schedules, list)
assert len(schedules) >= 2 # at least one schedule per device
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that the prices are constant, I'd expect the tie-breaking preference to charge sooner and discharge later would kick in.
The schedules should represent that by showing all charging happens in the first time slots, each up until the max capacity for the device (there is no site capacity).
Please add the assert statements for this behaviour and observe that the schedules are not currently reflecting this behaviour. Therefore, there must be a problem in the code, too. What do the schedules look like when you schedule this system against main (without setting the commodities)? I mean, you'd expect the same result as before, right?

Let's also add a check against the electricity costs for both devices. The expected totals should be explained in the code. For instance, at a 100 EUR/MWh, a total demand of x kWh and an efficiency of y, we expect z costs.

Comment on lines +418 to +423
def test_mixed_gas_and_electricity_assets(app, db):
"""
Test scheduling two flexible assets with different commodities:
- Battery (electricity)
- Gas boiler (gas)
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

What are you testing in this test? Please explain the reason for the test's existence in the docstring.

My take: the gas boiler is currently creating gas, which is pretty weird. :) You'll need a production-capacity set to 0 kW. Afterwards, the gas boiler just stands idle. I would expect this test to have the gas boiler do something, too, and then proof that electricity costs and gas costs are both as expected.
I also think in this test the two devices are essentially completely separate systems. That is, shared commodity, constraints or storage. I think that is worth pointing out.

Signed-off-by: F.N. Claessen <claessen@seita.nl>
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.

2 participants