Commit 96294c22 by Peter Jentsch

### optimization in solve

parent 99904e52
 """ A type that stores a pair of nodes representing an edge in the graph. A type that stores a destination node and a weight representing an directed edge in the graph. We need to define a custom type for these so we can define a hash function on graph edges, in order to more efficiently use them in hashmaps (dictionaries) We need to define a custom type for these so we can define custom equality on edges. """ struct HalfWeightedEdge a::Int ... ... @@ -10,7 +10,7 @@ end """ Define symmetric edge equality, matches the hash function. Define edge equality to exclude the weight. """ function Base.:(==)(e1::HalfWeightedEdge,e2::HalfWeightedEdge) return isequal(e1.a,e2.a) ... ...
 ... ... @@ -44,6 +44,8 @@ end Base.@propagate_inbounds @views function update_infection_state!(t,modelsol; record_degrees = false) @unpack β_y,β_m,β_o,α_y,α_m,α_o,recovery_rate,immunizing,immunization_begin_day = modelsol.params @unpack u_inf,u_vac,u_next_inf,demographics,inf_network,status_totals, immunization_countdown, output_data = modelsol β_vec = @SVector [β_y,β_m,β_o] α_vec = @SVector [α_y,α_m,α_o] function agent_transition!(node, from::AgentStatus,to::AgentStatus) immunization_countdown[node] = -1 ... ... @@ -64,8 +66,6 @@ Base.@propagate_inbounds @views function update_infection_state!(t,modelsol; rec for he in neighbors_and_weights(mixing_graph,i) j = he.a if u_inf[j] == Infected && u_next_inf[i] != Infected β_vec = (β_y,β_m,β_o) α_vec = (α_y,α_m,α_o) if rand(Random.default_rng(Threads.threadid())) < contact_weight(β_vec[Int(agent_demo)],he.weight[]) if agent_status == Immunized && rand(Random.default_rng(Threads.threadid())) < 1- α_vec[Int(agent_demo)] agent_transition!(i, Immunized,Infected) ... ... @@ -106,10 +106,12 @@ Base.@propagate_inbounds @views function update_vaccination_opinion_state!(t,mod @unpack infection_introduction_day, π_base_y,π_base_m,π_base_o, η,Γ,ζ, ω, ω_en,ξ = modelsol.params @unpack demographics,time_of_last_alert, nodes, soc_network,u_vac,u_next_vac,app_user,app_user_list,output_data = modelsol if t
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!