Commit 54c67019 authored by Peter Jentsch's avatar Peter Jentsch
Browse files

1000 particles new plots, loading matrices into ABM

parent 8694d604
......@@ -607,7 +607,7 @@ uuid = "30392449-352a-5448-841d-b1acce4e97dc"
version = "0.40.0+0"
[[Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs"]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
[[PlotThemes]]
......@@ -646,9 +646,9 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
[[Qt_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Fontconfig_jll", "Glib_jll", "JLLWrappers", "Libdl", "Libglvnd_jll", "OpenSSL_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libxcb_jll", "Xorg_xcb_util_image_jll", "Xorg_xcb_util_keysyms_jll", "Xorg_xcb_util_renderutil_jll", "Xorg_xcb_util_wm_jll", "Zlib_jll", "xkbcommon_jll"]
git-tree-sha1 = "7760cfea90bec61814e31dfb204fa4b81bba7b57"
git-tree-sha1 = "588b799506f0b956a7e6e18f767dfa03cf333f26"
uuid = "ede63266-ebff-546c-83e0-1c6fb6d0efc8"
version = "5.15.2+1"
version = "5.15.2+2"
[[QuadGK]]
deps = ["DataStructures", "LinearAlgebra"]
......@@ -704,10 +704,10 @@ uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
version = "0.6.1"
[[Rmath_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "d76185aa1f421306dec73c057aa384bad74188f0"
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "1b7bf41258f6c5c9c31df8c1ba34c1fc88674957"
uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
version = "0.2.2+1"
version = "0.2.2+2"
[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
......@@ -1071,6 +1071,10 @@ version = "1.3.6+6"
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
[[p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
[[x264_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "d713c1ce4deac133e3334ee12f4adff07f81778f"
......
,location,frequency,0,1,2,3,4,5,6,7,8
0,workschool,daily,3.1964647992527766,1.2547184122670996,0.006237831139178188,0.48589087391586855,2.4905386632966904,0.008553753347824449,0.0011922432682835138,0.002093297586440158,0.00442679226398468
1,workschool,3xweekly,0.7944954598823015,0.9083386189192323,0.0036113759226821087,0.3080433568287634,1.3066202996559655,0.004786396277663501,0.0004222528241837445,0.002093297586440158,0.00563409924507141
2,workschool,justonce,0.1138876488849416,0.40572458311725706,0.007879365649488237,0.1817533922793549,1.2604129250173148,0.007967033804110858,0.0003228992184934517,0.0030331454823928823,0.012073069810867311
3,rest,daily,1.0168944716132233,0.3299602444066508,0.04073636423457753,0.2925992588436326,0.5125821543230763,0.15144660611690303,0.05819329875669662,0.10602850831351676,0.10606175483955847
4,rest,3xweekly,0.904489814110522,0.3577232431793653,0.07128863741051067,0.303270525930871,0.8396222251306884,0.23999206592327127,0.07506092158472462,0.20517204855472723,0.23393059945921307
5,rest,justonce,0.8067923080567723,0.694873904534345,0.09433684349060058,0.5432019181826497,1.8933898836230174,0.3938579468982718,0.13156745805861844,0.4236550353825799,0.327106346701442
......@@ -11,9 +11,12 @@ end
Immunized
end
struct AgentModel{GraphType,DistMatrixList1,DistMatrixList2,DistMatrixList3}
demographics::Vector{AgentDemographic}
# is_app_user::Vector{Boolean}
# is_vaccinator::Vector{Boolean}
# app_user_indices::Vector{Int}
# vaccinator_indices::Vector{Int}
demographic_index_vectors::Vector{Vector{Int}}
base_network::GraphType
workschool_contacts_mean_adjusted_list::DistMatrixList1
......
......@@ -117,4 +117,31 @@ function parse_cases_data()::Tuple{Vector{Date},Matrix{Float64}} #this type decl
end
return dates, infection_data
end
using CSV
function load_mixing_matrices()
df = CSV.File(joinpath(PACKAGE_FOLDER,"data/csv/mixing_loc-freq.csv")) |> DataFrame
workschool_mixing = (
daily = zeros(3,3),
twice_a_week = zeros(3,3),
otherwise = zeros(3,3),
)
rest_mixing = (
daily = zeros(3,3),
twice_a_week = zeros(3,3),
otherwise = zeros(3,3),
)
mixing = [workschool_mixing,rest_mixing]
locations_labels = ["workschool", "rest"]
frequency_labels = ["daily","3xweekly","justonce"]
for r in eachrow(df)
location_ind = findfirst(==(r["location"]),locations_labels)
frequency_ind = findfirst(==(r["frequency"]),frequency_labels)
for i in 0:8
mixing[location_ind][frequency_ind]'[i+1] = r[string(i)]
end
end
return map(t -> from_mean.(Geometric{Float64},t),workschool_mixing), map(t -> from_mean.(Geometric{Float64}, t),rest_mixing)
end
\ No newline at end of file
......@@ -5,6 +5,7 @@ function adjust_distributions_mean(distribution_matrix::AbstractArray{T},mean_sh
return from_mean(typeof(dist),dist.α, new_mean)
end
end
function adjust_distributions_mean(distribution_matrix::AbstractArray{T},mean_shift_percentage) where T<:Distribution
return map(distribution_matrix) do dist
new_mean = mean(dist)*(1 + mean_shift_percentage)
......@@ -92,21 +93,12 @@ function make_workschool_mixing_matrix()
return ws_mixing_w_unemployment_symmetrized_weekday_adjusted
end
const initial_rest_mixing_matrix = symmetrize_means(get_household_data_proportions(),map(t->from_mean(t...),[
(Geometric{Float64},2.728177) (Geometric{Float64},1.382557) (Geometric{Float64},0.206362)
(Geometric{Float64},1.139072) (Geometric{Float64},3.245594) (Geometric{Float64},0.785297)
(Geometric{Float64},0.264822) (Geometric{Float64},0.734856) (Geometric{Float64},0.667099)
]))
const initial_workschool_mixing_matrix = make_workschool_mixing_matrix()
@views function ws_sample(age)
return rand.(initial_workschool_mixing_matrix[age,:]) * (rand(RNG) < (5/7))
end
# ws_adjust_mean(M) = from_mean.(typeof.(M),(7/5) .* mean.(M) ./ (1 .- alphas)) (5/7) * (1-u[i,j]) / { E[X[i,j]] + (5/7) * (1-u[i,j]) }
# const initial_workschool_mixing_whole_population_symmetrized = ws_adjust_mean(symmetrize_means(get_household_data_proportions(),initial_workschool_mixing_matrix))
# const initial_rest_mixing_matrix_whole_population_symmetrized = symmetrize_means(get_household_data_proportions(),initial_rest_mixing_matrix)
const workschool_mixing, rest_mixing = load_mixing_matrices()
const contact_time_distribution_matrix = [Geometric() for i in 1:(AgentDemographic.size-1), j in 1:(AgentDemographic.size-1)]
......
......@@ -3,7 +3,7 @@ using RandomNumbers.Xorshifts
using Test
using ThreadsX
import StatsBase.mean
model_sizes = [100,1000,1000,5000]
model_sizes = [100,1000,5000]
vaccination_strategies = [vaccinate_uniformly!]
vaccination_rates = [0.000,0.005,0.01,0.05]
infection_rates = [0.01,0.05,0.1]
......@@ -11,6 +11,8 @@ agent_models = ThreadsX.map(model_size -> AgentModel(model_size...), model_sizes
dem_cat = AgentDemographic.size -1
#network generation
#covidalert
@testset "mixing matrices, size: $sz" for (m,sz) in zip(agent_models,model_sizes)
ws_dist = m.workschool_contacts_mean_adjusted_list
......
......@@ -76,6 +76,7 @@ def Flatten(A):
# Flatten the mixing subdivided mixing matrices
flat_mixing = {}
for loc, fbins in list(product(locales_nohh, freqbins)):
print(Mixing[(loc,fbins)])
flat_mixing[(loc,fbins)] = Flatten(Mixing[(loc,fbins)])
# Save them to csv
......
Supports Markdown
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