我怎样才能找到代理商采取行动的netlogo中的确切时间?

时间:2017-10-20 12:38:30

标签: netlogo

我有代理商,他们的设备可能会随机出现故障并基于失败的可能性。 (工作设备?假) 当设备不工作时,我应该计算到现在等待时间的摘要,然后更新设备的状态(工作设备?真)。

我的问题出在更新部分。 假设等待时间= 1,我们在tick = 10那个工作设备?变得虚假,我们做我们的模型365天(滴答)。 在更新中,如果勾选>我应该让我的状态变为真。 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

1 个答案:

答案 0 :(得分:2)

您需要存储的是为每个客户添加另一个属性,该属性存储失败或修复时的滴答。我已采用后一种方法并调用该属性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