半径在 Netlogo 6.1.0 中的工作方式与以前的版本不同

The in-radius works different in Netlogo 6.1.0 than in previous version

我有以下代码,它创建了一个代理网格,如果它们在干扰距离内,则在对之间放置 links。

breed [ readers reader ]
undirected-link-breed [ rris rri ]

globals [
  interf-rri-radius
  num-readers
  distance-var-x
  distance-var-y
  readers-per-row
  readers-per-column
  num-checkouts
]


to setup
  ca
  setup-globals
  ask patches [ set pcolor blue - 3 ]
  spawn-by-row-col
  reset-ticks
end

to setup-globals
  set  interf-rri-radius 1005
  set num-readers 40
  set distance-var-x 12
  set distance-var-y 22
  set readers-per-row 8
  set readers-per-column 5
  set num-checkouts 0
end

to spawn-by-row-col
  let half-step 0.5 * distance-var-x
  let d-vals ( range ( min-pxcor + half-step ) ( min-pxcor + (readers-per-row * distance-var-x)) distance-var-x )

  let dc-vals ( range ( min-pxcor + half-step ) ( min-pycor + (readers-per-column * distance-var-y)) distance-var-y )
  show dc-vals
  ; Create an empty list to build into
  let possible-coords []

  ; For each possible vertical value, map all horizontal values in order and
  ; combine these into an ordered list starting at the lowest px and py coords

  foreach dc-vals [
    d ->
    set possible-coords ( sentence possible-coords map [ i -> (list i d) ] d-vals )
  ]

  show (word "possible-coords = " possible-coords)
  ; Use the number of readers to sublist the possible coordinates, and
  ; create a turtle at each of the coordinate combinations left.
  let max-positions length possible-coords
  if max-positions > (num-readers + num-checkouts) [ set max-positions (num-readers + num-checkouts) ]
  let use-coords sublist possible-coords num-checkouts max-positions
  foreach use-coords [
    coords ->
    create-readers 1 [
      setxy item 0 coords item 1 coords
      set shape "square 2"
      set size 2
      set color 15
    ]
  ]
  ask readers [ create-rris-with other readers in-radius (interf-rri-radius / 10) ]
end

reader0 的邻居是

show [sort [who] of rri-neighbors] of reader 0
[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39]

然而,reader 0 和 reader 39 之间的距离是

show [distance reader 0] of reader 39
121.6552506059644

并且连接半径为 1005/10= 100.5,因此它们不应与 rri link 连接。

注意,我使用了X和Y维度为-50到50的以原点为中心的世界。

我已经测试过之前 Netlogo 版本 6.0.4 中的代码,reader 39 不是 reader 0 的邻居。 我不知道可能是什么问题。我相信是新版本,但我想确定一下。

以防其他人遇到此问题,NetLogo 6.1.0 版本中 in-radius 有一个已确认的错误,详细信息在 the bug report on GitHub.

此问题仅在 non-wrapped 世界中使用时影响 in-radius,并且仅在海龟上使用时影响,并且仅在使用占世界宽度很大百分比的半径时影响。如果您使用的是带环绕的世界,或使用带补丁的 in-radius,或使用相对于世界大小的小半径,您的数据将是正确的,您不需要以下解决方法。

如果您的模型受到影响,作为解决方法,您可以在模型中使用简单的 user-defined NetLogo 程序,直到发布修复程序。它不会是 super-fast 如果你的海龟每次计算 in-radius 很多次,但如果你的海龟很少或者只是在设置期间使用它,它应该没问题:

to-report temp-in-radius [agentset r]
  report agentset with [ distance myself <= r ]
end

然后,您可以 create-rris-with (temp-in-radius other readers (interf-rri-radius / 10)) 而不是 create-rris-with other readers in-radius (interf-rri-radius / 10)

或者更一般地说,像 count other turtles in-radius 5 这样的东西会变成 count temp-in-radius (other turtles) 5