Simulation 优先依附模型到Bianconi-Barabasi模型的Netlogo扩展

Simulation 优先依附模型到Bianconi-Barabasi模型的Netlogo扩展,simulation,netlogo,Simulation,Netlogo,我试图将Netlogo模型库中的优先连接模型扩展到Bianconi Barabasi模型(),我一直在研究如何做到这一点。通过模型库中的“最新”模型,我们 to-report find-partner report [one-of both-ends] of one-of links end to-report find-partner let total random-float sum [count link-neighbors] of turtles let partner

我试图将Netlogo模型库中的优先连接模型扩展到Bianconi Barabasi模型(),我一直在研究如何做到这一点。通过模型库中的“最新”模型,我们

to-report find-partner
  report [one-of both-ends] of one-of links
end
to-report find-partner
  let total random-float sum [count link-neighbors] of turtles
  let partner nobody
  ask turtles
  [
    let nc count link-neighbors
    ;; if there's no winner yet...
    if partner = nobody
    [
      ifelse nc > total
        [ set partner self ]
        [ set total total - nc ]
    ]
  ]
  report partner
end
我理解它是如何导致优先依恋的。但我不知道如何将“健身”融入到这个简单的过程中

另外,在模型库中的优先附件模型的前一个版本中,我们有

to-report find-partner
  report [one-of both-ends] of one-of links
end
to-report find-partner
  let total random-float sum [count link-neighbors] of turtles
  let partner nobody
  ask turtles
  [
    let nc count link-neighbors
    ;; if there's no winner yet...
    if partner = nobody
    [
      ifelse nc > total
        [ set partner self ]
        [ set total total - nc ]
    ]
  ]
  report partner
end

我再一次想知道如何将健身融入到这个过程中。我想将指数分布的适应度与平均值1结合起来,那么,比如说,我是否要将“let nc(count link neights)*random exponential 1”之类的东西相乘?请让我知道。

如果您按照建议执行,那么每次调用该过程时都会重新生成随机数。在我看来,每个节点的适应度都是随机分配的,但一旦分配,该节点的适应度就是一个固定值。如果我正确地解释了模型,您将需要在
turtles own
列表中添加一个变量以适应,并在创建turtle时简单地分配它。然后你需要一个加权概率选择,你必须从头开始构建(我认为),没有明显的方法来修改你提供的过程。看看加权选择的想法。

JenB,谢谢。我重写了我的代码,如下所示,看起来这个代码产生了Bianconi和Barabasi在他们的论文中描述的东西。再次感谢你

;;;;;;;;;;;;;;;;;;;;;;;
;;; Setup Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;
turtles-own [fitness]

to setup
  clear-all
  set-default-shape turtles "circle"
  ;; make the initial network of two turtles and an edge
  make-node nobody        ;; first node, unattached
  make-node turtle 0      ;; second node, attached to first node
  reset-ticks
end

;;;;;;;;;;;;;;;;;;;;;;;
;;; Main Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;

to go
  ;; new edge is green, old edges are gray
  ask links [ set color gray ]
  make-node find-partner         ;; find partner & use it as attachment
                                 ;; point for new node
  tick
  if layout? [ layout ]
end

;; used for creating a new node
to make-node [old-node]
  crt 1
  [
    set color red
    set fitness random-exponential 1
    if old-node != nobody
      [ create-link-with old-node [ set color green ]
        ;; position the new node near its partner
        move-to old-node
        fd 8
      ]
  ]
end

;; This code is the heart of the "preferential attachment" mechanism, and acts like
;; a lottery where each node gets a ticket for every connection it already has.
;; While the basic idea is the same as in the Lottery Example (in the Code Examples
;; section of the Models Library), things are made simpler here by the fact that we
;; can just use the links as if they were the "tickets": we first pick a random link,
;; and than we pick one of the two ends of that link.
to-report find-partner
  let total random-float sum [(count link-neighbors) * fitness] of turtles
  let partner nobody
  ask turtles
  [
    let nc (count link-neighbors) * fitness
    ;; if there's no winner yet...
    if partner = nobody
    [
      ifelse nc > total
        [ set partner self ]
        [ set total total - nc ]
    ]
  ]
  report partner
end


;;;;;;;;;;;;;;
;;; Layout ;;;
;;;;;;;;;;;;;;

;; resize-nodes, change back and forth from size based on degree to a size of 1
to resize-nodes
  ifelse all? turtles [size <= 1]
  [
    ;; a node is a circle with diameter determined by
    ;; the SIZE variable; using SQRT makes the circle's
    ;; area proportional to its degree
    ask turtles [ set size (sqrt count link-neighbors) ]
  ]
  [
    ask turtles [ set size 1 ]
  ]
end

to layout
  ;; the number 3 here is arbitrary; more repetitions slows down the
  ;; model, but too few gives poor layouts
  repeat 3 [
    ;; the more turtles we have to fit into the same amount of space,
    ;; the smaller the inputs to layout-spring we'll need to use
    let factor (sqrt count turtles) 
    ;; numbers here are arbitrarily chosen for pleasing appearance
    layout-spring turtles links (1 / factor) (7 / factor) (1 / factor)
    display  ;; for smooth animation
  ]
  ;; don't bump the edges of the world
  let x-offset max [xcor] of turtles + min [xcor] of turtles
  let y-offset max [ycor] of turtles + min [ycor] of turtles
  ;; big jumps look funny, so only adjust a little each time
  set x-offset limit-magnitude x-offset 0.1
  set y-offset limit-magnitude y-offset 0.1
  ask turtles [ setxy (xcor - x-offset / 2) (ycor - y-offset / 2) ]
end

to-report limit-magnitude [number limit]
  if number > limit [ report limit ]
  if number < (- limit) [ report (- limit) ]
  report number
end


; Copyright 2005 Uri Wilensky.
; See Info tab for full copyright and license.
;;;;;;;;;;;;;;;;;;;;;;;
;;; 设置程序;;;
;;;;;;;;;;;;;;;;;;;;;;;;
海龟自己[健康]
设置
清除所有
将默认形状海龟设置为“圆形”
;; 使最初的网络由两个海龟和一个边缘组成
使节点无人;;第一个节点,未连接
使节点为0;;第二个节点,连接到第一个节点
重置滴答声
结束
;;;;;;;;;;;;;;;;;;;;;;;
;;; 主要程序;;;
;;;;;;;;;;;;;;;;;;;;;;;
外带
;; 新边为绿色,旧边为灰色
询问链接[设置灰色]
使节点找到合作伙伴;;找到合作伙伴并将其用作附件
;; 新节点的点
打上钩
如果布局?[版面]
结束
;; 用于创建新节点
创建节点[旧节点]
阴极射线管1
[
设置颜色为红色
集适应度随机指数1
如果旧节点!=无人
[创建与旧节点的链接[设置绿色]
;将新节点放置在其伙伴附近
移动到旧节点
fd 8
]
]
结束
;; 此代码是“优先依恋”机制的核心,其行为类似于
;; 一种抽签,其中每个节点为其已拥有的每个连接获得一张抽签。
;; 而基本思想与彩票示例(代码示例)中的相同
在这里,由于我们
;; 可以像使用“票”一样使用链接:我们首先选择一个随机链接,
;; 然后我们从链接的两端中选择一个。
报告查找合作伙伴
让海龟的总随机浮点和[(计数链接邻居)*适合度]
不要让任何人成为合伙人
问海龟
[
让nc(计算链接邻居)*适合度
如果还没有赢家。。。
如果合作伙伴=无人
[
ifelse nc>总计
[设置合作伙伴自我]
[设置总计-nc]
]
]
报告合伙人
结束
;;;;;;;;;;;;;;
;;; 布局;;;
;;;;;;;;;;;;;;
;; 调整节点大小,将大小从基于度来回更改为1
调整节点大小的步骤
还有别的吗?海龟[大小]