This page was automatically generated by NetLogo 5.0.4.

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.

powered by NetLogo

view/download model file: Final_QuarModel - Grace Baek.nlogo


-1 tick = 1 day

SETUP-establish (1) home patches; (2) work patches; (3) media patches

SETUP-TURTLES – create population of susceptible turtles with initial intent (to adopt a behavior) = 0 AND no behaviors already adopted

MOVE – An agent can only move to home patches (sick quarantine area) IF quarantine-behavior? (switch) is ON AND the agent is infected AND the agent has an intent to adopt behavior > 85. For as long as the agent remains on home patches, it jumps randomly within that area.
An agent can only to move to home patches 2 (susceptible quarantine area) IF there are no more than 88 agents during that tick sitting on home patches 2 AND quarantine-behavior? is ON AND the agent is susceptible (i.e. NOT immune, NOT infected) AND the agent has an intent to adopt behavior > 85. For as long as the agent remains on home patches 2, it jumps randomly within that area.
IF no combination of conditions above is fulfilled, an agent by default remains on the work patches WITH random jumping movement within the work patches area.
Uni-directional movement (per tick) BETWEEN different areas is achieved once an agent achieves the appropriate combination of the following changes: (1) move from the susceptible TO infected population; (2) quarantine-behavior? is turned ON; (3) intent to adopt quarantine behavior has a value > 85.

UPDATE-GLOBAL-VARIABLES – Assuming there is at least 1 turtle in the population, calculates per tick: %infected (within the total population) AND %immune AND %media-exposed (i.e. how many total agents have passed OR am passing over the media patches at least once / total population) AND % ever infected over the entire run of the program. Since all infected agents need to have a day 1 of infection to mark the transition from susceptible (day of infection = 0) REGARDLESS of their duration of illness (based on a normal curve [with std. dev. = 1 day] for average duration of remaining in the infected population before transitioning to the immune population), counting total # infected agents over time with day of infection = 1 is used.

MEDIA-EXPOSE – IF an agent is currently on a media patch, it has been exposed to media; media-exposure? = TRUE.

EST-INTENT – IF an agent has passed by a media patch AND it has been reported that the more than half of the population has adopted health behavior(s) such as quarantine currently, THEN the agent’s individual intent to adopt behavior is considered. If the individual intent to adopt behavior(s) is < 75, then 25 (arbitrary value) is added due to media exposure. If >75, then the appropriate value is added due to the intent to adopt the behavior for a MAXIMUM of 100. The MINIMUM intent to adopt a behavior is 0.

PONDER-INTENT – IF the (individual) intent to adopt behavior > 85 AFTER any additions VIA EST-INTENT THEN intend-to-vaccinate? (not a slider) = TRUE AND self-quarantine? = TRUE IF agent is susceptible. Infected agents can only have self-quarantine? = TRUE.

ALERT – The media patches change from WHITE (default) to RED IF %infected (of the entire population at that tick) is >30 AND media-alert? is set to TRUE.

RESPOND-TO-ALERT – IF %infected > 30 (AND media-alert? = TRUE) THEN intent to adopt behavior for all agents is INCREASED by 10 (arbitrary value). THEN we refer to PONDER-INTENT to recalculate any change (from FALSE, default, TO TRUE) for intend-to-vaccinate? OR self-quarantine? .

GET-OLDER – IF an agent is infected, INCREASES day of infection value by 1 for each passing tick. This procedure refers to EST-INTENT, PONDER-INTENT, and VACCINATE. Both SUSCEPTIBLE and INFECTED agents can change intent (numerically), BUT ONLY susceptible agents can adopt the vaccination behavior regardless of whether infected agents’ intent to adopt behavior > 85.

INFECT – This procedure looks at the changes effected by infected agents ON susceptible agents: IF neighbors of an infected agent (8 maximum susceptible neighbors around one infected agent)

GET-SICK – There are changes that susceptible agents which have become infected undergo, namely their status as infected? changes to TRUE BUT immune? status remains FALSE. An infected agent’s color changes to RED, and day of infection goes from 0 (susceptible) TO 1 (start infection).

VACCINATE – Only susceptible agents WITH intend to vaccinate set to TRUE AND random individual integer value out of 100 < vaccine efficacy (set by slider) can be vaccinated.

RECOVER – An infected turtle can recover IF its day of infection is greater than the duration (a random integer value adhering to a normal distribution with mean avg-duration AND with std. dev. = 1), THEN IF its individual chance of recovery is less than the chance of recovery (set by a slider). It is expected that ALL infected agents will recover eventually.

BECOME-IMMUNE – As with GET-SICK, an agent’s statuses for immune? and infected? are changed (immune? becomes TRUE; infected? FALSE) AND color is changed from red to gray AND the day of infection “ticker” is turned off BY setting day of infection to 0. The user can distinguish an immune agent with day of infection = 0 AND a susceptible agent with day of infection = 0 BY immune? status AND color.


-SIR model; an agent can only be S OR I OR R at any one time, with vaccinated agents included in the “Recovered” or “Immune” sub-population.
-A susceptible or infected agent is seeded with
-susceptible characteristics e.g. color (green or red); day of infection (0); etc.
-a unique “duration” value, assigned randomly based on a normal curve (with standard deviation = 1) around a value set by the “avg-duration” (slider)
-a unique “infectiousness” value, assigned randomly out of 100
-NO media exposure
-NO behaviors e.g. self-quarantine? FALSE
-location by default, work patches
-intent to adopt behavior = 0, which can later change dependent on exposure to media; reported % population adopting the behavior(s); etc.
- (IF the switches quarantine-behavior? OR vaccine-behavior? are off, then the respective behaviors cannot be applied to agents, even those with an intent to adopt behavior above the threshold.)
-Movement regardless of S/I/R status is by jumping, as opposed to moving forward 1, turning 360°, etc. BUT movement is contained to home patches, work patches, OR home patches 2 depending on status
-Duration of H1N1 infection for each agent is unique; average duration of the infection is set by a slider on the interface. From a normal distribution with average duration as the mean and standard deviation of 1 day, a random integer value of duration is produced.
-Note: 2009 H1N1 statistics indicate the average duration is ~7 days.
-If an agent is put into quarantine (either of home-patches areas), then it remains there until
(1) [for infected, home-patches] it becomes immune >> exits quarantine into work-patches
(2) [for susceptible, home-patches2] the end of the program
Note: New agents with the appropriate conditions met can enter home-patches2 until #agents in home-patches2 = 90; no overflow allowed.


Changing Intent –
IF quarantine/vaccine-behavior? ON/TRUE
IF susceptible passes media patch
IF %pop infected MAX over time > 30%
media patches FROM white TO red
intent-adopt-behav INC by 25 with MAX of 100
IFELSE reported pop % complying > 50 i.e. more than half of pop adopting
intent-adopt-behav INC by 25 with MAX of 100
intent-adopt-behav DEC by 10 with (implied) MIN of 0

Transmission of Disease (incl. Behavioral Effects) –

IF susceptible
IF intent-adopt-behav > 85 AND intend-tovaccinate TRUE
IF #turtles in home-patches 2 < 85 AND self-quarantine TRUE
self-quarantine (home-patches2)
;;home-patches2 = Healthy Quarantine area; for susceptible agents only
IF infected
day of infection INC 1 every tick
IF neighbors on surrounding work-patches = susc AND neighbors with indiv
infxiousness < infectiousness (slider)
neighbors now infected etc.
IF intent-adopt-behav > 85
self-quarantine (home-patches)
IF day of infection > (indiv) duration
infected >> recovered etc.
;;Home-patches = Sick Quarantine area; for infected agents only

Ending the Program –

STOP all procedures IF #turtles infected of pop = 0 i.e. all members of pop either have remained susc OR became immune
expect % ever infected (output) i.e. (# infected of initial pop / 300) = % immune over entire run of program




patches-own [ media-here? media-alert? ]

to setup
  ask patches [ set media-here? false set media-alert? false] ;7

  set home-patches patches with [pxcor > 2 and pycor > 2]
  ask home-patches [ set pcolor violet ]
  ask patches with [pxcor = 13 and pycor = 17] [set plabel "sick quarantine here"] 
  set media-patches ;5
    patches with [pxcor < 1 + expand-media and pxcor > -3 - expand-media and pycor < 1 + expand-media and pycor > -3 - expand-media ] ;;;;;;;;;;;;;;;
  ask media-patches [set media-here? true set pcolor white]
  ask patches with [pxcor = -1 and pycor = 0] [set plabel "media" set plabel-color black] 
  set home-patches-2-border                          
  patches with [pxcor < -5 and pycor < -5]
  ask home-patches-2-border [set pcolor 88]
  set home-patches-2 ;Healthy Quar
  patches with [pxcor < -6 and pycor < -6 ]
  ask home-patches-2 [set pcolor blue]
  ask patches with [pxcor = -7 and pycor = -17] [set plabel "healthy quarantine here"] 
  set work-patches patches with [pcolor = black or pcolor = white] 
  ask patches with [pxcor = -12 and pycor = 17] [set plabel "work space"] 

to setup-turtles
  set-default-shape turtles "person"
  crt people
    [ setxy random-xcor random-ycor
      set immune? false
      set size 1
      set day-of-infection 0
      set media-exposure? false
      set intent-adopt-behav random 101 
      set self-quarantine? false
      ;VACC; set intend-to-vaccinate? false
      set quarantine? false 
      set total-infected infected-people
  set infected-people %infected-people / 100 * people 
    ask n-of infected-people turtles
     set duration random-normal avg-duration 1.0] 

to move 
  ask turtles
  [ if not infected? or immune? [move-to-empty-one-of work-patches]
    if quarantine-behavior? and quarantine? and not immune?[ 
      ifelse count turtles-on home-patches < 90
        [move-to-empty-one-of home-patches] ;implicitly includes infected? as a condition (Please see quarantine? true statement below.)
        [move-to-empty-one-of work-patches] ]
    if infected? and (not quarantine-behavior? or not quarantine?) [move-to-empty-one-of work-patches]    
    if quarantine-behavior? and self-quarantine? and not immune? and not infected? [
      ifelse count turtles-on home-patches-2 < 90 
        [move-to-empty-one-of home-patches-2] ;implicitly includes infected? as a condition (Please see quarantine? true statement below.)
        [move-to-empty-one-of work-patches] ]]

to move-to-empty-one-of [locations] 
  move-to one-of locations
  while [any? other turtles-here][  
    move-to one-of locations]        

to update-global-variables
   if count turtles > 0
   [set %infected (count turtles with [infected?]) / (count turtles) * 100
    set %immune (count turtles with [immune?]) / (count turtles) * 100   
    set %media-exposed (count turtles with [media-exposure?]) / (count turtles) * 100
    set total-infected total-infected + count (turtles with [day-of-infection = 1]) 
    set %ever-infected (total-infected / count turtles ) * 100

to go

to get-older
  ask turtles
   [ est-intent
      ;VACC; vaccinate 
  ask turtles [if infected? [ set day-of-infection (day-of-infection + 1) ]   ]

to get-healthy 
  set infected? false
  set immune? false
  set day-of-infection 0
  set color green


to media-expose
  ask turtles [if [media-here?] of patch-here = true [set media-exposure? true ]]

to est-intent ;4
  ifelse media-exposure? [
    if reported-pop%-complying > 50 [        
      if intent-adopt-behav > 75 [set intent-adopt-behav 100]
      if intent-adopt-behav < 75 [set intent-adopt-behav intent-adopt-behav + 25] ]]
  [set intent-adopt-behav intent-adopt-behav - 10] 

to ponder-intent
  if intent-adopt-behav > 85[ ;intention-to-adopt-behavior-slider [ 
     if not immune?[ 
      ifelse not infected? 
     [set self-quarantine? true ]
     [set quarantine? true] 

to alert    
  ask media-patches [if %infected > alert-threshold [set media-alert? true set pcolor red] ] 
  ask media-patches [if %infected <= alert-threshold [set media-alert? false set pcolor white] ] 

to respond-to-alert
  ask turtles [
    if [media-alert?] of patch-here = true
     [set intent-adopt-behav intent-adopt-behav + 25 



to infect   
  ask turtles with [infected?]
    [ ask (turtles-on neighbors) with [ not immune? and not infected?][ 
        if (random-float 101) < infectiousness 
         [ get-sick 
           set duration random-normal avg-duration 1.0]]]

to get-sick
  set infected? true
  set immune? false
  set color red
  set day-of-infection 1


to recover
   ask turtles with [infected? and day-of-infection > 1]
     [ if day-of-infection > duration 

to become-immune 
  set infected? false
  set day-of-infection 0
  set immune? true
  set color gray


to vaccinate
  if intend-to-vaccinate? = true and ((random-float 100) < vaccine-efficacy)  
    [set immune? true