我怎样才能在代理采取行动的 netlogo 中找到确切的标记?

how can i find the exact tick in netlogo in which agents take an action?


我有代理商,他们的设备可能会根据故障概率随机面临故障。 (工作设备?假的) 当设备不工作时,我应该计算到现在的等待时间摘要,然后更新设备的状态(working-devices?true)。

我的问题出在更新部分。 让我们假设等待时间 = 1 并且我们在 tick = 10 那个工作设备?变成假的,我们做我们的模型 365 天(刻度)。 在更新中,如果 tick > 11 ( 10 + 1 ),我应该让我的状态变为真。 11 表示(滴答声 + 等待时间)。

我的问题是如何了解状态在哪个时刻变成了假? 编写更新程序的最佳方式是什么?

;; waiting-time is slider (for example ) 1

breed [ customers customer] 
....

customers-own [device-working? real-waiting-time? ... ]

to setup
....
ask customers [
 set real-waiting-time 0
 set device-working? true
.....
]
end

to go
  if ticks < 365  [
  ask customers [if (device-working? = true)
  [ impose update]
 ]

to impose 
 if random 100 > 95
 [set device-working? false
  set real-waiting-time real-waiting-time + waiting-time ]
end

to update
;; let the-tick when devices of customers faces failure
;; if tick > the-tick + waiting-time-slider and device-working? = false 
;; [set device-working? true]

end

您需要存储的是为每个客户添加另一个属性,用于存储失败时或修复时的报价。我采用了后一种方法并将该属性称为 end-waiting-time(未测试)。

to impose 
 if random 100 > 95
 [set device-working? false
  set real-waiting-time real-waiting-time + waiting-time
  set end-waiting-time ticks + waiting-time]      ; this is the new line
end

to update
  if device-working? = false tick and ticks = end-waiting-time
  [ set device-working? true ]
end