Using time:go-until in NetLogo time extension

吃可爱长大的小学妹 提交于 2019-12-11 00:48:54

问题


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 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

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.

What am I missing?


回答1:


The author of the time extension fixed the issue and time:go-until now works as intended when used with LogoTimes (see here).



来源:https://stackoverflow.com/questions/25060039/using-timego-until-in-netlogo-time-extension

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!