Helping Agents in Epidemics

No preview image

2 collaborators

Default-person Dorothy Catey (Author)
Default-person Bert Baumgaertner (Advisor)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.3 • Viewed 463 times • Downloaded 48 times • Run 0 times
Download the 'Helping Agents in Epidemics' 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 illustrates the impact of "helping" agents on the outcome of epidemics.

HOW IT WORKS

At the beginning of a simulation, N agents are placed on the map. Some of these are assigned as helpers, while the others are default agents. A small number begin as infected. As the simulation progresses, agents move according to the movement strategy selected by the "interaction-type" chooser. These movement strategies include random movement, infected seeking, helper seeking, infected smart seeking, helper smart seeking, and dual smart seeking. These strategies are discussed in more detail in the How to Use It section below. When an infected agent and susceptible agent are in contact, there is a chance of disease transmission. When a helping agent is in contact with an infected agent, the helping agent raises the probability of the infected agent's recovery at that time step. When no more infected agents remain, the simulation ends.

HOW TO USE IT

Run the model a few times with the default values. The Turtle Count plot keeps track of the number of agents of each color (black: susceptible, red: infected, blue: recovered). The Total Contacts plot keeps track of how many times agents have been within each other's infrad. The r0 display shows the r0 at the end of the simulation. R0 is the average number of agents infected by the initially infected agents before they recover.

world-size: Specifies the length and width of the world (world-size + 1 by world-size + 1)

N: specifies the total number of agents in the simulation.

N-H: specifies the number of helping agents in the simulation (must be smaller than N).

N-I: specifies the number of infected agents at the beginning of the simulation. Helping agents can be chosen as initially infected.

infrad: specifies a radius around an infected individual. Agents within this radius interact with the infected agent, and disease can be transmitted.

hrad: specifies a radius around a helper agent. Infected agents within this radius receive an increase in probability of recovery. If there are multiple agents within a single helper's radius, the total help a helper can provide is split evenly between them.

infectprob: Given an interaction with an infected individual, the probability that an agent will become sick (modified by the fraction of infected agents within the infrad).

recoverprob: Each infected agent recovers with this probability at each time step.

maxhelp: The maximum amount a helper agent can increase the recoverprob of a single agent.

helper-immunity: At 0, the helper agents are just as susceptible as the default agents. At 1, the helper agents are immune to disease. Intermediate values modify the probability of a helper agent getting infected.

interaction-type: Specifies how each type of agent will move.

Random Movement: Each agent moves randomly.

Helper Seek: Helping agents move toward the nearest infected.

Infected Seek: Infected agents move toward the nearest helping agent (who is not also infected).

Helper Smart Seek: Helper agents move as in Helper Seek, but only move toward infected agents without a helper already nearby.

Infected Smart Seek: Infected agents move as in Infected Seek, but only move toward helping agents that are not already nearby an infected.

Dual Smart Seek: Both Infected and Helper agents move according to Helper Smart Seek and Infected Smart Seek.

THINGS TO NOTICE

Notice how the counts for each agent type vary during the epidemic. Do the curves change shape if you run the model multiple times with the same parameters? Does R0 change? Multiple measured variables are assigned throughout the simulation. Consider plotting these or displaying these: max-infected, max-infected-time, end-time, final-epi-size.

THINGS TO TRY

Change the probabilities of infection and recovery to extreme values. Do your observations match what you expected? How does the number of agents initially infected affect the final epidemic size? How many do you need to get at least 10% of the agents infected every time? What is the optimal number of helpers? Should they be immune? What level of immunity is realistic?

EXTENDING THE MODEL

Consider creating more interaction-types. Is there an optimal way to get the infected to the helpers? How could the existing interaction types be modified to make them more realistic?

Consider adding another stage of the disease. What if agents did not know they were sick for a specified number of ticks? Would the epidemic spread faster?

CREDITS AND REFERENCES

Creator: Dorothy Catey.

Thanks to advisor Bert Baumgaertner

Support came from the 2015 Brian and Gayle Hill Undergraduate Research Fellowship and NIH Award Number P20GM104420.

Comments and Questions

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

Click to Run Model

globals [
  seed

 max-infected              ;; Maximum number of agents infected at a single time point
 max-infected-time         ;; time step at which the above occurs
end -time                  ;; time step at which the number of infected = 0 (DC: redundant due to step counter already output with csv file?)
 last-susceptible          ;; number of agents who were never infected. Subtracting from population size would give number of recovered at end.
 final-epi-size            ;; number of total people who got infected throughout the epidemic (N - last-susceptible)

 total-helper-infected     ;; total number of helpers that got infected throughout epidemic
 total-normal-infected     ;; total number of non-helpers infected throughout epidemic

 total-contacts             ;; interactions for every agent
 total-contact-list         ;; list of total contacts for each time step

 r0                        ;; r0 calculated by averaging number of people one indiv infects throughout time as infected
 length-infection          ;; average length of infection for initially infected agents

]

turtles-own [
initial-infected?          ;; turtle owned marker indicating if one of the initial infected agents
help                       ;; each helper's contribution depending on surroundings and maxhelp set by user, calc at each time step for each helper, normal setting = 0
totalInfected              ;; total number agents that a turtle infected thus far
helper-surrounding         ;; keeps track of how many helpers are around each sick individual at each time step
infected-surrounding       ;; keeps track of how many infected are around each helper at each time step
finish-infected            ;; (initial infected agents) how long initial agents were sick
]

to setup
  clear-all
  set seed new-seed
  random-seed seed
  resize-world 0 world-size 0 world-size

  set final-epi-size 0
  set total-helper-infected 0
  set total-normal-infected 0
  set total-contacts 0
  set total-contact-list []
  set max-infected 0
  set max-infected-time 0
  set end-time 0
  set last-susceptible 0
  turtle-creation

  ask patches [
    set pcolor 8
    if pxcor mod 2 = 1 and pycor mod 2 = 0 [set pcolor 9.9] if pxcor mod 2 = 0 and pycor mod 2 = 1 [set pcolor 9.9]]
  ask turtles [ set pen-mode "up"]

  reset-ticks
end 

to turtle-creation
  create-turtles N-H  [                               ;; create helpers
    set shape "person"
    set color black
    setxy random-xcor random-ycor
    set initial-infected? false
    ]
  if count turtles < N [                              ;; if helpers do not make up entire population, fill rest with default
    create-turtles (N - count turtles)[               ;; could theoretically put in more helpers than N, population size would be # helpers rather than N
      set color black
      setxy random-xcor random-ycor
      set initial-infected? false
    ]
  ]
  ask n-of N-I turtles [
    set initial-infected? true                        ;; initial infected
    set color red
  ]
end 

to go
  if count turtles with [color = red] = 0 [                         ;; check to see if epidemic over, do ending measurements
end -stats
    calculate-r0
    stop]

  tracking
  contacts
  targets-calc
  move
  infection-transmission
  help-calc
  recover
  update-plots
  tick-advance 1
end 

to tracking
  if count turtles with [color = red] > max-infected [              ;; keep writing over largest number of infected
    set max-infected count turtles with [color = red]               ;; record and write over time at which maximum number of infected achieved
    set max-infected-time ticks
  ]
end 

to targets-calc
  ask turtles with [color = red] [
    set helper-surrounding count turtles with [shape = "person" and color != red] in-radius hrad      ;;if sick, count number of helpers in help radius
  ]
  ask turtles with [color != red] [                                                                   ;; don't care about number of helpers surrounding the healthy or recovered
    set helper-surrounding 0
  ]
  ask turtles with [shape = "person" and color != red] [
    set infected-surrounding count turtles with [color = red] in-radius hrad
  ]
  ask turtles with [shape != "person"] [
    set infected-surrounding 0
  ]
  ask turtles with [shape = "person" and color = red] [
    set infected-surrounding 0
  ]
end 

to contacts
  ask turtles [
    set total-contacts total-contacts + count turtles in-radius infrad
  ]
set total-contact-list lput total-contacts total-contact-list
end 

to move


 if interaction-type = "random-move" [                                                      ;; all turtles move randomly
   ask turtles [
     right (random-float 2 * 90 ) - 90
    fd 1
   ]
 ]

 if interaction-type = "helper-seek" [
   ask turtles with [shape = "person" and color = red] [                                    ;; sick helpers move randomly
     right (random-float 2 * 90 ) - 90
     fd 1
   ]

   ask turtles with [shape = "default"][                                                    ;; non-helpers move randomly
     right (random-float 2 * 90 ) - 90
     fd 1
   ]
   ask turtles with [shape = "person" and color != red][                                    ;; non-sick helpers seek the sick
    ifelse any? turtles with [color = red][
      let target min-one-of turtles with [color = red] [distance myself]                    ;; move toward nearest sick person
      face target
      fd 1
    ]
    [
      right (random-float 2 * 90 ) - 90                                                     ;; if no one is sick, move normally
      fd 1
    ]
   ]
 ]

 if interaction-type = "helper-smart-seek" [                                                ;; non-helpers move randomly
   ask turtles with [shape = "default"][
     right (random-float 2 * 90 ) - 90
     fd 1
   ]
   ask turtles with [shape = "person" and color = red] [                                    ;; sick helpers move randomly
     right (random-float 2 * 90 ) - 90
     fd 1
   ]
   ask turtles with [shape = "person" and color != red][                                    ;; non-sick helpers seek...
     ifelse any? turtles with [color = red and (helper-surrounding = 0)][
       let possible-targets turtles with [color = red]
       let targets possible-targets with [helper-surrounding = 0]
       let target min-one-of targets [distance myself]                                      ;; nearest sick agent without a helper (helper-surrounding = 0)
       face target
       fd 1
     ]
     [
       right (random-float 2 * 90 ) - 90                                                    ;; if all helpers busy or all are non-sick, move randomly
       fd 1
     ]
   ]
 ]

 if interaction-type = "infected-seek"[
   ask turtles with [shape = "default" and color != red] [                                 ;; ask normal agents to move randomly
     right (random-float 2 * 90 ) - 90
     fd 1
   ]
   ask turtles with [shape = "person" and color != red] [                                  ;; ask non-sick helpers to move randomly
     right (random-float 2 * 90 ) - 90
     fd 1
   ]
   ask turtles with [color = red] [
     ifelse any? turtles with [shape = "person" and color != red] [                        ;; ask infected to seek nearest non-sick helper
       let target min-one-of turtles with [shape = "person" and color != red] [distance myself]
       face target
       fd 1
     ]
     [
       right (random-float 2 * 90 ) - 90                                                   ;; if no non-sick helpers, move randomly
       fd 1
     ]
   ]
 ]

 if interaction-type = "infected-smart-seek" [
   ask turtles with [shape = "default" and color != red] [                                ;; ask normal non-sick agents to move randomly
     right (random-float 2 * 90 ) - 90
     fd 1
   ]
   ask turtles with [shape = "person" and color != red] [                                 ;; ask helper non-sick agents to move randomly
     right (random-float 2 * 90 ) - 90
     fd 1
   ]
   ask turtles with [color = red] [                                                       ;; ask infected to seek nearest helper who isn't already helping someone else
     ifelse any? turtles with [shape = "person" and color != red and (infected-surrounding = 0)] [
       let possible-targets turtles with [shape = "person" and color != red]
       let targets possible-targets with [infected-surrounding = 0]
       let target min-one-of targets [distance myself]
       face target
       fd 1
     ]
     [
       right (random-float 2 * 90 ) - 90                                                 ;; if no non-sick helpers free, move randomly
       fd 1
     ]
   ]
 ]

if interaction-type = "dual-smart-seek" [
  ask turtles with [shape = "default" and color != red] [                                ;; ask normal non-sick agents to move randomly
    right (random-float 2 * 90 ) - 90
    fd 1
  ]
  ask turtles with [shape = "person" and color != red][                                    ;; non-sick helpers seek...
    ifelse any? turtles with [color = red and (helper-surrounding = 0)][
      let possible-targets turtles with [color = red]
      let targets possible-targets with [helper-surrounding = 0]
      let target min-one-of targets [distance myself]                                      ;; nearest sick agent without a helper (helper-surrounding = 0)
      face target
      fd 1
    ]
    [
      right (random-float 2 * 90 ) - 90                                                    ;; if all helpers busy or all are non-sick, move randomly
      fd 1
    ]
  ]
  ask turtles with [color = red] [                                                       ;; ask infected to seek nearest helper who isn't already helping someone else
    ifelse any? turtles with [shape = "person" and color != red and (infected-surrounding = 0)] [
      let possible-targets turtles with [shape = "person" and color != red]
      let targets possible-targets with [infected-surrounding = 0]
      let target min-one-of targets [distance myself]
      face target
      fd 1
    ]
    [
      right (random-float 2 * 90 ) - 90                                                 ;; if no non-sick helpers free, move randomly
      fd 1
    ]
  ]
]
end 

to infection-transmission
  ask turtles with [color = black and shape != "person"] [                                ;; normal suceptible agents calculate prob infection based on frac infected neighbors and infect-prob
    if (random-float 1) < infect-prob * count turtles with [color = red] in-radius infrad / count turtles in-radius infrad [
        set color red
        ask turtles with [color = red] in-radius infrad [
          set totalInfected totalInfected + 1                                             ;; infected how many agents across entire infective period
        ]
    ]
  ]
  ask turtles with [color = black and shape = "person"] [                                 ;; helpers get decreased chance of infection.
    if (random-float 1) < (1 - helper-immunity) * infect-prob * count turtles with [color = red] in-radius infrad / count turtles in-radius infrad [
        set color red
        ask turtles with [color = red] in-radius infrad [
          set totalInfected totalInfected + 1                                             ;; infected how many agents across entire infective period
        ]
    ]
  ]
end 

to help-calc
  ask turtles with [shape = "person" and color != red]
  [
    ifelse any? turtles with [color = red] in-radius hrad [
       set help maxhelp / count turtles with [color = red] in-radius hrad                 ;; ideal "maxhelp" from slider, helper splits effort between sick in radius
    ]
    [
       set help 0                                                                         ;; no one to help, set help 0
    ]
  ]
end 

to recover
  ask turtles with [color = red][
    ifelse any? turtles with [shape = "person" and color != red] in-radius hrad [        ;; ask helpers for help
      let totalhelp 0
      ask turtles with [shape = "person" and color != red] in-radius hrad [
        set totalhelp totalhelp + help
        if totalhelp > maxhelp [set totalhelp maxhelp]                                   ;; if aggregate help exceeds maxhelp, set total help back to max
      ]
      if (random-float 1) < recover-prob + totalhelp [                                   ;; increased probability of recovery with help
        set color blue
        if initial-infected? [set finish-infected ticks]
      ]
    ]
    [ if (random-float 1) < recover-prob [                                               ;; probability of recovery without help
        set color blue
        if initial-infected? [set finish-infected ticks]
      ]
      ]
  ]
end 

to calculate-r0
  set r0 mean [totalInfected] of turtles with [initial-infected?]                       ;; mean number infected by individual during entire infective state
  set length-infection mean [finish-infected] of turtles with [initial-infected?]       ;; average length of infection for initially infected agents
end 

to end-stats
  set end-time ticks
  set last-susceptible count turtles with [color = black]
  set final-epi-size (N - last-susceptible)
  set total-helper-infected count turtles with [color = blue and shape = "person"]
  set total-normal-infected count turtles with [color = blue and shape = "default"]
end 

There is only one version of this model, created over 8 years ago by Dorothy Catey.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.