【问题标题】:how can i find the exact tick in netlogo in which agents take an action?我如何在 netlogo 中找到代理采取行动的确切刻度?
【发布时间】:2017-10-20 12:38:29
【问题描述】:

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

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

【问题讨论】:

    标签: netlogo


    【解决方案1】:

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

    【讨论】:

    • 顺便说一句,我尽可能地保留了你的风格,但你可以使用if not device-working?而不是if device-working? = false,这样可能更容易阅读
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多