Skip to content

Commit 3e402b5

Browse files
committed
Log power allocations per actor in the PowerManager
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 4fe50f7 commit 3e402b5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ def _calc_targets(
9999
top_pri_bounds: Bounds[Power] | None = None
100100

101101
target_power = Power.zero()
102+
103+
allocations: dict[str, str] = {}
104+
102105
for next_proposal in sorted(proposals, reverse=True):
103106
# if a priority is given, the bounds calculated until that priority is
104107
# reached will be the bounds available to an actor with the given priority.
@@ -153,6 +156,8 @@ def _calc_targets(
153156
# Add the proposal power to the target power (aka shift in the opposite direction).
154157
target_power += proposal_power
155158

159+
allocations[next_proposal.source_id] = str(proposal_power)
160+
156161
# The `top_pri_bounds` is to ensure that when applying the exclusion bounds to
157162
# the target power at the end, we respect the bounds that were set by the first
158163
# power-proposing actor.
@@ -167,6 +172,13 @@ def _calc_targets(
167172
system_bounds.exclusion_bounds,
168173
)
169174

175+
if allocations:
176+
_logger.info(
177+
"PowerManager allocations for component IDs: %s: %s",
178+
sorted(component_ids),
179+
allocations,
180+
)
181+
170182
return target_power, Bounds[Power](lower=lower_bound, upper=upper_bound)
171183

172184
def _validate_component_ids(

0 commit comments

Comments
 (0)