如何在特定时间不打勾后停止模拟 运行

How to stop simulation run after specific time NOT tick

所有。

无论我的模型做什么,我都想在 运行 之后停止模拟特定时间(实时时钟时间)。例如,在 5 或 10 或 15 分钟后停止。我尝试在 5 分钟后使用 RunEnvironment.getInstance()endAt(double tick) 停止它,如下所示:

RunEnvironment.getInstance()endAt(5000)

它停在 4 分 44 秒处。我遇到了 this answer, but it seems not what I am looking for (I may be wrong). Is there a better way to achieve this? I am very new to RePast and somehow confused about the tick 概念。

谢谢。

引用最近的一篇论文。可能有帮助的报价概念。

Events in Repast simulations are driven by a discrete-event scheduler. These events themselves are scheduled to occur at a particular tick. Ticks do not necessarily represent clock-time but rather the priority of its associated event. Ticks determine the order in which events occur with respect to each other. For example, if event A is scheduled at tick 3 and event B at tick 6, event A will occur before event B. Assuming nothing is scheduled at the intervening ticks, A will be immediately followed by B. There is no inherent notion of B occurring after a duration of 3 ticks. Of course, ticks can and are often given some temporal significance through the model implementation. A traffic simulation, for example, may move the traffic forward the equivalent of 30 seconds for each tick.

如果您想在一定时间(例如 5 分钟)过去后安排停止,您可以安排一个在第一次调用时获取时间的操作,然后检查时间是否正确过去。那时,您可以调用 RunEnvironment.getInstance().endRun()。如何计算时间是一个 Java 问题,所以如果你 google 表示“Java time elapsed”或类似的东西,你应该得到答案。

就安排操作而言,您需要创建一个 class 来实现 IAction (https://repast.github.io/docs/api/repast_simphony/repast/simphony/engine/schedule/IAction.html) 并安排在任何合适的时间间隔。