Commit 0c4e34f0 authored by Peter Jentsch's avatar Peter Jentsch
Browse files

shift durations for weekly and daily edges, change gamma to reasonable value

parent 74af5547
......@@ -36,6 +36,12 @@ See `load_contact_time_distributions()`.
"""
const contact_time_distributions = load_contact_time_distributions()
function shift_contact_distributions(sampler_matrix::AbstractMatrix{T},proportion) where T<:Distributions.PoissonADSampler
return map(sampler_matrix) do sampler
μ_old = sampler.μ
return Distributions.PoissonADSampler(μ_old*proportion)
end
end
```
Given alphas given in `unemployment_matrix` computes the zero weight for each pair of demographic contacts given individual zero weights.
......
......@@ -81,19 +81,24 @@ Assumes the simulation begins on Thursday arbitrarily.
"""
function time_dep_mixing_graphs(len,base_network,demographics,index_vectors,ws_matrix_tuple,rest_matrix_tuple)
#weekly multiply durations by 1/5
daily_shift(dur_dists) = shift_contact_distributions(dur_dists,1/5)
#daily multiply by 1/2
weekly_shift(dur_dists) = shift_contact_distributions(dur_dists,1/2)
home_static_edges = WeightedGraph(base_network,demographics,contact_time_distributions.hh) #network with households and LTC homes
ws_static_edges = WeightedGraph(demographics,index_vectors,ws_matrix_tuple.daily,contact_time_distributions.ws)
ws_weekly_edges = WeightedGraph(demographics,index_vectors,ws_matrix_tuple.twice_a_week,contact_time_distributions.ws)
ws_justonce_edges = WeightedGraph(demographics,index_vectors,ws_matrix_tuple.otherwise,contact_time_distributions.ws)
ws_weekly_edges = WeightedGraph(demographics,index_vectors,ws_matrix_tuple.twice_a_week,weekly_shift(contact_time_distributions.ws))
ws_justonce_edges = WeightedGraph(demographics,index_vectors,ws_matrix_tuple.otherwise,daily_shift(contact_time_distributions.ws))
rest_static_edges = WeightedGraph(demographics,index_vectors,rest_matrix_tuple.daily,contact_time_distributions.rest)
rest_weekly_edges = WeightedGraph(demographics,index_vectors,rest_matrix_tuple.twice_a_week,contact_time_distributions.rest)
rest_justonce_edges = WeightedGraph(demographics,index_vectors,rest_matrix_tuple.otherwise,contact_time_distributions.rest)
rest_weekly_edges = WeightedGraph(demographics,index_vectors,rest_matrix_tuple.twice_a_week,weekly_shift(contact_time_distributions.rest))
rest_justonce_edges = WeightedGraph(demographics,index_vectors,rest_matrix_tuple.otherwise,daily_shift(contact_time_distributions.rest))
#weekly multiply durations by 1/5
#daily multiply by 1/2
inf_network_list = [home_static_edges,rest_static_edges,ws_justonce_edges,rest_justonce_edges]
soc_network_list = [home_static_edges,rest_static_edges,ws_static_edges]
......
......@@ -21,7 +21,7 @@
κ = 0.0,
ω = 0.0061,
ω_en = 0.05,
Γ = 1/7, #make this .906
Γ = 0.906,
ξ = 5.0,
notification_parameter = 0.0005,
vaccinator_prob = 0.6,
......
module CovidAlertVaccinationModel
using Distributions: PoissonADSampler
using Intervals: Ending
using Base: Float64, NamedTuple
using LightGraphs
......
......@@ -38,7 +38,7 @@ function err_ws(p,dist)
for age_j in YOUNG:OLD #for a given age_sample loop over possible contact ages
if neighourhoods[age_j] > 0
#get durations from our candidate distribtions for each of the contacts in neighbourhood
#get durations from our candidate distributions for each of the contacts in neighbourhood
durs = trunc.(Int,rand(Random.default_rng(Threads.threadid()),age_dists[age_sample,age_j],neighourhoods[age_j])) .% durmax
#this MODIFIES sample_list to contain samples from the distribution of total_durations, given intervals of length dur.
......
......@@ -101,6 +101,9 @@ function load_mixing_matrices()
return map(t -> from_mean.(Geometric{Float64},t),workschool_mixing), map(t -> from_mean.(Geometric{Float64}, t),rest_mixing)
end
function make_sampler(λ)
return Distributions.PoissonADSampler(λ)#Distributions.DiscreteNonParametricSampler(0:durmax,[pdf(Poisson(λ),x) for x in 0:durmax])
end
function load_contact_time_distributions()
distkey = "Distributions.Poisson"
fnames = (
......@@ -108,9 +111,6 @@ function load_contact_time_distributions()
ws = "ws",
rest = "rest"
)
function make_sampler(λ)
return Distributions.PoissonADSampler(λ)#Distributions.DiscreteNonParametricSampler(0:durmax,[pdf(Poisson(λ),x) for x in 0:durmax])
end
contact_distributions_tuple = map(fnames) do fname
dat = deserialize(joinpath(PACKAGE_FOLDER,"intervals_model_output","simulation_output","$fname.dat"))
return map(p -> make_sampler(mode(p.particles)), as_symmetric_matrix(dat[distkey].P))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment