使用时间:直到NetLogo时间扩展 [英] Using time:go-until in NetLogo time extension
问题描述
使用NetLogo 5.1.0和Windows 8.1上的NetLogo时间扩展,我希望模拟在特定日期或特定时间段后停止.
Using the NetLogo time extension on NetLogo 5.1.0 and Windows 8.1, I would like a simulation to stop either at a specific date, or after a specific period of time.
time:go-until
应该根据 https://github上的文档进行操作.com/colinsheppard/time/#discrete-event-scheduler ,但我不知道如何正确使用它.这是我到目前为止的内容:
time:go-until
should work for this according to the documentation on https://github.com/colinsheppard/time/#discrete-event-scheduler, but I can't figure out how to use it correctly. Here's what I have so far:
extensions [time]
globals[
start-time
current-time
]
to setup
clear-all
reset-ticks
set start-time time:create "2011-01-01"
set current-time time:anchor-to-ticks start-time 1.0 "days"
time:anchor-schedule start-time 1.0 "days"
create-turtles 2
time:schedule-repeating-event-with-period turtles task [fd 1] 1 1.0 "days"
end
to go-until
time:go-until 40
;time:go-until time:create "2011-03-01"
;time:go-until time:plus start-time 33.0 "days"
end
像这样,模拟运行40个滴答声,然后按预期结束.但是,当我用time:go-until time:create "2011-03-01"
或time:go-until time:plus start-time 33.0 "days"
替换time:go-until 40
时,在模拟开始时会出现此错误:
Like this, the sim runs for 40 ticks and then ends as expected. However, when I replace time:go-until 40
with either time:go-until time:create "2011-03-01"
or time:go-until time:plus start-time 33.0 "days"
, I get this error at the start of the simulation:
Extension exception: time: was expecting a number as argument 1, found this instead: {{time:logotime 2011-03-01}}
error while observer running TIME:GO-UNTIL
called by procedure GO-UNTIL
called by Button 'go'
以下是文档中的示例,该示例应该可以正常工作:
Here's an example from the documentation which should work correctly:
time:go-until time:plus t-datetime 1.0 "hour"
;; Execute events within the next hour; t-datetime is the current time.
我想念什么?
推荐答案
time
扩展名的作者解决了该问题,现在time:go-until
与LogoTimes一起使用时可以按预期工作(请参见
The author of the time
extension fixed the issue and time:go-until
now works as intended when used with LogoTimes (see here).
这篇关于使用时间:直到NetLogo时间扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!