NetLogo:比较邻居的值
NetLogo: comparing neighbors' values
在我建立创新扩散模型的过程中,我在 NetLogo 中遇到了另一个小编程问题。我想模拟人们更有可能向相似的人学习。因此,该模型考虑分配给每个代理的能力值:
[set ability random 20 ]
然后在 go 过程中,我希望他们将自己的能力值与链接的邻居的值进行比较。
例如:turtle1 的能力 = 5,neighbor1 的能力 = 10,neighbor2 的能力 = 4。因此(绝对)差异为 [5, 1]。因此,他从邻居 2 那里学到的东西比从邻居 1 学到的更多。
但我不知道如何解决向每个邻居询问差异的问题。作为第一个想法,我想通过像 [difference1, ..., difference(n)].
这样的列表变量来做到这一点
到目前为止,我只得到了一种使用平均值的聚合方法,但这与最近的社会学习理论并不完全一致,并且可能会覆盖代理人有许多不同邻居但与他非常相似的情况:
ask turtles
[
set ability random 20
set ability-of-neighbor (sum [ability] of link-neighbors / count link-neighbors)
set neighbor-coefficient (abs (ability - ability-of-neighbor))
;;the smaller the coefficient the more similar are the neighbors and the more the turtle learns from his neighbor(s)
]
再次感谢您的帮助和建议,非常感谢任何意见。
亲切的问候,
莫里茨
我花了一些时间来了解你想要什么,但这是一种排名方法 link-neighbors。
let link-neighbor-rank sort-on [abs (ability - [ability] of myself)] link-neighbors
它按能力差异的升序生成 link 个邻居列表。
如果你只想要最近的邻居使用
let best min-one-of link-neighbors [abs (ability - [ability] of myself)]
希望对您有所帮助。
在我建立创新扩散模型的过程中,我在 NetLogo 中遇到了另一个小编程问题。我想模拟人们更有可能向相似的人学习。因此,该模型考虑分配给每个代理的能力值:
[set ability random 20 ]
然后在 go 过程中,我希望他们将自己的能力值与链接的邻居的值进行比较。 例如:turtle1 的能力 = 5,neighbor1 的能力 = 10,neighbor2 的能力 = 4。因此(绝对)差异为 [5, 1]。因此,他从邻居 2 那里学到的东西比从邻居 1 学到的更多。
但我不知道如何解决向每个邻居询问差异的问题。作为第一个想法,我想通过像 [difference1, ..., difference(n)].
这样的列表变量来做到这一点到目前为止,我只得到了一种使用平均值的聚合方法,但这与最近的社会学习理论并不完全一致,并且可能会覆盖代理人有许多不同邻居但与他非常相似的情况:
ask turtles
[
set ability random 20
set ability-of-neighbor (sum [ability] of link-neighbors / count link-neighbors)
set neighbor-coefficient (abs (ability - ability-of-neighbor))
;;the smaller the coefficient the more similar are the neighbors and the more the turtle learns from his neighbor(s)
]
再次感谢您的帮助和建议,非常感谢任何意见。
亲切的问候,
莫里茨
我花了一些时间来了解你想要什么,但这是一种排名方法 link-neighbors。
let link-neighbor-rank sort-on [abs (ability - [ability] of myself)] link-neighbors
它按能力差异的升序生成 link 个邻居列表。
如果你只想要最近的邻居使用
let best min-one-of link-neighbors [abs (ability - [ability] of myself)]
希望对您有所帮助。