Skip to content

Commit 14eee2d

Browse files
committed
Rename parameter in_shifting_groupset_operating_point
This is part of the public interface in the constructors for the `*_pool`s in the data pipeline, but other than that, all changes are internal, except for the documentation. This commit updates all occurrences, docstrings, documentation and release notes to reflect the new name. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent bfc8de2 commit 14eee2d

File tree

10 files changed

+111
-111
lines changed

10 files changed

+111
-111
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
## New Features
2626

27-
- Calls to `microgrid.*_pool` methods now accept an optional `in_shifting_group` parameter. Power requests sent to `*_pool` instances that have the `in_shifting_group` flag set, will get resolved separately, and their target power will be added to the target power calculated from regular actors, if any, which would, in effect, shift the zero for the regular actors by the target power from the shifting group.
27+
- Calls to `microgrid.*_pool` methods now accept an optional `set_operating_point` parameter, for setting an operating point for the other actors. This would shift the target power by the operating point before actually applying it to the components.
2828

2929
## Bug Fixes
3030

src/frequenz/sdk/actor/_power_managing/_base_classes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class ReportRequest:
3333
priority: int
3434
"""The priority of the actor ."""
3535

36-
in_shifting_group: bool
37-
"""Whether the proposal gets sent to the shifting group of the power manager."""
36+
set_operating_point: bool
37+
"""Whether this proposal sets the operating point power or the normal power."""
3838

3939
def get_channel_name(self) -> str:
4040
"""Get the channel name for the report request.
@@ -219,8 +219,8 @@ class Proposal:
219219
request_timeout: datetime.timedelta = datetime.timedelta(seconds=5.0)
220220
"""The maximum amount of time to wait for the request to be fulfilled."""
221221

222-
in_shifting_group: bool
223-
"""Whether the proposal gets sent to the shifting group of the power manager."""
222+
set_operating_point: bool
223+
"""Whether this proposal sets the operating point power or the normal power."""
224224

225225
def __lt__(self, other: Proposal) -> bool:
226226
"""Compare two proposals by their priority.

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

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@ def __init__( # pylint: disable=too-many-arguments
8585

8686
self._system_bounds: dict[frozenset[int], SystemBounds] = {}
8787
self._bound_tracker_tasks: dict[frozenset[int], asyncio.Task[None]] = {}
88-
self._non_shifting_subscriptions: dict[
88+
self._set_power_subscriptions: dict[
8989
frozenset[int], dict[int, Sender[_Report]]
9090
] = {}
91-
self._shifting_subscriptions: dict[
91+
self._set_op_power_subscriptions: dict[
9292
frozenset[int], dict[int, Sender[_Report]]
9393
] = {}
9494
self._distribution_results: dict[frozenset[int], power_distributing.Result] = {}
9595

96-
self._non_shifting_group: BaseAlgorithm = Matryoshka(
96+
self._set_power_group: BaseAlgorithm = Matryoshka(
9797
max_proposal_age=timedelta(seconds=60.0)
9898
)
99-
self._shifting_group: BaseAlgorithm = Matryoshka(
99+
self._set_op_power_group: BaseAlgorithm = Matryoshka(
100100
max_proposal_age=timedelta(seconds=60.0)
101101
)
102102

@@ -113,25 +113,25 @@ async def _send_reports(self, component_ids: frozenset[int]) -> None:
113113
if bounds is None:
114114
_logger.warning("PowerManagingActor: No bounds for %s", component_ids)
115115
return
116-
for priority, sender in self._shifting_subscriptions.get(
116+
for priority, sender in self._set_op_power_subscriptions.get(
117117
component_ids, {}
118118
).items():
119-
status = self._shifting_group.get_status(
119+
status = self._set_op_power_group.get_status(
120120
component_ids,
121121
priority,
122122
bounds,
123123
self._distribution_results.get(component_ids),
124124
)
125125
await sender.send(status)
126-
for priority, sender in self._non_shifting_subscriptions.get(
126+
for priority, sender in self._set_power_subscriptions.get(
127127
component_ids, {}
128128
).items():
129-
status = self._non_shifting_group.get_status(
129+
status = self._set_power_group.get_status(
130130
component_ids,
131131
priority,
132132
self._calculate_shifted_bounds(
133133
bounds,
134-
self._shifting_group.get_target_power(component_ids),
134+
self._set_op_power_group.get_target_power(component_ids),
135135
),
136136
self._distribution_results.get(component_ids),
137137
)
@@ -209,34 +209,34 @@ def _add_system_bounds_tracker(self, component_ids: frozenset[int]) -> None:
209209
)
210210

211211
def _calculate_shifted_bounds(
212-
self, bounds: SystemBounds, target_power: Power | None
212+
self, bounds: SystemBounds, op_power: Power | None
213213
) -> SystemBounds:
214-
"""Calculate the shifted bounds corresponding to shifting group's target power.
214+
"""Calculate the shifted bounds shifted by the operating point power.
215215
216216
Any value regular actors choose within these bounds can be shifted by the
217-
shifting power and still remain within the actual system bounds.
217+
operating point power and still remain within the actual system bounds.
218218
219-
| system bounds | shifting | shifted |
220-
| | target power | bounds |
221-
|---------------+--------------+------------|
222-
| -100 to 100 | 70 | -170 to 30 |
223-
| -100 to 100 | -50 | -50 to 150 |
219+
| system bounds | operating | shifted |
220+
| | point power | bounds |
221+
|---------------+-------------+------------|
222+
| -100 to 100 | 70 | -170 to 30 |
223+
| -100 to 100 | -50 | -50 to 150 |
224224
225225
Args:
226226
bounds: The bounds to calculate the remaining bounds from.
227-
target_power: The target power to apply.
227+
op_power: The operating point power to shift by.
228228
229229
Returns:
230230
The remaining bounds.
231231
"""
232-
if target_power is None:
232+
if op_power is None:
233233
return bounds
234234

235235
inclusion_bounds: Bounds[Power] | None = None
236236
if bounds.inclusion_bounds is not None:
237237
inclusion_bounds = Bounds(
238-
bounds.inclusion_bounds.lower - target_power,
239-
bounds.inclusion_bounds.upper - target_power,
238+
bounds.inclusion_bounds.lower - op_power,
239+
bounds.inclusion_bounds.upper - op_power,
240240
)
241241
return SystemBounds(
242242
timestamp=bounds.timestamp,
@@ -252,8 +252,7 @@ def _calculate_target_power(
252252
) -> Power | None:
253253
"""Calculate the target power for a set of components.
254254
255-
This is the power from the non-shifting group, shifted by the power from the
256-
shifting group.
255+
This is the target power, shifted by the operating point power.
257256
258257
Args:
259258
component_ids: The component IDs for which to calculate the target power.
@@ -267,14 +266,14 @@ def _calculate_target_power(
267266
tgt_power_shift: Power | None = None
268267
tgt_power_no_shift: Power | None = None
269268
if proposal is not None:
270-
if proposal.in_shifting_group:
271-
tgt_power_shift = self._shifting_group.calculate_target_power(
269+
if proposal.set_operating_point:
270+
tgt_power_shift = self._set_op_power_group.calculate_target_power(
272271
component_ids,
273272
proposal,
274273
self._system_bounds[component_ids],
275274
must_send,
276275
)
277-
tgt_power_no_shift = self._non_shifting_group.calculate_target_power(
276+
tgt_power_no_shift = self._set_power_group.calculate_target_power(
278277
component_ids,
279278
None,
280279
self._calculate_shifted_bounds(
@@ -283,13 +282,13 @@ def _calculate_target_power(
283282
must_send,
284283
)
285284
else:
286-
tgt_power_no_shift = self._non_shifting_group.calculate_target_power(
285+
tgt_power_no_shift = self._set_power_group.calculate_target_power(
287286
component_ids,
288287
proposal,
289288
self._system_bounds[component_ids],
290289
must_send,
291290
)
292-
tgt_power_shift = self._shifting_group.calculate_target_power(
291+
tgt_power_shift = self._set_op_power_group.calculate_target_power(
293292
component_ids,
294293
None,
295294
self._calculate_shifted_bounds(
@@ -298,13 +297,13 @@ def _calculate_target_power(
298297
must_send,
299298
)
300299
else:
301-
tgt_power_no_shift = self._non_shifting_group.calculate_target_power(
300+
tgt_power_no_shift = self._set_power_group.calculate_target_power(
302301
component_ids,
303302
None,
304303
self._system_bounds[component_ids],
305304
must_send,
306305
)
307-
tgt_power_shift = self._shifting_group.calculate_target_power(
306+
tgt_power_shift = self._set_op_power_group.calculate_target_power(
308307
component_ids,
309308
None,
310309
self._calculate_shifted_bounds(
@@ -378,12 +377,12 @@ async def _run(self) -> None:
378377
sub = selected.message
379378
component_ids = sub.component_ids
380379
priority = sub.priority
381-
in_shifting_group = sub.in_shifting_group
380+
set_operating_point = sub.set_operating_point
382381

383382
subs_set = (
384-
self._shifting_subscriptions
385-
if in_shifting_group
386-
else self._non_shifting_subscriptions
383+
self._set_op_power_subscriptions
384+
if set_operating_point
385+
else self._set_power_subscriptions
387386
)
388387

389388
if component_ids not in subs_set:
@@ -427,7 +426,9 @@ async def _run(self) -> None:
427426
await self._send_reports(frozenset(result.request.component_ids))
428427

429428
elif selected_from(selected, drop_old_proposals_timer):
430-
self._non_shifting_group.drop_old_proposals(
429+
self._set_power_group.drop_old_proposals(
430+
asyncio.get_event_loop().time()
431+
)
432+
self._set_op_power_group.drop_old_proposals(
431433
asyncio.get_event_loop().time()
432434
)
433-
self._shifting_group.drop_old_proposals(asyncio.get_event_loop().time())

src/frequenz/sdk/microgrid/__init__.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -186,40 +186,39 @@
186186
[`propose_power`][frequenz.sdk.timeseries.battery_pool.BatteryPool.propose_power]
187187
methods.
188188
189-
### Shifting the target power by an offset
189+
### Shifting the target power by an Operating Point power
190190
191-
There are cases where the target power needs to be shifted by a certain amount, for
192-
example, to make adjustments to the operating point. This can be done by designating
193-
some actors to be part of the `shifting_group`.
191+
There are cases where the target power needs to be shifted by an operating point. This
192+
can be done by designating some actors to be able to set only the operating point power.
194193
195194
When creating a `*Pool` instance using the above-mentioned constructors, an optional
196-
`in_shifting_group` parameter can be passed to specify that this actor is special, and
197-
the target power of the regular actors will be shifted by the target power of all
198-
shifting actors together.
195+
`set_operating_point` parameter can be passed to specify that this actor is special, and
196+
the target power of the regular actors will be shifted by the target power of all actors
197+
with `set_operating_point` together.
199198
200-
In a location with 2 regular actors and 1 shifting actor, here's how things
199+
In a location with 2 regular actors and 1 `set_operating_point` actor, here's how things
201200
would play out:
202201
203-
1. When only non-shifting actors have made proposals, the power bounds available
204-
from the batteries are available to them exactly.
202+
1. When only regular actors have made proposals, the power bounds available from the
203+
batteries are available to them exactly.
205204
206-
| actor priority | in shifting group? | proposed power/bounds | available bounds |
207-
|----------------|--------------------|-----------------------|------------------|
208-
| 3 | No | 1000, -4000..2500 | -3000..3000 |
209-
| 2 | No | 2500 | -3000..2500 |
210-
| 1 | Yes | None | -3000..3000 |
205+
| actor priority | in op group? | proposed power/bounds | available bounds |
206+
|----------------|--------------|-----------------------|------------------|
207+
| 3 | No | 1000, -4000..2500 | -3000..3000 |
208+
| 2 | No | 2500 | -3000..2500 |
209+
| 1 | Yes | None | -3000..3000 |
211210
212211
Power actually distributed to the batteries: 2500W
213212
214-
2. When the shifting actor has made proposals, the bounds available to the
215-
regular actors gets shifted, and the final power that actually gets
216-
distributed to the batteries is also shifted.
213+
2. When the `set_operating_point` actor has made proposals, the bounds available to the
214+
regular actors gets shifted, and the final power that actually gets distributed to
215+
the batteries is also shifted.
217216
218-
| actor priority | in shifting group? | proposed power/bounds | available bounds |
219-
|----------------|--------------------|-----------------------|------------------|
220-
| 3 | No | 1000, -4000..2500 | -2000..4000 |
221-
| 2 | No | 2500 | -2000..2500 |
222-
| 1 | Yes | -1000 | -3000..3000 |
217+
| actor priority | in op group? | proposed power/bounds | available bounds |
218+
|----------------|--------------|-----------------------|------------------|
219+
| 3 | No | 1000, -4000..2500 | -2000..4000 |
220+
| 2 | No | 2500 | -2000..2500 |
221+
| 1 | Yes | -1000 | -3000..3000 |
223222
224223
Power actually distributed to the batteries: 1500W
225224
""" # noqa: D205, D400

0 commit comments

Comments
 (0)