Commit 90988db8 authored by Jorge Visca's avatar Jorge Visca

docs

parent c2b5a844
......@@ -12,12 +12,38 @@ Lua5.3 is also supported. For plotting install `gnuplot` and R (`r-base`)
## Run
Edit `run.lua` and modify the `conf` configuration table.
Create or edit a configuration file, such as `sample.conf`. Then run providing as:
```
$ luajit run.lua
$ luajit run.lua sample.conf
```
After finishing the program will print a brief summary of the simulation, such as:
```
Re avg,std: 0.82514789895481 0.090774578040495
runs runout 0
runs outbreak 0.2
runs extinction 0.8
```
`Re` is the effective Reproductive value of the simulation, and the `runs` indicate the proportion of the possible outcomes of the simulation (see configuration for meaning).
## Configuration
See `samples.conf` for documentation on possible parameters. For disease parameters, see `docs/disease.odt`.
## Logs
If the `out_path` parameter is set, logs will be written to indicated path.
## Parametrized simulations
Run `$ luajit run_ct.lua sample_ct.conf` for an example of a script running simulations over a set of parameters.
## License
......
......@@ -13,20 +13,16 @@ set key autotitle columnhead
set term post size 5in, 2in eps enhanced color
#set term png size 700,400
set out "contacttracing.eps"
filename = 'out/contacttracing.log'
stats filename nooutput
#plot "out/states1.log" using 1:2 w steps, \
# "out/states1.log" using 1:3 w steps, \
# "out/states1.log" using 1:4 w steps, \
set out "contacttracing.eps"
plot for [i=5:STATS_columns] filename using 1:i w l
set out "contacttracingR0.eps"
set out "contacttracingRe.eps"
set ylabel 'R_e'
unset yrange
set yrange [0:]
......
......@@ -78,9 +78,9 @@ end
local selfQuarantineProcess = function ( person )
local t = lib.esim.now
if not model.T_q then return end
if not model._q then return end
local d = person.disease
local tq = t+model.T_q
local tq = t+model._q
lib.esim.sleep_to(tq)
if not d.quarantined then
d.quarantined = true
......
......@@ -103,9 +103,9 @@ end
local selfQuarantineProcess = function ( person )
local t = lib.esim.now
if not model.T_q then return end
if not model._q then return end
local d = person.disease
local tq = t+model.T_q
local tq = t+model._q
lib.esim.sleep_to(tq)
if not d.quarantined then
d.quarantined = true
......
,xopxe,timur,23.06.2020 16:41,file:///home/xopxe/.config/libreoffice/4;
\ No newline at end of file
File added
......@@ -288,7 +288,7 @@ end
parse_files()
print('R_e avg std:', mathutil.avgstd(ReffA))
--print('R_e avg std:', mathutil.avgstd(ReffA))
process_finished()
process_Ecount()
......
local epitrace = require('epitrace')
--require('mobdebug').coro()
--------------------------------------------------------------------------
-- parameters
local conf = {
TMAX = math.huge, --12*30 -- Simulation time limit
NRUNS = 1000, -- Number of runs
out_path = 'out/', -- nil to disable logging
startExposed = {
[19220] = {t=0, count=20}, -- exposed at t=0
},
local confname = assert(arg[1], 'pass conf file as parameter')
--stop conditions
stop_dpto = nil, --'MONTEVIDEO',
stop_localidad = nil, -- any
outbreak_threshold = 200, -- Max number of actives
local conf
---[[
disease = {
model = 'SLIR',
R0 = 2.5,
do
local conffile = assert(io.open(confname), 'r')
local confstring = 'return {'
..conffile:read('*a')
..'}'
conf = assert(loadstring(confstring, 'confstring'))()
end
-- https://www.medrxiv.org/content/10.1101/2020.05.06.20092841v1
p = 0.25, --proportion of asymptomatic
_epsA = 5, --latent period
_eps = 3, --latent period
_gamma = 2, --pre-symptomatic period
_mu = 6, --2.5, --time to removed/home stay
k = 0.15, -- proportion of presymptomatic transmission
r = 0.5, -- relative infectiousness of asymptomatic individuals
T_q = 2, -- time to self quarantine
},
--]]
--[[
disease = {
model = 'SEIR',
R0 = 2,
T_E = 6, -- Duration of E state
T_I = 6, -- Duration of I state
T_q = 2.5, -- time to self quarantine
},
--]]
local epitrace = require('epitrace')
--require('mobdebug').coro()
contacttracers = 0,
contact_t_find = 1,
contacttracing_time = 5,
}
-- process that sets the scenario up.
conf.scenario_process = function (conf)
conf.scenario_process = conf.scenario_process or function (conf)
local G = require('lib.graph')
local lib = conf.lib
for zoneId, Exposition in pairs(conf.startExposed) do
--for zoneId, Exposition in pairs(conf.startExposed) do
for _, Exposition in ipairs(conf.startExposed) do
lib.esim.launch(function()
for i = 1, Exposition.count do
lib.esim.sleep_to(Exposition.t)
lib.agents.create_exposed (G.N[zoneId], nil)
lib.agents.create_exposed (G.N[Exposition.zone], nil)
end
end)
end
......@@ -70,11 +36,15 @@ local sim_result = epitrace.run(conf)
-- Print run totals
print('Re avg,std:', sim_result.R_e_avg, sim_result.R_e_std)
for status, count in pairs(sim_result.status_count) do
print('runs', status, count, count/conf.NRUNS)
print('runs', status, count/conf.NRUNS)
end
-- Launch plotting (on background)
print('plotting launched in background')
os.execute('gnuplot states.plot &')
os.execute('luajit parse_logs.lua '..conf.NRUNS..' &')
---[[
-- Launch plotting (in background)
if conf.out_path then
print('plotting launched in background')
os.execute('gnuplot states.plot &')
os.execute('luajit parse_logs.lua '..conf.NRUNS..' &')
end
--]]
local epitrace = require('epitrace')
--require('mobdebug').coro()
--------------------------------------------------------------------------
-- parameters
local conf = {
TMAX = math.huge, --12*30 -- Simulation time limit
NRUNS = 1000, -- Number of runs
out_path = nil,
startExposed = {
[19220] = {t=0, count=20}, -- exposed at t=0 , 33 capital
},
local confname = assert(arg[1], 'pass conf file as parameter')
--stop conditions
stop_dpto = 'MONTEVIDEO',
stop_localidad = nil, -- any
outbreak_threshold = 100, -- Max number of actives
local conf
---[[
disease = {
model = 'SLIR',
R0 = 2.5,
-- https://www.medrxiv.org/content/10.1101/2020.05.06.20092841v1
p = 0.25, --proportion of asymptomatic
_epsA = 5, --latent period
_eps = 3, --latent period
_gamma = 2, --pre-symptomatic period
_mu = 6, --2.5, --time to removed/home stay
k = 0.15, -- proportion of presymptomatic transmission
r = 0.5, -- relative infectiousness of asymptomatic individuals
do
local conffile = assert(io.open(confname), 'r')
local confstring = 'return {'
..conffile:read('*a')
..'}'
conf = assert(loadstring(confstring, 'confstring'))()
end
T_q = 3.0, -- time to self quarantine
},
--]]
--[[
disease = {
model = 'SEIR',
R0 = 2,
T_E = 6, -- Duration of E state
T_I = 6, -- Duration of I state
T_q = 2.5, -- time to self quarantine
},
--]]
local epitrace = require('epitrace')
--require('mobdebug').coro()
contacttracers = 0,
contact_t_find = 1,
contacttracing_time = 5,
}
-- process that sets the scenario up.
conf.scenario_process = function (conf)
conf.scenario_process = conf.scenario_process or function (conf)
local G = require('lib.graph')
local lib = conf.lib
for zoneId, Exposition in pairs(conf.startExposed) do
--for zoneId, Exposition in pairs(conf.startExposed) do
for _, Exposition in ipairs(conf.startExposed) do
lib.esim.launch(function()
for i = 1, Exposition.count do
lib.esim.sleep_to(Exposition.t)
lib.agents.create_exposed (G.N[zoneId], nil)
lib.agents.create_exposed (G.N[Exposition.zone], nil)
end
end)
end
......@@ -68,7 +33,7 @@ local frunlog = io.open('out/contacttracing.log', 'w')
frunlog:write('tracers Re ReStd runout outbreak extinction hitstop\n')
-- run simulations
for ntracers = 0, 20, 2 do
for ntracers = 0, 15, 2 do
conf.contacttracers = ntracers -- set sim. scenario
local s = epitrace.run(conf) -- run
......@@ -85,5 +50,6 @@ for ntracers = 0, 20, 2 do
end
frunlog:close()
print('generating contacttracing.eps and contacttracingRe.eps')
os.execute('gnuplot contacttracing.plot')
-- Basic execution parameters ----------------------------------
-- Simulated time limit. Use math.huge for infinity.
-- If time expires simulation will finish with 'runout' outcome.
TMAX = math.huge,
-- Number of runs to perform
NRUNS = 1000,
-- Path for writing logs. If set to nil, no logging will be performed.
out_path = 'out/',
-- Initial scenario description
-- Each register indicates the amount of new infections in a location
-- and time to be scheduled to appear.
startExposed = {
{zone=19220, t=0, count=20},
},
-- Hit stop condition
-- 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_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,
-- Basic execution parameters ----------------------------------
-- Disease parameters
-- See docs/disease.odt for details
disease = {
model = 'SLIR',
R0 = 2.5,
-- https://www.medrxiv.org/content/10.1101/2020.05.06.20092841v1
p = 0.25, --proportion of asymptomatic
_epsA = 5, --latent period
_eps = 3, --latent period
_gamma = 2, --pre-symptomatic period
_mu = 6, --time to removed
k = 0.15, -- proportion of presymptomatic transmission
r = 0.5, -- relative infectiousness of asymptomatic individuals
_q = 2, -- time to self quarantine
},
contacttracers = 0,
contact_t_find = 1,
contacttracing_time = 5,
-- Basic execution parameters ----------------------------------
TMAX = math.huge,
NRUNS = 500,
out_path = nil, --disabled logging
startExposed = {
{zone=19220, t=0, count=20},
},
outbreak_threshold = 200,
disease = {
model = 'SLIR',
R0 = 2.5,
p = 0.25,
_epsA = 5,
_eps = 3,
_gamma = 2,
_mu = 6,
k = 0.15,
r = 0.5,
_q = 3, -- slighly bigger than default 2
},
contacttracers = 0, -- this will be changed by script
contact_t_find = 1,
contacttracing_time = 5,
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