### initial implementation

parent 8d0333c7
 ... @@ -29,10 +29,10 @@ This function wires together a graph such that each household is in a complete s ... @@ -29,10 +29,10 @@ This function wires together a graph such that each household is in a complete s Also returns a vector of AgentDemographic representing each agent, defined by the household compositions. Also returns a vector of AgentDemographic representing each agent, defined by the household compositions. """ """ @views function complete_graph_from_households_composition(households_composition) @views function complete_graph_from_households_composition(households_composition, sampler_matrix) total_household_pop = sum(sum.(households_composition)) total_household_pop = sum(sum.(households_composition)) population_list = Vector{AgentDemographic}(undef,total_household_pop) population_list = Vector{AgentDemographic}(undef,total_household_pop) network = SimpleGraph(total_household_pop) wg = WeightedGraph(total_household_pop,sampler_matrix) vertex_pointer = 1 vertex_pointer = 1 for household in households_composition for household in households_composition num_vertices = sum(household) num_vertices = sum(household) ... @@ -43,12 +43,13 @@ Also returns a vector of AgentDemographic representing each agent, defined by th ... @@ -43,12 +43,13 @@ Also returns a vector of AgentDemographic representing each agent, defined by th end end for v in vertex_pointer:(vertex_pointer + num_vertices - 1), w in vertex_pointer:(vertex_pointer + num_vertices - 1) for v in vertex_pointer:(vertex_pointer + num_vertices - 1), w in vertex_pointer:(vertex_pointer + num_vertices - 1) if v != w if v != w add_edge!(network,v,w) weight::UInt8 = rand(Random.default_rng(Threads.threadid()),sampler_matrix[Int(population_list[v]),Int(population_list[w])]) add_edge!(wg,v,w,weight) end end end end vertex_pointer+=num_vertices vertex_pointer+=num_vertices end end return network,population_list return wg,population_list end end ... @@ -65,7 +66,7 @@ index_vectors: Vector of 3 vectors, each of which contains the indexes of all th ... @@ -65,7 +66,7 @@ index_vectors: Vector of 3 vectors, each of which contains the indexes of all th """ """ function generate_population(num_households) function generate_population(num_households) households_composition = sample_household_data(num_households) households_composition = sample_household_data(num_households) household_networks,population_list = complete_graph_from_households_composition(households_composition) household_networks,population_list = complete_graph_from_households_composition(households_composition, contact_time_distributions.hh) index_vectors = [findall(x -> x == AgentDemographic(i), population_list) for i in 1:(AgentDemographic.size-1)] index_vectors = [findall(x -> x == AgentDemographic(i), population_list) for i in 1:(AgentDemographic.size-1)] return (; return (; population_list, population_list, ... ...