Skip to content

Commit

Permalink
added household params to control the success rate of tracing & quara…
Browse files Browse the repository at this point in the history
…ntine among household members of a positive case
  • Loading branch information
eMaerthin committed Mar 18, 2022
1 parent b7ee044 commit 8104839
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/event_execution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ function quarantinehousehold!(state::SimState, params::SimParams, subject_id::In
if !include_subject && (member == subject_id)
continue
end

if rand(state.rng) > params.household_params.quarantine_prob
continue
end
member_freedom = freedom(state, member)

if (Hospitalized == member_freedom) || (Released == member_freedom)
Expand All @@ -450,8 +452,11 @@ end

function tracehousehold!(state::SimState, params::SimParams, subject_id::Integer; trace_household_connections::Bool)
for member in householdof(params, subject_id)
backtrace!(state, params, member, trace_household_connections=trace_household_connections)
forwardtrace!(state, params, member, trace_household_connections=trace_household_connections)
if rand(state.rng) > params.household_params.trace_prob
continue
end
backtrace!(state, params, member, trace_household_connections=trace_household_connections)
forwardtrace!(state, params, member, trace_household_connections=trace_household_connections)
end
nothing
end
Expand Down
5 changes: 5 additions & 0 deletions src/params/households.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Base.@kwdef struct HouseholdParams
quarantine_prob::Float64 = 0.5
trace_prob::Float64 = 0.5
end

function make_household_ptrs!(
ptrs::AbstractVector{Tuple{Ti,Ti}},
household_indices::AbstractVector{T} where T<:Integer
Expand Down
16 changes: 15 additions & 1 deletion src/simparams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ struct SimParams <: AbstractSimParams

screening_params::Union{Nothing, ScreeningParams}
spreading_params::Union{Nothing, SpreadingParams}

household_params::Union{Nothing, HouseholdParams}
end

numindividuals(params::SimParams) = length(params.household_ptrs)
Expand Down Expand Up @@ -170,6 +172,7 @@ function make_params(
age_coupling_use_genders::Bool=false,

screening_params::Union{Nothing,ScreeningParams}=nothing,
household_params::Union{Nothing,HouseholdParams}=nothing,

spreading_alpha::Union{Nothing,Real}=nothing,
spreading_x0::Real=1,
Expand Down Expand Up @@ -241,6 +244,16 @@ function make_params(
else error("spreading_alpha must be larger than 0, got $spreading_alpha")
end

household_params =
if nothing === household_params; HouseholdParmas()
elseif 0.0 <= household_params.quarantine_prob
&& 1.0 >= household_params.quarantine_prob
&& 0.0 <= household_params.trace_prob
&& 1.0 >= household_params.trace_prob
household_params
else error("household_params has invalid values for probas, got quarantine_prob: $(household_params.quarantine_prob) and trace_prob: $(household_params.trace_prob)")
end

params = SimParams(
household_ptrs,
individuals_df.age,
Expand Down Expand Up @@ -277,7 +290,8 @@ function make_params(
backward_tracing_modulation,

screening_params,
spreading_params
spreading_params,
household_params
)
params
end
Expand Down

0 comments on commit 8104839

Please sign in to comment.