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
21f736b8
Commit
21f736b8
authored
4 years ago
by
Bentriou Mahmoud
Browse files
Options
Downloads
Patches
Plain Diff
set_x0! + tests
parent
9190a75c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
core/MarkovProcesses.jl
+1
-1
1 addition, 1 deletion
core/MarkovProcesses.jl
core/model.jl
+23
-6
23 additions, 6 deletions
core/model.jl
tests/run_unit.jl
+1
-0
1 addition, 0 deletions
tests/run_unit.jl
tests/unit/set_x0.jl
+21
-0
21 additions, 0 deletions
tests/unit/set_x0.jl
with
46 additions
and
7 deletions
core/MarkovProcesses.jl
+
1
−
1
View file @
21f736b8
...
...
@@ -28,7 +28,7 @@ export get_index, get_value, length_var, isaccepted
# Model related methods
export
simulate
,
volatile_simulate
export
distribute_mean_value_lha
,
mean_value_lha
,
distribute_prob_accept_lha
export
set_param!
,
set_time_bound!
,
set_observed_var!
,
observe_all!
export
set_param!
,
set_x0!
,
set_time_bound!
,
set_observed_var!
,
observe_all!
export
get_param
,
getproperty
,
get_proba_model
,
get_observed_var
export
isbounded
,
isaccepted
,
check_consistency
export
draw_model!
,
draw!
,
fill!
,
prior_pdf!
,
prior_pdf
,
insupport
...
...
This diff is collapsed.
Click to expand it.
core/model.jl
+
23
−
6
View file @
21f736b8
...
...
@@ -393,18 +393,35 @@ function observe_all!(am::Model)
m
.
_g_idx
=
_g_idx
m
.
_map_obs_var_idx
=
m
.
map_var_idx
end
set_param!
(
m
::
ContinuousTimeModel
,
p
::
Vector
{
Float64
})
=
(
m
.
p
=
p
)
set_param!
(
m
::
ContinuousTimeModel
,
name_p
::
String
,
p_i
::
Float64
)
=
(
m
.
p
[
m
.
map_param_idx
[
name_p
]]
=
p_i
)
function
set_param!
(
m
::
ContinuousTimeModel
,
l_name_p
::
Vector
{
String
},
p
::
Vector
{
Float64
})
function
set_param!
(
am
::
Model
,
new_p
::
Vector
{
Float64
})
m
=
get_proba_model
(
am
)
@assert
length
(
new_p
)
==
m
.
k
m
.
p
=
new_p
end
function
set_param!
(
am
::
Model
,
name_p
::
String
,
p_i
::
Float64
)
m
=
get_proba_model
(
am
)
m
.
p
[
m
.
map_param_idx
[
name_p
]]
=
p_i
end
function
set_param!
(
am
::
Model
,
l_name_p
::
Vector
{
String
},
p
::
Vector
{
Float64
})
m
=
get_proba_model
(
am
)
@assert
length
(
l_name_p
)
==
length
(
p
)
for
i
=
eachindex
(
l_name_p
)
set_param!
(
m
,
l_name_p
[
i
],
p
[
i
])
end
end
get_param
(
m
::
ContinuousTimeModel
)
=
m
.
p
getindex
(
m
::
ContinuousTimeModel
,
name_p
::
String
)
=
m
.
p
[
m
.
map_param_idx
[
name_p
]]
function
set_x0!
(
am
::
Model
,
new_x0
::
Vector
{
Int
})
m
=
get_proba_model
(
am
)
@assert
length
(
new_x0
)
==
m
.
d
m
.
x0
=
new_x0
end
set_time_bound!
(
am
::
Model
,
b
::
Float64
)
=
(
get_proba_model
(
am
)
.
time_bound
=
b
)
get_param
(
am
::
Model
)
=
get_proba_model
(
am
)
.
p
function
getindex
(
am
::
Model
,
name_p
::
String
)
m
=
get_proba_model
(
am
)
m
.
p
[
m
.
map_param_idx
[
name_p
]]
end
function
getproperty
(
m
::
ContinuousTimeModel
,
sym
::
Symbol
)
if
sym
==
:
dobs
return
length
(
m
.
g
)
...
...
This diff is collapsed.
Click to expand it.
tests/run_unit.jl
+
1
−
0
View file @
21f736b8
...
...
@@ -32,6 +32,7 @@ using Test
@test
include
(
"unit/set_param.jl"
)
@test
include
(
"unit/set_x0.jl"
)
@test
include
(
"unit/side_effects_1.jl"
)
@test
include
(
"unit/simulate_available_models.jl"
)
@test
include
(
"unit/simulate_sir.jl"
)
...
...
This diff is collapsed.
Click to expand it.
tests/unit/set_x0.jl
0 → 100644
+
21
−
0
View file @
21f736b8
using
MarkovProcesses
load_model
(
"SIR"
)
load_model
(
"ER"
)
test_all
=
true
new_x0
=
[
92
,
10
,
2
]
set_x0!
(
SIR
,
new_x0
)
test_all
=
test_all
&&
SIR
.
x0
==
new_x0
new_x0
=
[
1
,
1
,
4
,
2
]
set_x0!
(
ER
,
new_x0
)
test_all
=
test_all
&&
ER
.
x0
==
new_x0
&&
SIR
.
x0
==
[
92
,
10
,
2
]
new_x0
=
[
10
,
10
,
2
]
set_x0!
(
SIR
,
new_x0
)
test_all
=
test_all
&&
SIR
.
x0
==
new_x0
&&
ER
.
x0
==
[
1
,
1
,
4
,
2
]
return
test_all
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