Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const univariate_path = "CovidAlertVaccinationModel/plots/univariate/"
const bivariate_path = "CovidAlertVaccinationModel/plots/univariate/"
function univarate_test(variable, variable_range)
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]
univariate_outlist = ThreadsX.map(solve_fn, parameter_range_list)
p = plot_model(variable,parameter_range_list,univariate_outlist,default_parameters.infection_introduction_day,default_parameters.immunization_begin_day)
return p
end
if !ispath(univariate_path)
mkdir(univariate_path)
end
function univariate_simulations()
len = 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.5, 1.5; length = len)),
# (:ω, range(0.0, 0.01; length = len)),
(:ω_en, range(0.0, 0.0005; 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_threshold, (1:len)),
# (:immunization_delay, [7,10,14,20]),
)
plt_list = ThreadsX.map(univarate_test_list) do ur
out = univarate_test(ur...)
display("done $(ur[1])")
return out
end
for ((varname,_),p) in zip(univarate_test_list,plt_list)
savefig(p,"$univariate_path/$varname.pdf")
end
end
using AxisKeys
function multivariate_simulations()
len = 10
samples = 10
app_simulations = (
(:η, range(0.0, 0.01; length = len)),
(:ω_en, range(0.0, 0.0005; length = len)),
# (:notification_threshold, (1:len)),
)
run_multivariate_sims(app_simulations,1)
# for ((varname,_),p) in zip(univarate_test_list,plt_list)
# savefig(p,"$univariate_path/$varname.pdf")
# end
end
using ProgressMeter
function run_multivariate_sims(sims,samples)
varnames, sim_ranges = zip(sims...)
default_parameters = get_app_parameters()
simvars = Iterators.product(sim_ranges...)
progmeter = Progress(length(simvars))
output = ThreadsX.map(simvars) do vars
vars_with_names = NamedTuple{varnames}(vars)
parameters = merge(default_parameters,vars_with_names)
out,_ = mean_solve(samples, parameters,DebugRecorder)
next!(progmeter)
return out
end
display(length(simvars))
fname = join(string.(varnames),"_")
keyed_output = KeyedArray(output;NamedTuple{varnames}(sim_ranges)...)
path = joinpath(PACKAGE_FOLDER,"abm_output","$fname.dat")
serialize(path,keyed_output)
return fname
end
function plot_parameter_plane(input_fname)
map(1: length(axiskeys(output)[end])) do i
end
end