SIIR

No preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Default-person Neal Clarin (Author)

Tags

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.4.0 • Viewed 19 times • Downloaded 0 times • Run 0 times
Download the 'SIIR ' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

globals [ b2 c3 ]

turtles-own [;; Turtle characteristics
  infectious? ;; note: symptomatics have the virus but not infectious (since they're assumed to be quarantined)
  infection_state ;; presymptomatic, asymptomatic, symptomatic
  dead ;; is alive [true/false]
  immune ;; is immune [true / false] ;recovered or susceptible
  inc_p ; incubation period for presymptomatics ;at the end they bifurcates to either asymp or symp ;note:Since there's already a global variable 'incubation period', they can't be of the same name
  ons_p ; (onset period) symp or asymp at the end of this period, bifurcates to recovered or dead (if symp)
  antibody_duration ;; if not immune auto 0 else the inverse of the set antibody decay
]

to setup ;; this procedure sets up the simulation for start
  clear-all

  set b2 1 - b1
  set c3 1 - c2

  create-turtles number_turtles [ setxy random-xcor random-ycor
    set infectious? false
    set infection_state "susceptible"
    set shape "person"
    set dead false
    set immune false
    set inc_p 0
    set ons_p 0
    set antibody_duration 0
  ]

  ask one-of turtles [
    set infectious? true
    set infection_state "presymptomatic"
    set inc_p incubation_period
    ;set infection_state "asymptomatic"
    ;set ons_p onset_period
  ] ;;one gets infected

  ask turtles [recolor]

  reset-ticks
end 

to go ;; each tick of simulation turtle do this
  if all? turtles [infectious?] [stop]
  if all? turtles [infectious? = false] [stop]

  ask turtles [move]
  ask turtles [spread]
  ask turtles [transform]
  ask turtles [recover]
  ask turtles [recolor]

  tick
end 

to move
  if dead = false and infection_state != "symptomatic" ;at the simplest form, symptomatics won't move since they're assumed to be quarantined
  [                                                    ;ig better if there are specific patches that is either their home or the hospital to be quarantined in (future endeavor)
    right random 150
    left random 150

    fd 1
  ]
end 

to spread
  ifelse infection_state != "susceptible" [] [
    if any? other turtles-here in-radius 1 with [infectious?]
    [
      if immune = false
      [
        if random-float 1.0 < infection_rate
        [
          set infectious? true
          set infection_state "presymptomatic"
          set inc_p incubation_period
          if connection [
            ask self [create-links-from other turtles-here with [infectious?]]
          ]
        ]
      ]
    ] ;; checking if there is virus near this agent
  ]
end 

to transform ;change states

  ;presymptomatic bifurcation
  ;presymptomatic to symptomatic - b1 ;presymptomatic to asymptomatic - b2
  if infection_state = "presymptomatic" and infectious? = true
  [
    ifelse inc_p = 0 [
      if b1 > b2
      [
        ifelse random-float 1 < b1
        [ set infection_state "symptomatic" set infectious? false set ons_p onset_period]
        [ set infection_state "asymptomatic" set ons_p onset_period]
      ]
      if b2 > b1
      [
        ifelse random-float 1 < b2
        [ set infection_state "asymptomatic" set ons_p onset_period]
        [ set infection_state "symptomatic" set infectious? false set ons_p onset_period]
      ]
      if b2 = b1
      [
        ifelse random-float 1.0 < 0.5
        [ set infection_state "symptomatic" set infectious? false set ons_p onset_period]
        [ set infection_state "asymptomatic" set ons_p onset_period]
      ]
    ] [ set inc_p inc_p - 1 ]
  ]

  ;recovered goes back to susceptible after some time
  if infection_state = "recovered" and infectious? = false and immune = true
  [
    ifelse antibody_duration = 0 [
      set infection_state "susceptible" set immune false
    ] [ set antibody_duration antibody_duration - 1]
  ]
end 

to recover ;symptomatic to recover or death? ;asymptomatic to recover?

  if infection_state = "asymptomatic" and infectious? = true
  [
    ifelse ons_p = 0
    [
      set infection_state "recovered" set infectious? false set immune true set antibody_duration 1 / antibody_decay
    ][ set ons_p ons_p - 1]
  ]

  if infection_state = "symptomatic" and infectious? = false
  [
    ;either death or recovery
    ifelse ons_p = 0
    [
      if c2 > c3
      [
        ifelse random-float 1 < c2
        [ set infection_state "recovered" set infectious? false set immune true set antibody_duration 1 / antibody_decay]
        [ set infection_state "dead" set dead true ]
      ]
      if c3 > c2
      [
        ifelse random-float 1 < c3
        [ set infection_state "dead" set dead true]
        [ set infection_state "recovered" set infectious? false set immune true set antibody_duration 1 / antibody_decay]
      ]
      if c2 = c3
      [
        ifelse random-float 1.0 < 0.5
        [ set infection_state "recovered" set infectious? false set immune true set antibody_duration 1 / antibody_decay]
        [ set infection_state "dead" set dead true]
      ]
    ][ set ons_p ons_p - 1]
  ]
end 

to recolor ;green-susceptible ;yellow-presymptomatic ;red-asymptomatic ;violet-symptomatic ;blue-recovered ;black-dead
  if infectious? = false and infection_state = "susceptible" [set color gray + 1]
  if infectious? and infection_state = "presymptomatic" [set color yellow]
  if infectious? and infection_state = "asymptomatic" [set color red]
  if infectious? = false and infection_state = "symptomatic" [set color violet]
  if immune [set color blue]
  if dead [set color black]
end 

;;;;;;;;;;;;;

to-report b2-value
  report 1 - b1
end 

to-report c3-value
  report 1 - c2
end 

to-report antibody-duration
  report 1 / antibody_decay
end 

;;;;;;;;;;;;;

to-report susceptible
  report count turtles with [infection_state = "susceptible"]
end 

to-report presymptomatic
  report count turtles with [infection_state = "presymptomatic"]
end 

to-report asymptomatic
  report count turtles with [infection_state = "asymptomatic"]
end 

to-report symptomatic
  report count turtles with [infection_state = "symptomatic"]
end 

to-report recovered
  report count turtles with [immune = true]
end 

to-report deceased
  report count turtles with [dead = true]
end 

There is only one version of this model, created 15 days ago by Neal Clarin.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.