diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 61ee6f2ad..cc77df3d2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,17 +1,5 @@ # Frequenz Python SDK Release Notes -## Summary - - - -## Upgrading - - - -## New Features - - - ## Bug Fixes - +- The additive `ShiftingMatryoshka` algorithm was made for batteries, but got set as the default algorithm for PV and EV chargers. This is now reversed and PV and EV chargers are back to using the original `Matryoshka` algorithm. diff --git a/src/frequenz/sdk/microgrid/_data_pipeline.py b/src/frequenz/sdk/microgrid/_data_pipeline.py index b1714398c..696ed32ae 100644 --- a/src/frequenz/sdk/microgrid/_data_pipeline.py +++ b/src/frequenz/sdk/microgrid/_data_pipeline.py @@ -19,6 +19,8 @@ from frequenz.channels import Broadcast, Sender from frequenz.client.microgrid import ComponentCategory, InverterType +from frequenz.sdk.microgrid._power_managing._base_classes import Algorithm + from .._internal._channels import ChannelRegistry from ..actor._actor import Actor from ..timeseries import ResamplerConfig @@ -103,16 +105,19 @@ def __init__( self._battery_power_wrapper = PowerWrapper( self._channel_registry, api_power_request_timeout=api_power_request_timeout, + power_manager_algorithm=Algorithm.SHIFTING_MATRYOSHKA, component_category=ComponentCategory.BATTERY, ) self._ev_power_wrapper = PowerWrapper( self._channel_registry, api_power_request_timeout=api_power_request_timeout, + power_manager_algorithm=Algorithm.MATRYOSHKA, component_category=ComponentCategory.EV_CHARGER, ) self._pv_power_wrapper = PowerWrapper( self._channel_registry, api_power_request_timeout=api_power_request_timeout, + power_manager_algorithm=Algorithm.MATRYOSHKA, component_category=ComponentCategory.INVERTER, component_type=InverterType.SOLAR, ) diff --git a/src/frequenz/sdk/microgrid/_power_managing/_power_managing_actor.py b/src/frequenz/sdk/microgrid/_power_managing/_power_managing_actor.py index 451657672..5b95d65c9 100644 --- a/src/frequenz/sdk/microgrid/_power_managing/_power_managing_actor.py +++ b/src/frequenz/sdk/microgrid/_power_managing/_power_managing_actor.py @@ -39,11 +39,9 @@ def __init__( # pylint: disable=too-many-arguments power_distributing_requests_sender: Sender[_power_distributing.Request], power_distributing_results_receiver: Receiver[_power_distributing.Result], channel_registry: ChannelRegistry, + algorithm: Algorithm, component_category: ComponentCategory, component_type: ComponentType | None = None, - # arguments to actors need to serializable, so we pass an enum for the algorithm - # instead of an instance of the algorithm. - algorithm: Algorithm = Algorithm.SHIFTING_MATRYOSHKA, ): """Create a new instance of the power manager. @@ -55,6 +53,7 @@ def __init__( # pylint: disable=too-many-arguments power_distributing_results_receiver: The receiver for power distribution results. channel_registry: The channel registry. + algorithm: The power management algorithm to use. component_category: The category of the component this power manager instance is going to support. component_type: The type of the component of the given category that this @@ -64,7 +63,6 @@ def __init__( # pylint: disable=too-many-arguments the inverter as a solar inverter or a battery inverter. This can be `None` when the component category is enough to uniquely identify the component. - algorithm: The power management algorithm to use. """ self._component_category = component_category self._component_type = component_type diff --git a/src/frequenz/sdk/microgrid/_power_wrapper.py b/src/frequenz/sdk/microgrid/_power_wrapper.py index 6f7f9ad61..9bd2f51bc 100644 --- a/src/frequenz/sdk/microgrid/_power_wrapper.py +++ b/src/frequenz/sdk/microgrid/_power_wrapper.py @@ -23,6 +23,7 @@ Request, Result, ) +from ._power_managing._base_classes import Algorithm _logger = logging.getLogger(__name__) @@ -30,11 +31,12 @@ class PowerWrapper: """Wrapper around the power managing and power distributing actors.""" - def __init__( + def __init__( # pylint: disable=too-many-arguments self, channel_registry: ChannelRegistry, *, api_power_request_timeout: timedelta, + power_manager_algorithm: Algorithm, component_category: ComponentCategory, component_type: ComponentType | None = None, ): @@ -44,6 +46,7 @@ def __init__( channel_registry: A channel registry for use in the actors. api_power_request_timeout: Timeout to use when making power requests to the microgrid API. + power_manager_algorithm: The power management algorithm to use. component_category: The category of the components that actors started by this instance of the PowerWrapper will be responsible for. component_type: The type of the component of the given category that this @@ -56,6 +59,7 @@ def __init__( """ self._component_category = component_category self._component_type = component_type + self._power_manager_algorithm = power_manager_algorithm self._channel_registry = channel_registry self._api_power_request_timeout = api_power_request_timeout @@ -101,6 +105,7 @@ def _start_power_managing_actor(self) -> None: self._power_managing_actor = _power_managing.PowerManagingActor( component_category=self._component_category, component_type=self._component_type, + algorithm=self._power_manager_algorithm, proposals_receiver=self.proposal_channel.new_receiver(), bounds_subscription_receiver=( self.bounds_subscription_channel.new_receiver()