Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NetLogo代理集表单与其他代理集的链接_Netlogo - Fatal编程技术网

NetLogo代理集表单与其他代理集的链接

NetLogo代理集表单与其他代理集的链接,netlogo,Netlogo,我希望有一个海龟集形式与其他海龟集链接 我目前的尝试也让人感觉做作,因为不是这里的每个蜂巢都会被选中。还有其他方法吗 to link-bees-to-hives [bees-agentset hives-agentset] ask bees-agentset [ create-link-with one-of hives-agentset ] end 我如何在两个代理之间创建链接,按海龟在集合中的顺序排列?你想让蜜蜂只与另一个蜂巢建立链接吗?如果你有相对足够的蜜蜂,你的尝试可能

我希望有一个海龟集形式与其他海龟集链接

我目前的尝试也让人感觉做作,因为不是这里的每个蜂巢都会被选中。还有其他方法吗

to link-bees-to-hives [bees-agentset hives-agentset]
  ask bees-agentset [
    create-link-with one-of hives-agentset
  ]
end

我如何在两个代理之间创建链接,按海龟在集合中的顺序排列?

你想让蜜蜂只与另一个蜂巢建立链接吗?如果你有相对足够的蜜蜂,你的尝试可能是好的,但是如果你想对蜜蜂选择进行加权,以便它们优先与关联蜜蜂较少的蜂巢相连接,你可以使用某种
min解决方案或
rnd
扩展中的某种方法。例如,蜜蜂和蜂巢设置:

extensions [ rnd ]

breed [ bees bee ]
breed [ hives hive ]

to setup
  ca
  create-hives 3 [
    set color white
    set shape "box"
    set size 2
    setxy random-xcor random-ycor
  ]
  create-bees 15 [
    set color yellow
    set shape "bug"
    setxy random-xcor random-ycor
  ]

  reset-ticks
end
以及加权选择:

to link-bee-to-hive
  ask bees [
    create-link-with rnd:weighted-one-of hives [ 1 - count my-links / count bees ]
  ]
  print [ count my-links ] of hives
end

当然,如果你没有足够的蜜蜂和蜂巢,你可能最终还是会有一两个蜂巢没有链接。

你能详细解释一下你所说的“按海龟的顺序排列”是什么意思吗?代理集是无序的。每次你看一个代理集,它都是一个新的,不同的随机顺序。