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 42 times • Downloaded 2 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.)


Info tab cannot be displayed because of an encoding error

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 4 months ago Model to check diffusion of Coronavirus in different network settings. Download this version
Amin Hussain 4 months ago Initial upload Download this version

Attached files

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

This model does not have any ancestors.

This model does not have any descendants.