Feat/offtick soc projection#2194
Conversation
…ataFrames Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
# Conflicts: # flexmeasures/api/common/schemas/sensor_data.py
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>
…nt-start Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com> # Conflicts: # flexmeasures/api/v3_0/tests/test_sensor_schedules.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@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>
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/be65737b-e479-49f5-bd8b-5c62a1b8b340 Co-authored-by: BelhsanHmida <149331360+BelhsanHmida@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/be65737b-e479-49f5-bd8b-5c62a1b8b340 Co-authored-by: BelhsanHmida <149331360+BelhsanHmida@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/be65737b-e479-49f5-bd8b-5c62a1b8b340 Co-authored-by: BelhsanHmida <149331360+BelhsanHmida@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/be65737b-e479-49f5-bd8b-5c62a1b8b340 Co-authored-by: BelhsanHmida <149331360+BelhsanHmida@users.noreply.github.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…dule_floors_flex_model_datetimes Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
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>
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 <149331360+BelhsanHmida@users.noreply.github.com>
…nt-start Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com> # Conflicts: # flexmeasures/api/common/schemas/sensor_data.py # flexmeasures/api/v3_0/tests/test_sensor_data.py # flexmeasures/data/schemas/sensors.py
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR updates storage scheduling to preserve user-provided (off-tick) SoC constraint timings during flex-model deserialization, and then projects those constraints onto the scheduler’s time grid using charge/discharge capacity so they remain enforceable. It also auto-enables SoC constraint relaxation when off-tick constraints are present, and adds tests for off-tick target projection + auto-relax behavior.
Changes:
- Stop flooring SoC event datetimes during storage flex-model schema deserialization (preserve original event times).
- Normalize/project off-tick SoC constraints onto the scheduling grid inside the storage scheduler using capacity-derived bounds.
- Auto-enable
relax-soc-constraintswhen off-tick SoC constraints are detected; add regression tests for target projection and auto-relax.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
flexmeasures/data/schemas/scheduling/storage.py |
Removes schema-level datetime flooring for soc-targets/soc-minima/soc-maxima so original timings are preserved. |
flexmeasures/data/models/planning/storage.py |
Adds detection of off-tick SoC constraints, enables relaxation automatically, and normalizes/project off-tick constraints onto the scheduling grid during _prepare. |
flexmeasures/data/models/planning/tests/test_storage.py |
Adds tests for off-tick SoC target projection and automatic enabling of SoC constraint relaxation. |
Comments suppressed due to low confidence (1)
flexmeasures/data/models/planning/storage.py:1125
- For multi-device scheduling (
self.flex_modelis a list), off-tick SoC events are checked againstself.resolutiononly. Whenresolutionis omitted,_preparelater derives it (or falls back) based on the sensors’ event resolutions, but this early check returnsFalsewithresolution=None, sorelax-soc-constraintswon’t be auto-enabled even though off-tick events will be projected later. Consider deriving a resolution here in the same way_preparedoes (minimum non-zero sensor resolution, with default fallback) before callingflex_model_has_off_tick_soc_constraints.
if isinstance(self.flex_model, list):
return any(
flex_model_has_off_tick_soc_constraints(
flex_model, resolution=self.resolution
)
for flex_model in self.flex_model
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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>
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>
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>
…nto feat/offtick-soc-normalization Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com> # Conflicts: # flexmeasures/data/schemas/scheduling/storage.py
…alization Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com> # Conflicts: # flexmeasures/data/schemas/tests/test_scheduling.py # flexmeasures/data/schemas/tests/test_sensor.py
Flix6x
left a comment
There was a problem hiding this comment.
Thanks for this. I still need to check the tests and the actual projection policy, but I'd like to hold that off until it's more documented.
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>
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>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Description
soc-targets,soc-minima, andsoc-maxima.relax-soc-constraintswhen off-tick SoC constraints are submitted, so generated/adjusted constraints can be softened safely.How to test
Manual test:
soc-target, e.g.17:12.0.04 MWcharging capacity and target1 MWh.17:00, but projects it onto the scheduling ticks as an adjusted previous-tick bound and a next-tick target.relax-soc-constraints.Projection policy
The scheduler can enforce SoC constraints only on its scheduling ticks. For point-like off-tick SoC events:
soc-targetsare projected to an exact target on the next scheduling tick, with capacity-adjusted lower and upper bounds on the previous tick.soc-minimaare projected as lower bounds on the surrounding ticks, adjusted by reachable charge/discharge capacity.soc-maximaare projected as upper bounds on the surrounding ticks, adjusted by reachable charge/discharge capacity.Related Items
Follow-up to PR #2146 review discussion around off-tick storage SoC constraints.
Sign-off