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

posteriors added, ZWDist pdf bugfix

parent cd6462b3
No related branches found
No related tags found
No related merge requests found
Showing
with 34 additions and 15 deletions
......@@ -12,7 +12,6 @@ import StatsBase:mean
using Dates
using ThreadsX
using DelimitedFiles
using NamedTupleTools
# using CUDA
using NetworkLayout:Stress
......@@ -30,7 +29,7 @@ include("graphs.jl")
const RNG = Xoroshiro128Star()
const population = 14.57e6 #population of ontario
const color_palette = palette(:seaborn_bright) #color theme for the plots
const color_palette = palette(:seaborn_pastel) #color theme for the plots
const age_bins = [(0.0, 25.0),(25.0,65.0),(65.0,Inf)]
const PACKAGE_FOLDER = dirname(dirname(pathof(CovidAlertVaccinationModel)))
const infection_data = parse_cases_data()
......@@ -43,18 +42,20 @@ using BenchmarkTools
function main()
# display(size.(agent_model.demographic_index_vectors))
agent_model = AgentModel(5000)
# Random.seed!(RNG,1)
VectorizedRNG.seed!(1)
agent_model = AgentModel(1000)
u_0 = get_u_0(length(agent_model.demographics))
steps = 300
Random.seed!(RNG,1)
@btime solve!($u_0,$get_parameters(),$steps,$agent_model,$vaccinate_uniformly!);
# agent_model = AgentModel(10_000)
@btime solve!($u_0,$get_parameters(),$steps,$agent_model,$vaccinate_uniformly!);
# @btime solve!($u_0,$get_parameters(),$steps,$agent_model,$vaccinate_uniformly!);
println("done")
# sol,graphs = solve!(u_0,get_parameters(),steps,agent_model,vaccinate_uniformly!);
# return aggregate_timeseries(sol)
# plot_model_spatial_gif(agent_model.base_network,graphs,sol1)
end
end
\ No newline at end of file
end
......@@ -39,8 +39,8 @@ end
function advance_mixing_graph!(t,mixing_graph,index_vectors)
mixing_graph.graph .= 0
mixing_graph.graph .= mixing_graph.base_graph
generate_mixing_graph!(mixing_graph.graph, index_vectors,mixing_graph.contact_vector_rest[t])
generate_mixing_graph!(mixing_graph.graph, index_vectors,mixing_graph.contact_vector_ws[t])
generate_mixing_graph!(mixing_graph.graph, index_vectors,mixing_graph.contact_vector_rest[t],contact_time_distribution_matrix)
generate_mixing_graph!(mixing_graph.graph, index_vectors,mixing_graph.contact_vector_ws[t],contact_time_distribution_matrix)
return nothing
end
......@@ -85,7 +85,7 @@ function generate_contact_vectors!(ij_dist,ji_dist,i_to_j_contacts, j_to_i_conta
return nothing
end
#add a bipartite graph derived from mixing matrices onto g
function generate_mixing_graph!(g,index_vectors,contacts)
function generate_mixing_graph!(g,index_vectors,contacts,edge_weight_dists)
for i in 1:length(index_vectors), j in 1:length(index_vectors)
random_bipartite_graph_fast_CL!(g,index_vectors[i],index_vectors[j],contacts.contact_array[i,j],contacts.contact_array[j,i])
end
......@@ -117,8 +117,8 @@ function random_bipartite_graph_fast_CL!(g::T,anodes,bnodes,aseq,bseq) where T<:
@assert sum(aseq) == sum(bseq) "degree sequences must have equal sum"
astubs = sample(RNG,anodes,StatsBase.weights(aseq./m), m)
bstubs = sample(RNG,bnodes,StatsBase.weights(bseq./m), m)
for k in 1:m
g[astubs[k],bstubs[k]] = 1
for i in 1:m
g[astubs[i],bstubs[i]] = 1
end
return g
end
......
......@@ -25,13 +25,13 @@ function agents_step!(t,u_next,u,population_list,graph,params,index_vectors,vacc
if t >= vaccination_start_day
vaccination_algorithm!(Int(floor(vaccines_per_day*length(u))),u_next,u,graph,population_list,index_vectors)
end
for i in 1:length(u)
@inbounds for i in 1:length(u)
agent_status = u[i]
agent_demo = population_list[i]
if agent_status == Susceptible
for j in 1:length(u) #LightGraphs.neighbors(graph,i)
if graph[i,j] == 1 && u[j] == Infected && rand(RNG) < contact_weight(p, agent_demo,population_list[j])
u_next[i] = Infected
@inbounds for j in 1:length(u) #LightGraphs.neighbors(graph,i)
if graph[i,j] == 1 && u[j] == Infected && rand(RNG) < contact_weight(p, agent_demo,population_list[j]) #only need contact weights for infected subnetwork
(u_next[i] = Infected)
end
end
elseif agent_status == Infected
......
......@@ -115,6 +115,11 @@ git-tree-sha1 = "ac5f2213e56ed8a34a3dd2f681f4df1166b34929"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.12.6"
[[Combinatorics]]
git-tree-sha1 = "08c8b6831dc00bfea825826be0bc8336fc369860"
uuid = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
version = "1.0.2"
[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "919c7f3151e79ff196add81d7f4e45d91bbf420b"
......@@ -359,6 +364,12 @@ git-tree-sha1 = "1179250d910c99810d8a7ff55c50c4ed68c77a58"
uuid = "e33a78d0-f292-5ffc-b300-72abe9b543c8"
version = "2.4.0+0"
[[HypothesisTests]]
deps = ["Combinatorics", "Distributions", "LinearAlgebra", "Random", "Rmath", "Roots", "Statistics", "StatsBase"]
git-tree-sha1 = "552892528991c3e17eb60e623f1ac94c0663eb7d"
uuid = "09f84164-cd44-5f33-b23f-e6b0d136a0d5"
version = "0.10.2"
[[IfElse]]
git-tree-sha1 = "28e837ff3e7a6c3cdb252ce49fb412c8eb3caeef"
uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
......@@ -833,6 +844,12 @@ git-tree-sha1 = "d76185aa1f421306dec73c057aa384bad74188f0"
uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
version = "0.2.2+1"
[[Roots]]
deps = ["Printf"]
git-tree-sha1 = "369e25546984dff5df351bc056fccc30de615080"
uuid = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
version = "1.0.8"
[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
......
......@@ -10,6 +10,7 @@ CovidAlertVaccinationModel = "9260c4ec-b5cf-4bc2-ad29-e1d23bf2bd6f"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
HypothesisTests = "09f84164-cd44-5f33-b23f-e6b0d136a0d5"
Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5"
JLSO = "9da8a3cd-07a3-59c0-a743-3fdc52c30d11"
KissABC = "9c9dad79-530a-4643-a18b-2704674d4108"
......
File added
File added
File added
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
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