2

以下と同様に、さまざまな年齢のエージェントのソーシャル ネットワークが NetLogo に設定され、リンクによって接続されたエージェントの輪ができます。これらのリンクの全体的な目的は、それらのリンク間の接触を表すことです。このモデルは、ネットワークを介した感染の広がりをシミュレートします。エージェントは感染しやすい状態から始まり、感染性のあるリンク ネイバーと接触すると感染する可能性があります。たとえば、感染した個人の隔離または検疫をモデル化したいと考えています。つまり、他のユーザーへのリンクが完全に無効化されるか、少なくともリンクの大部分が無効化されます。オブザーバー インターフェースのボタンを押して、感染したエージェントのリンクを非アクティブ化するのが理想的です。私' また、たとえば学校の閉鎖をモデル化できるようにしたいと考えています。これにより、大多数の幼児と子供、およびそれらの相互接続が無効になり、子供間の感染の可能性が停止します。大人へのリンクは、数が少ない場合はおそらく開いたままにする必要がありますが、今のところ一度に1つの品種間のリンクに焦点を当てる方が良いかもしれません.

breed [ toddlers toddler ]
breed [ children child ]
breed [ adults adult ]
breed [ over45s over45 ]

globals
[
  num-nodes
  num-infected
  num-susceptible  
  prob-infection-toddler
  prob-infection-child
  prob-infection-adult
  prob-infection-over45
  force-of-infection 
]

turtles-own
[
  temp-infected?    ;; temporary infected state
  infected?         ;; true if agent has been infected
  susceptible?
  num-infected-neighbors
]

links-own
[
 closed? 
]


to setup
  clear-all
  create-toddlers 20
  create-children 20
  create-adults 20
  create-over45s 20
  create-network
  reset-ticks
  layout-circle (sort turtles) max-pxcor - 8
  ask turtles
  [
     facexy 0 0
     if who mod 2 = 0 [fd 4]
  ]
  ask turtles
    [set susceptible? true]

  ask one-of turtles
  [
    set infected? true
    set susceptible? false
    set color red
  ]
  display
end

to create-network

  let connexions (list
    (list toddlers toddlers 5)
    (list toddlers children 2)
    (list toddlers adults 2)
    (list toddlers over45s 1)
    (list children toddlers 3)
    (list children children 8)
    (list children adults 5)
    (list children over45s 1)
    (list adults toddlers 1)
    (list adults children 3)
    (list adults adults 6)
    (list adults over45s 3)
    (list over45s toddlers 1)
    (list over45s children 1)
    (list over45s adults 5)
    (list over45s over45s 5)
  )

  foreach connexions [
    let source-breed item 0 ?
    let target-breed item 1 ?
    let num-connexions item 2 ?
    let reverse-num-connexions item 2 first filter [
      item 0 ? = target-breed and item 1 ? = source-breed
    ] connexions
    ask source-breed [
      repeat num-connexions [
        let possible-targets other target-breed with [
          (not member? myself link-neighbors) and
          (count link-neighbors with [ breed = source-breed ] < reverse-num-connexions)
        ]
        let target one-of possible-targets
        if target != nobody [ create-link-with target ]
      ]
    ]
  ]

  ask links [set closed? false]
end

to spread
  ;;; there is one of these for each age group as they have different probabilities for infection
  ask toddlers with [ susceptible? = true ]
    [

   ;;tried changing to something like this but this is the line that throws up an error  
   ask my-links with [closed? = false][
       set num-infected-neighbors count (link-neighbors with [infected? = true])
   ]
   ;;should only include active links
   set force-of-infection (prob-infection-toddler) ^ num-infected-neighbors ;;paraphrased equation but num-infected-neigbours is important

   if ( random-float 1 <= force-of-infection)  ;; infect with probability p
     [

            set temp-infected? true
            set susceptible? false

     ]
 ]
   ask turtles with [temp-infected? = true]
    [
      set infected? true
      set temp-infected? false
    ]
end

to isolate-infected
   ;;for all infected individuals deactivate their links
end


to close-schools
   ask toddlers 
   [
     ask my-links [set closed? true]
   ]

end

to close-offices
   ;; e.g cut the number of links between adults and so on
end

ご覧のとおり、ここには 2 つの問題があります。1 つは、エンド ノードの状態または品種に基づくリンクの非アクティブ化です (理想的には、学校の閉鎖が終わった後、または感染した個人が回復したときに、再びオンにすることができます)。彼らがそうであること。

そして、非アクティブ化されたリンクを含めずに、感染したリンクネイバーの数をカウントするという2番目の問題。リンクを非表示にしても、リンクが存在しなくなるわけではなく、非表示になるだけで連絡先が停止するわけではありません。また、非アクティブ化されたリンクの色を単に黒などに変更することも検討しました。感染した隣人のカウントを書き換えて、たとえば黒または非表示ではないリンクのみをカウントする方法はありますset num-infected-neighbors count (link-neighbors with [infected? = true]か...そして非表示のリンクはありますか? = false.... または link-color "!=" black?)

おそらく 2 番目の問題の方が簡単だと思いますが、間違っている可能性があります。私はこの段階であまりにも多くのレンガの壁にぶつかり、その問題で頭がいっぱいになりました。どんな助けでも本当に大歓迎です。すでにこれを読んでくれてありがとう、私はそれが少し暴言だったことに気づきました:) 以前に助けてくれたNicolas Payetteに再び感謝します

編集: クローズドにリンク独自のブール値を追加しましたか?

開いているリンクで感染した近隣の数をカウントするセクションを変更しようとしましたが、エラーが発生しました this code can't be run by a link error while link 14 15 running SET called by procedure SPREAD called by Button 'Spread'

また、閉鎖を設定することにより、すべての幼児リンクの非常に基本的な閉鎖を与える「閉鎖学校へ」の機能に追加されましたか? 真に

編集:これはここで可能な解決策でしょうか

set num-infected-neighbors 0
   ask my-links with [closed? = false][
      ask other-end [if (infected?) [set num-infected-neighbors num-infected-neighbors + 1 ]]
   ]
   set force-of-infection 1 - (1 - prob-infection-adult) ^ num-infected-neighbors

編集:turtles-own私が知る限り、num-infected-neighbors は変数である必要がありますが、カメに時計を付けてシミュレーションを実行すると、カメが持っている num-infected-neighbors は一貫して実際の数を上回っているようです。タートルが持っているリンクネイバー。それも間違っているだけです。理由はわかりませんが....

編集:

let infectnum 0
  set num-infected-neighbors 0
   ask my-links with [closed? = false][
      ask other-end [if (infected?) [set infectnum infectnum + 1 ]]
       ;;set num-infected-neighbors count (link-neighbors with [infected? = true])
   ]
   set num-infected-neighbors infectnum

どちらも正常に動作していないようです...

編集:将来の参考のために、問題は-によって解決されました

set num-infected-neighbors length filter [[infected?] of ?]
                        [other-end] of my-links with [not closed?]

最初に、閉じられていないリンクのリンクネイバーのリストが作成され、次にそれがフィルタリングされて、感染したリンクだけが表示されます。num-infected-neighbors はそのリストの長さです

4

1 に答える 1