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

add univariate snensitivity plots, some output code, added the model size and...

add univariate snensitivity plots, some output code, added the model size and length to parameter tuple. New output is in /CovidAlertVaccinationModel/plots/univariate
parent 189c2fa4
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,8 @@ using CSV
import Pandas: read_csv
using DataFrames
using StaticArrays
import LightGraphs.neighbors
export intervalsmodel, hh, ws, rest, abm
const DNDEBUG = false
......@@ -37,7 +39,7 @@ end
const durmax = 144
const PACKAGE_FOLDER = dirname(dirname(pathof(CovidAlertVaccinationModel)))
const RNG = Xoroshiro128Star(1)
const RNG = Xoroshiro128Star()
const color_palette = palette(:seaborn_pastel) #color theme for the plots
#consts that let give us nicer names for the indices
......@@ -48,7 +50,6 @@ include("ABM/contact_vectors.jl")
include("ABM/mixing_distributions.jl")
include("ABM/mixing_graphs.jl")
include("ABM/agents.jl")
include("ABM/plotting.jl")
include("ABM/model_setup.jl")
include("ABM/output.jl")
include("ABM/solve.jl")
......
using CovidAlertVaccinationModel
using CovidAlertVaccinationModel:ModelSolution,AgentDemographic,mean,AgentStatus,get_u_0,get_parameters,solve!, DebugRecorder
using Random
const model_sizes = [100,1000,5000]
const dem_cat = AgentDemographic.size -1
const steps = 300
const reps = 5
#network generation
#covidalert
@testset "mixing matrices, size: $sz" for sz in model_sizes
for rep = 1:reps
m = ModelSolution(10,get_parameters(),sz)
ws_dist = m.ws_matrix_tuple
r_dist = m.rest_matrix_tuple
index_vec =m.index_vectors
@testset "workschool" for i in dem_cat, j in dem_cat
for t in 1:length(ws_dist)
@test mean(ws_dist[t][i,j])*length(index_vec[i]) == mean(ws_dist[t][j,i])*length(index_vec[j])
end
end
@testset "rest" for i in dem_cat, j in dem_cat
for t in 1:length(ws_dist)
@test mean(r_dist[t][i,j])*length(index_vec[i]) == mean(r_dist[t][j,i])*length(index_vec[j])
end
end
end
end
@testset "status counter, size: $sz" for sz in model_sizes
for rep = 1:reps
Random.seed!(CovidAlertVaccinationModel.RNG,1)
m = ModelSolution(steps,get_parameters(),sz)
recording = DebugRecorder(steps)
output = solve!(m,recording )
@show recording.Total_I
@show recording.recorded_status_totals[2,:]
@test all(recording.Total_S .== recording.recorded_status_totals[1,:])
@test all(recording.Total_I .== recording.recorded_status_totals[2,:])
@test all(recording.Total_R .== recording.recorded_status_totals[3,:])
@test all(recording.Total_V .== recording.recorded_status_totals[4,:])
end
end
# function vaccinator_opinion_test(model,vac_strategy, π_base; rng = Xoroshiro128Plus())
# params = merge(get_parameters(),(I_0_fraction = 0.0,π_base))
# steps = 300
# sol1,_ = solve!(u_0,params,steps,model,vac_strategy);
# total_infections = count(x->x == AgentStatus(3),sol1[end])
# display(total_infections)
# return total_infections
# end
# function infection_rate_test(model, inf_parameter; rng = Xoroshiro128Plus())
# steps = 300
# # display(params)
# sol1,_ = solve!(params,steps,model,vaccinate_uniformly!);
# total_infections = count(x->x == AgentStatus(3),sol1[end])
# # display(total_infections)
# return total_infections
# end
# function test_comparison(f,xpts,comparison)
# xpts_sorted = sort(xpts)
# ypts = ThreadsX.map(f,xpts)
# return all(comparison(ypts[i],ypts[i+1]) for i in 1:length(ypts)-1)
# end
# @testset "vaccination efficacy $sz" for (m,sz) in zip(deepcopy(agent_models),model_sizes)
# @show vac_rate_test(m,vaccination_strategies[1],vaccination_rates[1])
# @testset "strategy" for strat in vaccination_strategies
# @test test_comparison(x->vac_rate_test(m,strat,x),vaccination_rates,>)
# end
# end
# @testset "infection efficacy $sz" for (m,sz) in zip(deepcopy(agent_models),model_sizes)
# @test test_comparison(x->infection_rate_test(m,x),infection_rates,<)
# end
# @testset "infection efficacy $sz" for (m,sz) in zip(deepcopy(agent_models),model_sizes)
# @test test_comparison(x->infection_rate_test(m,x),infection_rates,<)
# end
using CovidAlertVaccinationModel
using CovidAlertVaccinationModel:ModelSolution,AgentDemographic,mean,AgentStatus,get_u_0,get_parameters,solve!, DebugRecorder
using Random
using Plots
using ThreadsX
using OnlineStats
const model_sizes = [1000,5000]
const dem_cat = AgentDemographic.size -1
const samples = 10
#WRITE MORE TESTS
@testset "mixing matrices, size: $sz" for sz in model_sizes
for rep = 1:samples
m = ModelSolution(100,get_parameters(),sz)
ws_dist = m.ws_matrix_tuple
r_dist = m.rest_matrix_tuple
index_vec =m.index_vectors
@testset "workschool" for i in dem_cat, j in dem_cat
for t in 1:length(ws_dist)
@test mean(ws_dist[t][i,j])*length(index_vec[i]) == mean(ws_dist[t][j,i])*length(index_vec[j])
end
end
@testset "rest" for i in dem_cat, j in dem_cat
for t in 1:length(ws_dist)
@test mean(r_dist[t][i,j])*length(index_vec[i]) == mean(r_dist[t][j,i])*length(index_vec[j])
end
end
end
end
......@@ -4,5 +4,5 @@ using Test
using ThreadsX
import StatsBase.mean
include("ABM/abm_test.jl")
include("ABM/mixing_test.jl")
include("IntervalsModel/intervals_model_test.jl")
\ No newline at end of file
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