To Mask or Not to Mask
Model was written in NetLogo 6.3.0
•
Viewed 7 times
•
Downloaded 0 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
;; To Mask or Not to Mask - NetLogo Code ;; David Knoke, University of Minnesota ;; May 30, 2023 ;; ;; Use slider to set population size between 1,000 and 3,000 in increments of 500 ;; Use sliders to set percents of population Republican & Democrat mask-wearers and unmasked ;; Based on Gallup and Pew Polls in June 2020: ;; Proportions of partisans: Democrat = .56 Republican = .44 ;; Proportions wearing masks: Democrat = .43 Republican = .23 ;; Proportions not masked: Democrat = .13 Republican = .21 breed [repms repm] breed [repns repn] breed [demms demm] breed [demns demn] globals [ colors ;; Republican Masked = red, Republican Not Masked = pink, Democrat Masked = blue, Democrat Not Masked = cyan initial-red ;; How many turtles red at start? initial-blue ;; How many turtles blue at start? initial-pink ;; How many turtles pink at start? initial-cyan ;; How many turtles cyan at start? infectedreps infecteddems ratiorepsdems infectedmaskedreps infectedmaskeddems infectedunmaskedreps infectedunmaskeddems ] to setup clear-all ask patches [set pcolor white] ;; Make all patches white create-repms ((Population_Size) * (%_Republicans_Masked / 100)) [ ;; create initial Number of Republicans Wearing Masks setxy random-xcor random-ycor set color red set shape "person" set size 2 ] create-repns ((Population_Size) * (%_Republicans_Unmasked / 100)) [ ;; create initial Number of Republicans Not Wearing Masks setxy random-xcor random-ycor set color pink set shape "person" set size 2 ] create-demms ((Population_Size) * (%_Democrats_Masked / 100)) [ ;; create initial Number of Democrats Wearing Masks setxy random-xcor random-ycor set color blue set shape "person" set size 2 ] create-demns ((Population_Size) * (%_Democrats_Unmasked / 100)) [ ;; create initial Number of Democrats Not Wearing Masks setxy random-xcor random-ycor set color cyan set shape "person" set size 2 ] ask n-of (Population_Size * .01) turtles [set color black ;; Initial infected turtles are 1% of population ] ;; Count how many turtles of each color at start set initial-red count turtles with [color = red] set initial-blue count turtles with [color = blue] set initial-pink count turtles with [color = pink] set initial-cyan count turtles with [color = cyan] reset-ticks end to go ;; Stop the simulation when no turtles remain infected (black) if (count turtles with [color = black] = 0) [stop] move infect1 infect2 removal tally tick end to move ;; Turtles move one patch in a randomly selected 360-degree direction; removed turtles do not move ask turtles with [color != green][ right random 360 forward 1 ] end to infect1 ;; Republicans encountering an infected agent become infected if a random number is less than the infection rate for the masked or the unmasked ask turtles with [color = red] [ if any? turtles-here with [color = black] and random 100 < Masked_Infectiousness [ set color black] ask turtles with [color = pink] [ if any? turtles-here with [color = black] and random 100 < Unmasked_Infectiousness [ set color black] ] ] end to infect2 ;; Democrats encountering an infected agent become infected if a random number is less than the infection rate for masked or not masked ask turtles with [color = blue] [ if any? turtles-here with [color = black] and random 100 < Masked_Infectiousness [ set color black] ask turtles with [color = cyan] [ if any? turtles-here with [color = black] and random 100 < Unmasked_Infectiousness [ set color black] ] ] end to removal ;; Infected persons (black) are removed (turn green & stop infecting others) if a random number from 1 to 100 is below the removal rate (1 to 10) ask turtles with [color = black] [ if random 100 < Removal_Rate [ set color green] ] end to tally ;; Percentages for BehaviorSpace, based on Population_Size set infectedreps (100 - (((count turtles with [color = red]) + (count turtles with [color = pink])) / (initial-red + initial-pink) * 100)) set infecteddems (100 - (((count turtles with [color = blue]) + (count turtles with [color = cyan])) / (initial-blue + initial-cyan) * 100)) ;; Add +1 to denominator to avoid division by zero: set ratiorepsdems (infectedreps / (infecteddems + 1)) set infectedmaskedreps (100 - (count turtles with [color = red] / initial-red * 100)) set infectedmaskeddems (100 - (count turtles with [color = blue] / initial-blue * 100)) set infectedunmaskedreps (100 - (count turtles with [color = pink] / initial-pink * 100)) set infectedunmaskeddems (100 - (count turtles with [color = cyan] / initial-cyan * 100)) end
There is only one version of this model, created 3 days ago by David Knoke.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
To Mask or Not to Mask.png | preview | Preview for 'To Mask or Not to Mask' | 3 days ago, by David Knoke | Download |
This model does not have any ancestors.
This model does not have any descendants.