From 3b81a673cc8ce8ebddff42ab83f31867eae3fdfa Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Fri, 31 May 2024 11:27:50 +0200 Subject: [PATCH 1/3] Fix simulation stopping at unhandled messages in `DBFSAlgorithm`. --- CHANGELOG.md | 1 + .../edu/ie3/simona/agent/grid/DBFSAlgorithm.scala | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa9ff87da1..4c548d431c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Default RefSystem using the unit `Volt` for low voltage grids [#811](https://github.com/ie3-institute/simona/issues/811) - Fixed grid within GridSpec test [#806](https://github.com/ie3-institute/simona/issues/806) - Fixed log entry after power flow calculation [#814](https://github.com/ie3-institute/simona/issues/814) +- Simulation stopping at unhandled messages in `DBFSAlgorithm` [#821](https://github.com/ie3-institute/simona/issues/821) ## [3.0.0] - 2023-08-07 diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index 24236f43d3..6a7b1a2f77 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -490,9 +490,10 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { // return to Idle idle(cleanedGridAgentBaseData) - case _ => - // preventing "match may not be exhaustive" - Behaviors.unhandled + case (message, _) => + ctx.log.debug(s"Received the message $message to early. Stash away!") + buffer.stash(message) + Behaviors.same } } @@ -802,9 +803,10 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { buffer.stash(powerResponse) Behaviors.same - case _ => - // preventing "match may not be exhaustive" - Behaviors.unhandled + case (message, _) => + ctx.log.debug(s"Received the message $message to early. Stash away!") + buffer.stash(message) + Behaviors.same } } From 16e9aae3ae3a6da4c06123aadf1882fbb44cebec Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 11 Jun 2024 17:19:59 +0200 Subject: [PATCH 2/3] Fixing log messages. --- src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index 6a7b1a2f77..8dc1b65ae8 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -491,7 +491,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { idle(cleanedGridAgentBaseData) case (message, _) => - ctx.log.debug(s"Received the message $message to early. Stash away!") + ctx.log.debug(s"Received the message $message too early. Stash away!") buffer.stash(message) Behaviors.same } @@ -804,7 +804,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { Behaviors.same case (message, _) => - ctx.log.debug(s"Received the message $message to early. Stash away!") + ctx.log.debug(s"Received the message $message too early. Stash away!") buffer.stash(message) Behaviors.same } From b5eb5545ed207eecb82c8117a446dee237dffcd6 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Mon, 1 Jul 2024 09:02:43 +0200 Subject: [PATCH 3/3] Specifying the stashed messages. --- .../ie3/simona/agent/grid/DBFSAlgorithm.scala | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index 8dc1b65ae8..7999c226f0 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -490,9 +490,12 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { // return to Idle idle(cleanedGridAgentBaseData) - case (message, _) => - ctx.log.debug(s"Received the message $message too early. Stash away!") - buffer.stash(message) + // handles power request that arrive to early + case (requestGridPower: RequestGridPower, _) => + ctx.log.debug( + s"Received the message $requestGridPower too early. Stash away!" + ) + buffer.stash(requestGridPower) Behaviors.same } } @@ -784,7 +787,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { // happens only when we received slack data and power values before we received a request to provide grid data // (only possible when first simulation triggered and this agent is faster in this state as the request // by a superior grid arrives) - case (powerResponse: PowerResponse, _: GridAgentBaseData) => + case (powerResponse: PowerResponse, _) => ctx.log.debug( "Received Request for Grid Power too early. Stashing away" ) @@ -792,20 +795,11 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { buffer.stash(powerResponse) Behaviors.same - // happens only when we received slack data and power values before we received a request to provide grid - // (only possible when first simulation triggered and this agent is faster - // with its power flow calculation in this state as the request by a superior grid arrives) - case (powerResponse: PowerResponse, _: PowerFlowDoneData) => + case (requestGridPower: RequestGridPower, _) => ctx.log.debug( - "Received Request for Grid Power too early. Stashing away" + s"Received the message $requestGridPower too early. Stashing away!" ) - - buffer.stash(powerResponse) - Behaviors.same - - case (message, _) => - ctx.log.debug(s"Received the message $message too early. Stash away!") - buffer.stash(message) + buffer.stash(requestGridPower) Behaviors.same } }