output_test.jl 1.76 KB
Newer Older
Peter Jentsch's avatar
Peter Jentsch committed
1
2
3
using CovidAlertVaccinationModel:vaccination_data,ymo_vac,ymo_attack_rate
using OnlineStats
using Plots
Peter Jentsch's avatar
Peter Jentsch committed
4
const samples = 50
Peter Jentsch's avatar
Peter Jentsch committed
5
6
7
8
using Random

@testset "default parameters output" begin
    p =  CovidAlertVaccinationModel.get_parameters()
9
    out,avg_populations = mean_solve(samples, p)
Peter Jentsch's avatar
Peter Jentsch committed
10
    # plot_model(nothing,[nothing],[out],p.infection_introduction_day,p.immunization_begin_day)
Peter Jentsch's avatar
Peter Jentsch committed
11

Peter Jentsch's avatar
Peter Jentsch committed
12
    # ymo_vaccination_ts = mean.(out.daily_immunized_by_age)
Peter Jentsch's avatar
Peter Jentsch committed
13

Peter Jentsch's avatar
Peter Jentsch committed
14
15
16
    total_postinf_vaccination = mean.(out.total_postinf_vaccination)#sum.(eachrow(ymo_vaccination_ts[:,180:end]))
    final_size = mean.(out.unvac_final_size_by_age)#sum.(eachrow(mean.(out.daily_unvac_cases_by_age)))
    total_preinf_vaccination = mean.(out.total_preinf_vaccination)#sum.(eachrow(ymo_vaccination_ts[:,1:180]))
Peter Jentsch's avatar
Peter Jentsch committed
17
18
19
20
21
22
23
24
    target_final_size = ymo_attack_rate .*avg_populations
    target_preinf_vac = ymo_vac .* sum(vaccination_data[1:4]) .* avg_populations
    target_postinf_vac = ymo_vac .* sum(vaccination_data[5:end]) .*avg_populations

  
    println("obs final size: $final_size, target: $target_final_size")
    println("obs preinf vac: $total_preinf_vaccination, target: $target_preinf_vac")
    println("obs postinf vac: $total_postinf_vaccination,target: $target_postinf_vac")
Peter Jentsch's avatar
Peter Jentsch committed
25

26
    @test all(abs.(final_size .- target_final_size) .< [75,100,25])
Peter Jentsch's avatar
Peter Jentsch committed
27
    @test all(abs.(total_preinf_vaccination .- target_preinf_vac) .< [50,100,25])
Peter Jentsch's avatar
Peter Jentsch committed
28
    @test all(abs.(total_postinf_vaccination .- target_postinf_vac) .< [135,120,40])
Peter Jentsch's avatar
Peter Jentsch committed
29
30
31
32
end

@testset "perf" begin
    b = @belapsed CovidAlertVaccinationModel.bench()
Peter Jentsch's avatar
Peter Jentsch committed
33
    @test  4.0 < b < 4.9
34
    if Threads.nthreads() == 25
Peter Jentsch's avatar
Peter Jentsch committed
35
        b = @belapsed CovidAlertVaccinationModel.threaded_bench()
36
        @test  12.0 < b < 16.00
Peter Jentsch's avatar
Peter Jentsch committed
37
38
39
40
    else
        display("incorrect number of threads, skipping threaded perf test")
    end
end