Skip to content

Conversation

@shsms
Copy link
Contributor

@shsms shsms commented May 31, 2024

There are cases where the target power needs to be shifted by a certain amount, for example, to make adjustments to the operating point. This PR enables this by designating some actors to be part of the shifting_group.

Closes #905

@shsms shsms self-assigned this May 31, 2024
@shsms shsms requested a review from a team as a code owner May 31, 2024 08:32
@shsms shsms requested a review from llucax May 31, 2024 08:32
@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:data-pipeline Affects the data pipeline part:actor Affects an actor ot the actors utilities (decorator, etc.) part:microgrid Affects the interactions with the microgrid labels May 31, 2024
Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

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

I gave this a quick look, I still have to look at the commit doing the actual implementation in more detail, but I have a couple of comments:

  1. It is still no 100% clear what incremental means here. It might be nice to add some better description to the PR and maybe even the docs, like one example with a few actors some using incremental and some not, and seeing what difference does it make in terms of what is the resulting power.

  2. It looks like you have at least subscriptions and pools grouped in incremental and not incremental. It might be worth adding some class (not sure what it is exactly? Power requests? Algorithms?) that have 2 members, pool and subscriptions, and I don't know, maybe there is some more common code to manipulate both that can go there too. Maybe it doesn't make sense, not sure, as I said I only gave a quick look but it is something that popped out when looking at the commits.

@shsms shsms marked this pull request as draft June 4, 2024 09:51
@shsms
Copy link
Contributor Author

shsms commented Jun 4, 2024

Draft until I finish the renaming to shifting_group.

@llucax
Copy link
Contributor

llucax commented Jun 4, 2024

No in_? 😆

@shsms
Copy link
Contributor Author

shsms commented Jun 4, 2024

in_ in the argument names and class fields.

@shsms shsms force-pushed the incremental-power branch from b9403b7 to 62e0552 Compare June 4, 2024 13:35
@shsms shsms changed the title Support power requests from incremental actors in the PowerManager Support power requests from shifting actors in the PowerManager Jun 5, 2024
@shsms shsms force-pushed the incremental-power branch from 62e0552 to 8697321 Compare June 5, 2024 09:07
shsms added 8 commits June 5, 2024 14:43
The older name was a bit ambiguous, because there are also bounds
calculated by the power manager for use by actors.

This change clears this ambiguity.

Signed-off-by: Sahas Subramanian <[email protected]>
This would return the most recently calculated target power for a
given set of components.

Signed-off-by: Sahas Subramanian <[email protected]>
And propagate it all the way to the power manager.

Signed-off-by: Sahas Subramanian <[email protected]>
This is done by having an additional `Matryoshka` instance for
resolving requests from shifting actors.  And the target power thus
obtained is added to the target power from the regular actors, which
in effect, shifts the target power of the regular actors by the target
power of the shifting actors.

Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
@shsms shsms force-pushed the incremental-power branch from 8697321 to fc889ee Compare June 5, 2024 13:41
@shsms shsms marked this pull request as ready for review June 5, 2024 13:46
llucax
llucax previously approved these changes Jun 6, 2024
Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

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

I really like how this turned up! And the new documentation is great, it makes things so much clearer!

I made several comments but they are all part of the same thing, a proposal to have a specific class for managing pool groups, as I mentioned in my first review.

I really think it could simplify the code quite a bit and remove some duplication. If you agree, I think this refactoring should be done in a separate PR since I don't have any other comments other than that, I think it would be a good idea to merge this PR as is to keep things moving. So approving.

name: An optional name used to identify this instance of the pool or a
corresponding actor in the logs.
in_shifting_group: Whether the power requests get sent to the shifting group
in the PowerManager or not.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to include a link to the shifting group docs in here (and in every place that receives a in_shifting_group). I will be quite verbose, but we can greatly simplify it by creating a [macro like we did for linking to the glossary][https://github.com/frequenz-floss/frequenz-sdk-python/blob/8e5d65e383442c3fa85060e985e225d5e6412a9e/docs/_scripts/macros.py#L79-L97].

Comment on lines -87 to +99
self._subscriptions: dict[frozenset[int], dict[int, Sender[_Report]]] = {}
self._non_shifting_subscriptions: dict[
frozenset[int], dict[int, Sender[_Report]]
] = {}
self._shifting_subscriptions: dict[
frozenset[int], dict[int, Sender[_Report]]
] = {}
self._distribution_results: dict[frozenset[int], power_distributing.Result] = {}

self._algorithm: BaseAlgorithm = Matryoshka(
self._non_shifting_group: BaseAlgorithm = Matryoshka(
max_proposal_age=timedelta(seconds=60.0)
)
self._shifting_group: BaseAlgorithm = Matryoshka(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not going to insist a lot on this because I don't want to keep focusing on bikeshedding, but I though it out there just in case you agree it could bring some extra clarity. Back to my previous suggestion of grouping the groups, what about having something like:

class PoolGroup:
    algorithm: BaseAlgorithm
    subscriptions: dict[...]
    # Again, I'm not sure if there are common operations with
    # these algorithm and subscriptions that could be moved here too.

class PowerManagingActor(Actor):
    def __init__(self, ...):
        self._default_group = PoolGroup(...)
        self._shifting_group = PoolGroup(...)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we end up adding more than two groups, I think it makes sense to refactor at that time. For now, I'm not sure it is worth the effort, the code is not really that complicated the way it is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I created an issue just so it doesn't get lost, but I agree is OK as it is for now:

@llucax
Copy link
Contributor

llucax commented Jun 6, 2024

Oh, right, there is also the cross referencing of in_shifting_group to the high-level docs of what a shifting group is, but that's also optional and I don't mind if that's also done in a separate PR.

@llucax
Copy link
Contributor

llucax commented Jun 6, 2024

It looks like DCO is still not working

Co-authored-by: Leandro Lucarella <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
Also update the function's docstring.

Signed-off-by: Sahas Subramanian <[email protected]>
@shsms shsms requested a review from llucax June 7, 2024 08:36
@shsms shsms added this pull request to the merge queue Jun 7, 2024
Merged via the queue into frequenz-floss:v1.x.x with commit d5d74a3 Jun 7, 2024
@shsms shsms deleted the incremental-power branch June 7, 2024 14:05
shsms added a commit to shsms/frequenz-sdk-python that referenced this pull request Jan 10, 2025
shsms added a commit to shsms/frequenz-sdk-python that referenced this pull request Jan 15, 2025
…er (frequenz-floss#957)"

This reverts commit d5d74a3, reversing
changes made to 8e5d65e.

Signed-off-by: Sahas Subramanian <[email protected]>
shsms added a commit to shsms/frequenz-sdk-python that referenced this pull request Jan 28, 2025
…er (frequenz-floss#957)"

This reverts commit d5d74a3, reversing
changes made to 8e5d65e.

Signed-off-by: Sahas Subramanian <[email protected]>
shsms added a commit to shsms/frequenz-sdk-python that referenced this pull request Mar 19, 2025
…er (frequenz-floss#957)"

This reverts commit d5d74a3, reversing
changes made to 8e5d65e.

Signed-off-by: Sahas Subramanian <[email protected]>
shsms added a commit to shsms/frequenz-sdk-python that referenced this pull request Mar 20, 2025
…er (frequenz-floss#957)"

This reverts commit d5d74a3, reversing
changes made to 8e5d65e.

Signed-off-by: Sahas Subramanian <[email protected]>
shsms added a commit to shsms/frequenz-sdk-python that referenced this pull request Mar 21, 2025
…er (frequenz-floss#957)"

This reverts commit d5d74a3, reversing
changes made to 8e5d65e.

Signed-off-by: Sahas Subramanian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:actor Affects an actor ot the actors utilities (decorator, etc.) part:data-pipeline Affects the data pipeline part:docs Affects the documentation part:microgrid Affects the interactions with the microgrid part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

Development

Successfully merging this pull request may close these issues.

Support multiple Matryoshka pools in the Power Manager that can be aggregated

2 participants