Commit 54733796 authored by Peter Jentsch's avatar Peter Jentsch
Browse files

switch back to poissoncountsampler, much faster

parent b8f8000d
...@@ -38,8 +38,8 @@ const contact_time_distributions = load_contact_time_distributions() ...@@ -38,8 +38,8 @@ const contact_time_distributions = load_contact_time_distributions()
function shift_contact_distributions(sampler_matrix::AbstractMatrix{T},proportion) where T function shift_contact_distributions(sampler_matrix::AbstractMatrix{T},proportion) where T
return map(sampler_matrix) do sampler return map(sampler_matrix) do sampler
μ_old = mean(sampler) μ_old = sampler.μ#mean(sampler)
return Poisson(μ_old*proportion) return Distributions.PoissonCountSampler(Poisson(μ_old*proportion))
end end
end end
......
...@@ -95,8 +95,6 @@ function time_dep_mixing_graphs(len,base_network,demographics,index_vectors,ws_m ...@@ -95,8 +95,6 @@ function time_dep_mixing_graphs(len,base_network,demographics,index_vectors,ws_m
rest_static_edges = WeightedGraph(demographics,index_vectors,rest_matrix_tuple.daily,contact_time_distributions.rest) 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,weekly_shift(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)) rest_justonce_edges = WeightedGraph(demographics,index_vectors,rest_matrix_tuple.otherwise,daily_shift(contact_time_distributions.rest))
inf_network_list = [home_static_edges,rest_static_edges,ws_justonce_edges,rest_justonce_edges] inf_network_list = [home_static_edges,rest_static_edges,ws_justonce_edges,rest_justonce_edges]
......
...@@ -101,9 +101,9 @@ function load_mixing_matrices() ...@@ -101,9 +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) return map(t -> from_mean.(Geometric{Float64},t),workschool_mixing), map(t -> from_mean.(Geometric{Float64}, t),rest_mixing)
end end
# function make_sampler(λ) function make_sampler(λ)
# return Distributions.PoissonADSampler(λ)#Distributions.DiscreteNonParametricSampler(0:durmax,[pdf(Poisson(λ),x) for x in 0:durmax]) return Distributions.PoissonADSampler(λ)#Distributions.DiscreteNonParametricSampler(0:durmax,[pdf(Poisson(λ),x) for x in 0:durmax])
# end end
function load_contact_time_distributions() function load_contact_time_distributions()
distkey = "Distributions.Poisson" distkey = "Distributions.Poisson"
fnames = ( fnames = (
...@@ -113,7 +113,7 @@ function load_contact_time_distributions() ...@@ -113,7 +113,7 @@ function load_contact_time_distributions()
) )
contact_distributions_tuple = map(fnames) do fname contact_distributions_tuple = map(fnames) do fname
dat = deserialize(joinpath(PACKAGE_FOLDER,"intervals_model_output","simulation_output","$fname.dat")) dat = deserialize(joinpath(PACKAGE_FOLDER,"intervals_model_output","simulation_output","$fname.dat"))
return map(p -> Poisson(mode(p.particles)), as_symmetric_matrix(dat[distkey].P)) return map(p -> make_sampler(mode(p.particles)), as_symmetric_matrix(dat[distkey].P))
end end
return contact_distributions_tuple return contact_distributions_tuple
end end
......
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