Infectious disease

Infectious disease preview image

2 collaborators

Default-person Michael Ball (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 717 times • Downloaded 32 times • Run 0 times
Download the 'Infectious disease' 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 model simulates the spread of an infectious disease traveling via contact through a randomly moving population. The user can draw walls, buildings, or obstacles in the environment to simulate different environments.

HOW IT WORKS

The agents wander randomly throughout the simulation grid. If a healthy agent occupies a patch with a sick or infected agent, the healthy agent has a chance to become infected. This is controled by the immune-chance slider. A healthy agent that does not become infected, becomes immune. An agent remains infected for a period determined by the incubation-period slider. During this time, the agent is contagious. Once the incubation period ends, the agent becomes sick. Sick agents remain contagious through the length of the disease period (controlled by the disease-period slider). At the end of the disease period, the agent either dies or recovers and becomes immune. This is determined by the terminal-chance slider.

HOW TO USE IT

  1. Use the Draw Walls button to create different landscapes for the agents to move around.
  2. Set the initial healthy and sick populations.
  3. Set the incubation and disease period to desired levels.
  4. Set the chance for immunity and terminal illness.
  5. Click Setup to populate the simulation grid.
  6. Click Go to set the agents in motion.

EXTENDING THE MODEL

Hit me with suggestions, or get into modeling yourself ;)

NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

RELATED MODELS

All disease models

CREDITS AND REFERENCES

Credit goes to: Copyright 2010 Michael D. Ball. All rights reserved. ; See http://www.personal.kent.edu/~mdball/netlogo_models.htm who created the code, Stefan Baumgartner simply updated it to version 6.1.1. and tweaked it a bit.

Comments and Questions

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

Click to Run Model

breed [healthies healthy] ;;Different breeds of turtles to show heatlh state.
breed [infecteds infected]
breed [sicks sick]
breed [immunes immune]
breed [deads dead]

globals [ ;; Global variables.
  total-healthy
  total-sick
  total-infected
  total-immune
  total-dead
]

turtles-own [  ;; Turtle variables.
  turn-check
  wall-turn-check
  incubate
  sickness
  terminal-check
  immune-check
]

to building-draw ;; Use the mouse to draw buildings.
  if mouse-down?
    [
      ask patch mouse-xcor mouse-ycor
        [ set pcolor brown ]]
end 

to setup  ;; Initialize the model.
  clear-turtles
  reset-ticks
  pop-check
  ask patches [set pcolor grey]
  setup-agents
  update-globals
  do-plots
end 

to go  ;; Run the model.
   disease-check
  tick
  repeat 5 [ ask healthies [ fd 0.2 ] display ]
   repeat 5 [ ask infecteds [ fd 0.2 ] display ]
   repeat 5 [ ask sicks [ fd 0.2 ] display ]
   repeat 5 [ ask immunes [ fd 0.2 ] display ]
   update-globals
   do-plots
end 

to setup-agents  ;;  Setup the begining number of agents and their initial states.
  set-default-shape healthies "person"
  set-default-shape infecteds "person"
  set-default-shape sicks "person"
  set-default-shape immunes "person"
  set-default-shape deads "person"

  ask n-of initial-healthy patches with [pcolor  = grey]
     [ sprout-healthies 1
      [ set color blue ] ]

  ask n-of initial-sick patches with [pcolor = grey]
    [ sprout-sicks 1
      [ set color yellow
        set sickness disease-period ] ]
end 

to disease-check ;;  Check to see if an infected or sick turtle occupies the same patch.
  ask healthies [
    if any? other turtles-here with [color = yellow]
    [infect]
    if any? other turtles-here with [color = pink]
    [infect]
    wander
  ]

  ask sicks [
    if any? other turtles-here with [color = blue]
    [infect]
    wander
    set sickness sickness - 1
    if sickness < 1
    [live-or-die]
  ]

  ask infecteds [
    if any? other turtles-here with [color = blue]
    [infect]
    wander
    set incubate incubate - 1
    if incubate = 0
    [get-sick]
  ]

  ask immunes [wander]
end 

to infect ;;  Infect a healthy turtle, test if it is immune and set the incubation timer if it isn't.
  set immune-check random 100
  ifelse immune-check < immune-chance-beforehand
  [recover]
  [ask healthies-on patch-here[
    set breed infecteds
    set incubate incubation-period]
  ask infecteds-on patch-here [set color pink]]
end 

to get-sick ;;  Change an infected turtle into an sick turtle and set the disease progression timer.
   set breed sicks
   set color yellow
   set sickness disease-period
end 

to terminate ;;  Kill a sick turtle who reaches the end of the disease progression and fails the terminal check.
  set breed deads
  set color black
end 

to live-or-die ;; Test if the turtle dies from the disease.
  set terminal-check random 100
  ifelse terminal-check < terminal-chance
  [terminate]
  [recover]
end 

to recover  ;;  Change turtle breed to immune.
  set immune-check random 100
  if immune-chance-after > immune-check
  [set breed immunes
  set color sky]
  if immune-chance-after < immune-check
  [set breed healthies set color blue]
end 

to wander ;; Random movement for agents.
    set turn-check random 20
    if turn-check > 15
    [right-turn]
    if turn-check < 5
    [left-turn]
     if [pcolor] of patch-ahead 1 != grey
     [wall]
end 

to wall ;;  Turn agent away from wall
    set wall-turn-check random 10
    if wall-turn-check >= 6
    [wall-right-turn]
    if wall-turn-check <= 5
    [wall-left-turn]
end 

to wall-right-turn ;;Generate a random degree of turn for the wall sub-routine.
  rt 170
end 

to wall-left-turn ;;Generate a random degree of turn for the wall sub-routine.
  lt 170
end 

to right-turn ;;Generate a random degree of turn for the wander sub-routine.
  rt random-float 10
end 

to left-turn   ;;Generate a random degree of turn for the wander sub-routine.
  lt random-float 10
end 

to update-globals ;;Set globals to current values for reporters.
  set total-healthy (count healthies)
  set total-infected (count infecteds)
  set total-sick (count sicks)
  set total-immune (count immunes)
  set total-dead (count deads)
end 

to do-plots ;; Update graph.
  set-current-plot "Population Totals"
  set-current-plot-pen "Healthy"
  plot total-healthy
  set-current-plot-pen "Infected"
  plot total-infected
  set-current-plot-pen "Sick"
  plot total-sick
  set-current-plot-pen "Immune"
  plot total-immune
  set-current-plot-pen "Dead"
  plot total-dead
end 

to pop-check  ;; Make sure total population does not exceed total number of patches.
  if initial-healthy + initial-sick > count patches
    [ user-message (word "This simulation only has room for " count patches " agents.")
      stop ]
end 

; *** NetLogo 4.1 Model Copyright Notice ***
;
; Copyright 2010 by Michael D. Ball.  All rights reserved.
;
; Permission to use, modify or redistribute this model is hereby granted,
; provided that both of the following requirements are followed:
; a) this copyright notice is included.
; b) this model will not be redistributed for profit without permission
;    from Michael D. Ball.
; Contact Michael D. Ball for appropriate licenses for redistribution for
; profit.
;
; To refer to this model in academic publications, please use:
; Ball, M. (2010).  Infectious Disease Model ver. 1.
; http://www.personal.kent.edu/~mdball/netlogo_models.htm.
; The Center for Complexity in Health,
; Kent State University at Ashtabula, Ashtabula, OH.
;
; In other publications, please use:
; Copyright 2010 Michael D. Ball.  All rights reserved.
; See http://www.personal.kent.edu/~mdball/netlogo_models.htm
; for terms of use.
;
; *** End of NetLogo 4.1 Model Copyright Notice ***

There are 3 versions of this model.

Uploaded by When Description Download
Stefan Baumgartner about 4 years ago info tab updated Download this version
Stefan Baumgartner about 4 years ago added an "immunity after the disease" slider Download this version
Stefan Baumgartner about 4 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Infectious disease.png preview Preview for 'Infectious disease' about 4 years ago, by Stefan Baumgartner Download

This model does not have any ancestors.

This model does not have any descendants.