【发布时间】:2017-06-30 21:39:18
【问题描述】:
我正在尝试调整(简单)优先附件网络模型(可在 Netlogo 模型库中获得)以包含一个确定网络结构的滑块变量。根据优先依恋模型(或“意见领袖”模型)的理论,网络中的每个个体都被分配了许多关系,k,根据分布 p(k) ∝ k^- γ,并随机连接到这个数量的人。因此,我想要一个可以调整 γ 的滑块。
在原代码中的核心合作伙伴和链接是随机选择的,如下:
to go
if count turtles > num-nodes [ stop ]
;; choose a partner attached to a random link
;; this gives a node a chance to be a partner based on how many links it has
;; this is the heart of the preferential attachment mechanism
let partner one-of [both-ends] of one-of links
;; create new node, link to partner
create-turtles 1 [
set color red
;; move close to my partner, but not too close -- to enable nicer looking networks
move-to partner
fd 1
create-link-with partner
]
;; lay out the nodes with a spring layout
layout
tick
end
我有点不知道应该如何包含这个参数。
谁能帮忙?
提前致谢。
编辑:仍然无法使其正常工作。我在设置而不是去(再次改编自模型库)中制作了一个“正常”的优先附件模型。但是我仍然无法理解我应该如何调整这段代码以包含 gamma 参数。我的代码:
to create-new-nodes [n]
clear-all
ask patches [ set pcolor white ]
create-nodes n [
set color red
set shape "circle"
]
reset-ticks
end
to wire-pref-attach
create-new-nodes 2 ; create the first two nodes (0 and 1)
ask node 0 [ create-edge-with node 1] ; link them together
create-nodes num-nodes - 2 [
create-edge-with [one-of both-ends] of one-of edges ; pref select old node with more links
set color red
set shape "circle"
]
radial-layout
end
to radial-layout
layout-radial nodes edges (node 0)
end
非常感谢您的帮助!
【问题讨论】:
-
这里的问题是原始的 Barabasi-Albert 优先附件算法不允许调整 gamma。它总是-3。 NetLogo 库模型实现了 Barabasi-Albert(这可能是你所知道的),其中节点按一定数量的边按顺序添加,另一端与现有附件的数量成正比。参见维基百科文章en.wikipedia.org/wiki/Preferential_attachment
-
您可以通过选择概率 K + 现有附件来实现可调 gamma,其中 K 是一个常数。
-
我不认为我完全明白你想说什么。这将如何转化为上述代码?
-
在上面的代码中,随机选择要附加的地方是在
let partner one-of [both-ends] of one-of links行中完成的。这会选择概率与其现有链接数量成正比的现有节点,因为它会选择具有统一概率的链接。您需要完全重新设计此选择以实现正确的算法。可能最容易使用rnd扩展,它允许加权概率选择。 -
我用一些应该更容易适应的新代码编辑了我的原始帖子。但是,我仍然不明白我应该如何包含参数。