Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MarkovProcesses.jl
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bentriou Mahmoud
MarkovProcesses.jl
Commits
89a448ff
Commit
89a448ff
authored
4 years ago
by
Bentriou Mahmoud
Browse files
Options
Downloads
Patches
Plain Diff
SIR tauleap
parent
c848213f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
models/SIR_tauleap.jl
+45
-0
45 additions, 0 deletions
models/SIR_tauleap.jl
with
45 additions
and
0 deletions
models/SIR_tauleap.jl
0 → 100644
+
45
−
0
View file @
89a448ff
import
StaticArrays
:
SVector
,
SMatrix
,
@SVector
,
@SMatrix
import
Distributions
:
Poisson
,
rand
d
=
3
k
=
2
dict_var_SIR_tauleap
=
Dict
(
"S"
=>
1
,
"I"
=>
2
,
"R"
=>
3
)
dict_p_SIR_tauleap
=
Dict
(
"ki"
=>
1
,
"kr"
=>
2
,
"tau"
=>
3
)
l_tr_SIR_tauleap
=
[
"U"
]
p_SIR_tauleap
=
[
0.0012
,
0.05
,
5.0
]
x0_SIR_tauleap
=
[
95
,
5
,
0
]
t0_SIR_tauleap
=
0.0
function
SIR_tauleap_f!
(
xnplus1
::
Vector
{
Int
},
l_t
::
Vector
{
Float64
},
l_tr
::
Vector
{
Union
{
Nothing
,
String
}},
xn
::
Vector
{
Int
},
tn
::
Float64
,
p
::
Vector
{
Float64
})
tau
=
p
[
3
]
a1
=
p
[
1
]
*
xn
[
1
]
*
xn
[
2
]
a2
=
p
[
2
]
*
xn
[
2
]
l_a
=
SVector
(
a1
,
a2
)
asum
=
sum
(
l_a
)
# column-major order
nu_1
=
SVector
(
-
1
,
1
,
0
)
nu_2
=
SVector
(
0
,
-
1
,
1
)
nbr_R1
=
rand
(
Poisson
(
a1
*
tau
))
nbr_R2
=
rand
(
Poisson
(
a2
*
tau
))
for
i
=
1
:
3
xnplus1
[
i
]
=
xn
[
i
]
+
nbr_R1
*
nu_1
[
i
]
+
nbr_R2
*
nu_2
[
i
]
end
l_t
[
1
]
=
tn
+
tau
l_tr
[
1
]
=
"U"
end
isabsorbing_SIR_tauleap
(
p
::
Vector
{
Float64
},
xn
::
Vector
{
Int
})
=
(
p
[
1
]
*
xn
[
1
]
*
xn
[
2
]
+
p
[
2
]
*
xn
[
2
])
===
0.0
g_SIR_tauleap
=
[
"I"
]
SIR_tauleap
=
ContinuousTimeModel
(
d
,
k
,
dict_var_SIR_tauleap
,
dict_p_SIR_tauleap
,
l_tr_SIR_tauleap
,
p_SIR_tauleap
,
x0_SIR_tauleap
,
t0_SIR_tauleap
,
SIR_tauleap_f!
,
isabsorbing_SIR_tauleap
;
g
=
g_SIR_tauleap
)
function
create_SIR_tauleap
(
new_p
::
Vector
{
Float64
})
SIR_tauleap_new
=
deepcopy
(
SIR_tauleap
)
@assert
length
(
SIR_tauleap_new
.
p
)
==
length
(
new_p
)
set_param!
(
SIR_tauleap_new
,
new_p
)
return
SIR_tauleap_new
end
export
SIR_tauleap
,
create_SIR_tauleap
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
register
or
sign in
to comment