Skip to content

Commit

Permalink
Merge pull request #33 from ZiluTian/latest
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
ZiluTian authored Apr 4, 2024
2 parents dc92b72 + 718baf3 commit b876d46
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Akka/src/main/scala/core/DriverImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
3 changes: 2 additions & 1 deletion Akka/src/test/scala/simulateUntilTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion Base/src/main/scala/Simulate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
8 changes: 8 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b876d46

Please sign in to comment.