COVID19-variable-SD-Testing

COVID19-variable-SD-Testing preview image

7 collaborators

Emb-carnet Eduardo Bringa (Author)
Diego_19-12-20_crop Diego Vazquez (Team member)
Default-person Romina Aparicio (Team member)
Default-person Geraudys Mora (Team member)

Tags

Model group COVID19-Simulation-Mza | Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 556 times • Downloaded 51 times • Run 0 times
Download the 'COVID19-variable-SD-Testing' modelDownload this modelEmbed this model

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


WHAT IS IT?

This is an extension of the model “Effects of testing and social distancing on the spread of infectious diseases ("Flattening the Curve")” by Shikhara Bhat http://modelingcommons.org/browse/one_model/6238#model_tabs_browse_info

This is a model to describe the effect of social distancing (SD) and testing on the spread of an infectious disease, using the SIRS model for spread of infectious diseases.

HOW IT WORKS

At the beginning of the model, a certain number of people in the population (controlled by the parameter NUMBER _ SICK) are INFECTED (shown in red), and the rest are SUSCEPTIBLE to infection (shown in green). This infection spreads according to the rules described below. The model stops once either everybody is infected, or nobody is infected (i.e the infection has 'died out')

Infection (the SIRS model)

A SUSCEPTIBLE person can acquire the disease from an INFECTED with probability TRANSMISSIBILITY, if they are within MAX _ INF _ RADIUS of that person.

All INFECTED have the potential to recover from the disease after time INFECTION _ PERIOD has passed. Once this time has passed, an INFECTED individual becomes a RECOVERED individual (shown in blue) with probability RECOVERY _ RATE.

RECOVERED individuals cannot acquire the infection. Every RECOVERED individual has the potential to lose their immunity, and become SUSCEPTIBLE again, with probability SUSCEPTIBILITY.

Social Distancing (SD)

A percentage of the individuals, determined by PERCENTAGESD, is assigned an exclusion radius or SDradius obtained from a DISTRISD (Uniform, Normal or Poisson) radius distribution, with mean value SDMean. If MovementType= “MetropolisT=0”, the individuals move to a new position only if there isn't another individual within a distance of its own exclusion radius, and do not move otherwise. If MovementType= “awayfrommean”, individuals move away from their location if there are any other individuals within a distance of its own exclusion radius from them, and do not move otherwise. Individuals with no exclusion radius assigned, move randomly in either MovementType configuration.

Testing

A random sample (of size NUM _ TO _ TEST) of the population is tested for the disease at regular intervals (A test is conducted once every TEST _ PERIOD ticks). If an individual is found to be infected, they are removed from the population (This represents quarantine).

HOW TO USE IT

Set a random SEED, to make sure that the runs both begin with the same initial positions and statuses of the agents. Press SETUP to set the model with the initial conditions you have chosen (on the sliders), and press GO to run the model. Press CLEAR PLOT to clear the plot of all graphs, if the view gets too cluttered

Set a random SEED, to make sure that the runs both begin with the same initial positions and statuses of the agents. With NUMEXPERIMENTS one can set a number of different runs to get statistical averages. Press SETUP to set the model with the initial conditions you have chosen (on the sliders), and press GOEXPERIMENTS to run the model. Press CLEAR PLOT to clear the plot of all graphs, if the view gets too cluttered

Two OUTPUT files will be generated: LAMMPSFILE and OUTPUTFILE. The names of these files can be changed in the corresponding text boxes of the interface. The first file is a DUMMP file to be read by graphical softwares such as Ovito to produce movies or snapshots. This file saves the coordinates, type(Infected, Susceptible, Recovered) and SDradius of all individuals every FREQDUMP_FILE ticks. The second output file is a .dat file containing the average infected individuals over time and the standard deviation of the average values.

THINGS TO NOTICE

Social distancing 'flattens the curve'. In the real world, this means that the rate of infection is lower, greatly decreasing the burden on healthcare professionals and medical institutions, and thus lowering overall death rates. This is why social distancing is so important in the event of an epidemic/pandemic. Additionally, effective testing (either large number of individuals being tested at each step, or more tests being conducted in the same amount of time) can also flatten the curve.

THINGS TO TRY

Change the ratio of MIN _ SD _ RADIUS to MIN _ INF _ RADIUS to see how this affects the effectiveness of social distancing. In real world terms, this could be seen as a measure of HOW MUCH distance (not necessarily simply physical) you need to maintain for social distancing to be effective.

Try changing the MOVEMENT_TYPE to see how these rules affect the dynamics and the final results. Try changing the distributions of the SD to see how this modifies the flattening of the curve. Specially, compare UNIFORM distribution to others to see the effect of not all individuals having the same amount of SD.

EXTENDING THE MODEL

Suppose quarantined individuals aren't permanently removed but are instead 're-inserted' into the population as healthy individuals once the infection period has passed. How does this affect dynamics? Suppose individuals in the population can reproduce and die of old age (or die due to the disease itself). How is the model affected by this?

RELATED MODELS

“Effects of testing and social distancing on the spread of infectious diseases ("Flattening the Curve") “, by Shikhara Bhat (Author) .
http://modelingcommons.org/browse/one_model/6238#model_tabs_browse_info

The AIDS model (in the Biology section of the standard NetLogo models).

CREDITS AND REFERENCES

SIR model: Kermack, W; McKendrick, A (1991). "Contributions to the mathematical theory of epidemics—I". Bulletin of Mathematical Biology. 53 (1–2): 33–55. doi:10.1007/BF02464423

Comments and Questions

Ancestors and extensions

This is an extension of the model “Effects of testing and social distancing on the spread of infectious diseases ("Flattening the Curve")” by Shikhara Bhat. http://modelingcommons.org/browse/one_model/6238 Includes variable Social Distance and different types of agent motion. Also includes output with agent position and type.

Posted over 5 years ago

Model Info and NetLogo Web

detailed Model Info can be found by using "Run in NetLogo" and then clicking on "Model Info" at the bottom. Running in NetLogo Web is not yet possible, and we are working to solve this issue as soon as possible.

Posted over 5 years ago

Downloading the model

There is a problem with the zip file obtained by clicking on "Download this model ". To download a working version: Run in NetLogo Web--&rt; Click to Run Model --&rt; Export NetLogo. The "Export" buttom is at the top-rigth corner of the web screen.

Posted over 5 years ago

Click to Run Model

;-------------------------------------------------------------------------------------------------------------------
;
;
;
; percentage_SD:      % of agents who keep SD
;
; SD_mean, SD_sigma:  mean value and variance of SD (normal distribution)
;
; movement_type:      "away from mean" o "metropolis T=0"
;
; test_period:        ticks between tests
;
; num_to_test:        number of tests performed each test_period ticks
;
; max_inf_radius:     maximum radius of infection
; transmissibility:   probability of becoming infected when there is a patient less than max_inf_radius
;
;
;-------------------------------------------------------------------------------------------------------------------

extensions [array]     ; to use arrays

globals [acum acum2 sigma n_experiments t s1 s2]

breed [infecteds infected]
breed [susceptibles susceptible]
breed [recovereds recovered]

infecteds-own [ clock tested? ]

turtles-own [ neighbours keep_SD SD_own xcor_old ycor_old ]




;-------------------------------------------------------------------------------------------------------------------
; General setup and setup to restart an experiment
;-------------------------------------------------------------------------------------------------------------------

to setup
  set acum array:from-list n-values t_max [0]   ; fill the array with zeros
  set acum2 array:from-list n-values t_max [0]
  set sigma array:from-list n-values t_max [0]
  set n_experiments 1        ; set number of experiments initially to zero

  setup-experiment

  let LX ( max-pxcor * 2 + 1)
  let LY ( max-pycor * 2 + 1)

  clear-output
  output-print "DENSITY:"
  output-write (number / (LX * LY)) output-print " agents/m2"
  output-write ((LX * LY) / number) output-print " m2/agent"
  output-write sqrt ((LX * LY) / number) output-print " average distance"
end 

; setup for a new experiment

to setup-experiment

  clear-turtles
  clear-ticks
  random-seed new-seed    ; to start each simulation with a different seed
  create-turtles number
  [setxy random-xcor random-ycor
    set size 1
    set keep_SD ((random-float 1) < (percentage_SD / 100.0))  ; is a fixed attribute of each agent
    (ifelse distri_SD = "uniforme"
    [
      set SD_own SD_mean
    ]
    distri_SD = "normal"
    [
      set SD_own random-normal SD_mean SD_sigma
      if (SD_own < 0 )  [set SD_own 0 ]
    ]
    distri_SD = "poisson"
    [
      set SD_own random-poisson SD_mean
    ])

    ifelse (who < number_sick_initial)
    [set breed infecteds
    set clock 0
    set tested? False]
    [set breed susceptibles]
    recolor
  ]
  reset-ticks

  file-close ;cierra el lammps_file
  if file-exists? lammps_file     
      [ file-delete lammps_file ] 
  file-open lammps_file
end 

to recolor
  if (breed = susceptibles) [
    set color green
  ]
  if (breed = infecteds) [
    ifelse (tested? = True)
    [set color white]
    [set color red]
  ]
  if (breed = recovereds) [
    set color blue
  ]
end 


;-------------------------------------------------------------------------------------------------------------------
; move
;-------------------------------------------------------------------------------------------------------------------

to move [dist]
  ifelse(keep_SD) ; that an agent save SD is an attribute that is defined in setup with some probability
  [ ; aqui guarda SD...

    (ifelse
    movement_type = "metropolis T=0"
    [
      ; type of Metropolis movement at temperature 0 (move-count-accept-reject)
      set xcor_old xcor
      set ycor_old ycor
      rt random-float 360
      fd dist
      if (count(other turtles in-radius SD_own) >= 1 )
      [ set xcor xcor_old
        set ycor ycor_old
      ]

    ]
    movement_type = "away from mean"
    [
      ; type of movement runs away from the center of mass of neighbors (counts-turns 180-moves)
      set neighbours other turtles in-radius SD_own
      if (count(neighbours) >= 1) ;Move only if you have neighbours
      [
        facexy (mean [xcor] of neighbours)
               (mean [ycor] of neighbours)
        rt 180  ; Turn away from the mean x and y co_ordinates of your neighbours
        fd dist
      ]

    ]
    [
      error 111
    ])

  ]
  [
    ; random walk...
    rt random-float 360  ;Turn to a random direction
    fd dist

  ]
end 

to get_infected ;S _> I
  let sick_neighbours infecteds in-radius max_inf_radius
  if (breed = susceptibles and count sick_neighbours  >= 1)
   [if ((random-float 1) <  (1 - ((1 - transmissibility_rate)^(count(sick_neighbours)))))
    [set breed infecteds
      set clock 0
      set tested? False]
      ]
end 

to recover ;I _> R
  if (clock >= infection_period and (random-float 1 < recovery_rate))
    [set breed recovereds]
end 

to lose_immunity ;R _> S
  if (random-float 1 < lose_immunity_rate)
  [set breed susceptibles]
end 

to advance_clock ;For recovery of infected people
  set clock (clock + 1)
end 

to runtest
  if (breed = infecteds)
  [die]
end 

to test;
  ifelse (num_to_test <= count(turtles))
    [let testsubjects n-of num_to_test turtles
    ask (testsubjects) [runtest]]
    [ask (turtles) [runtest]]
end 

;-------------------------------------------------------------------------------------------------------------------
; go to do various experiments and average
;-------------------------------------------------------------------------------------------------------------------

to go-experiments

  go

  if (count(infecteds) = 0 or count(infecteds) = count(turtles) or ticks > t_max) ;Stop if nobody is infected, or everybody is infected
  [
    ; if you enter here start a new experiment

    if (n_experiments = num_experiments)
    [
      file-close ;cierra el lammps_file
      if file-exists? output_file     
         [ file-delete output_file ]  
      file-open output_file
      file-print "# t infecteds error"
      set t 0
      while [t < t_max]
      [
        set s1 array:item acum t
        set s2 array:item acum2 t
        array:set sigma t sqrt ( s2 / num_experiments - ( (s1 / num_experiments) ^ 2 ) )
        file-write t
        file-write ( s1 / num_experiments )
        file-write ( ( array:item sigma t ) / sqrt(num_experiments ) )
        file-print ""
        set t (t + 1)
      ]
      file-close
      stop
    ]
    set n_experiments (n_experiments + 1)
    setup-experiment
  ]
end 

to lammps
  file-print "ITEM: TIMESTEP"
  file-print ticks
  file-print "ITEM: NUMBER OF ATOMS"
  file-print count turtles
  file-print "ITEM: BOX BOUNDS xx yy zz"
  file-write min-pxcor
  file-type " "
  file-print max-pxcor
  file-write min-pycor
  file-type " "
  file-print max-pycor
  file-print "0.0 0.0"
  file-print "ITEM: ATOMS id type x y z radius"
  ask (recovereds) [
    file-write who
    file-write 1
    file-type " "
    file-write xcor
    file-type " "
    file-write ycor
    file-type " "
    file-write 0.0
    file-type " "
    file-print SD_own
  ]
  ask (susceptibles) [
    file-write who
    file-write 2
    file-type " "
    file-write xcor
    file-type " "
    file-write ycor
    file-type " "
    file-write 0.0
    file-type " "
    file-print SD_own
  ]
  ask (infecteds) [
    file-write who
    file-write 3
    file-type " "
    file-write xcor
    file-type " "
    file-write ycor
    file-type " "
    file-write 0.0
    file-type " "
    file-print SD_own
  ]
end 

; go of an experiment

to go

  if (ticks mod freq_dump_file = 0)
     [lammps]

  ask (recovereds) [lose_immunity]
  ask (susceptibles) [get_infected]
  ask (infecteds) [advance_clock]
  ask (infecteds) [recover]
  ask (turtles) [move 1]
  ask (turtles) [recolor]
  if (ticks mod test_period = 0)
      [test]

  if ticks < t_max
  [
    array:set acum ticks  ( array:item acum ticks  + (100 * count(infecteds) / count(turtles) ) )
    array:set acum2 ticks ( array:item acum2 ticks + ((100 * count(infecteds) / count(turtles)) ^ 2) )

    set s1 array:item acum ticks
    set s2 array:item acum2 ticks
    array:set sigma ticks sqrt ( s2 / n_experiments - ( (s1 / n_experiments) ^ 2 ) )
  ]

  tick
end 

There are 4 versions of this model.

Uploaded by When Description Download
Eduardo Bringa over 5 years ago Modified Info Download this version
Eduardo Bringa over 5 years ago Corrected error calculation. Download this version
Fabricio Fioretti over 5 years ago minor changes Download this version
Eduardo Bringa over 5 years ago Initial upload Download this version

Attached files

File Type Description Last updated
COVID19-variable-SD-Testing.png preview Preview for 'COVID19-variable-SD-Testing' over 5 years ago, by Eduardo Bringa Download

This model does not have any ancestors.

This model does not have any descendants.