-
Notifications
You must be signed in to change notification settings - Fork 5
Fixed bugs in congestion management. #1394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
danielfeismann
merged 11 commits into
dev
from
ms/#1393-fix-bug-in-returned-next-tick-after-congestion-management
Jun 6, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e0757a0
Fixed bug in returned next tick after congestion management.
staudtMarius 49e4dfa
Fixed bug in `CongestionResult` value.
staudtMarius 11e1fb3
Merge branch 'dev' into ms/#1393-fix-bug-in-returned-next-tick-after-…
staudtMarius cdaef30
Add tests for `CongestionResults` and next simulation tick.
staudtMarius 6c2d58e
Merge branch 'dev' into ms/#1393-fix-bug-in-returned-next-tick-after-…
staudtMarius 0627d94
Including reviewer's comments.
staudtMarius 55dcafb
Merge branch 'dev' into ms/#1393-fix-bug-in-returned-next-tick-after-…
staudtMarius b197882
Merge branch 'dev' into ms/#1393-fix-bug-in-returned-next-tick-after-…
staudtMarius b6a5af2
Merge branch 'dev' into ms/#1393-fix-bug-in-returned-next-tick-after-…
staudtMarius 3672d0e
Merge branch 'dev' into ms/#1393-fix-bug-in-returned-next-tick-after-…
staudtMarius 0c77de7
Merge branch 'dev' into ms/#1393-fix-bug-in-returned-next-tick-after-…
staudtMarius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/test/scala/edu/ie3/simona/agent/grid/congestion/DCMAlgorithmSpec.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* © 2025. TU Dortmund University, | ||
* Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
* Research group Distribution grid planning and operation | ||
*/ | ||
|
||
package edu.ie3.simona.agent.grid.congestion | ||
|
||
import edu.ie3.simona.agent.grid.GridAgent | ||
import edu.ie3.simona.agent.grid.congestion.data.CongestionManagementData | ||
import edu.ie3.simona.agent.grid.congestion.detection.DetectionMessages.CongestionCheckRequest | ||
import edu.ie3.simona.event.ResultEvent.PowerFlowResultEvent | ||
import edu.ie3.simona.ontology.messages.SchedulerMessage.Completion | ||
import edu.ie3.simona.test.common.UnitSpec | ||
import org.apache.pekko.actor.testkit.typed.scaladsl.{ | ||
BehaviorTestKit, | ||
ScalaTestWithActorTestKit, | ||
TestProbe, | ||
} | ||
|
||
import scala.concurrent.duration.DurationInt | ||
|
||
class DCMAlgorithmSpec | ||
extends ScalaTestWithActorTestKit | ||
with UnitSpec | ||
with CongestionTestBaseData { | ||
|
||
"The DCMAlgorithm" should { | ||
|
||
"start the congestion management correctly" in { | ||
val inferiorGA = TestProbe[GridAgent.Request]("inferiorGridAgent") | ||
|
||
val baseData = gridAgentBaseData(inferiorRefs = Set(inferiorGA.ref)) | ||
|
||
// behavior, that will start the congestion management by creating the state data and checking the result for congestions | ||
// we need to spawn the behavior here, since we send a start message internally | ||
testKit.spawn( | ||
behaviorWithContextAndBuffer { (ctx, buffer) => | ||
GridAgent.startCongestionManagement( | ||
baseData, | ||
3600L, | ||
Some( | ||
PowerFlowResultEvent( | ||
Iterable(nodeResult1), | ||
Iterable.empty, | ||
Iterable(lineResult23), | ||
Iterable.empty, | ||
Iterable.empty, | ||
) | ||
), | ||
ctx, | ||
)(using constantData, buffer) | ||
} | ||
) | ||
|
||
// we should receive a request to check for congestions | ||
inferiorGA.expectMessageType[CongestionCheckRequest](10.seconds) | ||
} | ||
|
||
"finish the congestion management correctly" in { | ||
val stateData = CongestionManagementData( | ||
gridAgentBaseData(), | ||
3600, | ||
100, | ||
PowerFlowResultEvent( | ||
Iterable(nodeResult1), | ||
Iterable.empty, | ||
Iterable(lineResult23), | ||
Iterable.empty, | ||
Iterable.empty, | ||
), | ||
Congestions( | ||
voltageCongestions = true, | ||
lineCongestions = false, | ||
transformerCongestions = false, | ||
), | ||
CongestedComponents.empty, | ||
) | ||
|
||
// this will return the idle behavior of the grid agent | ||
BehaviorTestKit( | ||
behaviorWithContextAndBuffer { (ctx, buffer) => | ||
GridAgent.finishCongestionManagement( | ||
stateData, | ||
ctx, | ||
)(using constantData, buffer) | ||
} | ||
) | ||
|
||
// we should receive an empty result event | ||
resultListener.expectMessageType[PowerFlowResultEvent] match { | ||
case PowerFlowResultEvent( | ||
nodeResults, | ||
_, | ||
lineResults, | ||
_, | ||
_, | ||
congestionResults, | ||
) => | ||
nodeResults shouldBe Iterable(nodeResult1) | ||
lineResults shouldBe Iterable(lineResult23) | ||
} | ||
|
||
// we should receive a next tick of 7200 | ||
val completionMsg = scheduler.expectMessageType[Completion] | ||
completionMsg.actor shouldBe gridAgentActivation.ref | ||
completionMsg.newTick shouldBe Some(7200) | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.