Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/harrykipper/covid
Browse files Browse the repository at this point in the history
  • Loading branch information
harrykipper committed Jun 1, 2020
2 parents 727a634 + 050f127 commit fa61d3c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
29 changes: 18 additions & 11 deletions Covid19VO.nlogo
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ globals
tests-per-day
tests-performed
hospital-beds ;; Number of places in the hospital (currently unused)
counters ;; Table containing various information
counters ;; Table containing information on source of infection e.g household, friends...
populations ;;
cummulatives ;; table of cummulative disease states
infections ;; table containing the average number of infections of people recovered or dead in the past week

;; Reproduction rate
Expand Down Expand Up @@ -191,6 +192,7 @@ to set-initial-variables

set counters table:from-list (list ["household" 0]["relations" 0]["friends" 0]["school" 0]["random" 0])
set populations table:from-list (list ["susceptible" 0]["infected" 0]["recovered" 0]["isolated" 0]["dead" 0]["in-hospital" 0]["incubation" 0]["symptomatic" 0]["asymptomatic" 0]["severe" 0])
set cummulatives table:from-list (list ["incubation" 0] ["asymptomatic" 0] ["symptomatic" 0] ["severe" 0 ] ["in-hospital" 0]["recovered" 0 ]["dead" 0])
table:put populations "susceptible" N-people

;; initally there will be no tests------------------------------
Expand Down Expand Up @@ -324,13 +326,13 @@ to go
ifelse behaviorspace-run-number != 0 [ save-individual ]
[
if ticks = 7
[set double-t 3
set cum-infected table:get populations "infected"
]
[set double-t 7
set cum-infected table:get cummulatives "asymptomatic" + table:get cummulatives "symptomatic" + table:get cummulatives "severe"
]
if (ticks > 7) and (inc-rate >= 2) [
print-double-time
set double-t ticks
set cum-infected table:get populations "infected"
set cum-infected table:get cummulatives "asymptomatic" + table:get cummulatives "symptomatic" + table:get cummulatives "severe"
]

if show-layout [ask turtles [assign-color]]
Expand All @@ -349,6 +351,12 @@ to change-state [new-state]
table:put populations my-state (table:get populations my-state - 1)
set my-state new-state
table:put populations my-state (table:get populations my-state + 1)
table:put cummulatives my-state (table:get cummulatives my-state + 1)
end

to-report inc-rate
let current (table:get cummulatives "asymptomatic" + table:get cummulatives "symptomatic" + table:get cummulatives "severe" ) / cum-infected
report current
end

;; =========================================================================
Expand Down Expand Up @@ -422,7 +430,7 @@ to kill-agent
table:put populations my-state (table:get populations my-state - 1)
table:put populations "infected" (table:get populations "infected" - 1)
table:put populations "dead" (table:get populations "dead" + 1)

table:put cummulatives "dead" (table:get cummulatives "dead" + 1)
if hospitalized? [set isolated? false]
if isolated? [table:put populations "isolated" (table:get populations "isolated" - 1)]

Expand Down Expand Up @@ -606,7 +614,7 @@ to infect ;; turtle procedure
;; Here we determine who are the unknown people we encounter. This is the 'random' group.
;; If we are isolated or there is a lockdown, this is assumed to be zero.
;; Elderly people are assumed to go out half as much as everyone else
;;currently an individual meets on average howmany/2 because it is randomly between 0 to howmany- I changed it to a draw from poisson distribution with average howmanyrnd or howmanyelder
;;currently an individual meets a draw from poisson distribution with average howmanyrnd or howmanyelder
if random-passersby != nobody [
ask random-passersby [
if can-be-infected? and (not isolated?) [
Expand Down Expand Up @@ -1312,10 +1320,9 @@ true
true
"" ""
PENS
"Symptomatic" 1.0 0 -955883 true "" "plot table:get populations \"symptomatic\""
"Asymptomatic" 1.0 0 -13840069 true "" "plot table:get populations \"asymptomatic\""
"Severe" 1.0 0 -2674135 true "" "plot table:get populations \"severe\""
"Pre-symptomatic" 1.0 0 -7500403 true "" "plot table:get populations \"incubation\""
"Symptomatic" 1.0 0 -955883 true "" "plot table:get cummulatives \"symptomatic\""
"Asymptomatic" 1.0 0 -13840069 true "" "plot table:get cummulatives \"asymptomatic\""
"Severe" 1.0 0 -2674135 true "" "plot table:get cummulatives \"severe\""

@#$#@#$#@
# covid19 in small communities
Expand Down
23 changes: 14 additions & 9 deletions output.nls
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ to print-double-time
output-print (word "On day " ticks " cases doubled within: " (ticks - double-t) " days" )
end

to-report inc-rate
let current table:get populations "infected" / cum-infected
report current
end


to print-final-summary
let deaths table:get populations "dead"
Expand All @@ -74,11 +71,19 @@ to print-final-summary
output-print (word "Total deaths: " deaths ". - Mortality rate: " precision ((deaths / totalinf) * 100) 2 "%")
output-print (word "Tests performed: " tests-performed)
;output-print (word "R0: " precision r0 2)
let tot sum table:values counters
output-print "Infections from household, relations, friends, school, random: "
foreach table:values counters [c ->
output-type (word (precision (c / tot) 2) " ")
]
let asy table:get cummulatives "asymptomatic"
let sym table:get cummulatives "symptomatic"
let sev table:get cummulatives "severe"
let all-cases asy + sym + sev
output-print (word "Ratio: hospital reported/community non-reported: " precision (( asy + sym) / sev ) 1 )
output-print (word "Severe: " precision (100 * sev / all-cases) 1 "% " " Symptomatic: " precision (100 * sym / all-cases) 1 "% " " Asymptomatic: " precision (100 * asy / all-cases) 1 "% ")
let tot sum table:values counters
let names( list "household: " " relations: " " friends: " " school: " " random: ")
let i 0
output-print (word "Infection sources: ")
foreach table:values counters [c ->
output-type (word item i names (precision (100 * c / tot) 1) "%" )
set i i + 1]
]
[
ifelse file-exists? "covid19.csv"
Expand Down

0 comments on commit fa61d3c

Please sign in to comment.