diff --git a/CovidAlertVaccinationModel/Manifest.toml b/CovidAlertVaccinationModel/Manifest.toml index 9f2dd289cf1e7347e1255edf9e28e64f56b22f94..def003c2756bfd854c7597740a98b0604e84d996 100644 --- a/CovidAlertVaccinationModel/Manifest.toml +++ b/CovidAlertVaccinationModel/Manifest.toml @@ -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" diff --git a/CovidAlertVaccinationModel/data/csv/mixing_loc-freq.csv b/CovidAlertVaccinationModel/data/csv/mixing_loc-freq.csv new file mode 100644 index 0000000000000000000000000000000000000000..e45f1f98ab15cd1629bd0c4411de9f46ff52afd9 --- /dev/null +++ b/CovidAlertVaccinationModel/data/csv/mixing_loc-freq.csv @@ -0,0 +1,7 @@ +,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 diff --git a/CovidAlertVaccinationModel/src/agents.jl b/CovidAlertVaccinationModel/src/agents.jl index 995790eb957b80e6b6743add7844eccb5bd8e6db..7e0a1dfcf8af6a71cb8ba6e5ba181f9f65ca9640 100644 --- a/CovidAlertVaccinationModel/src/agents.jl +++ b/CovidAlertVaccinationModel/src/agents.jl @@ -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 diff --git a/CovidAlertVaccinationModel/src/data.jl b/CovidAlertVaccinationModel/src/data.jl index 65ff2d8935d722d8103b56be299f2eadfd04af9c..f4727795afb3b32eca8e0daff534d868c9806a4d 100644 --- a/CovidAlertVaccinationModel/src/data.jl +++ b/CovidAlertVaccinationModel/src/data.jl @@ -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 diff --git a/CovidAlertVaccinationModel/src/mixing_distributions.jl b/CovidAlertVaccinationModel/src/mixing_distributions.jl index e55c0c24ccb35fa7d0c8a2c1fe9c2e1586f7ee6c..3fc3aba12c91b37641f1c7a5842f7bd09f53d6f3 100644 --- a/CovidAlertVaccinationModel/src/mixing_distributions.jl +++ b/CovidAlertVaccinationModel/src/mixing_distributions.jl @@ -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)] diff --git a/CovidAlertVaccinationModel/test/runtests.jl b/CovidAlertVaccinationModel/test/runtests.jl index 56772e1bff2aabea6ad711506b1edc00923f4931..ae7b6c5a241d106449d14a3647edcd11d8be3e19 100644 --- a/CovidAlertVaccinationModel/test/runtests.jl +++ b/CovidAlertVaccinationModel/test/runtests.jl @@ -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 diff --git a/IntervalsModel/network-data/POLYMOD/Frequency-distribution.py b/IntervalsModel/network-data/POLYMOD/Frequency-distribution.py index b6bb77f8a7f4870266576851d0929f97cbfd7b47..47d428ef1fe20d881a3212347f56d060fb2c461e 100644 --- a/IntervalsModel/network-data/POLYMOD/Frequency-distribution.py +++ b/IntervalsModel/network-data/POLYMOD/Frequency-distribution.py @@ -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 diff --git a/IntervalsModel/plots/Distributions.Poisson_hh.pdf b/IntervalsModel/plots/Distributions.Poisson_hh.pdf index 897c478f8c5f5f0349825428abef1c263c6cac8e..03e971bb313fa2472f73fea32808f4c86ca68198 100644 Binary files a/IntervalsModel/plots/Distributions.Poisson_hh.pdf and b/IntervalsModel/plots/Distributions.Poisson_hh.pdf differ diff --git a/IntervalsModel/plots/Distributions.Poisson_rest.pdf b/IntervalsModel/plots/Distributions.Poisson_rest.pdf index 46c804b2d5d90dc70a1c2135799327a1f3287a2a..66245107491db9a0d542976fda1af39d5018dfbe 100644 Binary files a/IntervalsModel/plots/Distributions.Poisson_rest.pdf and b/IntervalsModel/plots/Distributions.Poisson_rest.pdf differ diff --git a/IntervalsModel/plots/Distributions.Poisson_ws.pdf b/IntervalsModel/plots/Distributions.Poisson_ws.pdf index e1a1170dcfe42af9865b1a34710806ff01188c4c..5e690f9cd51bbb51bb304a14619b90762947db29 100644 Binary files a/IntervalsModel/plots/Distributions.Poisson_ws.pdf and b/IntervalsModel/plots/Distributions.Poisson_ws.pdf differ diff --git a/IntervalsModel/plots/hh.pdf b/IntervalsModel/plots/hh.pdf index e8ed9b76925cead9d344c44d6779a707abfd613f..24d154c2619955174b8efcb60e5774acdd4317d3 100644 Binary files a/IntervalsModel/plots/hh.pdf and b/IntervalsModel/plots/hh.pdf differ diff --git a/IntervalsModel/plots/rest.pdf b/IntervalsModel/plots/rest.pdf index 2170af1f9f2aaedeb020941c59e91874e360379b..2a60cb926b7895e4a32ff90cdb5c5d53331a307f 100644 Binary files a/IntervalsModel/plots/rest.pdf and b/IntervalsModel/plots/rest.pdf differ diff --git a/IntervalsModel/plots/ws.pdf b/IntervalsModel/plots/ws.pdf index 460c62c7763212ce4899693c37c66aa5a239f955..94f333f091194461fda35fa6766bafb615549d69 100644 Binary files a/IntervalsModel/plots/ws.pdf and b/IntervalsModel/plots/ws.pdf differ diff --git a/IntervalsModel/simulation_data/hh.dat b/IntervalsModel/simulation_data/hh.dat index 9aee133c9e8f7c4d7dbbe9466d9b9a028bcfd743..7a80bdfcc2405180ab17d5424e641ba61fb55c87 100644 Binary files a/IntervalsModel/simulation_data/hh.dat and b/IntervalsModel/simulation_data/hh.dat differ diff --git a/IntervalsModel/simulation_data/rest.dat b/IntervalsModel/simulation_data/rest.dat index c46819b79ee195eaebeada1d17f6db6f44f3bd25..280e025f942c99a1816e8f80acdd9471c566b569 100644 Binary files a/IntervalsModel/simulation_data/rest.dat and b/IntervalsModel/simulation_data/rest.dat differ diff --git a/IntervalsModel/simulation_data/ws.dat b/IntervalsModel/simulation_data/ws.dat index 1209fd8bde9f5b5b1274668ed93096d6db3e5ff4..62d5d500ffd5c3e33796571e291dac897e6b5f42 100644 Binary files a/IntervalsModel/simulation_data/ws.dat and b/IntervalsModel/simulation_data/ws.dat differ