【发布时间】:2025-12-12 00:00:02
【问题描述】:
我是第一次发帖,六个月的读者。我喜欢这个网站,并感谢所涵盖的大量主题。现在我感觉使用 NetLogo 更有能力了,我尝试了一些更难的东西并卡住了......
基本上,我创建了一个隶属函数,它在一个包含两个变量(对摇滚和嘻哈的观点)的向量上衡量代理之间的相互关系:
to-report membership [ agent1 agent2 ]
let w 0.5
let w2 sq w
report exp (- d2 agent1 agent2 / w2)
end
在哪里
;;;;;;;;;;;;;;Shortcut functions;;;;;;;;;;;;;;;;;;;;;;;;;;;
to-report d2 [agent1 agent2 ]
report ( (sq ([rock] of agent1 - [rock] of agent2)) + (sq ([hip-hop] of agent1 - [hip-hop] of agent2)) )
end
to-report sq [ x ]
report x * x
end
这一切都很好,我可以毫无问题地比较任何两个代理。 但是,当我尝试将单个代理 [agent1] 与他附近的所有代理进行比较时,我的问题就出现了。
to go
ask turtles [
let neighbours turtle-set turtles in-radius neighbourhood
show membership self neighbours]
end
每当我运行此模型时,我都会收到一个错误,即 d2 报告者期望输入而不是列表 - 我从理论上理解 - 通过具有 1+ 个代理的邻域,计算正在接收例如 [0.1 0.8] [0.2 0.4] [0.5 0.6].......
我只是想知道,该程序是否可以考虑所有邻居并得出一个会员编号?我已经通过帖子和我拥有的几本 netlogo 书籍进行了广泛搜索,但到目前为止还没有运气。感谢您抽出宝贵时间阅读这篇文章以及任何有用的 cmets。
【问题讨论】:
标签: netlogo