Example base simulation
Model was written in NetLogo 6.1.1
•
Viewed 72 times
•
Downloaded 12 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
turtles-own [ sick? ;; if true, the turtle is infectious remaining-immunity ;; how many weeks of immunity the turtle has left sick-time ;; how long, in weeks, 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 lifespan of a turtle chance-reproduce ;; the probability of a turtle generating an offspring each tick carrying-capacity ;; the number of turtles that can be in the world at one time immunity-duration ] ;; how many weeks immunity lasts ;; The setup is divided into four procedures to setup clear-all setup-constants setup-turtles update-global-variables update-display reset-ticks end ;; We create a variable number of turtles of which 10 are infectious, ;; and distribute them randomly to setup-turtles create-turtles number-people [ setxy random-xcor random-ycor set age random lifespan set sick-time 0 set remaining-immunity 0 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 remaining-immunity 0 end to get-healthy ;; turtle procedure set sick? false set remaining-immunity 0 set sick-time 0 end to become-immune ;; turtle procedure set sick? false set sick-time 0 set remaining-immunity immunity-duration end ;; This sets up basic constants of the model. to setup-constants set lifespan 50 * 52 ;; 50 times 52 weeks = 50 years = 2600 weeks old set carrying-capacity 300 set chance-reproduce 1 set immunity-duration 52 end to go ask turtles [ get-older move if sick? [ recover-or-die ] ifelse sick? [ infect ] [ reproduce ] ] update-global-variables update-display 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 to update-display ask turtles [ if shape != turtle-shape [ set shape turtle-shape ] set color ifelse-value sick? [ red ] [ ifelse-value immune? [ grey ] [ green ] ] ] end ;;Turtle counting variables are advanced. to get-older ;; turtle procedure ;; Turtles die of old age once their age exceeds the ;; lifespan (set at 50 years in this model). set age age + 1 if age > lifespan [ die ] if immune? [ set remaining-immunity remaining-immunity - 1 ] if sick? [ set sick-time sick-time + 1 ] end ;; Turtles move about at random. to move ;; turtle procedure 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 ;; turtle procedure ask other turtles-here with [ not sick? and 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-or-die ;; turtle procedure if sick-time > duration ;; 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. to reproduce if count turtles < carrying-capacity and random-float 100 < chance-reproduce [ hatch 1 [ set age 1 lt 45 fd 1 get-healthy ] ] end to-report immune? report remaining-immunity > 0 end to startup setup-constants ;; so that carrying-capacity can be used as upper bound of number-people slider end ; Copyright 1998 Uri Wilensky. ; See Info tab for full copyright and license.
There is only one version of this model, created over 4 years ago by john blue.
This model does not have any ancestors.
This model does not have any descendants.