Commit 9710f3da authored by Jorge Visca's avatar Jorge Visca

recursive notification implemented

parent 8dc59017
......@@ -30,7 +30,8 @@ M.create_exposed = function ( zone, exposed_from )
}
M.people[new_exposed.id] = new_exposed
if type(exposed_from)=='table' then
exposed_from.exposed_to[#exposed_from.exposed_to+1] = new_exposed
local exposed_to = exposed_from.exposed_to
exposed_to[#exposed_to+1] = new_exposed
end
-- disease process
......
......@@ -26,6 +26,27 @@ M.models.forward1 = function ( case )
end
end
M.models.recursive = function ( case )
local t = lib.esim.now
if math.random()<conf.ca_p then
local cases = { [case]=true }
while true do
local c = next(cases)
if c==nil then break end
cases[c] = nil
for i=1, #c.exposed_to do
local contact = c.exposed_to[i]
cases[contact] = true
if (not contact.disease.quarantined) and (math.random()<conf.ca_p) then
w_log(t, ' app case: ', c.id, ' contact: ', contact.id )
contact.disease.quarantined = true
end
end
end
end
end
M.initialize = function ( c )
conf = assert(c)
......@@ -35,7 +56,7 @@ M.initialize = function ( c )
M.new_case=function() end
return
end
M.new_case = assert(M.models[conf.ca_model],
'unknown ca model: '..tostring(conf.ca_model))
......
......@@ -15,7 +15,8 @@ local function w_log (t, ...)
--conf.f_log:flush()
end
local function tracer_process ( t, tracer_id )
local function tracer_process ( tracer_id )
local t = lib.esim.now
while true do
-- wait for a case
while M.cases:len() == 0 do
......@@ -42,8 +43,8 @@ end
M.create_tracer = function ( t, id )
lib.esim.launch(tracer_process, t, id)
M.create_tracer = function ( id )
lib.esim.launch(tracer_process, id)
end
......@@ -55,7 +56,7 @@ M.initialize = function ( c )
M.cases = queue:new()
for i = 1, c.ct_count or 0 do
M.create_tracer(0, i)
M.create_tracer(i)
end
end
......
No preview for this file type
......@@ -34,4 +34,4 @@ disease = {
ct_count = 0,
ca_p = 0, -- this will be changed by script
ca_model = 'forward1',
\ No newline at end of file
ca_model = 'forward1',
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