Skip to content

Commit 22653fd

Browse files
committed
Don't bypass proposals with out-of-bounds power requests
Instead the proposed powers need to be clamped to the available bounds.
1 parent 07b1c1b commit 22653fd

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@ def _calc_targets(
112112
if proposal_upper < proposal_lower:
113113
continue
114114

115-
if proposal_power and (
116-
proposal_power < proposal_lower or proposal_power > proposal_upper
117-
):
118-
continue
119-
120115
if proposal_lower >= upper_bound:
121116
proposal_lower = upper_bound
122117
proposal_upper = upper_bound

tests/actor/_power_managing/test_shifting_matryoshka.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,21 +323,21 @@ async def test_matryoshka_with_excl_2() -> None:
323323
tester.tgt_power(priority=1, power=-10.0, bounds=(-10.0, 50.0), expected=30.0)
324324
tester.bounds(priority=0, expected_power=30.0, expected_bounds=(0.0, 50.0))
325325

326-
tester.tgt_power(priority=1, power=-10.0, bounds=(-10.0, 20.0), expected=-10.0)
327-
tester.bounds(priority=0, expected_power=-10.0, expected_bounds=(0.0, 20.0))
326+
tester.tgt_power(priority=1, power=-10.0, bounds=(-10.0, 20.0), expected=0.0)
327+
tester.bounds(priority=0, expected_power=0.0, expected_bounds=(0.0, 20.0))
328328

329-
tester.tgt_power(priority=1, power=-10.0, bounds=(-10.0, -5.0), expected=None)
329+
tester.tgt_power(priority=1, power=-10.0, bounds=(-10.0, -5.0), expected=-10.0)
330330
tester.bounds(priority=0, expected_power=-10.0, expected_bounds=(0.0, 0.0))
331331

332-
tester.tgt_power(priority=2, power=-10.0, bounds=(-200.0, -5.0), expected=-20.0)
333-
tester.bounds(priority=1, expected_power=-20.0, expected_bounds=(-190.0, 5.0))
334-
tester.bounds(priority=0, expected_power=-20.0, expected_bounds=(0.0, 5.0))
332+
tester.tgt_power(priority=2, power=-10.0, bounds=(-200.0, -5.0), expected=-15.0)
333+
tester.bounds(priority=1, expected_power=-15.0, expected_bounds=(-190.0, 5.0))
334+
tester.bounds(priority=0, expected_power=-15.0, expected_bounds=(0.0, 5.0))
335335

336336
tester.tgt_power(priority=1, power=-10.0, bounds=(-100.0, -5.0), expected=None)
337-
tester.bounds(priority=0, expected_power=-20.0, expected_bounds=(-90.0, 5.0))
337+
tester.bounds(priority=0, expected_power=-15.0, expected_bounds=(-90.0, 5.0))
338338

339-
tester.tgt_power(priority=1, power=-40.0, bounds=(-100.0, -35.0), expected=-50.0)
340-
tester.bounds(priority=0, expected_power=-50.0, expected_bounds=(-60.0, 5.0))
339+
tester.tgt_power(priority=1, power=-40.0, bounds=(-100.0, -35.0), expected=-45.0)
340+
tester.bounds(priority=0, expected_power=-45.0, expected_bounds=(-60.0, 5.0))
341341

342342

343343
async def test_matryoshka_with_excl_3() -> None:

0 commit comments

Comments
 (0)