如何建立邻居网络?

时间:2020-05-06 13:22:46

标签: gis netlogo

嗨,我是netlogo的新手,没有编程背景, 我正在尝试使用GIS扩展来创建“邻居”网络, 到目前为止,我正在使用in-radius函数,但不确定它是否合适。 因为我不了解Netlogo中radius的单位

这是代码:

to setup
  clear-drawing
  clear-all
  reset-ticks

  ; zoom to study area
  resize-world 00 45 0 20
  set-patch-size 20

  ; upload city boundries
  set mosul-data gis:load-dataset"data/MosulBoundries.shp"
  gis:set-world-envelope gis:envelope-of mosul-data
  gis:apply-coverage mosul-data "Q_NAME_E" neighbor


to Neighbour-network
  ;; set 7 neighbour agents inside the city  
  ask turtles [ 
    let target other turtles in-radius 1 
    if any? target
    [ask one-of target [create-link-with myself]]
  ]
  print count links

我希望每个邻居neighbor都链接到最近的7个邻居。 我的猜测是在if any? target行中必须进行某些更改,但是到目前为止,我的所有尝试都没有用。

预先感谢

1 个答案:

答案 0 :(得分:-1)

萨拉:

1)这帮助我了解了NetLogo中“半径”的用法(或半径单位):当您在色块上下文中使用“半径1”时,将选择5个色块(其中询问龟的位置和四个邻居,不是所有的八个相邻补丁

enter image description here

2)考虑使用“最小目标值[我自己的距离]”而不是“一个目标值”。

至少之一:http://ccl.northwestern.edu/netlogo/docs/dict/min-one-of.html

距离自己:http://ccl.northwestern.edu/netlogo/docs/dict/distance.html

to Neighbour-network
; set 7 neighbour agents inside the city
ask turtles [
    let target other turtles in-radius 1
    let counter 0
    while [ count target > 0 and counter < 8 ]
    [ ask min-one-of target [ distance myself ] [
        create-link-with myself
        set counter counter + 1
      ]
    ]
    show my-links
  ]

3)考虑探索Nw扩展名:https://ccl.northwestern.edu/netlogo/docs/nw.html