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
bf7e270e
Commit
bf7e270e
authored
4 years ago
by
Bentriou Mahmoud
Browse files
Options
Downloads
Patches
Plain Diff
Same changes for ER model
parent
d690d6b9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
models/ER.jl
+15
-14
15 additions, 14 deletions
models/ER.jl
models/SIR.jl
+0
-2
0 additions, 2 deletions
models/SIR.jl
with
15 additions
and
16 deletions
models/ER.jl
+
15
−
14
View file @
bf7e270e
import
StaticArrays
:
SVector
,
SMatrix
,
@SMatrix
d
=
4
...
...
@@ -7,11 +6,12 @@ k=3
dict_var
=
Dict
(
"E"
=>
1
,
"S"
=>
2
,
"ES"
=>
3
,
"P"
=>
4
)
dict_p
=
Dict
(
"k1"
=>
1
,
"k2"
=>
2
,
"k3"
=>
3
)
l_tr
=
[
"R1"
,
"R2"
,
"R3"
]
p
=
SVector
{
3
,
Float64
}(
1.0
,
1.0
,
1.0
)
x0
=
SVector
{
4
,
Int
}(
100
,
100
,
0
,
0
)
p
=
[
1.0
,
1.0
,
1.0
]
x0
=
[
100
,
100
,
0
,
0
]
t0
=
0.0
function
f
(
xn
::
SVector
{
4
,
Int
},
tn
::
Float64
,
p
::
SVector
{
3
,
Float64
})
function
f!
(
xnplus1
::
Vector
{
Int
},
tnplus1
::
Vector
{
Float64
},
tr
::
Vector
{
String
},
xn
::
Vector
{
Int
},
tn
::
Float64
,
p
::
Vector
{
Float64
})
a1
=
p
[
1
]
*
xn
[
1
]
*
xn
[
2
]
a2
=
p
[
2
]
*
xn
[
3
]
a3
=
p
[
3
]
*
xn
[
3
]
...
...
@@ -35,17 +35,18 @@ function f(xn::SVector{4, Int}, tn::Float64, p::SVector{3, Float64})
b_sup
+=
l_a
[
i
+
1
]
end
nu
=
l_nu
[
:
,
reaction
]
xnplus1
=
SVector
{
4
,
Int
}(
xn
[
1
]
+
nu
[
1
],
xn
[
2
]
+
nu
[
2
],
xn
[
3
]
+
nu
[
3
],
xn
[
4
]
+
nu
[
4
])
tnplus1
=
tn
+
tau
transition
=
"R
$(reaction)
"
return
xnplus1
,
tnplus1
,
transition
nu
=
@view
l_nu
[
:
,
reaction
]
xnplus1
[
1
]
=
xn
[
1
]
+
nu
[
1
]
xnplus1
[
2
]
=
xn
[
2
]
+
nu
[
2
]
xnplus1
[
3
]
=
xn
[
3
]
+
nu
[
3
]
xnplus1
[
4
]
=
xn
[
4
]
+
nu
[
4
]
tnplus1
[
1
]
=
tn
+
tau
tr
[
1
]
=
"R
$(reaction)
"
end
is_absorbing_er
(
p
::
S
Vector
{
3
,
Float64
},
xn
::
S
Vector
{
4
,
Int
})
=
(
p
[
1
]
*
xn
[
1
]
*
xn
[
2
]
+
(
p
[
2
]
+
p
[
3
])
*
xn
[
3
])
==
0.0
g
=
SVector
(
"P"
)
is_absorbing_er
(
p
::
Vector
{
Float64
},
xn
::
Vector
{
Int
})
=
(
p
[
1
]
*
xn
[
1
]
*
xn
[
2
]
+
(
p
[
2
]
+
p
[
3
])
*
xn
[
3
])
==
=
0.0
g
=
[
"P"
]
ER
=
CTMC
(
d
,
k
,
dict_var
,
dict_p
,
l_tr
,
p
,
x0
,
t0
,
f
,
is_absorbing_er
;
g
=
g
)
ER
=
CTMC
(
d
,
k
,
dict_var
,
dict_p
,
l_tr
,
p
,
x0
,
t0
,
f
!
,
is_absorbing_er
;
g
=
g
)
export
ER
This diff is collapsed.
Click to expand it.
models/SIR.jl
+
0
−
2
View file @
bf7e270e
...
...
@@ -40,8 +40,6 @@ function f!(xnplus1::Vector{Int}, tnplus1::Vector{Float64}, tr::Vector{String},
xnplus1
[
3
]
=
xn
[
3
]
+
nu
[
3
]
tnplus1
[
1
]
=
tn
+
tau
tr
[
1
]
=
"R
$(reaction)
"
#return xnplus1, tnplus1, transition
end
is_absorbing_sir
(
p
::
Vector
{
Float64
},
xn
::
Vector
{
Int
})
=
(
p
[
1
]
*
xn
[
1
]
*
xn
[
2
]
+
p
[
2
]
*
xn
[
2
])
===
0.0
g
=
[
"I"
]
...
...
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