我在格子上有一些代理。如果我们考虑一个代理$i$,那么我将根据代理$i$的特征为所有剩余的代理分配不同的概率。现在,我的目标是从具有指定概率的剩余代理中选择一个代理$j$,并创建从代理$i$到代理$j$的链接。我必须为所有的智能体晶格做这件事。每次概率根据不同的智能体而变化时,$i$可以帮助一些人如何在netlogo上实现这一点。谢谢。
发布于 2014-07-21 05:34:50
如果你不对问题进行更多的约束,计算成本将会很高。假设你有一个assign-probabilities记者,这是一个基本的想法:
to form-links ;;turtle proc
let %others [self] of other turtles ;;list of other turltes
let %p assign-probabilities %others
let %idx random-index %p
create-link-with item %idx %others
end
to-report random-index [#p] ;;input probability dist as list
let %draw random-float 1
let %cum-p item 0 #p
let %ct 0
while [%draw > %cum-p] [
set %ct (%ct + 1)
set %cum-p (%cum-p + item %ct #p)
]
report %ct
end以下是一些可以帮助降低计算成本的东西。如果没有创建或死亡海龟,则在设置期间只能计算其他海龟一次(并设置为海龟属性)。如果概率不随时间变化,则可以对概率执行相同的操作。在后一种情况下,您可能需要计算累积概率(一次),并使用二分法生成随机指数。
https://stackoverflow.com/questions/24837263
复制相似问题