feat: Split flex-context settings by commodity for dynamic capacity scheduling#2172
Open
Ahmad-Wahid wants to merge 12 commits into
Open
feat: Split flex-context settings by commodity for dynamic capacity scheduling#2172Ahmad-Wahid wants to merge 12 commits into
Ahmad-Wahid wants to merge 12 commits into
Conversation
… scheduler Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
…capacity scheduling test Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Flix6x
requested changes
May 14, 2026
Member
Flix6x
left a comment
There was a problem hiding this comment.
Quick review. Also please triage the failing test suite.
Comment on lines
+98
to
+137
| # Backwards-compatible electricity defaults from old top-level fields. | ||
| if "electricity" not in commodity_contexts: | ||
| commodity_contexts["electricity"] = { | ||
| "commodity": "electricity", | ||
| "consumption_price": self.flex_context.get( | ||
| "consumption_price", | ||
| self.flex_context.get("consumption_price_sensor"), | ||
| ), | ||
| "production_price": self.flex_context.get( | ||
| "production_price", | ||
| self.flex_context.get("production_price_sensor"), | ||
| ), | ||
| "ems_power_capacity_in_mw": self.flex_context.get( | ||
| "ems_power_capacity_in_mw" | ||
| ), | ||
| "ems_consumption_capacity_in_mw": self.flex_context.get( | ||
| "ems_consumption_capacity_in_mw" | ||
| ), | ||
| "ems_production_capacity_in_mw": self.flex_context.get( | ||
| "ems_production_capacity_in_mw" | ||
| ), | ||
| "ems_consumption_breach_price": self.flex_context.get( | ||
| "ems_consumption_breach_price" | ||
| ), | ||
| "ems_production_breach_price": self.flex_context.get( | ||
| "ems_production_breach_price" | ||
| ), | ||
| "ems_peak_consumption_in_mw": self.flex_context.get( | ||
| "ems_peak_consumption_in_mw" | ||
| ), | ||
| "ems_peak_consumption_price": self.flex_context.get( | ||
| "ems_peak_consumption_price" | ||
| ), | ||
| "ems_peak_production_in_mw": self.flex_context.get( | ||
| "ems_peak_production_in_mw" | ||
| ), | ||
| "ems_peak_production_price": self.flex_context.get( | ||
| "ems_peak_production_price" | ||
| ), | ||
| } |
Member
There was a problem hiding this comment.
Let's shorten this, by looping over all flex-context fields except the ones you wish to exclude. The commitments and inflexible-device-sensors, for instance, are also about electricity devices, and they are missed right now.
I think the only ones you want to exclude are the gas ones and the constraint relaxations.
| class CommodityFlexContextSchema(Schema): | ||
| commodity = fields.Str( | ||
| required=True, | ||
| validate=validate.OneOf(["electricity", "gas"]), |
Member
There was a problem hiding this comment.
I want to let go of this constraint. I suggest moving this list to
metadata={
"description": "<please suggest something>",
"examples": ["electricity", "gas"],
}
Contributor
Author
There was a problem hiding this comment.
Sorry, I didn't understant this comment.
Member
There was a problem hiding this comment.
I meant that:
- We should not limit commodity to just those two options. I want to let users freely define commodities.
- We can still use the
["electricity", "gas"]list, but then use it as an example only (not a restriction). Examples can be defined using themetadataargument offields.Str(together with a field description).
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
…odity-flex-context Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
…'gas-price' for electricity as commodity Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
…split-flexcontext-by-commodity # Conflicts: # flexmeasures/data/models/planning/storage.py
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
…split-flexcontext-by-commodity
…split-flexcontext-by-commodity
…split-flexcontext-by-commodity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR updates the dynamic consumption capacity scheduling test to use split, commodity-specific flex-context settings for electricity and gas. It adds dynamic electricity and gas price data so the scheduler can prefer the electric heater when electricity is cheaper and the gas boiler when gas is cheaper, while ensuring that the dynamic electricity site consumption capacity is only applied to electricity devices and does not incorrectly constrain gas devices.
documentation/changelog.rstLook & Feel
...
How to test
...
Further Improvements
...
Related Items
...
Sign-off