Skip to content

test: multi-session same-sensor schedules accumulate (sum)#2344

Open
sankalpsthakur wants to merge 3 commits into
FlexMeasures:mainfrom
sankalpsthakur:test-1947-multi-session-same-sensor
Open

test: multi-session same-sensor schedules accumulate (sum)#2344
sankalpsthakur wants to merge 3 commits into
FlexMeasures:mainfrom
sankalpsthakur:test-1947-multi-session-same-sensor

Conversation

@sankalpsthakur

@sankalpsthakur sankalpsthakur commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #1947

Completes the regression-test slice discussed after #1948. Documentation example deferred pending product discussion (nhoening).

Core fix was #1948 (storage_schedule[sensor] += ...). This PR only locks that in with focused tests maintainers asked for (high value / low effort).

Impact

Severity: silent schedule loss — with multiple flex-model entries on one power sensor (common for EV sessions on a single charge point), only the last session's schedule was kept. Earlier sessions were overwritten with no error.

Before #1948: two non-overlapping 2 kWh sessions on one sensor → ~2 kWh delivered (first half zeros). After: ~4 kWh (both halves active).

Look & Feel

N/A (test-only).

Non-overlapping

Window Session Power
hours 0–1 session 1 1 kW
hours 2–3 session 2 1 kW

Overlapping (capacity pre-split)

Both sessions active all 4 hours at 0.5 kW each (pre-allocation per Flix6x on #1947):

  • Correct (sum): [1, 1, 1, 1] kW (~4 kWh)
  • Overwrite: ~0.5 kW (~2 kWh)

How to test

pytest \
  flexmeasures/data/models/planning/tests/test_storage.py::test_multiple_sessions_same_sensor_accumulate_schedules \
  flexmeasures/data/models/planning/tests/test_storage.py::test_multiple_sessions_same_sensor_accumulate_overlapping_windows \
  -v

Further Improvements

Related Items


Sign-off

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

@read-the-docs-community

read-the-docs-community Bot commented Jul 22, 2026

Copy link
Copy Markdown

@sankalpsthakur
sankalpsthakur force-pushed the test-1947-multi-session-same-sensor branch 2 times, most recently from 81ae216 to b7b2d6d Compare July 22, 2026 18:24
Regression for FlexMeasures#1947 after core fix FlexMeasures#1948: two flex-model sessions
sharing one power sensor must return a summed schedule, not overwrite.

Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
Strengthen the non-overlap regression with per-half assertions and add
a companion case where capacity is pre-split across concurrent sessions
on one power sensor (sum, not overwrite).

Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
@sankalpsthakur
sankalpsthakur force-pushed the test-1947-multi-session-same-sensor branch from d446240 to 6632b8a Compare July 22, 2026 19:03
@Flix6x
Flix6x requested a review from Ahmad-Wahid July 22, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StorageScheduler overwrites schedules when multiple sessions use the same sensor

1 participant