Skip to content
Snippets Groups Projects
Commit c7d64811 authored by Peter Jentsch's avatar Peter Jentsch
Browse files

more univariate sims

parent 03b8007a
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -6,7 +6,7 @@ const household_data = read_household_data()
default(dpi = 300)
default(framestyle = :box)
import LightGraphs.neighbors
export DebugRecorder,mean_solve,plot_model, get_parameters, HeatmapRecorder
export DebugRecorder,mean_solve,plot_model, univariate_simulations, plot_parameter_plane, get_parameters, HeatmapRecorder
"""
bench()
......
......@@ -13,13 +13,13 @@ function get_parameters()#(0.0000,0.00048,0.0005,0.16,-1.30,-1.24,-0.8,0.35,0.35
π_base_y = -1.37,
π_base_m = -1.46,
π_base_o = -0.95,
η = 0.00,
η = 0.01,
κ = 0.0,
ω = 0.0055,
ω_en = 0.0005,
ω_en = 0.0,
Γ = 1/7,
ξ = 5.0,
notification_parameter = 0.001,
notification_parameter = 0.0005,
vaccinator_prob = 0.6,
app_user_fraction = 0.0,
notification_threshold = 2,
......@@ -33,7 +33,7 @@ function get_parameters()#(0.0000,0.00048,0.0005,0.16,-1.30,-1.24,-0.8,0.35,0.35
end
function get_app_parameters()
return merge(get_parameters(),(app_user_fraction = 0.5,))
return merge(get_parameters(),(app_user_fraction = 0.3,))
end
function get_u_0(nodes,vaccinator_prob)
is_vaccinator = rand(Random.default_rng(Threads.threadid()),nodes) .< vaccinator_prob
......
......@@ -123,12 +123,13 @@ function record!(t,modelsol, recorder::Nothing)
end
function mean_solve(samples,parameter_tuple,recorder)
function mean_solve(samples,parameter_tuple,recorder;progmeter = nothing)
stat_recorder = recorder(Variance(), parameter_tuple.sim_length)
output_recorder = recorder(0.0,parameter_tuple.sim_length)
avg_populations = [0.0,0.0,0.0]
for _ in 1:samples
sol = abm(parameter_tuple,output_recorder)
isnothing(progmeter) || next!(progmeter)
avg_populations .+= length.(sol.index_vectors)
fit!(stat_recorder,output_recorder)
end
......@@ -136,14 +137,13 @@ function mean_solve(samples,parameter_tuple,recorder)
return stat_recorder,avg_populations
end
function mean_solve(samples,parameter_tuple,recorder::Type{HeatmapRecorder})
function mean_solve(samples,parameter_tuple,recorder::Type{HeatmapRecorder};progmeter = nothing)
stat_recorder = recorder(parameter_tuple.sim_length)
avg_populations = [0.0,0.0,0.0]
for _ in 1:samples
output_recorder = recorder(parameter_tuple.sim_length)
sol = abm(parameter_tuple,output_recorder)
isnothing(progmeter) || next!(progmeter)
avg_populations .+= length.(sol.index_vectors)
fit!(stat_recorder,output_recorder)
end
......
......@@ -2,10 +2,10 @@
const univariate_path = "CovidAlertVaccinationModel/plots/univariate/"
const bivariate_path = "CovidAlertVaccinationModel/plots/univariate/"
function univarate_test(variable, variable_range)
function univarate_test(variable, variable_range,samples; progmeter = nothing)
default_parameters = get_app_parameters()
parameter_range_list = [merge(default_parameters,NamedTuple{(variable,)}((value,))) for value in variable_range]
solve_fn(p) = mean_solve(samples, p,DebugRecorder)[1]
solve_fn(p) = mean_solve(samples, p,DebugRecorder;progmeter)[1]
univariate_outlist = ThreadsX.map(solve_fn, parameter_range_list)
......@@ -17,28 +17,32 @@ if !ispath(univariate_path)
mkdir(univariate_path)
end
function univariate_simulations()
len = 20
len = 5
samples = 10
univarate_test_list = (
# (:I_0_fraction, range(0.0, 0.05; length = len)),
# (:base_transmission_probability, range(0.0002, 0.002; length = len)),
# (:recovery_rate, range(0.1, 0.5; length = len)),
# (:immunization_loss_prob, range(0.00, 0.05; length = len)),
# (:π_base, range(-4.5, -3.5; length = len)),
(:η, range(0.0, 0.01; length = len)),
(:η, range(0.0, 0.005; length = len)),
# (:κ, range(0.5, 1.5; length = len)),
# (:ω, range(0.0, 0.01; length = len)),
(:ω_en, range(0.0, 0.0005; length = len)),
(:ω_en, range(0.0, 0.001; length = len)),
# (:γ, range(0.0, 0.5; length = len)),
# (:ξ, range(1, 15; length = len)),
# (:notification_parameter, range(0.00, 0.05; length = len)),
# (:app_user_fraction, range(0.05, 0.25; length = len)),
(:notification_parameter, range(0.000, 0.002; length = len)),
(:app_user_fraction, range(0.05, 0.8; length = len)),
(:notification_threshold, (1:len)),
# (:immunization_delay, [7,10,14,20]),
)
numsim = sum(map(t -> length(t[2]), univarate_test_list))
display(numsim)
progmeter = Progress(numsim*samples)
plt_list = ThreadsX.map(univarate_test_list) do ur
out = univarate_test(ur...)
display("done $(ur[1])")
out = univarate_test(ur...,samples;progmeter)
return out
end
for ((varname,_),p) in zip(univarate_test_list,plt_list)
......@@ -48,10 +52,10 @@ end
using AxisKeys
function multivariate_simulations()
len = 15
samples = 10
len = 10
samples = 25
app_simulations = (
(:η, range(0.0, 0.01; length = len)),
(:η, range(0.0, 0.005; length = len)),
(:ω_en, range(0.0, 0.05; length = len)),
# (:notification_threshold, (1:len)),
)
......@@ -70,12 +74,12 @@ function run_multivariate_sims(sims,samples)
default_parameters = get_app_parameters()
simvars = Iterators.product(sim_ranges...)
progmeter = Progress(length(simvars))
progmeter = Progress(length(simvars)*samples)
app_output = ThreadsX.map(simvars) do vars
vars_with_names = NamedTuple{varnames}(vars)
parameters = merge(default_parameters,vars_with_names)
out,_ = mean_solve(1, parameters,HeatmapRecorder)
next!(progmeter)
out,_ = mean_solve(samples, parameters,HeatmapRecorder;progmeter)
return out
end
display(length(simvars))
......
......@@ -32,7 +32,7 @@ function plot_model(varname,univariate_series, output_list::Vector{T},infection_
labelname = nothing
end
for (plt,(ts,title)) in zip(plts,ts_list(data))
plot!(plt, mean.(ts); ribbon = std.(ts),
plot!(plt, mean.(ts); #yerr = std.(ts),
label = labelname, line_z = i, color=:blues,
ylabel = "no. of people",
colorbar = false,
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment