Commit f2303cde authored by Jorge Visca's avatar Jorge Visca

parametrize workhours and add inf. distribution

parent 2fe46d41
......@@ -9,6 +9,8 @@ local conf
local lib
local ds_model
local workhours
local function w_states ( t )
--w_states('t', 'L', 'P', 'I', 'R', 'quarantined')
conf.w_states(t, ' ', M.state_count.L, ' ', M.state_count.P, ' ',
......@@ -49,7 +51,8 @@ local states_mt = {
}
local function compute_beta_SLIR (d)
local function compute_beta_SLIR (p)
local d = p.disease
local beta
if d.state == 'I' then
if d.symptomatic then
......@@ -60,6 +63,16 @@ local function compute_beta_SLIR (d)
elseif d.state == 'P' then
beta = ds_model.k * ds_model.R0 / ds_model._mu
end
if not beta then return end -- not infective
local beta_h = beta * 24 / ( 24+workhours*(conf.mobility.ws-1) )
if p.in_zone == p.home_zone then
beta = beta_h
elseif p.in_zone == p.work_zone then
beta = conf.mobility.ws * beta_h
end
return beta
end
......@@ -70,7 +83,7 @@ M.infector = function (person, to_t)
local infgen = d.infgen + 1
d.infgen = infgen
local beta = compute_beta_SLIR(d)
local beta = compute_beta_SLIR(person)
if not beta then
return lib.esim.sleep_to(to_t)
end
......@@ -85,7 +98,7 @@ M.infector = function (person, to_t)
and not d.quarantined then
lib.agents.create_exposed(zone, person)
end
local beta = compute_beta_SLIR(d)
local beta = compute_beta_SLIR(person)
if not beta then
return lib.esim.sleep_to(to_t)
end
......@@ -161,6 +174,10 @@ M.initialize = function ( c )
conf = assert(c)
ds_model = c.disease
lib = conf.lib
workhours = conf.mobility.random_bus_day.end_hour -
conf.mobility.random_bus_day.start_hour
conf.mobility.ws = conf.mobility.ws or 1
M.state_count = {L=0, P=0, I=0, R=0, quarantined=0}
w_states('t', 'L', 'P', 'I', 'R', 'quarantined')
......
......@@ -78,44 +78,45 @@ end
M.process.random_bus_day = function ( person )
local f = function ()
local t = lib.esim.now
local home, work
local next_go = next_hour_of_day(t, 7)
local next_ret = next_hour_of_day(t, 17)
local next_go = next_hour_of_day(t, conf.mobility.random_bus_day.start_hour)
local next_ret = next_hour_of_day(t, conf.mobility.random_bus_day.end_hour)
local trip = 0.2 + 0.8 * math.random()
if next_ret<next_go then -- started at work
work = person.in_zone
person.work_zone = person.in_zone
lib.disease.infector(person, next_ret)
if person.disease.state=='R' then return end
t = esim.sleep_to(next_ret)
home = pick_random_source( person, t ) -- ponderated source of workers for work
-- ponderated source of workers for work
person.home_zone = pick_random_source( person, t )
person.in_zone = nil
t = esim.sleep_to(t+trip)
person.in_zone = home
person.in_zone = person.home_zone
else
home = person.in_zone
person.home_zone = person.in_zone
end
while true do
local next_go = next_hour_of_day(t, 7)
local next_go = next_hour_of_day(t, conf.mobility.random_bus_day.start_hour)
t = lib.disease.infector(person, next_go)
if person.disease.state=='R' then return end
work = work or pick_random_destination( person, t )
person.work_zone = person.work_zone or pick_random_destination( person, t )
--person.in_zone = nil
--t = esim.sleep_to(t+trip)
person.in_zone = work
person.in_zone = person.work_zone
local next_ret = next_hour_of_day(t, 17)
local next_ret = next_hour_of_day(t, conf.mobility.random_bus_day.end_hour)
t = lib.disease.infector(person, next_ret)
if person.state=='R' then return end
home = home or pick_random_source( person, t ) -- ponderated source of workers for work
-- ponderated source of workers for work
person.home_zone = person.home_zone or pick_random_source( person, t )
--person.in_zone = nil
--t = esim.sleep_to(t+trip)
person.in_zone = home
person.in_zone = person.home_zone
end
end
return f
......@@ -133,8 +134,8 @@ M.pick_mobility_model = function ( t, zone, exposed_from )
local trabajan_aca = zone.trabajacasa + zone.trabajaloc
local trabajan_remoto
local next_go = next_hour_of_day(t, 7)
local next_ret = next_hour_of_day(t, 17)
local next_go = next_hour_of_day(t, conf.mobility.random_bus_day.start_hour)
local next_ret = next_hour_of_day(t, conf.mobility.random_bus_day.end_hour)
if next_ret<next_go then -- work hour
trabajan_remoto = zone.trabajar_viene
else
......
......@@ -50,6 +50,16 @@ disease = {
q_coop = 1, -- probability of entering self quarantine
},
-- mobility related parameters
mobility = {
random_bus_day = {
start_hour = 7, -- working hours
end_hour = 17,
},
ws = 1.0, -- infective power at work / infective power at home
},
-- contact tracers behavior
ct_count = 0, -- number if contact tracers working
ct_hit_t = 1, -- time to hitting an exposed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment