Netlogo的SEIR模型中的n-of错误

Netlogo的SEIR模型中的n-of错误,netlogo,Netlogo,我试图在我的NetLogo代码中实现社交距离,当我使用n-of“从一组只有0个代理中请求500个随机代理时,我不断地得到一个错误。 观察器运行N-OF时出错 由过程设置调用 由“设置”按钮调用 我添加了一个名为“社交距离”的滑块,目前已将其设置为0.5 以下是我的设置: globals [susceptible-code exposed-code infectious-code recovered-code distancing-yes-code distancing-no-code popul

我试图在我的NetLogo代码中实现社交距离,当我使用n-of“从一组只有0个代理中请求500个随机代理时,我不断地得到一个错误。 观察器运行N-OF时出错 由过程设置调用 由“设置”按钮调用

我添加了一个名为“社交距离”的滑块,目前已将其设置为0.5

以下是我的设置:

globals [susceptible-code exposed-code infectious-code recovered-code distancing-yes-code distancing-no-code population total-dead]
turtles-own [epi-state distancing] ;; each turtle has an epidemiological state


;; Creating the  the initial configuration of the model
to setup
  clear-all
  set susceptible-code "susceptible"
  set infectious-code "infectious"
  set exposed-code "exposed"
  set recovered-code "recovered"
  set distancing-yes-code "distancing"
  set distancing-no-code "not-distancing"

  create-turtles 1000 [
    set epi-state susceptible-code ;; setting the turtle state as susceptible
    set color blue
    set size 0.4
    set shape "circle"
    set xcor random-xcor
    set ycor random-ycor
    set distancing-no-code "not-distancing"
  ]

  ;; makeing one turtle infectious

  let initial-no-of-sd count turtles * social-distancing

  ask one-of turtles [
    set epi-state infectious-code
    set color red ;; we color infectious turtles in red
  ]

  ask n-of initial-no-of-sd turtles with [distancing = distancing-yes-code] [
    set distancing distancing-yes-code
    set color yellow
  ]

  set population count turtles
  reset-ticks
end

错误消息告诉您,您要求一组中的500只海龟做某事,但该组中没有海龟。我猜是这样的:

ask n-of initial-no-of-sd turtles with [distancing = distancing-yes-code]
实际上,您还没有设置“距离是”代码“是”,因此没有满足条件的海龟。事实上,您在代码块中设置了该变量,因此我希望您希望:

 let initial-no-of-sd count turtles * social-distancing
 ask n-of initial-no-of-sd turtles [
    set distancing distancing-yes-code
    set color yellow
  ]

请注意,我还移动了
let
语句,这样您就不必创建变量,也不必使用与代码不同的代码来分隔变量(在本例中,创建一个感染性海龟)。这是一个很好的实践,因此随着模型变得越来越复杂,调试变得更容易。

错误消息告诉您,您要求一组中的500只海龟做一些事情,但该组中没有海龟。我猜是这样的:

ask n-of initial-no-of-sd turtles with [distancing = distancing-yes-code]
实际上,您还没有设置“距离是”代码“是”,因此没有满足条件的海龟。事实上,您在代码块中设置了该变量,因此我希望您希望:

 let initial-no-of-sd count turtles * social-distancing
 ask n-of initial-no-of-sd turtles [
    set distancing distancing-yes-code
    set color yellow
  ]

请注意,我还移动了
let
语句,这样您就不必创建变量,也不必使用与代码不同的代码来分隔变量(在本例中,创建一个感染性海龟)。这是一个很好的实践,因此随着模型变得越来越复杂,调试也会变得更容易。

非常感谢!!我整晚都在挣扎,非常感谢你的帮助!非常感谢你!!我整晚都在挣扎,非常感谢你的帮助!