【发布时间】:2016-01-15 21:27:44
【问题描述】:
我正在尝试为 NetLogo 中的优先连接网络创建一个使用(更正的)Barabasi-Albert 算法的生成器。有两个参数:(最终)节点数和每个节点添加的边数。网络扩展有一个版本,但仅限于每个节点添加 1 条边的情况。
简化的完整模型:
extensions [rnd]
to makeNW-BA
clear-all
let new-edges 4
let popn 25
create-turtles new-edges [ setxy random-xcor random-ycor ]
ask turtles [ create-links-with other turtles with [not link-neighbor? myself] ]
repeat popn - count turtles
[ let targets rnd:weighted-n-of new-edges turtles [ count my-links ]
create-turtles 1
[ setxy random-xcor random-ycor
create-links-with targets
]
]
end
let targets rnd:weighted-n-of degree turtles [ count my-links ] 行正在创建一个 java 错误(ClassCastException) while observer running _asm_proceduremakenwba_setprocedurevariable_11。这是我第一次使用rnd扩展所以我不知道问题是我的编码问题,还是实际上是一个导致java错误的错误。
更新
我现在已经为度数设置了一个海龟自己的变量(即计算我的链接)并尝试做let targets rnd:weighted-n-of new-edges turtles [ degree ]。这给我带来了一个 NetLogo 错误,即the observer can't access a turtle variable without specifying which turtle。但是,尝试添加 of self 并没有帮助。
【问题讨论】:
-
不是一个答案,而是一个推测。它有点必须是一个错误。我的问题是,“它是 netlogo、Java 还是扩展中的一个?”
-
它可能不是 Java,因为它给了我同样的错误。 @Nicolas-Payette 写的也许他很熟悉。
-
由于它导致 java 错误而不是 netlogo 错误,我已将其报告为 rnd 扩展中的一个可能错误。但这也可能是我构建代码的方式,例如,如果它以某种方式自我引用。
-
@King-Ink 有正确的解决方案,但它给出 Java 异常的事实确实是 Rnd 扩展中的一个错误。见github.com/NetLogo/Rnd-Extension/issues/…。
-
哦,对于 NW 扩展中缺少功能齐全的 Barabási–Albert 生成器,请参阅 github.com/NetLogo/NW-Extension/issues/17。
标签: netlogo