virus 2

virus 2 preview image

1 collaborator

Virus_2 xarty ulep (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.3 • Viewed 297 times • Downloaded 29 times • Run 0 times
Download the 'virus 2' 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

virus 2 (Question)

This model simulates the transmission and perpetuation of a virus in a human population. removed stat infacted

Posted about 12 years ago

Click to Run Model

turtles-own
  [ sick?        ;; if true, the turtle is infectious
    immune?      ;; if true, the turtle can't be infected
    sick-count   ;; how long the turtle has been infectious
    age ]        ;; how many weeks old the turtle is

globals
[
  %infected            ;; what % of the population is infectious
  %immune              ;; what % of the population is immune
  lifespan             ;; the average lifespan of a turtle
  average-offspring    ;; the average number of offspring a turtle could have
  carrying-capacity    ;; the number of turtles that can be in the world at one time
]

;; The setup is divided into three subroutines

to setup
  clear-all
  setup-constants
  setup-turtles
  update-global-variables
  reset-ticks
end 

;; We create a variable number of turtles of which 10 are infectious,
;; and distribute them randomly

to setup-turtles
  set-default-shape turtles "person"
  crt people
    [ setxy random-xcor random-ycor
      set age random lifespan
      set sick-count 0
      set immune? false
      set size 1.5  ;; easier to see
      get-healthy ]
  ask n-of 10 turtles
    [ get-sick ]
end 

to get-sick ;; turtle procedure
  set sick? true
  set immune? false
  set color red
end 

to get-healthy ;; turtle procedure
  set sick? false
  set immune? false
  set sick-count 0
  set color green
end 

to become-immune ;; turtle procedure
  set sick? false
  set sick-count 0
  set immune? true
  set color gray
end 

to setup-constants
  set lifespan 100
  set carrying-capacity 750
  set average-offspring 4
end 

to go
  get-older
  move
  infect
  recover
  reproduce
  update-global-variables
  tick
end 

to update-global-variables
  if count turtles > 0
  [
    set %infected (count turtles with [sick?]) / (count turtles) * 100
    set %immune (count turtles with [immune?]) / (count turtles) * 100
  ]
end 

;;Turtle counting variables are advanced.

to get-older
  ask turtles
  [
    set age age + 1
    if sick?
      [ set sick-count (sick-count + 1) ]
    ;; Turtles die of old age once their age equals the
    ;; lifespan (set at 1500 in this model).
    if age > lifespan
      [ die ]
  ]
end 

;;Turtles move about at random.

to move
  ask turtles
  [ rt random 100
    lt random 100
    fd 1 ]
end 

;; If a turtle is sick, it infects other turtles on the same patch.
;; Immune turtles don't get sick.

to infect
  ask turtles with [sick?]
    [ ask other turtles-here with [ not immune? ]
        [ if (random-float 100) < infectiousness
            [ get-sick ] ] ]
end 

;; Once the turtle has been sick long enough, it
;; either recovers (and becomes immune) or it dies.

to recover
   ask turtles with [sick?]
     [ if (random sick-count) > (lifespan * (duration / 100))  ;; If the turtle has survived past the virus' duration, then
         [ ifelse ((random-float 100) < chance-recover)        ;; either recover or die
             [ become-immune ]
             [ die ] ] ]
end 

;; If there are less turtles than the carrying-capacity
;;  then turtles can reproduce.
;; The probability of reproduction depends on average number
;;  of offspring per life.  In this model it is 4 per life (e.g.
;;  4 per 100 weeks.  The chance, therefore, for a turtle to
;;  reproduce at any given turn is 0.04 (if the population
;;  is below carrying-capacity).

to reproduce
  ask turtles with [not sick?]
    [ if (count turtles) < carrying-capacity
         and (random lifespan) < average-offspring
       [ hatch 1
           [ set age 1
             lt 45 fd 1
             get-healthy ] ] ]
end 


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

There is only one version of this model, created about 12 years ago by xarty ulep.

Attached files

File Type Description Last updated
virus 2.nlogo extension hey there about 12 years ago, by xarty ulep Download
virus 2.png preview Preview for 'virus 2' about 12 years ago, by xarty ulep Download

This model does not have any ancestors.

This model does not have any descendants.