Modeling Superspreader behavior

No preview image

1 collaborator

Default-person Alex Brown (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 122 times • Downloaded 6 times • Run 0 times
Download the 'Modeling Superspreader behavior' 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

globals [
  max-infected
  daily-delta
  total-infected
  avg-daily-delta
  total-delta
  moving-average
  day-1
  day-2
  day-3
  day-4
  day-5
  transmissibility ; what is the chance the healthy person becomes sick if they contact a carrier
  interactions ; total dialy interactions
  pop-density
  Ro
]


turtles-own[
  infected?
  immune?
  recovered?
  mask?
  dead? ; add superspeader?
  infectionDay?
  recoveryDay?
  quarantineDay?
  death?
  mouthBreather? ;how likely is this person to ifect others if they come into contact
  secondaryinfections?
  superspreader?
  lambda?
  movement? ;how much a turtle moves - also should account for frequency
  distanced?
  quarantine-if-sick?
  quarantined?
  sub-tick-interactions?
  num-neighbors?

]

to setup
  clear-all
  set-patch-size (275 / max-pxcor) ; just resets display size
  reset-ticks
  setup-turtles
  setup-masked
  setup-mouthBreather
  setup-distancers
  setup-quarantine
  setup-infected
  set max-infected (count turtles with [infected?])
  set transmissibility (probability-of-transmission)
  set pop-density (num-people / (((max-pxcor * 2) + 1) * ((max-pycor * 2) + 1) ) )
  set Ro (0)
  update-plots
end 

to setup-turtles
  create-turtles num-people [
    set color white
    set shape "person"
    set size 2
    set infected? false
    set immune? false
    set mask? false
    set dead? false
    set death? false
    set distanced? false
    set mouthBreather? 0
    set secondaryinfections? 0
    set superspreader? false
    set lambda? random-gamma shape-r ((sociability-prob) / (1 - sociability-prob) )
    set movement? 0
    set quarantine-if-sick? false
    set quarantineDay? 0
    set quarantined? false
    set recovered? false
    set sub-tick-interactions? 0
    set num-neighbors? 0
    setxy random-pxcor random-pycor
  ]
end 

to setup-masked
  ask n-of ((percent-masked / 100) * num-people) turtles [
    set color white
    set shape "person business"
    set mask? true
  ]
end 

to setup-distancers
  ask n-of((prop-distancers / 100) * num-people) turtles [
    set distanced? true
  ]
end 

; this function makes some turtles become infected

to setup-infected
  ask n-of init-infected turtles [    ;n-of takes two inputs, an integer , and a group (turtles),
    set infected? true
    set color 26
    if mask?
      [set shape "person business"]
    recover-time
  ]
end 

to-report random-beta [ #alpha #beta ]
  let XX random-gamma #alpha 1
  let YY random-gamma #beta 1
  report XX / (XX + YY)
end 

to-report random-nbinom [ #r #p ]
  let lambda random-gamma #r ((#p) / (1 - #p) )
  report random-poisson lambda
end 

to setup-mouthBreather
  let mu (Probability-of-Transmission)
  let v (Transmission-shape-parameter)
  let alpha (mu * v)
  let beta ((1 - mu) * v)

  ask turtles [
    set mouthBreather? (random-beta alpha beta)
  ]
end 

to setup-quarantine
  ask n-of ((percent-who-quarantine / 100) * num-people) turtles [
  set quarantine-if-sick? true
  ]
end 

to change-tendencies
  setup-masked
  setup-distancers
  setup-quarantine
end 

to go
  no-display
  move-normal
  infect-susceptibles
  quarantine
  recover-infected-die
  recolor
  calculate-daily-intereactions
  if (ticks >= 1) [
      calculate-max-infected
      calculate-daily-delta
      calculate-avg-daily-delta
      calculate-total-infected
      calculate-moving-average]
  if (count turtles with [dead? or recovered?] ) >= 1 [
      set Ro (mean [secondaryinfections?] of turtles with [dead? or recovered?])
  ]
  if ( ((ticks mod 1) > 0.85) and ((ticks mod 1) < 0.95) ) [
    update-plots ]
  tick-advance 0.1
  display
end 


; see social distancing model for implementing social distancing w/r turtles

to move-normal

  ask turtles with [not dead? and not distanced? and not quarantined?] [
    right random 360 ;;get a new random heading
    set movement? (random-poisson lambda?)
    forward movement? ;default socialbility is 3 integer becasue finite number of patches maybe change to long tail distribution,
    ; add quarrentine metric, see social distance model - sociability distanced: how much do people who are social distances move- typically set at zero
  ]
end 

to recover-time

  set infectionDay? (floor ticks) ; maybe remove this floor? but also dont if add incubation period
  let rv (random-poisson 14)
  set recoveryDay? (infectionDay? + rv)
   ifelse random-float 1 < 0.01
    [set death? true]
    [set death? false]
  set quarantineDay? (infectionDay? + 5) ; this should eventually be changed
end 

to infect-susceptibles ;; S -> I version of Susceptible Infected Recover model
  ask turtles with [infected? and not dead? and not quarantined?][
    let x 0
    let infectivity ifelse-value (mask? = true)
    [(mouthBreather? * masked-transmissibility)]
    [mouthBreather?]
    ask turtles-on neighbors  [
      if (not infected? and not immune?)[
        if (random-float 1 < infectivity)[
          set secondaryinfections? 0
          set infected? true
          recover-time
          set x (x + 1)
        ]
      ]
    ]
    set secondaryinfections? (secondaryinfections? + x)
    if (secondaryinfections? >= Super-Spreader-Threshold)[
      set superspreader? true
    ]


  ]
end 

to quarantine ;
  ask turtles with [infected? and not dead? and quarantine-if-sick?]
  [
    if (ticks >= quarantineDay?)
    [set quarantined? true
    ]
  ]
end 

to recover-infected-die ;;I -> R

  ;;avg case length is 2 weeks.
  ;;should have 50% chance of becoming immune at 2 weeks
  ;;if we are saying each tick equals 1 day,
  ;;daily odds of recovering should be (1-x)^14=.5, x= 0.0483 ;eventually change this to a Normal? distribution look into this


  ask turtles with [infected? and not dead?]
  [
    if (ticks >= recoveryDay?)
    [
      ifelse (death? = false)
      [
        set infected? false
        set recovered? true ;added
        ifelse (are-survivors-immune? = true)
        [
          set immune? true
          ;set color gray
        ]
        [
          ;set color white
        ]
      ]
      [ set dead? true
        ;set color green
        set infected? false

      ]
      set quarantined? false
    ]
  ]
end 

to recolor

  ask turtles with [infected? and not dead? and (secondaryinfections? < Super-Spreader-Threshold)]
  [ set color 26]
  ask turtles with [infected? and not dead? and (secondaryinfections? >= Super-Spreader-Threshold)]
  [ set color red]
  ask turtles with [not infected?]
  [set color white]
  ask turtles with [immune?]
  [set color gray]
  ask turtles with [dead?]
  [ set color green]
  ask turtles with [quarantined?]
  [ set color pink]
end 

to calculate-max-infected
  let x (count turtles with [infected? and not dead?])
  if x > max-infected
  [set max-infected x]
end 

to calculate-total-infected
  set total-infected ((count turtles with [infected? and not dead?])) ;double parenthesis not necessary
end 

to calculate-daily-delta
  set daily-delta (count turtles with [infected? and not dead?] - total-infected)
end 

to calculate-avg-daily-delta
  let y (daily-delta)
  set total-delta (total-delta + y)
  set avg-daily-delta (total-delta / ticks)
end 

to calculate-moving-average

  set day-1 (day-2)
  set day-2 (day-3)
  set day-3 (day-4)
  set day-4 (day-5)
  set day-5 (daily-delta)
 if (ticks >= 5) [
  set moving-average ((day-1 + day-2 + day-3 + day-4 + day-5) / 5)
  ]
end 

to calculate-daily-intereactions
  if (((ticks + 0.00000000001) mod 1) < 0.05) [
    ask turtles [
      set sub-tick-interactions? (0)
    ]
  ]
  ask turtles [
    set sub-tick-interactions? (sub-tick-interactions? + (count turtles-on neighbors) )
    set num-neighbors? sub-tick-interactions? ; this is pretty dumb and can be cleaned up - but it works rn
  ]
end 

to-report max-infected-prop
  report max-infected / num-people
end 

to-report prop-dead
  let y (count turtles with [dead?])
  report y / num-people
end 

to-report prop-uninfected
  report (count turtles with [not infected? and not immune?]) / num-people
end 

There is only one version of this model, created over 3 years ago by Alex Brown.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.