Commit 9cab9919 authored by Jorge Visca's avatar Jorge Visca

tracers by dept support

parent 07bb4c26
......@@ -9,15 +9,37 @@ local lib
M.cases = nil --queue
local function tracer_process ( tracer_id )
local function tracer_process ( tracer_id, dept )
local t = lib.esim.now
while true do
-- wait for a case
while M.cases:len() == 0 do
t = lib.esim.sleep_to(t+CHECKTIME)
end
local case
repeat
if dept then
-- only in a dept
if M.cases_dept[dept]:len() > 0 then
case = M.cases_dept[dept]:popleft()
end
else
--search worse dept
local wdept, wdeptcount = nil, 0
for idept = 1, #M.cases_dept do
if M.cases_dept[idept]:len() > wdeptcount then
wdept, wdeptcount = idept, M.cases_dept[idept]:len()
end
end
if wdept then
case = M.cases_dept[wdept]:popleft()
end
end
-- if none found, sleep
if not case then
t = lib.esim.sleep_to(t+CHECKTIME)
end
until case
local case = M.cases:popleft()
--local case = cases:popleft()
conf.w_log(t, ' trace_start tid: ', tracer_id, ' id: ', case.id )
local t_end = t + conf.ct_trace_t
local i = 1
......@@ -37,8 +59,8 @@ end
M.create_tracer = function ( id )
lib.esim.launch(tracer_process, id)
M.create_tracer = function ( id, dept )
lib.esim.launch(tracer_process, id, dept)
end
......@@ -50,9 +72,25 @@ M.initialize = function ( c )
lib.esim.launch(function ()
lib.esim.sleep_to(start_t)
M.cases = queue:new()
for i = 1, c.ct_count or 0 do
M.create_tracer(i)
--M.cases = queue:new()
M.cases_dept = {}
for dept = 1, 19 do M.cases_dept[dept] = queue:new() end
if type(c.ct_count) == 'number' then
for i = 1, c.ct_count do
M.create_tracer(i)
end
elseif type(c.ct_count) == 'table' then
local itracer = 1
for dept = 1, #c.ct_count do
for i = 1, c.ct_count[dept] do
M.create_tracer(itracer, dept)
itracer=itracer+1
end
end
elseif type(c.ct_count) == 'nil' then
else
error('unsuported type for ct_count: ' .. tostring(c.ct_count))
end
end)
end
......
......@@ -9,6 +9,8 @@ local conf
local lib
local ds_model
local G = require('data')
local ahsm = require 'lib.ahsm'
ahsm.get_time = function() return lib.esim.now end
......@@ -119,8 +121,9 @@ local selfQuarantineProcess = function ( person )
d.quarantined = true
conf.w_log(t, ' selfquarantined id:', person.id)
end
if lib.contacttracer.cases then
lib.contacttracer.cases:pushright(person)
if lib.contacttracer.cases_dept then
local dpto = G.N[person.row.codloc].dpto
lib.contacttracer.cases_dept[dpto]:pushright(person)
end
lib.contactapp.new_case(person)
lib.contactfam.notify(person)
......
......@@ -5,7 +5,7 @@
TMAX = math.huge
-- Number of runs to perform
NRUNS = 5000
NRUNS = 100
-- Path for writing logs. If set to nil, no logging will be performed.
out_path = 'out/'
......@@ -16,9 +16,9 @@ out_path = 'out/'
startExposed = {
--{zone=19220, t=0, count=1},
--{zone=3421, t=0, count=10}, --progreso
{zone=1020, barrio=6, t=0, count=10}, --pque rodo
--{zone=1020, barrio=6, t=0, count=25}, --pque rodo
--{id=2978025},
--{zone=16220, t=0, count=10}, --san josé
{zone=16220, t=0, count=25}, --san josé
--{t=0, count=10, where='pered02_codloc=1020 and pered02_barrcod=6 and (pered03_r=11 or pered03_r=12)'} --est. universitario, estudia en pque rodo
}
......@@ -29,13 +29,13 @@ startExposed = {
-- Describe a condition to stop simulation when an infected appears in
-- a location. When hit, the simulation ends with the outcome 'hit_stop'.
-- Set to nil to disable.
stop_dpto = nil --'MONTEVIDEO',
stop_dpto = nil --'MONTEVIDEO'
stop_localidad = nil -- any
-- Outbreak conditions
-- Set the maximum number of active cases to handle. If exceeded simulation
-- stops with outcome 'outbreak'. Set to math.huge to disable
outbreak_threshold = 200
outbreak_threshold = 100
-- Basic execution parameters ----------------------------------
......@@ -89,7 +89,31 @@ mobility = {
-- contact tracers behavior
ct_count = 0 -- number if contact tracers working
ct_count = 0 --50 -- number if contact tracers working
--[[
ct_count = {
[1] = 50, --montevideo
[2] = 0, --artigas
[3] = 0, --canelones
[4] = 0, --cerro largo
[5] = 0, --colonia
[6] = 0, --durazno
[7] = 0, --flores
[8] = 0, --florida
[9] = 0, --lavalleja
[10] = 0, --maldonado
[11] = 0, --paysandu
[12] = 0, --rio negro
[13] = 0, --rivera
[14] = 0, --rocha
[15] = 0, --salto
[16] = 0, --san jose
[17] = 0, --soriano
[18] = 0, --tacuarembo
[19] = 0, --treinta y tres
}
--]]
ct_hit_t = 1 -- time to hitting an exposed
ct_trace_t = 5 -- time attending a single case
ct_coop = 1 -- cooperation rate
......
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