From 3eb9b201ff6139f6be69a4667a932c3189a156ff Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 29 Oct 2024 09:38:36 +0100 Subject: [PATCH 1/7] Fix filter for thermal result checking for lastTick not for currentTick --- .../agent/participant/hp/HpAgentFundamentals.scala | 4 ++-- .../edu/ie3/simona/model/thermal/ThermalGrid.scala | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala index b95d25671d..0b46e609f9 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala @@ -188,7 +188,7 @@ trait HpAgentFundamentals ) val accompanyingResults = baseStateData.model.thermalGrid.results( - tick, + lastState.lastTimeTick, updatedState.thermalGridState, )(baseStateData.startDate) val result = AccompaniedSimulationResult(power, accompanyingResults) @@ -253,7 +253,7 @@ trait HpAgentFundamentals relevantData, ) val accompanyingResults = baseStateData.model.thermalGrid.results( - currentTick, + lastModelState.lastTimeTick, lastModelState.thermalGridState, )(baseStateData.startDate) val result = AccompaniedSimulationResult(power, accompanyingResults) diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index b6aace8407..9df56aa980 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -404,7 +404,7 @@ final case class ThermalGrid( /** Convert the given state of the thermal grid into result models of it's * constituent models * - * @param currentTick + * @param lastTick * Actual simulation tick * @param state * State to be converted @@ -413,13 +413,13 @@ final case class ThermalGrid( * @return * A [[Seq]] of results of the constituent thermal model */ - def results(currentTick: Long, state: ThermalGridState)(implicit - startDateTime: ZonedDateTime + def results(lastTick: Long, state: ThermalGridState)(implicit + startDateTime: ZonedDateTime ): Seq[ResultEntity] = { val maybeHouseResult = house .zip(state.houseState) - .filter { case (_, state) => state.tick == currentTick } + .filter { case (_, state) => state.tick == lastTick } .map { case ( thermalHouse, @@ -435,7 +435,7 @@ final case class ThermalGrid( val maybeStorageResult = storage .zip(state.storageState) - .filter { case (_, state) => state.tick == currentTick } + .filter { case (_, state) => state.tick == lastTick } .map { case ( storage: CylindricalThermalStorage, From c8df5d0d219526708d7476958384c88cb14e7354 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 29 Oct 2024 09:42:40 +0100 Subject: [PATCH 2/7] changelog and fmt --- CHANGELOG.md | 1 + src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33098b858f..223be89be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -125,6 +125,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix scheduling at Evcs with more than one Ev at a time without Em [#787](https://github.com/ie3-institute/simona/issues/787) - Fix CheckWindow duration [#921](https://github.com/ie3-institute/simona/issues/921) - Fixed ThermalStorageResults having multiple entries [#924](https://github.com/ie3-institute/simona/issues/924) +- Fix filter for thermal result checking for lastTick not for currentTick [#1008](https://github.com/ie3-institute/simona/issues/1008) ## [3.0.0] - 2023-08-07 diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index 9df56aa980..8234e065f9 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -414,7 +414,7 @@ final case class ThermalGrid( * A [[Seq]] of results of the constituent thermal model */ def results(lastTick: Long, state: ThermalGridState)(implicit - startDateTime: ZonedDateTime + startDateTime: ZonedDateTime ): Seq[ResultEntity] = { val maybeHouseResult = house From adfa7242731f56349721d7e01a14511e149607c8 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 29 Oct 2024 09:49:00 +0100 Subject: [PATCH 3/7] make store of ValueStore available from external --- src/main/scala/edu/ie3/simona/agent/ValueStore.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala index a21f7d0f58..fbae2ff77c 100644 --- a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala +++ b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala @@ -22,7 +22,7 @@ import scala.collection.SortedMap */ final case class ValueStore[+D]( maxTickSpan: Long, - private val store: SortedMap[Long, D] = SortedMap.empty[Long, D], + store: SortedMap[Long, D] = SortedMap.empty[Long, D], ) { /** Determine the lastly known data tick, if available. Includes the given From 67d7b37fca9e0afd7db8c38d4ad56cfadbfc2a28 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 29 Oct 2024 18:01:04 +0100 Subject: [PATCH 4/7] rename lastTimeTick into tick and use updatedState for thermalResults --- .../simona/agent/participant/hp/HpAgentFundamentals.scala | 6 +++--- .../scala/edu/ie3/simona/model/participant/HpModel.scala | 6 +++--- .../agent/participant/HpAgentModelCalculationSpec.scala | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala index 0b46e609f9..9094058deb 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala @@ -188,7 +188,7 @@ trait HpAgentFundamentals ) val accompanyingResults = baseStateData.model.thermalGrid.results( - lastState.lastTimeTick, + updatedState.tick, updatedState.thermalGridState, )(baseStateData.startDate) val result = AccompaniedSimulationResult(power, accompanyingResults) @@ -253,8 +253,8 @@ trait HpAgentFundamentals relevantData, ) val accompanyingResults = baseStateData.model.thermalGrid.results( - lastModelState.lastTimeTick, - lastModelState.thermalGridState, + updatedState.tick, + updatedState.thermalGridState, )(baseStateData.startDate) val result = AccompaniedSimulationResult(power, accompanyingResults) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 4d9fc68899..5be2781b29 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -326,8 +326,8 @@ object HpModel { * * @param isRunning * indicates if CHP is turned on - * @param lastTimeTick - * contains last time tick + * @param tick + * the time tick of the HpState * @param ambientTemperature * Optional ambient temperature, if available * @param activePower @@ -342,7 +342,7 @@ object HpModel { */ final case class HpState( isRunning: Boolean, - lastTimeTick: Long, + tick: Long, ambientTemperature: Option[Temperature], activePower: Power, qDot: Power, diff --git a/src/test/scala/edu/ie3/simona/agent/participant/HpAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/HpAgentModelCalculationSpec.scala index 3ff4229ab7..03007b225a 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/HpAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/HpAgentModelCalculationSpec.scala @@ -506,7 +506,7 @@ class HpAgentModelCalculationSpec _, HpState( isRunning, - lastTimeTick, + tick, _, activePower, qDot, @@ -516,7 +516,7 @@ class HpAgentModelCalculationSpec ) ) => isRunning shouldBe false - lastTimeTick shouldBe 0L + tick shouldBe 0L activePower should approximate(Kilowatts(0.0)) qDot should approximate(Kilowatts(0.0)) @@ -634,7 +634,7 @@ class HpAgentModelCalculationSpec _, HpState( isRunning, - lastTimeTick, + tick, _, activePower, qDot, @@ -644,7 +644,7 @@ class HpAgentModelCalculationSpec ) ) => isRunning shouldBe false - lastTimeTick shouldBe 0L + tick shouldBe 0L activePower should approximate(Kilowatts(0d)) qDot should approximate(Kilowatts(0d)) From 9692602aea37098567b2bdaa9fe25586b42c4aa5 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 29 Oct 2024 18:08:58 +0100 Subject: [PATCH 5/7] rollback changes at ThermalGrid.results() --- .../scala/edu/ie3/simona/model/thermal/ThermalGrid.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index 8234e065f9..b6aace8407 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -404,7 +404,7 @@ final case class ThermalGrid( /** Convert the given state of the thermal grid into result models of it's * constituent models * - * @param lastTick + * @param currentTick * Actual simulation tick * @param state * State to be converted @@ -413,13 +413,13 @@ final case class ThermalGrid( * @return * A [[Seq]] of results of the constituent thermal model */ - def results(lastTick: Long, state: ThermalGridState)(implicit + def results(currentTick: Long, state: ThermalGridState)(implicit startDateTime: ZonedDateTime ): Seq[ResultEntity] = { val maybeHouseResult = house .zip(state.houseState) - .filter { case (_, state) => state.tick == lastTick } + .filter { case (_, state) => state.tick == currentTick } .map { case ( thermalHouse, @@ -435,7 +435,7 @@ final case class ThermalGrid( val maybeStorageResult = storage .zip(state.storageState) - .filter { case (_, state) => state.tick == lastTick } + .filter { case (_, state) => state.tick == currentTick } .map { case ( storage: CylindricalThermalStorage, From dc19d7850c6456afe3b7ec6b4b80947b1630527c Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 1 Nov 2024 09:22:12 +0100 Subject: [PATCH 6/7] rollback changes in ValueStore --- src/main/scala/edu/ie3/simona/agent/ValueStore.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala index fbae2ff77c..a21f7d0f58 100644 --- a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala +++ b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala @@ -22,7 +22,7 @@ import scala.collection.SortedMap */ final case class ValueStore[+D]( maxTickSpan: Long, - store: SortedMap[Long, D] = SortedMap.empty[Long, D], + private val store: SortedMap[Long, D] = SortedMap.empty[Long, D], ) { /** Determine the lastly known data tick, if available. Includes the given From ca3dff546477b99167778f78d250a0f685234e26 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Fri, 1 Nov 2024 10:41:32 +0100 Subject: [PATCH 7/7] One more small doc fix Signed-off-by: Sebastian Peter --- src/main/scala/edu/ie3/simona/model/participant/HpModel.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 5be2781b29..37cd4b1a8e 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -325,7 +325,7 @@ object HpModel { * temperature. * * @param isRunning - * indicates if CHP is turned on + * indicates if HP is turned on * @param tick * the time tick of the HpState * @param ambientTemperature