Skip to content

Commit c2b263b

Browse files
committed
Use the additive ShiftingMatryoshka algorithm only for batteries
And revert back to plain Matryoshka for PV and EV chargers. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 2036409 commit c2b263b

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from frequenz.channels import Broadcast, Sender
2020
from frequenz.client.microgrid import ComponentCategory, InverterType
2121

22+
from frequenz.sdk.microgrid._power_managing._base_classes import Algorithm
23+
2224
from .._internal._channels import ChannelRegistry
2325
from ..actor._actor import Actor
2426
from ..timeseries import ResamplerConfig
@@ -103,16 +105,19 @@ def __init__(
103105
self._battery_power_wrapper = PowerWrapper(
104106
self._channel_registry,
105107
api_power_request_timeout=api_power_request_timeout,
108+
power_manager_algorithm=Algorithm.SHIFTING_MATRYOSHKA,
106109
component_category=ComponentCategory.BATTERY,
107110
)
108111
self._ev_power_wrapper = PowerWrapper(
109112
self._channel_registry,
110113
api_power_request_timeout=api_power_request_timeout,
114+
power_manager_algorithm=Algorithm.MATRYOSHKA,
111115
component_category=ComponentCategory.EV_CHARGER,
112116
)
113117
self._pv_power_wrapper = PowerWrapper(
114118
self._channel_registry,
115119
api_power_request_timeout=api_power_request_timeout,
120+
power_manager_algorithm=Algorithm.MATRYOSHKA,
116121
component_category=ComponentCategory.INVERTER,
117122
component_type=InverterType.SOLAR,
118123
)

src/frequenz/sdk/microgrid/_power_managing/_power_managing_actor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ def __init__( # pylint: disable=too-many-arguments
3939
power_distributing_requests_sender: Sender[_power_distributing.Request],
4040
power_distributing_results_receiver: Receiver[_power_distributing.Result],
4141
channel_registry: ChannelRegistry,
42+
algorithm: Algorithm,
4243
component_category: ComponentCategory,
4344
component_type: ComponentType | None = None,
44-
# arguments to actors need to serializable, so we pass an enum for the algorithm
45-
# instead of an instance of the algorithm.
46-
algorithm: Algorithm = Algorithm.SHIFTING_MATRYOSHKA,
4745
):
4846
"""Create a new instance of the power manager.
4947
@@ -55,6 +53,7 @@ def __init__( # pylint: disable=too-many-arguments
5553
power_distributing_results_receiver: The receiver for power distribution
5654
results.
5755
channel_registry: The channel registry.
56+
algorithm: The power management algorithm to use.
5857
component_category: The category of the component this power manager
5958
instance is going to support.
6059
component_type: The type of the component of the given category that this
@@ -64,7 +63,6 @@ def __init__( # pylint: disable=too-many-arguments
6463
the inverter as a solar inverter or a battery inverter. This can be
6564
`None` when the component category is enough to uniquely identify the
6665
component.
67-
algorithm: The power management algorithm to use.
6866
"""
6967
self._component_category = component_category
7068
self._component_type = component_type

src/frequenz/sdk/microgrid/_power_wrapper.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@
2323
Request,
2424
Result,
2525
)
26+
from ._power_managing._base_classes import Algorithm
2627

2728
_logger = logging.getLogger(__name__)
2829

2930

3031
class PowerWrapper:
3132
"""Wrapper around the power managing and power distributing actors."""
3233

33-
def __init__(
34+
def __init__( # pylint: disable=too-many-arguments
3435
self,
3536
channel_registry: ChannelRegistry,
3637
*,
3738
api_power_request_timeout: timedelta,
39+
power_manager_algorithm: Algorithm,
3840
component_category: ComponentCategory,
3941
component_type: ComponentType | None = None,
4042
):
@@ -44,6 +46,7 @@ def __init__(
4446
channel_registry: A channel registry for use in the actors.
4547
api_power_request_timeout: Timeout to use when making power requests to
4648
the microgrid API.
49+
power_manager_algorithm: The power management algorithm to use.
4750
component_category: The category of the components that actors started by
4851
this instance of the PowerWrapper will be responsible for.
4952
component_type: The type of the component of the given category that this
@@ -56,6 +59,7 @@ def __init__(
5659
"""
5760
self._component_category = component_category
5861
self._component_type = component_type
62+
self._power_manager_algorithm = power_manager_algorithm
5963
self._channel_registry = channel_registry
6064
self._api_power_request_timeout = api_power_request_timeout
6165

@@ -101,6 +105,7 @@ def _start_power_managing_actor(self) -> None:
101105
self._power_managing_actor = _power_managing.PowerManagingActor(
102106
component_category=self._component_category,
103107
component_type=self._component_type,
108+
algorithm=self._power_manager_algorithm,
104109
proposals_receiver=self.proposal_channel.new_receiver(),
105110
bounds_subscription_receiver=(
106111
self.bounds_subscription_channel.new_receiver()

0 commit comments

Comments
 (0)