【问题标题】:Netlogo extension of preferential attachment model to Bianconi-Barabasi model优先依恋模型向 Bianconi-Barabasi 模型的 Netlogo 扩展
【发布时间】:2015-10-26 04:56:12
【问题描述】:

我正在尝试将 Netlogo 模型库中的优先附件模型扩展到 Bianconi-Barabasi 模型 (https://en.wikipedia.org/wiki/Bianconi%E2%80%93Barab%C3%A1si_model),但我不知道该怎么做。有了模型库中的“最新”模型,我们就有了

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 结合起来,所以,比方说,我是否要乘以“让 nc(计数链接邻居)* 随机指数 1”之类的东西?请告诉我。

【问题讨论】:

    标签: simulation netlogo


    【解决方案1】:

    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.
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-10
        • 1970-01-01
        • 2014-06-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多