Skip to content
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

Update #33

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading