-
Notifications
You must be signed in to change notification settings - Fork 17
Stream exclusion bounds from the battery pool #537
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5ef4d13
Rename internal inclusion-bound variables to latest naming scheme
shsms f4e51f2
Support fetching of exclusion bounds from the data sourcing actor
shsms 6bf4805
Rename BatteryPool.Bound to `Bounds`
shsms 77a4548
Rename fields to power inclusion/exclusion bounds, in battery pool
shsms bbf2a0c
Use `Power` objects to represent power bounds in battery pool
shsms dfa6edf
Refactor inclusion_bounds extraction code to a separate method
shsms a3797b6
Implement fetching and streaming of exclusion bounds in battery pool
shsms 5bb5bb3
Update RELEASE_NOTES.md
shsms 639394c
Replace `Power.from_watts(0)` with `Power.zero()`
llucax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,15 +6,17 @@ | |
from dataclasses import dataclass, field | ||
from datetime import datetime | ||
|
||
from .._quantities import Power | ||
|
||
|
||
@dataclass | ||
class Bound: | ||
class Bounds: | ||
"""Lower and upper bound values.""" | ||
|
||
lower: float | ||
lower: Power | ||
"""Lower bound.""" | ||
|
||
upper: float | ||
upper: Power | ||
"""Upper bound.""" | ||
|
||
|
||
|
@@ -26,38 +28,24 @@ class PowerMetrics: | |
timestamp: datetime = field(compare=False) | ||
"""Timestamp of the metrics.""" | ||
|
||
supply_bound: Bound | ||
"""Supply power bounds. | ||
|
||
Upper bound is always 0 and will be supported later. | ||
Lower bound is negative number calculated with with the formula: | ||
```python | ||
working_pairs: Set[BatteryData, InverterData] # working batteries from the battery | ||
pool and adjacent inverters | ||
|
||
supply_bound.lower = sum( | ||
max( | ||
battery.power_inclusion_lower_bound, inverter.active_power_inclusion_lower_bound) | ||
for each working battery in battery pool | ||
) | ||
) | ||
``` | ||
# pylint: disable=line-too-long | ||
inclusion_bounds: Bounds | ||
"""Inclusion power bounds for all batteries in the battery pool instance. | ||
|
||
This is the range within which power requests are allowed by the battery pool. | ||
|
||
When exclusion bounds are present, they will exclude a subset of the inclusion | ||
bounds. | ||
|
||
More details [here](https://github.com/frequenz-floss/frequenz-api-common/blob/v0.3.0/proto/frequenz/api/common/metrics.proto#L37-L91). | ||
""" | ||
|
||
consume_bound: Bound | ||
"""Consume power bounds. | ||
|
||
Lower bound is always 0 and will be supported later. | ||
Upper bound is positive number calculated with with the formula: | ||
```python | ||
working_pairs: Set[BatteryData, InverterData] # working batteries from the battery | ||
pool and adjacent inverters | ||
|
||
consume_bound.upper = sum( | ||
min( | ||
battery.power_inclusion_upper_bound, inverter.active_power_inclusion_upper_bound) | ||
for each working battery in battery pool | ||
) | ||
) | ||
``` | ||
exclusion_bounds: Bounds | ||
"""Exclusion power bounds for all batteries in the battery pool instance. | ||
|
||
This is the range within which power requests are NOT allowed by the battery pool. | ||
If present, they will be a subset of the inclusion bounds. | ||
|
||
More details [here](https://github.com/frequenz-floss/frequenz-api-common/blob/v0.3.0/proto/frequenz/api/common/metrics.proto#L37-L91). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. |
||
""" | ||
# pylint: enable=line-too-long |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could now point to the generated docs: https://frequenz-floss.github.io/frequenz-api-common/next/python-reference/frequenz/api/common/metrics_pb2/#frequenz.api.common.metrics_pb2.Metric.system_exclusion_bounds
We could even just use python symbols for cross referencing if we add these object indexes:
But for this to work we need to initialize the microgrid API generated docs and we need to tag
v0.3.1
in the common API so we can have a stable link to the docs (for now only thenext
version is provided), so we can update this in a followup PR.(as a nice side-effect we can remove the
# pylint: disable=line-too-long
too, probably :D)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.