From 022a800945c52f0842e43cc5fb26703c90e2a6b6 Mon Sep 17 00:00:00 2001 From: ZiluTian Date: Thu, 4 Apr 2024 10:24:56 +0200 Subject: [PATCH 1/3] Require Java 8 or 11 --- build.sbt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build.sbt b/build.sbt index b6e5e542..b72678e6 100644 --- a/build.sbt +++ b/build.sbt @@ -17,6 +17,14 @@ run / fork := true val pubLocal = Option(System.getProperty("pubLocal")).getOrElse("false") +initialize := { + val _ = initialize.value // run the previous initialization + val java8 = "1.8" + val java11 = "11" + val current = sys.props("java.specification.version") + assert(current == java8 || current == java11, s"Unsupported JDK: java.specification.version $current != $java8 or $java11") +} + lazy val commonSettings = Seq( libraryDependencies += "org.scalatest" %% "scalatest" % scalaTestVersion % "test", libraryDependencies += "org.scalanlp" %% "breeze" % breezeVersion, From 36c1a07b467ca87b933f2b3a3ae6cf9701f49701 Mon Sep 17 00:00:00 2001 From: ZiluTian Date: Thu, 4 Apr 2024 10:34:46 +0200 Subject: [PATCH 2/3] Bug fix (change to the updated graph API) --- Akka/src/test/scala/simulateUntilTest.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Akka/src/test/scala/simulateUntilTest.scala b/Akka/src/test/scala/simulateUntilTest.scala index a6e7164a..f5592d51 100644 --- a/Akka/src/test/scala/simulateUntilTest.scala +++ b/Akka/src/test/scala/simulateUntilTest.scala @@ -11,7 +11,8 @@ class simulateUntilTest extends FlatSpec { f"The epidemics example" should "stop as soon as the termination condition is met" in { val population = 10000 - val agents = generated.example.epidemic.InitData(population, 0.01) + val graph = cloudcity.lib.Graph.ErdosRenyiGraph(population, 0.01) + val agents = generated.example.epidemic.InitData(graph) (new API.SimulateUntil()).apply(agents, totalRounds, (ts: Iterable[Iterable[Serializable]]) => { val x = ts.last.filter(i => i match { case y: generated.example.epidemic.Person => y.health == 1 From 718baf32955c653082cc937e427d47ad7878599a Mon Sep 17 00:00:00 2001 From: ZiluTian Date: Thu, 4 Apr 2024 10:42:54 +0200 Subject: [PATCH 3/3] Bug fix (log msg) --- Akka/src/main/scala/core/DriverImpl.scala | 6 +++++- Base/src/main/scala/Simulate.scala | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Akka/src/main/scala/core/DriverImpl.scala b/Akka/src/main/scala/core/DriverImpl.scala index 95ba851a..ece1d68b 100644 --- a/Akka/src/main/scala/core/DriverImpl.scala +++ b/Akka/src/main/scala/core/DriverImpl.scala @@ -129,7 +129,11 @@ class Driver { case LogControllerFinished() => Behaviors.stopped {() => - ctx.log.info(f"Average ${(end-initialStart)/(currentTurn-1)} ms") + if (currentTurn > 1) { + ctx.log.info(f"Average ${(end-initialStart)/(currentTurn)} ms") + } else { + ctx.log.info(f"Average ${end-initialStart} ms") + } ctx.log.debug(f"Simulation completes! Stop the driver") workersStop.foreach(a => a ! WorkerSpec.Stop()) } diff --git a/Base/src/main/scala/Simulate.scala b/Base/src/main/scala/Simulate.scala index 6cd5cda5..ede9b152 100644 --- a/Base/src/main/scala/Simulate.scala +++ b/Base/src/main/scala/Simulate.scala @@ -48,7 +48,11 @@ object Simulate { end = System.currentTimeMillis() println(f"Round ${currentRound} takes ${end-start} ms") } - println(f"Average ${(end - initial)/totalRound} ms") + if (totalRound >= 1) { + println(f"Average ${(end - initial)/totalRound} ms") + } else { + println(f"Average ${end - initial} ms") + } SimulationSnapshot(actors, collectedMessages.flatMap(i => i._2).toList) } }