berea covid_19 with quarentine

No preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Tags

quarentine 

Tagged by Diego Díaz Córdova over 4 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 1040 times • Downloaded 33 times • Run 0 times
Download the 'berea covid_19 with quarentine' modelDownload this modelEmbed this model

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 days, the turtle has been infectious
    age                  ;; how many weeks old the turtle is
    quarentine?          ;; if true the turtle is in quarentine
   ]

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
    chance-recover       ;; the probability of recovery at each tick
    carrying-capacity    ;; the number of turtles that can be in the world at one time
    immunity-duration    ;; how many weeks immunity lasts
    number-dead ]        ;; how many turtles die

;; 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 1 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 .7 ;; easier to see
      get-healthy
      set quarentine? false
    ]
  ifelse call-for-quarentine
          [ask n-of ((accepted-quarentine * number-people) / 100) turtles [set quarentine? call-for-quarentine]]
          [ask turtles [set quarentine? false]]

  ask n-of 1 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
  ask my-links [ die ] ;; remove link to turtle who infected us, if there was one
end 

;; This sets up basic constants of the model.

to setup-constants
  set lifespan 80 * 52 * 7     ;; 80 times 52 weeks times 7 days = 50 years = 2600 weeks old = 18200 days
  set carrying-capacity 1089
  set chance-reproduce 0.34 ;; birth rate per 1000 people per week
  set immunity-duration 4 * 7 ;; 4 weeks for immunity duration
  if Weather = "Hot-Humid" [set infectiousness  .9 * infectiousness]
  if Weather = "Hot-Dry" [set infectiousness  .95 * infectiousness]
  if Weather = "Cold-Dry" [set infectiousness  .97 * infectiousness]
  if Weather = "Cold-Humid" [set infectiousness infectiousness]
end 

to go
  ask turtles [
    get-older
    if not quarentine?
         [move]
    if sick? [ recover-or-die ]
    ifelse sick? [ infect ] [ reproduce ]
  ]
  update-global-variables
  update-display
  tick
  if ticks = 100 [stop]
  ;; here ask for call-for-quarentine
  ;; if quarentine colour patch with red and inmovilize turtle
  if call-for-quarentine
     [
     if count (turtles with [quarentine? = true]) = 0
            [ask n-of ((accepted-quarentine * number-people) / 100) turtles [set quarentine? call-for-quarentine]]
     ask turtles with [quarentine? = true]
                      [
                      ask patch pxcor pycor [set pcolor red]
                      ]
  ]
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 label ifelse-value show-age? [ floor (age / 364) ] [ "" ]
      set color ifelse-value sick? [ red ] [ ifelse-value immune? [ grey ] [ green ] ]
      ;; not showing colour by age
      ;if age < 10 * 52 * 7 [set color blue]
      ;if age > 60 * 52 * 7 [set color yellow]

    ]
  stop-inspecting-dead-agents
  if watch-a-person? and subject = nobody
    [ watch one-of turtles with [ not hidden? ]
      clear-drawing
      ask subject [ pen-down ]
      inspect subject ]
  if not watch-a-person? and subject != nobody
    [ stop-inspecting subject
      ask subject
        [ pen-up
          ask my-links [ die ] ]
      clear-drawing
      reset-perspective ]
  ask patches [
  if Weather = "Hot-Humid" [set pcolor 68]
  if Weather = "Hot-Dry" [set pcolor 48]
  if Weather = "Cold-Dry" [set pcolor 38]
  if Weather = "Cold-Humid" [set pcolor 108]
  ]
  ;;actualiza color de parche
  ask turtles with [quarentine? = true]
                      [
                      ask patch pxcor pycor [set pcolor red]
                      ]
end 

;;Turtle counting variables are advanced.

to get-older ;; turtle procedure
  ;; Turtles die of old age once their age exceeds the
  ;; lifespan (set at 80 years in this model).
  set age age + 1
  if age > lifespan [ die ]
  if age > 60 * 52 * 7 [ set chance-recover .93]
  if age < 60 * 52 * 7 [ set chance-recover .97]
  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 movement
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? and not quarentine?]
    [ if random-float 100 < infectiousness
      [ get-sick
        if self = subject             ;; if its the watched turtle getting sick
          [ create-link-with myself   ;; create a link with the one that infected it
            [ set color red
              set thickness .3 ] ] ] ]
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 age > 60 * 52 * 7 [ set chance-recover .93]
  if age < 60 * 52 * 7 [ set chance-recover .97]
  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 ]
      [ set number-dead number-dead + 1
        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
        pen-up ;; in case we're hatched from the watched turtle
        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 are 2 versions of this model.

Uploaded by When Description Download
Diego Díaz Córdova over 4 years ago improve functionality Download this version
Diego Díaz Córdova over 4 years ago Initial upload Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.