Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
epibus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jorge Visca
epibus
Commits
f2303cde
Commit
f2303cde
authored
Jul 3, 2020
by
Jorge Visca
Browse files
Options
Downloads
Patches
Plain Diff
parametrize workhours and add inf. distribution
parent
2fe46d41
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
disease_SLIR.lua
+20
-3
20 additions, 3 deletions
disease_SLIR.lua
mobility.lua
+16
-15
16 additions, 15 deletions
mobility.lua
sample.conf
+10
-0
10 additions, 0 deletions
sample.conf
with
46 additions
and
18 deletions
disease_SLIR.lua
+
20
−
3
View file @
f2303cde
...
@@ -9,6 +9,8 @@ local conf
...
@@ -9,6 +9,8 @@ local conf
local
lib
local
lib
local
ds_model
local
ds_model
local
workhours
local
function
w_states
(
t
)
local
function
w_states
(
t
)
--w_states('t', 'L', 'P', 'I', 'R', 'quarantined')
--w_states('t', 'L', 'P', 'I', 'R', 'quarantined')
conf
.
w_states
(
t
,
' '
,
M
.
state_count
.
L
,
' '
,
M
.
state_count
.
P
,
' '
,
conf
.
w_states
(
t
,
' '
,
M
.
state_count
.
L
,
' '
,
M
.
state_count
.
P
,
' '
,
...
@@ -49,7 +51,8 @@ local states_mt = {
...
@@ -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
local
beta
if
d
.
state
==
'I'
then
if
d
.
state
==
'I'
then
if
d
.
symptomatic
then
if
d
.
symptomatic
then
...
@@ -60,6 +63,16 @@ local function compute_beta_SLIR (d)
...
@@ -60,6 +63,16 @@ local function compute_beta_SLIR (d)
elseif
d
.
state
==
'P'
then
elseif
d
.
state
==
'P'
then
beta
=
ds_model
.
k
*
ds_model
.
R0
/
ds_model
.
_mu
beta
=
ds_model
.
k
*
ds_model
.
R0
/
ds_model
.
_mu
end
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
return
beta
end
end
...
@@ -70,7 +83,7 @@ M.infector = function (person, to_t)
...
@@ -70,7 +83,7 @@ M.infector = function (person, to_t)
local
infgen
=
d
.
infgen
+
1
local
infgen
=
d
.
infgen
+
1
d
.
infgen
=
infgen
d
.
infgen
=
infgen
local
beta
=
compute_beta_SLIR
(
d
)
local
beta
=
compute_beta_SLIR
(
person
)
if
not
beta
then
if
not
beta
then
return
lib
.
esim
.
sleep_to
(
to_t
)
return
lib
.
esim
.
sleep_to
(
to_t
)
end
end
...
@@ -85,7 +98,7 @@ M.infector = function (person, to_t)
...
@@ -85,7 +98,7 @@ M.infector = function (person, to_t)
and
not
d
.
quarantined
then
and
not
d
.
quarantined
then
lib
.
agents
.
create_exposed
(
zone
,
person
)
lib
.
agents
.
create_exposed
(
zone
,
person
)
end
end
local
beta
=
compute_beta_SLIR
(
d
)
local
beta
=
compute_beta_SLIR
(
person
)
if
not
beta
then
if
not
beta
then
return
lib
.
esim
.
sleep_to
(
to_t
)
return
lib
.
esim
.
sleep_to
(
to_t
)
end
end
...
@@ -161,6 +174,10 @@ M.initialize = function ( c )
...
@@ -161,6 +174,10 @@ M.initialize = function ( c )
conf
=
assert
(
c
)
conf
=
assert
(
c
)
ds_model
=
c
.
disease
ds_model
=
c
.
disease
lib
=
conf
.
lib
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
}
M
.
state_count
=
{
L
=
0
,
P
=
0
,
I
=
0
,
R
=
0
,
quarantined
=
0
}
w_states
(
't'
,
'L'
,
'P'
,
'I'
,
'R'
,
'quarantined'
)
w_states
(
't'
,
'L'
,
'P'
,
'I'
,
'R'
,
'quarantined'
)
...
...
This diff is collapsed.
Click to expand it.
mobility.lua
+
16
−
15
View file @
f2303cde
...
@@ -78,44 +78,45 @@ end
...
@@ -78,44 +78,45 @@ end
M
.
process
.
random_bus_day
=
function
(
person
)
M
.
process
.
random_bus_day
=
function
(
person
)
local
f
=
function
()
local
f
=
function
()
local
t
=
lib
.
esim
.
now
local
t
=
lib
.
esim
.
now
local
home
,
work
local
next_go
=
next_hour_of_day
(
t
,
conf
.
mobility
.
random_bus_day
.
start_hour
)
local
next_go
=
next_hour_of_day
(
t
,
7
)
local
next_ret
=
next_hour_of_day
(
t
,
conf
.
mobility
.
random_bus_day
.
end_hour
)
local
next_ret
=
next_hour_of_day
(
t
,
17
)
local
trip
=
0
.
2
+
0
.
8
*
math.random
()
local
trip
=
0
.
2
+
0
.
8
*
math.random
()
if
next_ret
<
next_go
then
-- started at work
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
)
lib
.
disease
.
infector
(
person
,
next_ret
)
if
person
.
disease
.
state
==
'R'
then
return
end
if
person
.
disease
.
state
==
'R'
then
return
end
t
=
esim
.
sleep_to
(
next_ret
)
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
person
.
in_zone
=
nil
t
=
esim
.
sleep_to
(
t
+
trip
)
t
=
esim
.
sleep_to
(
t
+
trip
)
person
.
in_zone
=
hom
e
person
.
in_zone
=
person
.
home_zon
e
else
else
hom
e
=
person
.
in_zone
person
.
home_zon
e
=
person
.
in_zone
end
end
while
true
do
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
)
t
=
lib
.
disease
.
infector
(
person
,
next_go
)
if
person
.
disease
.
state
==
'R'
then
return
end
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
--person.in_zone = nil
--t = esim.sleep_to(t+trip)
--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
)
t
=
lib
.
disease
.
infector
(
person
,
next_ret
)
if
person
.
state
==
'R'
then
return
end
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
--person.in_zone = nil
--t = esim.sleep_to(t+trip)
--t = esim.sleep_to(t+trip)
person
.
in_zone
=
hom
e
person
.
in_zone
=
person
.
home_zon
e
end
end
end
end
return
f
return
f
...
@@ -133,8 +134,8 @@ M.pick_mobility_model = function ( t, zone, exposed_from )
...
@@ -133,8 +134,8 @@ M.pick_mobility_model = function ( t, zone, exposed_from )
local
trabajan_aca
=
zone
.
trabajacasa
+
zone
.
trabajaloc
local
trabajan_aca
=
zone
.
trabajacasa
+
zone
.
trabajaloc
local
trabajan_remoto
local
trabajan_remoto
local
next_go
=
next_hour_of_day
(
t
,
7
)
local
next_go
=
next_hour_of_day
(
t
,
conf
.
mobility
.
random_bus_day
.
start_hour
)
local
next_ret
=
next_hour_of_day
(
t
,
17
)
local
next_ret
=
next_hour_of_day
(
t
,
conf
.
mobility
.
random_bus_day
.
end_hour
)
if
next_ret
<
next_go
then
-- work hour
if
next_ret
<
next_go
then
-- work hour
trabajan_remoto
=
zone
.
trabajar_viene
trabajan_remoto
=
zone
.
trabajar_viene
else
else
...
...
This diff is collapsed.
Click to expand it.
sample.conf
+
10
−
0
View file @
f2303cde
...
@@ -50,6 +50,16 @@ disease = {
...
@@ -50,6 +50,16 @@ disease = {
q_coop
=
1
, --
probability
of
entering
self
quarantine
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
--
contact
tracers
behavior
ct_count
=
0
, --
number
if
contact
tracers
working
ct_count
=
0
, --
number
if
contact
tracers
working
ct_hit_t
=
1
, --
time
to
hitting
an
exposed
ct_hit_t
=
1
, --
time
to
hitting
an
exposed
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment