Feat/offtick soc normalization#2194
Open
BelhsanHmida wants to merge 11 commits into
Open
Conversation
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>
7 tasks
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Contributor
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>
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
soc-targets,soc-minima, andsoc-maxima.relax-soc-constraintswhen off-tick SoC constraints are submitted, so generated/adjusted constraints can be softened safely.Look & Feel
N/A
How to test
.venv/bin/pytest flexmeasures/api/v3_0/tests/test_sensor_schedules.py flexmeasures/data/schemas/tests/test_scheduling.py flexmeasures/data/models/planning/tests/test_storage.py -q PATH="$PWD/.venv/bin:$PATH" .venv/bin/pre-commit run --all-filesManual test:
soc-target, e.g.17:12.0.04 MWcharging capacity and target1 MWh.17:00, but projects it onto the grid as an adjusted previous-tick bound and a next-tick target.relax-soc-constraints.Further Improvements
soc-minima/soc-maxima/soc-targets.Related Items
Follow-up to PR #2146 review discussion around off-tick storage SoC constraints.
Sign-off