Network Corona Model

Network Corona Model preview image

1 collaborator

Default-person Amin Hussain (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 221 times • Downloaded 17 times • Run 0 times
Download the 'Network Corona Model' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


MODELLING THE SPREAD OF CONTAGION (v.1.1)

WHAT IS IT?

This model looks to model the spread of contagion in various networks under different arrangements

HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

We begin with deciding the kind of network to create, and the model allows users to choose from 4 different arrangements:

  1. Lattice— a lattice arrangement has nodes tightly packed to each other
  2. Cluster— a collection of nodes across space, similar to real life
  3. Erdos Renyi (ER)— random nodes scattered across space
  4. Star— a wheel-like arrangement, where n-1 nodes are connected to one central node

Apart from the arrangements themselves, certain nodes will be allowed to connect to nodes outside of their immediate neighbourhood, rather than only the nodes that surround them.

Once a virus is introduced, its diffusion varies across these arrangements as it spreads if an infected node is connected to a susceptible node. This transmission depends on the defined tranmission rate.

This model also allows users to separate nodes into city like structures, whereby nodes arrange themselves within upto 4 cities: only particular nodes from each city are allowed to connect to nodes in other societies.

HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

  • Setup: sets up the model
  • Seed: introduces the virus amongst the population through a random node
  • Go: begins the simulation (cannot be started without seeding)
  • Hub: creates the defined number of hubs
  • Rearrange:
  • ConnectHubs: connects the hubs to each other
  • Separate:
  • Lockdown: the first kind of lockdown available-gets rid of x% all links
  • Lockdown2: the second kind of lockdown available-gets rid of x% of only secondary links
  • StaggeredLock:

  • numtur: number of nodes to be generated

  • network: drop down list that allows users to select the desired arrangement

  • radius: used in lattice networks, spatial limit of knowledge for nodes

  • transmission: transmission rate of the virus

  • removed: how long the virus lasts

  • mort: mortality rate

  • immunity: how long immunity lasts

  • knowsize: used in cluster networks to define the size of each cluster

  • freqsec: the frequency of activation/deactivation of links

  • numhubs: the number of hubs in the network

  • outsidelink: used in cluster networks to define how many nodes from other clusters a member of the cluster knows

  • secondary: different from outsidelink in that they are just random nodes with "outside" links

  • weekend: defines the length of the weekend

Users begin by deciding the type of network they would like to create. Here we explain three such arrangements, lattice, cluster and star:

Cluster

You begin by setting knowsize, which defines the size of the cluster. In a cluster arrangement, nodes only form links with a neighbourhood defined by knowsize.

In addition, members of a cluster can also create outside links which signify which members of the cluster can form links outside the cluster

Lattice

You create a lattice by first defining radius and knowsize. Radius define how far links can be made a node: for example, if radius is 1, out of all the people within it, they will form a link with them.

Star

A star is a simple arrangement whereby there is one central node,i.e, a hub, and all other nodes form links to it. Here knowsize=1 and hub=1

The model also allows you to set up hubs or secondary links.

Hubs

If you do decide to create hubs, randomly chosen nodes will become hubs. These are differentiated by the fact that all nodes with "outside links" must connect to the hub

Secondary Links

Secondary links are just random nodes with outside links—these are different from outside links in that outside links pertain to cluster arrangements

A key feature of this model is its abiity to simulate a lockdown. This model allows the creation of two types of lockdown.

Lockdown

Here, the model gets rid of x% all links, as defined by users.

Lockdown2

Here, the model gets rid of x% of only secondary links.

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

Not all edges need to be permanent, those links can be turned on or off as defined by freqsecond.

We can also test the effectiveness of a lockdown.

THINGS TO TRY

Cities

Try building cities as well. Those can be created using the separate button, and you can create up to 4 cities. Here intercity links are limited by what the user defines under secondary.

Here's how the process: * cities * cities form * cancel with each other * then form links as many as secondary defines them to be

You should also look into weekends, those can lead to some interesting results. (suggested things for the user to try to do (move sliders, switches, etc.) with the model)

EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

turtles-own [infected? infecttime immtime fam hub? city everinfected? outside?]
globals [maxinfected separated? ld? totturt]
links-own [active? strength offset second?]

to Setup
  clear-all
  clear-turtles
  clear-plot
  set maxinfected 0
  set separated? false
  set ld? false

  if network = "lattice" [
    ask n-of numtur patches [
      sprout 1[
        nodeprops
      ]
    ]
    ask-concurrent turtles[
      create-links-with up-to-n-of knowsize other turtles in-radius radius with [count my-links < knowsize + 1][
        activelinkprops
      ]
    ]

  ]

  if network = "Clustered" [
    ask n-of (numtur / knowsize) patches [
      sprout knowsize[
        nodeprops
      ]
      ask up-to-n-of outsidelinks turtles-here [set outside? true]
    ]
    ask turtles[
      create-links-with other turtles-here [activelinkprops]
    ]
    ask turtles[
            fd 1
    ]
  ]


 if network = "ER" [
  create-turtles numtur [
      nodeprops    ]

    ask turtles [
      setxy random-float max-pxcor random-float max-pycor
    ]
    ask turtles [
      create-links-with up-to-n-of knowsize other turtles in-radius radius with [count my-links < knowsize][activelinkprops]
    ]
  ]

 if network = "star" [
    create-turtles numtur [
      nodeprops
    ]

    ask one-of turtles [set hub? true]
    layout-circle turtles with [hub? = false]  40
    layout-circle turtles with [hub? = true] 0

    ask turtles with [hub? = true][
      create-links-with other turtles [activelinkprops]
    ]
  ]

  ask turtles [ set everinfected? false]
  set totturt count turtles
  reset-ticks
end 

to nodeprops
  set shape "circle"
  set size 0.5
  set color yellow
  set infected? false
  set immtime 0
  set hub? false
  set outside? false
end 

to activelinkprops
  set active? true
  set strength 1
  set color white
  set offset random knowsize
  set second? false
end 

to seed
  ask n-of initial turtles[
    set color red
    set infected? true
    set everinfected? true
    set infecttime 0
  ]
end 

to Go
  linkupdate
  ask turtles with [infected? = true][
    ask in-link-neighbors with [[active?] of link-with myself and infected? = false and immtime = 0][
      if (transmission / 100 > random-float 1) [
        set color red
        set infected? true
        set everinfected? true
        ;set infecttime 0
      ]
    ]
    set infecttime infecttime + 1
    if infecttime > removed [
      ifelse (mort / 100 > random-float 1) [
        die
      ]
      [
        set infected? false
        set infecttime 0
        set color yellow
        set immtime immunity
      ]
    ]
  ]
  ask turtles [
    if immtime > 0 [
      set immtime immtime - 1
      if immtime = 0 [set color yellow]
    ]
  ]
  ask turtles with [immtime > 0][set color blue]
  if maxinfected < count turtles with [infected?] [
    set maxinfected count turtles with [infected?]
  ]
  if count turtles with [infected?] < 1 [stop]
 ;set infections count turtles with [infected?]



  tick
end 

to-report infections
  report count turtles with [everinfected?]
end 

to linkupdate
  if ld? = false [
    ask links[
      ifelse ((ticks + offset) mod strength = 0) [
        set active? true
        set color white
      ]
      [
        set active? false
        set color black
      ]
    ]
  ]
end 

to Rearrange
  layout-tutte turtles with [not outside?] links with [second?] 45

  ;layout-circle turtles with [hub?] 45
  ;ask turtles with [hub? = false][
   ; face one-of in-link-neighbors with [hub?]
    ;fd 1
  ;]
end 

to Hubs
   ask n-of numhubs turtles[
      set hub? true
      set shape "star"
      set size 1
    ]
  if numhubs != 1 [
    ask turtles with [outside? and hub? = false][
      create-link-with one-of turtles with [hub?][
        set active? true
        set color white
        set strength freqsecond
        set second? true
        set offset random (freqsecond + wends)
        if strength < 1 [set strength 1]
    ]
      set fam [who] of in-link-neighbors with [hub?]
    ]
  ]
  if numhubs = 1 [
    ask turtles with [hub?] [create-links-with other turtles[
      set active? true
      set color white
      set strength freqsecond - 4 + (random 8)
      if strength < 1 [set strength 1]
    ]
  ]
    layout-circle turtles with [hub? = false ] 39
    ask turtles with [hub? = false] [
      set heading random 360
      fd 5
    ]
    ask turtles with [hub?][
      set xcor ((max [xcor] of in-link-neighbors) - (min [xcor] of in-link-neighbors)) / 2
      set ycor ((max [ycor] of in-link-neighbors) - (min [ycor] of in-link-neighbors)) / 2
    ]
  ]
end 

to Separate
  ask turtles [
    ifelse (xcor > max-pxcor / 2) [
      set heading 90
      fd 2
      set city  "1"
    ]
    [
      set heading 270
      fd 2
      set city "2"
   ]
  ]

  if (separator = "4")[
    ask turtles [
      ifelse (ycor > max-pycor / 2) [
        set heading 0
        fd 2
      ]
      [
        set heading 180
        fd 2
        if city = "1" [set city  "3"]
        if city = "2" [set city  "4"]
      ]
    ]
  ]


  ask turtles with [city = "1"][
    ask my-links [if ([city] of other-end) != "1" [die]]
    create-links-with up-to-n-of Secondlink other turtles with [city = "1"] in-radius radius [
      set active? true
      set color white
      set strength freqsecond
     ; - 4 + (random 8)
    ]
  ]

  ask turtles with [city = "2"][
    ask my-links [if ([city] of other-end) != "2" [die]]
    create-links-with up-to-n-of Secondlink other turtles with [city = "2"] in-radius radius [
      set active? true
      set color white
      set strength freqsecond
     ; - 4 + (random 8)
    ]
  ]
  ask turtles with [city = "3"][
    ask my-links [if ([city] of other-end) != "3" [die]]
    create-links-with up-to-n-of Secondlink other turtles with [city = "3"] in-radius radius [
      set active? true
      set color white
      set strength freqsecond
     ; - 4 + (random 8)
    ]
  ]
  ask turtles with [city = "4"][
    ask my-links [if ([city] of other-end) != "4" [die]]
    create-links-with up-to-n-of Secondlink other turtles with [city = "4"] in-radius radius [
      set active? true
      set color white
      set strength freqsecond
     ; - 4 + (random 8)
    ]
  ]

  ask up-to-n-of Secondlink turtles with [city = "1"][create-link-with one-of turtles with [city != "1"][activelinkprops]]
  ask up-to-n-of Secondlink turtles with [city = "2"][create-link-with one-of turtles with [city != "2"][activelinkprops]]
  ask up-to-n-of Secondlink turtles with [city = "3"][create-link-with one-of turtles with [city != "3"][activelinkprops]]
  ask up-to-n-of Secondlink turtles with [city = "4"][create-link-with one-of turtles with [city != "4"][activelinkprops]]


  set separated? true
end 

to ConnectHubs
  ask turtles with [hub?] [
    create-link-with one-of other turtles with [hub?][
      set active? true
      set strength freqsecond
     ; - 4 + (random 8)
    ]
  ]
end 

to Lockdown
  ifelse ld? [set ld? false][set ld? true]
  if separated? = false and ld? [
    ask up-to-n-of (linksbroken / 100 * count links) links [
      set active? false
      set color black
    ]
  ]
  if separated? = false and ld? = false [
    ask links [
      set active? true
      set color white
    ]
  ]

  ;if separated? = true [
   ; ask turtles[
    ;  if
end 

to Lockdown2
  ifelse ld? [set ld? false][set ld? true]
  if separated? = false and ld? [
    ask up-to-n-of (linksbroken / 100 * count links with [second?]) links with [second?] [
      set active? false
      set color black
    ]
  ]
  if separated? = false and ld? = false [
    ask links [
      set active? true
      set color white
    ]
  ]
end 

to StaggeredLock
  if ticks mod 4 = 0 [
    Lockdown
  ]
end 

to Secondary
  ask turtles with [outside?] [
    create-links-with n-of Secondlink other turtles with [outside?] [
      set strength freqsecond
      set offset random (freqsecond + wends)
      set second? true
      ]

  ]
  linkupdate
  histogram [count my-links with [active?]] of turtles
end 

There are 2 versions of this model.

Uploaded by When Description Download
Amin Hussain over 5 years ago Model to check diffusion of Coronavirus in different network settings. Download this version
Amin Hussain over 5 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Network Corona Model.png preview Preview for 'Network Corona Model' over 5 years ago, by Amin Hussain Download

This model does not have any ancestors.

This model does not have any descendants.