Skip to content
Snippets Groups Projects
Commit 05166570 authored by Peter Jentsch's avatar Peter Jentsch
Browse files

initial opinion dynamics, just need to do app notifications now..

parent 1492c78d
No related branches found
No related tags found
No related merge requests found
......@@ -16,11 +16,32 @@ function contact_weight(p, contact_time)
return 1 - (1-p)^contact_time
end
function vac_switch_probability()
return 0.1
function EN_payoff()
return 0.0
end
function agents_step!(t,u_next,u,population_list,network_list,params,covid_alert_times,app_user_index)
function vac_switch_probability(u, population_list,vac, params,total_infected,soc_nbrs)
@unpack π_base, η, κ, ω, ρ, ω_en,ρ_en,γ,β = params
if vac
soc_nbrs_vac = [0,0,0]
for nbr in soc_nbrs
if u.is_vaccinator[nbr]
soc_nbrs_vac[Int(population_list[nbr])] += 1
end
end
return Φ(π_base + κ * (sum(soc_nbrs_vac)/length(soc_nbrs)) + dot(ρ,soc_nbrs_vac) + 0,β)
else
soc_nbrs_nonvac = 0
for nbr in soc_nbrs
if u.is_vaccinator[nbr]
soc_nbrs_nonvac += 1
end
end
return Φ(κ * soc_nbrs_nonvac/length(soc_nbrs),β)
end
end
function agents_step!(t,u_next,u,population_list,soc_network,network_list,params,covid_alert_times,app_user_index)
@unpack p, recovery_rate, immunization_loss_prob = params
u_next.status .= u.status
......@@ -36,7 +57,7 @@ function agents_step!(t,u_next,u,population_list,network_list,params,covid_alert
end
for i in 1:length(population_list)
if rand(RNG)<vac_switch_probability()
if rand(RNG)<vac_switch_probability(u, population_list,u.is_vaccinator[i],params,count(==(Infected),u),neighbors(soc_network.g,i))
u_next.is_vaccinator[i] = !u.is_vaccinator[i]
end
end
......@@ -120,7 +141,7 @@ function solve!(params,steps,agent_model; record = false)
sample_mixing_graph!(network,population_list, contact_time_distribution_matrix) #get new contact weights
end
#advance agent states based on the new network
agents_step!(t,solution[t+1],solution[t],population_list,network_list,params,covid_alert_times,app_user_index)
agents_step!(t,solution[t+1],solution[t],population_list,home_static_edges,network_list,params,covid_alert_times,app_user_index)
end
return solution, network_lists
end
......@@ -128,11 +149,22 @@ function get_parameters()
params = (
p = 0.05,
recovery_rate = 0.1,
vaccines_per_day = 0.0, #percentage of population vaccinated per day
vaccination_start_day = 60,
immunization_loss_prob = 0.01
immunization_loss_prob = 0.01,
π_base = 0.1,
η = 0.0,
κ = 0.0,
ω = 0.0,
ρ = [0.0,0.0,0.0],
ω_en = 0.0,
ρ_en = 0.0,
γ = 0.0,
β = 0.1
)
return params
end
function Φ(payoff,β)
return 1 / (exp(-1*β*payoff))
end
......@@ -101,7 +101,7 @@ function load_mixing_matrices()
end
function load_contact_time_distributions()
dat = deserialize(joinpath(PACKAGE_FOLDER,"data/intervals_model_particle/hh.dat"))
dat = deserialize(joinpath(PACKAGE_FOLDER,"intervals_model_output/simulation_output/hh.dat"))
return dat
end
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment