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

join counts redux

parent cae29db1
......@@ -25,6 +25,9 @@ struct Recorder{ElType,ArrT1,ArrT2,ArrT3,StatAccumulator}
total_app_weight::ArrT2
avg_weighted_degree_of_vaccinator_belief::Vector{StatAccumulator}
vac_join_counts::ArrT2
vac_join_11_counts::ArrT2
vac_join_01_counts::ArrT2
vac_join_00_counts::ArrT2
function Recorder(val::T,sim_length; record_degrees = false) where T
......@@ -48,8 +51,11 @@ struct Recorder{ElType,ArrT1,ArrT2,ArrT3,StatAccumulator}
final_size_by_age = [copy(val) for i in 1:3]
total_app_weight = [copy(val) for i in 1:sim_length]
vac_join_counts =[copy(val) for j in 1:sim_length]
vac_join_11_counts =[copy(val) for j in 1:sim_length]
vac_join_01_counts =[copy(val) for j in 1:sim_length]
vac_join_00_counts =[copy(val) for j in 1:sim_length]
avg_weighted_degree_of_vaccinators = [Variance() for _ in 1:3]
avg_weighted_degree_of_vaccinators_no_EN = [Variance() for _ in 1:3]
avg_weighted_degree_of_vaccinator_belief = [Variance() for _ in 1:sim_length]
......@@ -72,7 +78,10 @@ struct Recorder{ElType,ArrT1,ArrT2,ArrT3,StatAccumulator}
avg_weighted_degree_of_vaccinators_no_EN,
total_app_weight,
avg_weighted_degree_of_vaccinator_belief,
vac_join_counts
vac_join_counts,
vac_join_11_counts,
vac_join_01_counts,
vac_join_00_counts
)
end
end
......
......@@ -119,21 +119,31 @@ function plot_parameter_plane(input_fname)
final_size_map = map(x-> (mean_final_size(x) - base_outcome),output)
mean_weighted_degree_change(p,age) = mean(p.avg_weighted_degree_of_vaccinators[age])-mean(p.avg_weighted_degree_of_vaccinators_no_EN[age])
weighted_degree_map = [map(p -> mean_weighted_degree_change(p,i),output) for i in 1:3]
mean_join_count(p) = mean(reduce(merge!, p.vac_join_counts[end-30:end]))
join_count_maps = map(x-> (mean_join_count(x)),output)
mean_join_11_count(p) = mean(reduce(merge!,p.vac_join_counts[end-30:end]))
mean_join_01_count(p) = mean(p.vac_join_01_counts[end])
# mean_join_00_count(p) = mean(p.vac_join_00_counts[end])
join_count_maps = [
map(x-> (mean_join_11_count(x) - mean_join_11_count(output_no_app)),output),
map(x-> (mean_join_01_count(x) - mean_join_11_count(output_no_app)),output),
# map(x-> (mean_join_00_count(x)),output),
]
for en_interval in var_ranges[3]
subfolder_path = joinpath(PACKAGE_FOLDER,"plots","app_heatmaps","$en_interval")
mkpath(subfolder_path)
cs = cgrad(:blues)
datamaps = (weighted_degree_map..., final_size_map,map(std_final_size,output),join_count_maps)
datamaps = (weighted_degree_map..., final_size_map,map(std_final_size,output),join_count_maps...)
fnames = [
"wdg_change_Y.pdf",
"wdg_change_M.pdf",
"wdg_change_O.pdf",
"final_size_change.pdf",
"final_size_standard_dev.pdf",
"join_counts.pdf"
"join_counts_imm.pdf",
"join_01_counts.pdf",
"join_00_counts.pdf",
]
titles = [
"Change in w. deg. of vaccinators with EN",
......@@ -141,10 +151,12 @@ function plot_parameter_plane(input_fname)
"Change in w. deg. of vaccinators with EN",
"Effect of EN on tot. infections",
"Standard deviation from the mean of total infection size",
"Join counts"
"Join counts (J_11 + J_00)",
"Join counts (J_01)",
]
for (fname,title,datamap) in zip(fnames,titles,datamaps)
p = heatmap(var_ranges[1],var_ranges[2],transpose(datamap(EN_intervals = en_interval)); title, xlabel = vars[1], ylabel = vars[2], seriescolor=cs, size = (600,400))
p = heatmap(var_ranges[1],var_ranges[2],transpose(datamap(EN_intervals = en_interval)); title, xlabel = vars[1], ylabel = vars[2], seriescolor=cs,
size = (800,600))
savefig(p,joinpath(subfolder_path,"$(en_interval)_$fname"))
end
end
......
......@@ -34,6 +34,7 @@ function plot_model(varname,univariate_series, output_list::Vector{T},p) where T
zoom((x_axis, data.daily_immunized_by_age.M, "new M vaccinations each day (zoomed in)", "no. individuals")),
zoom((x_axis, data.daily_immunized_by_age.O, "new O vaccinations each day (zoomed in)", "no. individuals")),
(x_axis, data.vac_join_counts, "join counts", "no. joins"),
(x_axis, data.vac_join_01_counts, "join 01 counts", "no. joins"),
]
sample_data = ts_list(output_list[1])
l = length(sample_data)
......
......@@ -119,17 +119,25 @@ function update_vaccination_opinion_state!(t,agent,agent_demo,modelsol,vaccinate
return 0
end
function weighted_degree_and_join_count(t,node,network::TimeDepMixingGraph,u_vac)
function weighted_degree_and_join_count(t,node,network::TimeDepMixingGraph,u_inf)
weighted_degree = 0
join_count = 0
node_is_vac = u_vac[node]
join_count_11 = 0
join_count_01 = 0
join_count_00 = 0
node_is_immunized = u_inf[node] == Immunized
for g in network.graph_list[t]
for j in neighbors(g,node)
weighted_degree += get_weight(g,GraphEdge(node,j))
join_count+= ifelse(node_is_vac == u_vac[j],1,0)
weight = get_weight(g,GraphEdge(node,j))
weighted_degree += weight
j_is_immunized = u_inf[j] == Immunized
join_count_11 += ifelse(node_is_immunized && j_is_immunized,weight,0)
join_count_01 += ifelse(xor(node_is_immunized, j_is_immunized),weight,0)
join_count_00 += ifelse(!(node_is_immunized) && !(j_is_immunized),weight,0)
end
end
return weighted_degree,join_count
return weighted_degree,(join_count_11,join_count_01,join_count_00)
end
function sample_initial_nodes(nodes,graphs,I_0_fraction)
......@@ -172,9 +180,13 @@ function agents_step!(t,modelsol)
end
for (agent,(agent_inf_status,agent_is_vaccinator,agent_demo)) in enumerate(zip(u_inf,u_vac,demographics))
weighted_degree_of_i, join_count = output_data.record_degrees_flag ? weighted_degree_and_join_count(t,agent,inf_network,u_vac) : (0,0)
output_data.vac_join_counts[t] += join_count
if agent_inf_status == Susceptible
weighted_degree_of_i, join_counts = output_data.record_degrees_flag ? weighted_degree_and_join_count(t,agent,inf_network,u_inf) : (0,(0,0,0))
output_data.vac_join_counts[t] += join_counts[1] + join_counts[3]
output_data.vac_join_11_counts[t] += join_counts[1]
output_data.vac_join_01_counts[t] += join_counts[2]
output_data.vac_join_00_counts[t] += join_counts[3]
if agent_inf_status == Susceptible
is_susceptible_infected!(t, modelsol, agent,agent_inf_status,agent_demo,α_vec,β_vec)
if vaccinate_today_flag && agent_is_vaccinator && t<(infection_introduction_day-1)
fit!(output_data.avg_weighted_degree_of_vaccinators[Int(agent_demo)],weighted_degree_of_i)
......
No preview for this file type
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