NetLogo rnd :weighted-n-of by turtle variable

标签 netlogo

我正在尝试创建一个生成器,该生成器使用(已更正的)Barabasi-Albert 算法来生成 NetLogo 中的优先连接网络。有两个参数:(最终)节点数和每个节点添加的边数。网络扩展有一个版本,但仅限于每个节点添加 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] 在观察者运行 _asm_proceduremakenwba_setprocedurevariable_11 时创建了一个 java 错误 (ClassCastException)。这是我第一次使用 rnd 扩展,所以我不知道问题是我的编码问题,还是实际上有一个错误导致了 java 错误。

更新

我现在已经为度数设置了一个海龟自己的变量(即计算我的链接数)并尝试做 let targets rnd:weighted-n-of new-edges turtles [ degree ]。这反而给我带来了一个 NetLogo 错误,观察者无法在不指定哪只海龟的情况下访问海龟变量。但是,尝试添加 of self 没有帮助。

最佳答案

这会产生所需的网络吗?

let targets rnd:weighted-n-of new-edges turtles [ [count my-links] of ? ]

将 new-eges 设置为 4 时,我很难注意到它。当我将它设置为 1 时,它似乎建立了一个优先附件网络。 看起来(让上帝的声音不同意我)[rnd:weighted-n-of] 被设计为与列表一起工作,并且其中有一个隐藏的 foreach 或 map 导致它在给定代理集时在转换时出错。

关于NetLogo rnd :weighted-n-of by turtle variable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34802274/

相关文章:

Netlogo file-write/file-print/file-type 输出不完整的文件

python - 如何将 pyNetLogo 连接到 netlogo 版本 5

list - 将主体集转换为 NetLogo 中的列表

从 R 并行运行 NetLogo 模拟

netlogo - 在询问海龟时无法计算补丁之间的距离

netlogo - 使用哪个 NetLogo NW 扩展?

netlogo - 从字符串读取在 NetLogo Web 中工作吗?

Netlogo:计算图形/网络的直径

netlogo - 识别聚集 Netlogo 模型中的子组

netlogo - 要求红海龟避开其他海龟并移动到其空的且浓度最高的邻居之一