Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/multi asset StorageScheduler #1313

Draft
wants to merge 131 commits into
base: main
Choose a base branch
from

Conversation

Tammevesky
Copy link
Contributor

@Tammevesky Tammevesky commented Jan 21, 2025

Description

  • New service to create_sequential_scheduling_job
  • New service to create_simultaneous_scheduling_job
  • Test new services
  • Schema used by StorageScheduler accepts multi-asset flex-models
  • StorageScheduler transforms multi-asset flex-models into device_scheduler input

Look & Feel

This section can contain example pictures for UI, Input/Output for CLI, Request / Response for API endpoint, etc.

How to test

  • test_ceate_sequential_scheduling_job
  • test_ceate_simultaneous_scheduling_job
  • flexmeasures-client is not yet compatible, because the API is not yet compatible. This PR is only for (plugin) developers.

Further Improvements

In scope:

  • Added changelog item in documentation/changelog.rst under 'Infrastructure / Support' section, targeting (plugin) developers in this particular PR.

Follow-up issue:

Related Items

Mention if this PR closes an Issue or Project.

Flix6x and others added 30 commits May 16, 2024 16:56
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: Victor Garcia Reolid <[email protected]>
Signed-off-by: Victor Garcia Reolid <[email protected]>
…ing-asset' into feature/api/endpoint-for-scheduling-asset
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.

Self-review, incl. 1 suggestion for @Tammevesky to take up.

flexmeasures/data/schemas/generic_assets.py Outdated Show resolved Hide resolved
@@ -211,3 +219,91 @@ def _get_variable_quantity_unit(
f"Unexpected type '{type(variable_quantity)}' for '{field}': {variable_quantity}."
)
return unit


class SequentialFlexModelSchema(Schema):
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently being used for both simultaneous and sequential multi-asset scheduling, but not meant to be used for the simultaneous case. Misusing it for that is likely causing the double nesting of the sensor-flex-model field.

return {"sensor-flex-model": extra, **rest}


class AssetTriggerSchema(Schema):
Copy link
Contributor

Choose a reason for hiding this comment

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

Cherry-picked, but currently not used in this PR. May belong in #1065 instead.

flexmeasures/data/schemas/sensors.py Outdated Show resolved Hide resolved
) -> list[Job]:
jobs = []

# scheduler_kwargs["resolution"] = sensor.event_resolution # todo: needed?
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding a test involving two flexible devices with different resolutions should clear this up.

force_new_job_creation: bool = False,
scheduler_specs: dict | None = None,
depends_on: list[Job] | None = None,
**scheduler_kwargs,
Copy link
Contributor

Choose a reason for hiding this comment

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

scheduler_kwargs is in desperate need of a docstring example, especially for its flex_model after we'll (partially?) deserialize it by passing it through a to-be-created SimultaneousFlexModelSchema.

force_new_job_creation: bool = False,
scheduler_specs: dict | None = None,
depends_on: list[Job] | None = None,
**scheduler_kwargs,
Copy link
Contributor

Choose a reason for hiding this comment

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

scheduler_kwargs is in desperate need of a docstring example, especially for its flex_model, which is partially deserialized after passing through SequentialFlexModelSchema.

Comment on lines +72 to +73
assert all(ev_power.loc[start_charging:end_charging] == -0.01) # 10 kW
assert all(battery_power.loc[start_charging:end_charging] == 0.01) # 10 kW
Copy link
Contributor

Choose a reason for hiding this comment

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

@svenay We should adjust this test so our expectations here differ from that of the sequential case.


if soc_targets and not isinstance(soc_targets, Sensor):
max_target_datetime = max([soc_target["end"] for soc_target in soc_targets])
if max_target_datetime > self.end:
max_server_horizon = get_max_planning_horizon(self.resolution)
Copy link
Contributor

Choose a reason for hiding this comment

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

My first thought is that this function still does what it is supposed to do, namely extending the planning horizon if needed, therein taking into account the resolution of each device's power sensor. But it deserves a closer look, especially regarding how the horizon is derived using the resolution.

flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
Flix6x added 21 commits January 31, 2025 09:57
…straints for device d rather than device 0.

Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
…a future version, please use 'h' instead.

Signed-off-by: F.N. Claessen <[email protected]>
…fields is deprecated. Use 'dump_default' instead.

Signed-off-by: F.N. Claessen <[email protected]>
…ated with new scheduler data source "<Data source 12 (None's SuccessfulScheduler model vNone)>".`

Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
This reverts commit bad7cba.
Signed-off-by: F.N. Claessen <[email protected]>
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.

3 participants