Disease complex

No preview image

1 collaborator

Default-person Frederick Peck (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.0 • Viewed 23 times • Downloaded 0 times • Run 0 times
Download the 'Disease complex' 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
[
  how-many-people
]

turtles-own
[
  infected?           ;; If true, the person is infected
  cured?              ;; If true, the person has lived through an infection.
  susceptible?        ;; Tracks whether the person is susceptible
  recovery-time       ;; How long this turtle takes to recover
  has-been-infected?  ;; Tracks whether the person has even been infected
  infection-length    ;; How long the person has been infected
]


;;;
;;; SETUP PROCEDURES
;;;

to setup
  clear-all
  set how-many-people 300
  setup-people
  reset-ticks
end 

to setup-people
  let number-immune (how-many-people * (percent-vaccinated / 100))
  let number-infected ((how-many-people - number-immune) * (percent-sick-to-start / 100))
  let number-susceptible (how-many-people - number-immune - number-infected)

  ;; Create the vaccinated turtles
  create-turtles number-immune
  [
    setxy random-xcor random-ycor
    set cured? false
    set infected? false
    set susceptible? false
    set has-been-infected? false

    set shape "person"

    ;; Set the recovery time for each agent to fall on a
    ;; normal distribution around average recovery time
    set recovery-time random-normal average-recovery-time average-recovery-time / 4

    ;; make sure it lies between 0 and 2x average-recovery-time
    if recovery-time > average-recovery-time * 2 [
      set recovery-time average-recovery-time * 2
    ]
    if recovery-time < 0 [ set recovery-time 0 ]


    assign-color
  ]


  ;; Create the infected turtles
  create-turtles number-infected
  [
    setxy random-xcor random-ycor
    set cured? false
    set infected? true
    set susceptible? false
    set has-been-infected? true

    set shape "person"

    ;; Set the recovery time for each agent to fall on a
    ;; normal distribution around average recovery time
    set recovery-time random-normal average-recovery-time average-recovery-time / 4

    ;; make sure it lies between 0 and 2x average-recovery-time
    if recovery-time > average-recovery-time * 2 [
      set recovery-time average-recovery-time * 2
    ]
    if recovery-time < 0 [ set recovery-time 0 ]


    assign-color
  ]

  ;; Create the susceptible turtles
  create-turtles number-susceptible
  [
    setxy random-xcor random-ycor
    set cured? false
    set infected? false
    set susceptible? true
    set has-been-infected? false

    set shape "person"

    ;; Set the recovery time for each agent to fall on a
    ;; normal distribution around average recovery time
    set recovery-time random-normal average-recovery-time average-recovery-time / 4

    ;; make sure it lies between 0 and 2x average-recovery-time
    if recovery-time > average-recovery-time * 2 [
      set recovery-time average-recovery-time * 2
    ]
    if recovery-time < 0 [ set recovery-time 0 ]


    assign-color
  ]
end 

;; Different people are displayed in 3 different colors depending on health
;; White is a healthy but susceptible person
;; Green is a healthy immune (non-susceptible) person
;; Red is an infected person

to assign-color  ;; turtle procedure
  (ifelse
    infected?
    [
      set color red
    ]
    susceptible?
    [
      set color white
    ]
    [
      set color blue  ;; immune
    ])
end 


;;;
;;; GO PROCEDURES
;;;

to go
  if all? turtles [ not infected? ]
    [ stop ]

  ask turtles
    [ move ]

  ask turtles with [ infected? ]
    [ infect
      maybe-recover ]

  ask turtles
    [ assign-color ]

  tick
end 


;; People move about at random.

to move  ;; turtle procedure
  rt random-float 360
  fd 1
end 


;; Infection can occur to any susceptible person nearby

to infect  ;; turtle procedure
   let nearby-susceptible (turtles-on neighbors)
     with [ susceptible? ]

     if nearby-susceptible != nobody
     [ ask nearby-susceptible
       [ if random-float 100 < infection-chance
         [
           set infected? true
           set susceptible? false
           set has-been-infected? true
         ]
       ]
     ]
end 

to maybe-recover
  set infection-length infection-length + 1

  if infection-length > recovery-time
  [
    set infected? false
    set cured? true
    ifelse immune-after-recovery
       [ set susceptible? false ]
       [ set susceptible? true ]

  ]
end 


; Copyright 2011 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created 3 months ago by Frederick Peck.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.