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

parallel mean solve

parent c7d64811
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -3,10 +3,10 @@ using OnlineStats
using Plots
using CovidAlertVaccinationModel:vaccination_data,ymo_vac,ymo_attack_rate
const samples = 10
const samples = 25
function solve_and_plot_parameters()
p = CovidAlertVaccinationModel.get_app_parameters()
p = CovidAlertVaccinationModel.get_parameters()
display(p)
out,avg_populations = mean_solve(samples, p,DebugRecorder)
p = plot_model(nothing,[nothing],[out],p.infection_introduction_day,p.immunization_begin_day)
......
No preview for this file type
No preview for this file type
......@@ -13,7 +13,7 @@ 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.01,
η = 0.0,
κ = 0.0,
ω = 0.0055,
ω_en = 0.0,
......
......@@ -125,12 +125,15 @@ end
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_list = ThreadsX.map(1:samples) do _
output_recorder = recorder(0.0,parameter_tuple.sim_length)
sol = abm(parameter_tuple,output_recorder)
isnothing(progmeter) || next!(progmeter)
avg_populations .+= length.(sol.index_vectors)
return output_recorder,length.(sol.index_vectors)
end
for (output_recorder,pop) in sol_list
avg_populations .+= pop
fit!(stat_recorder,output_recorder)
end
avg_populations ./= samples
......@@ -140,11 +143,14 @@ end
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
sol_list = ThreadsX.map(1:samples) do _
output_recorder = recorder(parameter_tuple.sim_length)
sol = abm(parameter_tuple,output_recorder)
isnothing(progmeter) || next!(progmeter)
avg_populations .+= length.(sol.index_vectors)
return output_recorder,length.(sol.index_vectors)
end
for (output_recorder,pop) in sol_list
avg_populations .+= pop
fit!(stat_recorder,output_recorder)
end
avg_populations ./= samples
......
......@@ -113,10 +113,13 @@ Base.@propagate_inbounds @views function update_vaccination_opinion_state!(t,mod
if !isempty(neighbors(random_soc_network,i))
random_neighbour = sample(Random.default_rng(Threads.threadid()), neighbors(random_soc_network.g,i))
if u_vac[random_neighbour] == u_vac[i]
vac_payoff = π_base[Int(demographics[i])] + total_infections*ω
app_vac_payoff = 0.0
if app_user[i] && time_of_last_alert[app_user_list[i]]>=0
vac_payoff += Γ^(-1*(t - time_of_last_alert[app_user_list[i]])) * (η + total_infections*ω_en)
app_vac_payoff = Γ^(-1*(t - time_of_last_alert[app_user_list[i]])) * (η + total_infections*ω_en)
end
vac_payoff = π_base[Int(demographics[i])] + total_infections*ω + app_vac_payoff
if u_vac[i]
# display(1 - Φ(vac_payoff,ξ))
if rand(Random.default_rng(Threads.threadid())) < 1 - Φ(vac_payoff,ξ)
......
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