NetLogo 代理集形成与其他代理集的链接
NetLogo agentset form links with other agentset
我希望有一个 turtle-set 形式与其他 turtle-set 的链接。
我目前的尝试也让人觉得做作,因为不是这里的每个蜂巢都会selected.Is还有另一种方法吗?
to link-bees-to-hives [bees-agentset hives-agentset]
ask bees-agentset [
create-link-with one-of hives-agentset
]
end
如何按照集合中海龟的顺序在两个代理集 netlogo 之间创建链接?
你想让蜜蜂只用另一个蜂巢做一个 link 吗?如果你有相对足够的蜜蜂,你的尝试可能没问题,但如果你想对蜜蜂的选择进行加权,以便它们优先 link 与蜂箱相关的蜜蜂较少,你可以使用某种 min-one-of
解决方案或a 可能来自 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
当然,如果您的蜜蜂和蜂箱足够少,您最终可能还是会得到一两个蜂箱 linked-to。
我希望有一个 turtle-set 形式与其他 turtle-set 的链接。
我目前的尝试也让人觉得做作,因为不是这里的每个蜂巢都会selected.Is还有另一种方法吗?
to link-bees-to-hives [bees-agentset hives-agentset]
ask bees-agentset [
create-link-with one-of hives-agentset
]
end
如何按照集合中海龟的顺序在两个代理集 netlogo 之间创建链接?
你想让蜜蜂只用另一个蜂巢做一个 link 吗?如果你有相对足够的蜜蜂,你的尝试可能没问题,但如果你想对蜜蜂的选择进行加权,以便它们优先 link 与蜂箱相关的蜜蜂较少,你可以使用某种 min-one-of
解决方案或a 可能来自 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
当然,如果您的蜜蜂和蜂箱足够少,您最终可能还是会得到一两个蜂箱 linked-to。