prem_mixing_approx.jl 2.83 KB
Newer Older
1
using CovidAlertVaccinationModel:abm,ModelSolution, get_parameters, neighbors, GraphEdge, get_weight
2
3
4
5
using LightGraphs
function approximate_mixing_matricies_1(sol)
    mean_mixing_degree = zeros(3,3)
    mean_mixing_weighted_degree = zeros(3,3)
6
    display(p.O_distribution_shift)
7
    te = 0
8
9
10
        for g_list in sol.inf_network.graph_list
            for g in g_list
                # display(g.mixing_edges.weights_dict)
Peter Jentsch's avatar
Peter Jentsch committed
11
12
13
                for e in keys(g.mixing_edges.weights_dict)
                    demo_i = sol.demographics[e.a]
                    demo_j = sol.demographics[e.b]
14
15
16
17
18
19
20
21
22
23
24
                    if(has_edge(g.g,e.a,e.b))
                        mean_mixing_degree[Int(demo_i), Int(demo_j)] += 1#get_weight(g,GraphEdge(node_i,node_j)) /2
                        mean_mixing_degree[Int(demo_j), Int(demo_i)] += 1#get_weight(g,GraphEdge(node_i,node_j)) /2
                        mean_mixing_weighted_degree[Int(demo_i), Int(demo_j)] += get_weight(g,GraphEdge(e.a,e.b))
                        mean_mixing_weighted_degree[Int(demo_j), Int(demo_i)] += get_weight(g,GraphEdge(e.a,e.b))
                        
                    else
                        if(demo_i == demo_j)
                            te += 1
                        end
                    end
25
26
27
                end 
             end
    end
28
29
30
31
32
    mean_mixing_degree ./= (500 .* length.(sol.index_vectors) * 2)
    mean_mixing_weighted_degree ./= (500 .* length.(sol.index_vectors) * 2)
    display(mean_mixing_degree)
    display(mean_mixing_weighted_degree)
    display(te)
33
34
    return sol
end
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function approximate_mixing_matricies_2(sol)
mean_mixing_degree = zeros(3,3)
mean_mixing_weighted_degree = zeros(3,3)
    display(p.O_distribution_shift)
        for g_list in sol.inf_network.graph_list
            for g in g_list
                # display(g.mixing_edges.weights_dict)
                for e in edges(g.g)  
                    demo_i = sol.demographics[src(e)]
                    demo_j = sol.demographics[dst(e)]
                    mean_mixing_degree[Int(demo_i), Int(demo_j)] += 1#get_weight(g,GraphEdge(node_i,node_j)) /2
                    mean_mixing_degree[Int(demo_j), Int(demo_i)] += 1#get_weight(g,GraphEdge(node_i,node_j)) /2
                    mean_mixing_weighted_degree[Int(demo_i), Int(demo_j)] += get_weight(g,GraphEdge(src(e),dst(e)))
                    mean_mixing_weighted_degree[Int(demo_j), Int(demo_i)] += get_weight(g,GraphEdge(src(e),dst(e)))
                end 
             end
    end
    mean_mixing_degree ./= (500 .* length.(sol.index_vectors) * 2)
    mean_mixing_weighted_degree ./= (500 .* length.(sol.index_vectors) * 2)
    display(mean_mixing_degree)
    display(mean_mixing_weighted_degree)
    return sol
end


p = get_parameters()
sol = abm(p,nothing)
approximate_mixing_matricies_1(sol);
approximate_mixing_matricies_2(sol);
64
println("dasdlkjasdas")
65
66
#rerun with weights
#