turtles-own [ sick? ;; if true, the turtle is infectious immune? ;; if true, the turtle can't be infected recover? ;; if true, the turtle has recovered sick-count ;; how long the turtle has been infectious age ] ;; how many weeks old the turtle is globals [ weeks ;; each tick is called a week %infected ;; what % of the population is infectious %immune ;; what % of the population is immune %dead ;; mortality 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 on the screen at one time dead ] ;; the total number of turtles that has died ;; The setup is divided into three subroutines to setup ca set weeks 0 setup-constants setup-turtles update-plot update-global-variables 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" cct people [ setxy random-float screen-size-x random-float screen-size-y set age random lifespan set sick-count 0 set dead 0 set %dead 0 set immune? false set recover? false ifelse (who < ((init-infected / 100) * people)) ;; set initially infected people [ get-sick] [ get-healthy ] if (who < (((init-immune / 100) * people) + ((init-infected / 100) * people)) and (not sick?)) ;; set initially immune people [become-immune] ] 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 recover? true 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 blue end to make-die set dead (dead + 1) set %dead (%dead + 1) set shape "dead" wait 0.2 ;; Make some time to show dying turtles flash yellow crosses die end to setup-constants set lifespan 100 set carrying-capacity 750 ;;set average-offspring 0 end to go set %dead 0 set weeks (weeks + 1) get-older move infect recover reproduce if not any? turtles [stop] ;; Stop when the population is extinct update-global-variables update-plot end to update-global-variables set %infected (count turtles with [sick?]) / (count turtles) * 100 set %immune (count turtles with [immune?]) / (count turtles) * 100 if %dead = 0 [stop] ;; Prevent division by zero in last run set %dead (%dead / (count turtles with [sick?] + %dead) * 100) ;; calculate %mortality 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-float 100 - random-float 100 fd 1 ] end ;; If a turtle is sick, it infects other turtles on the same patch. ;; Immune turtles don't get sick but are still contageous to infect ask turtles with [sick? or recover?] ;; recovered people are still contageous [ ask other-turtles-here with [ (not immune?) and (not sick?) ] [ 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 set recover? true ] [ make-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 and (count turtles) > 1 ;; assuming sexual reproduction which needs at least two [ hatch 1 [ set age 1 lt 45 fd 1 get-healthy ] ] ] end to update-plot set-current-plot "Populations" set-current-plot-pen "#sick" plot count turtles with [sick?] set-current-plot-pen "#immune" plot count turtles with [immune?] set-current-plot-pen "#healthy" plot count turtles with [not sick? and not immune?] set-current-plot-pen "%mortality" plot (%dead) end ; *** NetLogo Model Copyright Notice *** ; ; This model was created as part of the project: CONNECTED MATHEMATICS: ; MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL ; MODELS (OBPML). The project gratefully acknowledges the support of the ; National Science Foundation (Applications of Advanced Technologies ; Program) -- grant numbers RED #9552950 and REC #9632612. ; ; Copyright 1998 by Uri Wilensky. 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 Uri Wilensky. ; Contact Uri Wilensky for appropriate licenses for redistribution for ; profit. ; ; This model was converted to NetLogo as part of the project: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN ; CLASSROOMS. The project gratefully acknowledges the support of the ; National Science Foundation (REPP program) -- grant number REC #9814682. ; Converted from StarLogoT to NetLogo, 2001. Updated 2002. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (1998). NetLogo Virus model. ; http://ccl.northwestern.edu/netlogo/models/Virus. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; In other publications, please use: ; Copyright 1998 by Uri Wilensky. All rights reserved. See ; http://ccl.northwestern.edu/netlogo/models/Virus ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 321 11 707 418 13 13 13.93 1 10 1 1 1 CC-WINDOW 321 455 707 563 Command Center SLIDER 33 230 227 263 duration duration 0.0 99.0 4.0 1.0 1 weeks SLIDER 33 196 227 229 chance-recover chance-recover 0.0 99.0 30.0 1.0 1 % SLIDER 33 162 227 195 infectiousness infectiousness 0.0 99.0 40.0 1.0 1 % BUTTON 55 10 125 45 NIL setup NIL 1 T OBSERVER T BUTTON 131 10 202 46 NIL go T 1 T OBSERVER T PLOT 9 377 311 563 Populations weeks people 0.0 52.0 0.0 150.0 true true PENS "#sick" 1.0 0 -65536 true "#immune" 1.0 0 -16776961 true "#healthy" 1.0 0 -11352576 true "%mortality" 1.0 0 -13421773 true SLIDER 33 57 227 90 people people 0 300 99 1 1 NIL MONITOR 9 317 84 366 NIL %infected 1 1 MONITOR 88 317 158 366 NIL %immune 1 1 MONITOR 255 318 311 367 years weeks / 52 1 1 SLIDER 33 92 227 125 init-infected init-infected 0 100 4 1 1 % SLIDER 33 127 227 160 init-immune init-immune 0 100 4 1 1 % MONITOR 162 317 251 366 total viral deaths dead 1 1 MONITOR 243 471 306 520 population count turtles 0 1 SLIDER 33 265 227 298 average-offspring average-offspring 0 10 4 1 1 NIL @#$#@#$#@ VIRUS 2 -- Marco J. de Vries ------- I have adapted and extended the original VIRUS model of Dr. Wilensky. I added the assumption that recovered and immune people are still able to transmit the virus. I added the following sliders init-infected: sets the initially infected people, instead of the constant ten in the original model. init-immune: gives the possibility to render a part of the population already immune from the start. average-offspring: originally a constant (it is a variable with a considrable weight). I added the following monitors Viral deaths: monitors the count of people who have died of the disease. population: monitors the count of the total population In the place of total population, I added the % mortality of viral infection to the plotting routine. Dying people will flash yellow briefly in the graph window. I added 2 escape routines to prevent division by zero under extreme conditions. WHAT IS IT? -- original description of Dr. Wilensky ----------- This model simulates the transmission and perpetuation of a virus in a human population. Ecological biologists have suggested a number of factors which may influence the survival of a directly transmitted virus within a population. (Yorke, et al. "Seasonality and the requirements for perpetuation and eradication of viruses in populations." Journal of Epidemiology, volume 109, pages 103-123) The model is initialized with 150 people, of which 10 are infected. People move randomly about the screen in one of three states: healthy and susceptible to infection (green), sick and infectious (red), and healthy and immune (white). People may die of infection or old age. When the population dips below the environment's "carrying capacity" (set at 700 in this model) healthy people may reproduce healthy and susceptible offspring. Some of these factors are summarized below with an explanation of how each one is treated in this model. The density of the population ----------------------------- Population density affects how often infected, immune and susceptible individuals come into contact with each other. You can change the size of the initial population through the PEOPLE slider. Population turnover ------------------- As individuals die, some who die will be infected, some will be susceptible and some will be immune. All the new individuals who are born, replacing those who die, will be susceptible. People may die from the virus, the chances of which are determined by the slider CHANCE-RECOVER, or they may die of old age. In this model, people die of old age at the age of approximately 27 years. Reproduction rate is constant in this model. Each turn, every healthy individual has a chance to reproduce. That chance is set so that each person will on average reproduce four times if they live 27 years. Degree of immunity ------------------ If a person has been infected and recovered, how immune are they to the virus? We often assume that immunity lasts a lifetime and is assured, but in some cases immunity wears off in time and immunity might not be absolutely secure. Nonetheless, in this model, immunity does last forever and is secure. Infectiousness (or transmissibility) ------------------------------------ How easily does the virus spread? Some viruses with which we are familiar spread very easily. Some viruses spread from the smallest contact every time. Others (the HIV virus, which is responsible for AIDS, for example) require significant contact, perhaps many times, before the virus is transmitted. In this model, infectiousness is determined by a slider. Duration of infectiousness -------------------------- How long is a person infected before they either recover or die? This length of time is essentially the virus's window of opportunity for transmission to new hosts. In this model, duration of infectiousness is determined by a slider. HOW TO USE IT ------------- Each "tick" represents a week in the time scale of this model. The INFECTIOUSNESS slider determines how great the chance is that virus transmission will occur when an infected person and susceptible person occupy the same patch. For instance, when the slider is set to 50, the virus will spread roughly once every two chance encounters. The DURATION slider determines the percent of the average life-span (which is 1500 weeks, or approximately 27 years, in this model) that an infected person goes through before the infection ends in either death or recovery. Note that although zero is a slider possibility, it produces an infection of very short duration (approximately 2 weeks) not an infection with no duration at all. The CHANCE-RECOVERY slider controls the likelihood that an infection will end in recovery/immunity. When this slider is set at zero, for instance, the infection is always deadly. The SETUP button resets the graphics and plots and randomly distributes 140 green susceptible people and 10 red infected people (of randomly distributed ages). The GO button starts the simulation and the plotting function. Three output monitors show the percent of the population that is infected, the percent that is immune, and the number of years that have passed. The plot shows (in their respective colors) the number of susceptible, infected, and immune people. It also shows the number of individuals in the total population in blue. THINGS TO NOTICE -------------------- The factors controlled by the three sliders interact to influence how likely the virus is to thrive in this population. Notice that in all cases, these factors must create a balance in which an adequate number of potential hosts remain available to the virus and in which the virus can adequately access those hosts. Often there will initially be an explosion of infection since no one in the population is immune and the population density is at its maximum. This approximates the initial "outbreak" of a viral infection in a population, one that often has devastating consequences for the humans concerned. Soon, however, the virus becomes less common as the population dynamics change. What ultimately happens to the virus is determined by the factors controlled the sliders. Notice that viruses that are too successful at first (infecting almost everyone) may not survive in the long term. Since everyone infected generally dies or becomes immune as a result, the potential number of hosts is often limited. The exception to the above is when the DURATION slider is set so high that population turnover (reproduction) can keep up and provide new hosts. THINGS TO TRY ------------- Think about how different slider values might approximate the dynamics of real-life viruses. The famous Ebola virus in central Africa has a very short duration, a very high infectiousness value, and an extremely low recovery rate. For all the fear this virus has raised, how successful is it? Set the sliders appropriately and watch what happens. The HIV virus which causes AIDS, has an extremely long duration, an extremely low recovery rate, but an extremely low infectiousness value. How does a virus with these slider values fare in this model? EXTENDING THE MODEL ------------------- Add additional sliders controlling the carrying capacity of the world (how many people can be on the screen at one time) and the average lifespan of the people. Build a similar model simulating viral infection of a non-human host with very different reproductive rates, lifespans, and population densities. Add a slider controlling how long immunity lasts so that immunity is not perfect or eternal. CREDITS AND REFERENCES ---------------------- To refer to this model in academic publications, please use: Wilensky, U. (1998). NetLogo Virus model. http://ccl.northwestern.edu/netlogo/models/Virus. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. In other publications, please use: Copyright 1998 by Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/Virus for terms of use. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 dead false 0 Rectangle -7566196 true true 114 55 188 288 Rectangle -7566196 true true 50 109 112 149 Rectangle -7566196 true true 49 108 117 152 Rectangle -7566196 true true 187 109 263 152 Rectangle -7566196 true true 42 108 49 150 Rectangle -7566196 true true 41 150 48 151 Rectangle -7566196 true true 42 148 46 151 Rectangle -7566196 true true 41 150 47 152 Rectangle -7566196 true true 188 151 262 154 Rectangle -7566196 true true 38 107 42 152 Rectangle -7566196 true true 47 150 48 150 Rectangle -7566196 true true 38 150 115 161 Rectangle -7566196 true true 187 154 262 164 Rectangle -7566196 true true 114 287 187 297 Rectangle -256 true false 114 54 186 297 Rectangle -256 true false 37 106 262 162 healthy-person false 15 Circle -11352576 true false 108 3 80 Rectangle -11352576 true false 89 76 209 205 Polygon -11352576 true false 89 75 23 139 26 151 54 151 99 100 Polygon -11352576 true false 207 75 275 137 275 150 245 150 200 99 Polygon -11352576 true false 148 204 118 298 74 298 108 205 Polygon -11352576 true false 155 204 172 298 211 298 190 203 person false 0 Circle -7566196 true true 104 15 94 Rectangle -7566196 true true 107 107 193 231 Line -7566196 true 60 128 242 129 Line -7566196 true 127 230 107 286 Line -7566196 true 170 230 193 284 @#$#@#$#@ NetLogo 2.0.0 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@