Skip to content
Snippets Groups Projects
prem_mixing_approx.jl 2.79 KiB
using CovidAlertVaccinationModel:abm,ModelSolution, get_parameters, neighbors, GraphEdge, get_weight, contact_time_distributions
using LightGraphs
function approximate_mixing_matricies_1(sol)
    mean_mixing_degree = zeros(3,3)
    mean_mixing_weighted_degree = zeros(3,3)
    display(p.O_distribution_shift)
    te_missed = zeros(8)
    te = zeros(8)
        edgelist = []
        for g_list in sol.inf_network.graph_list
            for (k,g) in enumerate(g_list)
                # display(g.mixing_edges.weights_dict)
                for e in keys(g.mixing_edges.weights_dict)
                    demo_i = sol.demographics[e.a]
                    demo_j = sol.demographics[e.b]
                    if(has_edge(g.g,e.a,e.b))
                        mean_mixing_degree[Int(demo_i), Int(demo_j)] += 1
                        mean_mixing_degree[Int(demo_j), Int(demo_i)] += 1
                        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))
                        te[k] += 1
                    else 
                        push!(edgelist,e)
                        te_missed[k] += 1
                    end
                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)
    display(te_missed)
    return sol
end
function approximate_mixing_matricies_2(sol)
mean_mixing_degree = zeros(3,3)
mean_mixing_weighted_degree = zeros(3,3)
te_missed = zeros(8)
    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)
    return sol
end


p = get_parameters()
sol = abm(p,nothing)
approximate_mixing_matricies_1(sol);
approximate_mixing_matricies_2(sol);
println("dasdlkjasdas")



#rerun with weights
#