Covid_19_Intervention_Timing_Effects

Covid_19_Intervention_Timing_Effects preview image

1 collaborator

Default-person Eduardo Tapia (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.2 • Viewed 225 times • Downloaded 14 times • Run 0 times
Download the 'Covid_19_Intervention_Timing_Effects' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

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

Click to Run Model

globals [ lista %_infected %_recovered activated]
turtles-own [ marker mover]

to setup
  ca
  set lista []
  ask patches [ set pcolor white]
  ask patches with [ pycor = -50] [ set pcolor black]
  ask patches with [ pycor = -49] [ set pcolor black]
  ask patches with [ pycor = 50] [ set pcolor black]
  ask patches with [ pycor = 49] [ set pcolor black]
  ask patches with [ pxcor = -80] [ set pcolor black]
  ask patches with [ pxcor = -79] [ set pcolor black]
  ask patches with [ pxcor = 79] [ set pcolor black]
  ask patches with [ pxcor = 80] [ set pcolor black]
  ask n-of Population patches with [ pcolor = white ] [ sprout 1 [ set shape "circle" set color blue fd 0.5]]
  ask one-of turtles [ set color red set marker Recovery_time]
  ask turtles [ set mover 1] ; all can move
  set activated 1
  reset-ticks
end 

to go
  if (ticks = 500) [ stop ]
  move2
  spread_virus
  updatemaker
  %_infec
  which_action
  tick
end 

to which_action
  if (intervention = "nothing" ) []
  if (intervention = "focalized_quarantine_hard" ) [if (%_infected > Intervention_Timing and activated = 1) [ intervene_quarantine_hard] ]
  if (intervention = "focalized_quarantine_soft" ) [if (%_infected > Intervention_Timing and activated = 1) [ intervene_quarantine_soft] ]
  if (intervention = "social_distance_hard" ) [if (%_infected > Intervention_Timing and activated = 1) [social_distance_hard] ]
  if (intervention = "social_distance_soft" ) [if (%_infected > Intervention_Timing and activated = 1) [social_distance_soft] ]
  if (intervention = "close_borders_soft" ) [if (%_infected > Intervention_Timing and activated = 1) [close_b_soft] ]
  if (intervention = "close_borders_hard" ) [if (%_infected > Intervention_Timing and activated = 1) [close_b_hard] ]
end 

to %_infec
  set %_infected ((count turtles with [ color = red]) / (count turtles)) * 100
  set %_recovered ((count turtles with [ color = green]) / (count turtles)) * 100
end 

to updatemaker
  ask turtles with [ color = red ] [ set marker marker - 1 ]
  ask turtles with [ ( color = red OR color = yellow )  and marker < 0 ] [ set color green ]
end 

to spread_virus
  ask turtles with [ (color = red OR color = yellow) and marker > 0]
  [ if any? other turtles-here
    [ let otro one-of turtles-here
      let colorotro [color] of otro
      ifelse (colorotro = green)
      [ ]
      [
        let dado random-float 1
        ifelse(dado < Probability_of_being_asymptomatic)
        [ ask otro [ set color yellow set marker Recovery_time] ]
        [ ask otro [ set color red set marker Recovery_time] ]
      ]
    ]
  ]
end 

to move2
  ask turtles with [mover = 1] [
    let patcha [pcolor] of patch-ahead 1
    ifelse (patcha = black)
    [
      set heading heading + random 360
    ]

    [
     fd 1
    ]
  ]
end 

to intervene_quarantine_hard

  let aa (count (turtles-on patches with [ pxcor > 0 and pycor > 0 ]) with [ color = red ])
  set lista lput aa lista
  let bb (count (turtles-on patches with [ pxcor < 0 and pycor > 0 ]) with [ color = red ])
  set lista lput bb lista
  let cc (count (turtles-on patches with [ pxcor < 0 and pycor < 0 ]) with [ color = red ])
  set lista lput cc lista
  let dd (count (turtles-on patches with [ pxcor > 0 and pycor < 0 ]) with [ color = red ])
  set lista lput dd lista

  let maximo max lista

  let posicion position maximo lista
  ;print posicion
  if (posicion = 0) [ask patches with [ (pxcor >= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor black ]]
  if (posicion = 1) [ask patches with [ (pxcor <= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor black ]]
  if (posicion = 2) [ask patches with [ (pxcor <= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor black ]]
  if (posicion = 3) [ask patches with [ (pxcor >= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor black ]]
  set activated 0
end 

to intervene_quarantine_soft

  let aa (count (turtles-on patches with [ pxcor > 0 and pycor > 0 ]) with [ color = red ])
  set lista lput aa lista
  let bb (count (turtles-on patches with [ pxcor < 0 and pycor > 0 ]) with [ color = red ])
  set lista lput bb lista
  let cc (count (turtles-on patches with [ pxcor < 0 and pycor < 0 ]) with [ color = red ])
  set lista lput cc lista
  let dd (count (turtles-on patches with [ pxcor > 0 and pycor < 0 ]) with [ color = red ])
  set lista lput dd lista

  let maximo max lista
  let posicion position maximo lista
  if (posicion = 0) [ask patches with [ (pxcor >= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor black ]]
  if (posicion = 0) [ask n-of 3 patches with [ (pxcor >= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor white ]]
  if (posicion = 1) [ask patches with [ (pxcor <= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor black ]]
  if (posicion = 1) [ask n-of 3 patches with [ (pxcor <= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor white ]]
  if (posicion = 2) [ask patches with [ (pxcor <= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor black ]]
  if (posicion = 2) [ask n-of 3 patches with [ (pxcor <= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor white ]]
  if (posicion = 3) [ask patches with [ (pxcor >= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor black ]]
  if (posicion = 3) [ask n-of 3 patches with [ (pxcor >= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor white ]]
  set activated 0
end 

to social_distance_hard
  ask n-of ((95 * Population) / 100 ) turtles [ set mover 0 ]
  set activated 0
end 

to social_distance_soft
  ask n-of ((80 * Population) / 100 ) turtles [ set mover 0 ]
  set activated 0
end 

to close_b_hard
  ask patches with [ (pxcor >= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor black ]
  ask patches with [ (pxcor <= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor black ]
  ask patches with [ (pxcor <= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor black ]
  ask patches with [ (pxcor >= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor black ]
  set activated 0
end 

to close_b_soft
  ask patches with [ (pxcor >= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor black ]
  ask n-of 3 patches with [ (pxcor >= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor white ]
  ask patches with [ (pxcor <= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor black ]
  ask n-of 3 patches with [ (pxcor <= 0 and pycor = 0) OR (pycor > 0 and pxcor = 0) ] [ set pcolor white ]
  ask patches with [ (pxcor <= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor black ]
  ask n-of 3 patches with [ (pxcor <= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor white ]
  ask patches with [ (pxcor >= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor black ]
  ask n-of 3 patches with [ (pxcor >= 0 and pycor = 0) OR (pycor < 0 and pxcor = 0) ] [ set pcolor white ]
  set activated 0
end 

There is only one version of this model, created almost 5 years ago by Eduardo Tapia.

Attached files

File Type Description Last updated
Covid_19_Intervention_Timing_Effects.png preview Preview for 'Covid_19_Intervention_Timing_Effects' almost 5 years ago, by Eduardo Tapia Download

This model does not have any ancestors.

This model does not have any descendants.