-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from jangevaare/dev
v0.4.7
- Loading branch information
Showing
42 changed files
with
590 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
# Documentation: http://docs.travis-ci.com/user/languages/julia/ | ||
## Documentation: http://docs.travis-ci.com/user/languages/julia/ | ||
codecov: true | ||
language: julia | ||
os: | ||
- linux | ||
- osx | ||
julia: | ||
- 1.1 | ||
- 1.2 | ||
- 1.3 | ||
- 1.4 | ||
- nightly | ||
notifications: | ||
email: false | ||
matrix: | ||
allow_failures: | ||
- julia: nightly | ||
fast_finish: true | ||
after_success: | ||
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())' | ||
fast_finish: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
function initialize(::Type{TransmissionRates}, | ||
states::Vector{DiseaseState}, | ||
pop::Population, | ||
rf::RiskFunctions{T}, | ||
rp::RiskParameters{T}) where T <: EpidemicModel | ||
n_ids = length(states) | ||
tr = TransmissionRates(n_ids) | ||
for i in findall(states .== Ref(State_S)) | ||
# External exposure | ||
#tr.external[i] = rf.susceptibility(rp.susceptibility, pop, i) * rf.sparks(rp.sparks, pop, i) | ||
tr.external[i] = rf.sparks(rp.sparks, pop, i) | ||
# Internal exposure | ||
for k in findall(states .== Ref(State_I)) | ||
tr.internal[k, i] = rf.susceptibility(rp.susceptibility, pop, i) * | ||
rf.infectivity(rp.infectivity, pop, i, k) * | ||
rf.transmissibility(rp.transmissibility, pop, k) | ||
end | ||
end | ||
@debug "Initialization of $T TransmissionRates complete" external = tr.external ∑external = sum(tr.external) internal = tr.internal ∑internal = sum(tr.internal) | ||
return tr | ||
end | ||
|
||
function initialize(::Type{EventRates}, | ||
tr::TransmissionRates, | ||
states::Vector{DiseaseState}, | ||
pop::Population, | ||
rf::RiskFunctions{T}, | ||
rp::RiskParameters{T}) where T <: EpidemicModel | ||
n_ids = length(states) | ||
rates = EventRates{T}(n_ids) | ||
for i = 1:n_ids | ||
if states[i] == State_S | ||
if T in [SEIR; SEI] | ||
rates.exposure[i] = tr.external[i] + sum(tr.internal[:,i]) | ||
elseif T in [SIR; SI] | ||
rates.infection[i] = tr.external[i] + sum(tr.internal[:,i]) | ||
end | ||
elseif states[i] == State_E | ||
rates.infection[i] = rf.latency(rp.latency, pop, i) | ||
elseif states[i] == State_I | ||
if T in [SEIR; SIR] | ||
rates.removal[i] = rf.removal(rp.removal, pop, i) | ||
end | ||
end | ||
end | ||
@debug "Initialization of $T EventRates complete" rates = rates[_state_progressions[T][2:end]] | ||
return rates | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
function update!(events::Events{T}, | ||
event::Event{T}) where T <: EpidemicModel | ||
events[event.new_state][event.individual] = event.time | ||
return events | ||
end | ||
|
||
function update!(states::Vector{DiseaseState}, | ||
event::Event{T}) where T <: EpidemicModel | ||
states[event.individual] = event.new_state | ||
return states | ||
end | ||
|
||
function update!(net::TransmissionNetwork, | ||
xfer::ExogenousTransmission) | ||
net.external[xfer.individual] = true | ||
return net | ||
end | ||
|
||
function update!(net::TransmissionNetwork, | ||
xfer::EndogenousTransmission) | ||
net.internal[xfer.source, xfer.individual] = true | ||
return net | ||
end | ||
|
||
function update!(net::TransmissionNetwork, | ||
xfer::NoTransmission) | ||
return net | ||
end | ||
|
||
function update!(tr::TransmissionRates, | ||
event::Event{T}, | ||
states::Vector{DiseaseState}, | ||
pop::Population, | ||
rf::RiskFunctions{T}, | ||
rp::RiskParameters{T}; | ||
xzero::Bool=false) where T <: EpidemicModel | ||
id = event.individual | ||
if _new_transmission(event) && xzero | ||
tr.external[id] = 0.0 | ||
tr.internal[:, id] .= 0.0 | ||
end | ||
if event.new_state == State_I | ||
transmissibility = rf.transmissibility(rp.transmissibility, pop, id) | ||
@simd for i in findall(states .== Ref(State_S)) | ||
tr.internal[id, i] = rf.susceptibility(rp.susceptibility, pop, i) * | ||
rf.infectivity(rp.infectivity, pop, i, id) * | ||
transmissibility | ||
end | ||
elseif event.new_state == State_R | ||
@simd for i in findall(states .== Ref(State_S)) | ||
tr.internal[id, i] = 0.0 | ||
end | ||
end | ||
return tr | ||
end | ||
|
||
function update!(rates::EventRates{T}, | ||
tr::TransmissionRates, | ||
event::Event{T}, | ||
states::Vector{DiseaseState}, | ||
pop::Population, | ||
rf::RiskFunctions{T}, | ||
rp::RiskParameters{T}) where T <: EpidemicModel | ||
id = event.individual | ||
if event.new_state == State_E | ||
rates.exposure[id] = 0.0 | ||
rates.infection[id] = rf.latency(rp.latency, pop, id) | ||
@logmsg LogLevel(-5000) "Exposure rate total for i = $id updated" λ = rates.exposure[id] | ||
@logmsg LogLevel(-5000) "Infection rate for i = $id updated" λ = rates.infection[id] | ||
elseif event.new_state == State_I | ||
rates.infection[id] = 0.0 | ||
@logmsg LogLevel(-5000) "Infection rate for i = $id updated" λ = rates.infection[id] | ||
if T in [SEIR; SIR] | ||
rates.removal[id] = rf.removal(rp.removal, pop, id) | ||
@logmsg LogLevel(-5000) "Removal rate for i = $id updated" λ = rates.removal[id] | ||
end | ||
if T in [SEIR; SEI] | ||
@simd for i in findall(states .== Ref(State_S)) | ||
# This assumes `TransmissionRates` already updated! | ||
rates.exposure[i] += tr.internal[id, i] | ||
@logmsg LogLevel(-5000) "Exposure rate total for i = $id updated" λ = rates.exposure[id] | ||
end | ||
elseif T in [SIR; SI] | ||
@simd for i in findall(states .== Ref(State_S)) | ||
# This assumes `TransmissionRates` already updated! | ||
rates.infection[i] += tr.internal[id, i] | ||
@logmsg LogLevel(-5000) "Infection rate total for i = $id updated" λ = rates.infection[id] | ||
end | ||
end | ||
elseif event.new_state == State_R | ||
rates.removal[id] = 0.0 | ||
@logmsg LogLevel(-5000) "Removal rate for i = $id updated" λ = rates.removal[id] | ||
if T == SEIR | ||
@simd for i in findall(states .== Ref(State_S)) | ||
# This assumes `TransmissionRates` already updated! | ||
rates.exposure[i] = sum(tr.internal[:, i]) | ||
@logmsg LogLevel(-5000) "Exposure rate total for i = $i updated" λ = rates.exposure[i] | ||
end | ||
elseif T == SIR | ||
@simd for i in findall(states .== Ref(State_S)) | ||
# This assumes `TransmissionRates` already updated! | ||
rates.infection[i] = sum(tr.internal[:, i]) | ||
@logmsg LogLevel(-5000) "Infection rate for i = $i updated" λ = rates.infection[i] | ||
end | ||
end | ||
end | ||
return rates | ||
end | ||
|
||
function update!(tr::TransmissionRates, | ||
rates::EventRates{T}, | ||
event::Event{T}, | ||
states::Vector{DiseaseState}, | ||
pop::Population, | ||
rf::RiskFunctions{T}, | ||
rp::RiskParameters{T}) where T <: EpidemicModel | ||
update!(tr, event, states, pop, rf, rp) | ||
update!(rates, tr, event, states, pop, rf, rp) | ||
return tr, rates | ||
end |
Oops, something went wrong.
fa1cab4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
Release notes:
TransmissionNetworkPrior
for conducting inference via MCMCfa1cab4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/11431
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: