Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bentriou Mahmoud
MarkovProcesses.jl
Commits
a94525a5
Commit
a94525a5
authored
Feb 02, 2021
by
Bentriou Mahmoud
Browse files
Now pictures are saved in svg. All tests passed.
parent
2fd6f15d
Changes
18
Hide whitespace changes
Inline
Side-by-side
core/plots.jl
View file @
a94525a5
import
Plots
:
plot
,
plot!
,
scatter!
,
hline!
,
Shape
,
text
import
Plots
:
current
,
palette
,
display
,
png
,
close
import
Plots
:
current
,
palette
,
display
,
png
,
close
,
savefig
"""
`plot(σ, var...; plot_transitions=false)`
...
...
@@ -27,14 +27,14 @@ function plot(σ::AbstractTrajectory, vars::VariableModel...; plot_transitions::
@assert
var
in
get_obs_var
(
σ
)
"Variable
$
var is not observed."
plot!
(
p
,
times
(
σ
),
σ
[
var
],
xlabel
=
"Time"
,
ylabel
=
"Number of species"
,
label
=
var
,
label
=
"
$
var
"
,
linetype
=:
steppost
)
end
if
plot_transitions
for
(
i
,
var
)
in
enumerate
(
to_plot
)
for
tr
in
l_tr
idx_tr
=
findall
(
x
->
x
==
tr
,
transitions
(
σ
))
label
=
(
tr
==
nothing
||
i
>
1
)
?
""
:
tr
label
=
(
tr
==
nothing
||
i
>
1
)
?
""
:
"
$
tr
"
alpha
=
(
tr
==
nothing
)
?
0.0
:
0.5
scatter!
(
p
,
times
(
σ
)[
idx_tr
],
σ
[
var
][
idx_tr
],
label
=
label
,
markershape
=:
cross
,
markeralpha
=
alpha
,
...
...
@@ -49,7 +49,7 @@ function plot(σ::AbstractTrajectory, vars::VariableModel...; plot_transitions::
if
filename
==
""
display
(
p
)
else
pn
g
(
p
,
filename
)
savefi
g
(
p
,
filename
)
end
end
...
...
@@ -124,7 +124,7 @@ function plot_periodic_trajectory(A::LHA, σ::SynchronizedTrajectory, sym_obs::S
if
filename
==
""
display
(
p
)
else
pn
g
(
p
,
filename
)
savefi
g
(
p
,
filename
)
end
end
...
...
examples/scripts/doping_3way_oscillator.jl
View file @
a94525a5
...
...
@@ -10,7 +10,7 @@ sync_doping = doping_3way_oscillator * A_per
set_time_bound!
(
sync_doping
,
0.1
)
set_x0!
(
doping_3way_oscillator
,
[
:
A
,
:
B
,
:
C
,
:
DA
,
:
DB
,
:
DC
],
[
333
,
333
,
333
,
10
,
10
,
10
])
σ
=
simulate
(
sync_doping
)
plot
(
σ
;
A
=
A_per
,
filename
=
"traj_full.
pn
g"
)
plot
(
σ
,
:
A
;
A
=
A_per
,
filename
=
"traj_A.
pn
g"
)
plot_periodic_trajectory
(
A_per
,
σ
,
:
A
,
filename
=
"traj_automaton.
pn
g"
)
plot
(
σ
;
A
=
A_per
,
filename
=
"traj_full.
sv
g"
)
plot
(
σ
,
:
A
;
A
=
A_per
,
filename
=
"traj_A.
sv
g"
)
plot_periodic_trajectory
(
A_per
,
σ
,
:
A
,
filename
=
"traj_automaton.
sv
g"
)
examples/scripts/enzym_1d.jl
View file @
a94525a5
...
...
@@ -45,7 +45,7 @@ samples_weights = r.weights
# Histogram
histogram
(
samples_abc_post
,
weights
=
r
.
weights
,
normalize
=
:
density
)
pn
g
(
path_results
*
"histogram.
pn
g"
)
savefi
g
(
path_results
*
"histogram.
sv
g"
)
## Satisfaction function
...
...
@@ -92,5 +92,5 @@ y_MC = readdlm("/home/moud/plot_R1-3/estim_MC/$(exp)/satisfaction_func.csv", ','
inf_x
,
sup_x
=
0.0
,
100.0
x_MC
=
inf_x
:
((
sup_x
-
inf_x
)
/
(
length
(
y_MC
)
-
1
))
:
sup_x
plot!
(
x_MC
,
y_MC
,
label
=
"MC spf"
)
pn
g
(
path_results
*
"satisfaction_prob_function.
pn
g"
)
savefi
g
(
path_results
*
"satisfaction_prob_function.
sv
g"
)
examples/scripts/enzym_2d.jl
View file @
a94525a5
...
...
@@ -47,7 +47,7 @@ samples_weights = r.weights
# Histogram
histogram2d(samples_abc_post[1,:], samples_abc_post[2,:], weights = samples_weights, normalize = :density)
pn
g(path_results * "histogram.
pn
g")
savefi
g(path_results * "histogram.
sv
g")
=#
## Satisfaction function
...
...
@@ -88,11 +88,11 @@ xaxis = 0:0.1:1.5
yaxis
=
0
:
1.0
:
100.0
p
=
plot
(
title
=
"Multivariate KDE"
,
dpi
=
480
,
background_color_legend
=
:
transparent
)
plot!
(
p
,
xaxis
,
yaxis
,
prob_func
,
st
=
:
surface
,
c
=
:
coolwarm
,
camera
=
(
30
,
45
))
pn
g
(
path_results
*
"estim_abc_satisfaction_prob_function.
pn
g"
)
savefi
g
(
path_results
*
"estim_abc_satisfaction_prob_function.
sv
g"
)
x_MC
=
readdlm
(
"/home/moud/results_last_automata/estim_satisfaction_func_MC/
$(exp)
/grid_X.csv"
,
','
)
y_MC
=
readdlm
(
"/home/moud/results_last_automata/estim_satisfaction_func_MC/
$(exp)
/grid_Y.csv"
,
','
)
z_MC
=
readdlm
(
"/home/moud/results_last_automata/estim_satisfaction_func_MC/
$(exp)
/satisfaction_func.csv"
,
','
)
p
=
plot
(
title
=
"ABC MC"
,
dpi
=
480
,
background_color_legend
=
:
transparent
)
plot!
(
p
,
[
x_MC
...
],
[
y_MC
...
],
[
z_MC
...
],
st
=
:
surface
,
c
=
:
coolwarm
,
camera
=
(
30
,
45
),
label
=
"MC spf"
)
pn
g
(
path_results
*
"estim_MC_satisfaction_prob_function.
pn
g"
)
savefi
g
(
path_results
*
"estim_MC_satisfaction_prob_function.
sv
g"
)
tests/automaton_abc/R1.jl
View file @
a94525a5
...
...
@@ -20,5 +20,5 @@ return test
#using Plots
#histogram(r.mat_p_end', weights = r.weights, normalize = :density)
#
pn
g("R1_hist.
pn
g")
#
savefi
g("R1_hist.
sv
g")
tests/automaton_abc/R2.jl
View file @
a94525a5
...
...
@@ -13,5 +13,5 @@ pm_sync_ER = ParametricModel(sync_ER, (:k3, Uniform(0.0, 100.0)))
@show
r
.
nbr_sim
histogram
(
r
.
mat_p_end
'
,
bins
=
:
sqrt
,
weights
=
r
.
weights
,
normalize
=
:
density
,
xlims
=
(
0.0
,
100.0
))
pn
g
(
"R2_hist.
pn
g"
)
savefi
g
(
"R2_hist.
sv
g"
)
tests/automaton_abc/R3.jl
View file @
a94525a5
...
...
@@ -11,5 +11,5 @@ pm_sync_ER = ParametricModel(sync_ER, (:k3, Uniform(0.0, 100.0)))
r
=
automaton_abc
(
pm_sync_ER
;
nbr_particles
=
1000
)
histogram
(
r
.
mat_p_end
'
,
weights
=
r
.
weights
,
normalize
=
:
density
,
xlims
=
(
0.0
,
100.0
))
pn
g
(
"R3_hist.
pn
g"
)
savefi
g
(
"R3_hist.
sv
g"
)
tests/automaton_abc/R6.jl
0 → 100644
View file @
a94525a5
using
MarkovProcesses
load_model
(
"ER"
)
observe_all!
(
ER
)
load_automaton
(
"automaton_G_and_F"
)
A_G_F_R6
=
create_automaton_G_and_F
(
ER
,
50.0
,
100.0
,
0.0
,
0.8
,
:
E
,
30.0
,
100.0
,
0.8
,
0.9
,
:
P
)
sync_ER
=
A_G_F_R6
*
ER
pm_sync_ER
=
ParametricModel
(
sync_ER
,
(
:
k1
,
Uniform
(
0.0
,
100.0
)),
(
:
k2
,
Uniform
(
0.0
,
100.0
)))
r
=
automaton_abc
(
pm_sync_ER
;
alpha
=
0.2
)
using
Plots
histogram2d
(
r
.
mat_p_end
[
1
,
:
],
r
.
mat_p_end
[
2
,
:
],
bins
=
50
)
savefig
(
"R6_hist.svg"
)
tests/automaton_abc/distributed_R1.jl
View file @
a94525a5
...
...
@@ -34,5 +34,5 @@ test = size(r.mat_p_end)[1] == pm_sync_ER.df &&
return
test
#histogram(r.mat_p_end', weights = r.weights, normalize = :density)
#
pn
g("R1_hist.
pn
g")
#
savefi
g("R1_hist.
sv
g")
tests/simulation/sim_er_row_buffer_bounded.jl
View file @
a94525a5
...
...
@@ -9,7 +9,7 @@ ER_row_buffer.time_bound = 10.0
σ
=
_simulate_row_buffer
(
ER_row_buffer
)
plt
.
figure
()
plt
.
step
(
times
(
σ
),
_get_values_row
(
σ
,
:
P
),
"ro--"
,
marker
=
"x"
,
where
=
"post"
,
linewidth
=
1.0
)
plt
.
savefig
(
get_module_path
()
*
"/tests/simulation/res_pics/sim_er_row_buffer_bounded.
pn
g"
)
plt
.
savefig
(
get_module_path
()
*
"/tests/simulation/res_pics/sim_er_row_buffer_bounded.
sv
g"
)
plt
.
close
()
return
true
...
...
tests/simulation/sim_pm_er.jl
View file @
a94525a5
...
...
@@ -9,7 +9,7 @@ pm_ER = ParametricModel(ER, (:k1, Uniform(0.0,100.0)), (:k2, Uniform(0.0,100.0))
prior_p
=
[
0.2
,
40.0
]
σ
=
simulate
(
pm_ER
,
prior_p
)
MarkovProcesses
.
plot
(
σ
;
filename
=
get_module_path
()
*
"/tests/simulation/res_pics/sim_pm_er_long.
pn
g"
)
MarkovProcesses
.
plot
(
σ
;
filename
=
get_module_path
()
*
"/tests/simulation/res_pics/sim_pm_er_long.
sv
g"
)
return
true
tests/simulation/sim_pm_sync_er.jl
View file @
a94525a5
...
...
@@ -11,7 +11,7 @@ pm_sync_ER = ParametricModel(ER*A_F, (:k1, Uniform(0.0,100.0)), (:k2, Uniform(0.
prior_p
=
[
0.2
,
40.0
]
σ
=
simulate
(
pm_sync_ER
,
prior_p
)
MarkovProcesses
.
plot
(
σ
;
filename
=
get_module_path
()
*
"/tests/simulation/res_pics/sim_pm_sync_er_long.
pn
g"
)
MarkovProcesses
.
plot
(
σ
;
filename
=
get_module_path
()
*
"/tests/simulation/res_pics/sim_pm_sync_er_long.
sv
g"
)
return
true
tests/simulation/sim_poisson.jl
View file @
a94525a5
...
...
@@ -4,7 +4,7 @@ load_plots()
load_model
(
"poisson"
)
σ
=
simulate
(
poisson
)
MarkovProcesses
.
plot
(
σ
;
filename
=
get_module_path
()
*
"/tests/simulation/res_pics/sim_poisson.
pn
g"
)
MarkovProcesses
.
plot
(
σ
;
filename
=
get_module_path
()
*
"/tests/simulation/res_pics/sim_poisson.
sv
g"
)
return
true
tests/simulation/sim_sir.jl
View file @
a94525a5
...
...
@@ -7,7 +7,7 @@ load_model("SIR")
σ
=
simulate
(
SIR
)
plt
.
figure
()
plt
.
step
(
times
(
σ
),
σ
[
:
I
],
"ro--"
,
marker
=
"x"
,
where
=
"post"
,
linewidth
=
1.0
)
plt
.
savefig
(
get_module_path
()
*
"/tests/simulation/res_pics/sim_sir.
pn
g"
)
plt
.
savefig
(
get_module_path
()
*
"/tests/simulation/res_pics/sim_sir.
sv
g"
)
plt
.
close
()
return
true
...
...
tests/simulation/sim_sir_bounded.jl
View file @
a94525a5
...
...
@@ -8,7 +8,7 @@ SIR.time_bound = 100.0
σ
=
simulate
(
SIR
)
plt
.
figure
()
plt
.
step
(
times
(
σ
),
σ
[
:
I
],
"ro--"
,
marker
=
"x"
,
where
=
"post"
,
linewidth
=
1.0
)
plt
.
savefig
(
get_module_path
()
*
"/tests/simulation/res_pics/sim_sir_bounded.
pn
g"
)
plt
.
savefig
(
get_module_path
()
*
"/tests/simulation/res_pics/sim_sir_bounded.
sv
g"
)
plt
.
close
()
return
true
...
...
tests/simulation/sim_sir_col_buffer_bounded.jl
View file @
a94525a5
...
...
@@ -9,7 +9,7 @@ SIR_col_buffer.time_bound = 100.0
σ
=
_simulate_col_buffer
(
SIR_col_buffer
)
plt
.
figure
()
plt
.
step
(
times
(
σ
),
_get_values_col
(
σ
,
:
I
),
"ro--"
,
marker
=
"x"
,
where
=
"post"
,
linewidth
=
1.0
)
plt
.
savefig
(
get_module_path
()
*
"/tests/simulation/res_pics/sim_sir_col_buffer_bounded.
pn
g"
)
plt
.
savefig
(
get_module_path
()
*
"/tests/simulation/res_pics/sim_sir_col_buffer_bounded.
sv
g"
)
plt
.
close
()
return
true
...
...
tests/simulation/sim_sir_row_buffer_bounded.jl
View file @
a94525a5
...
...
@@ -9,7 +9,7 @@ SIR_row_buffer.time_bound = 100.0
σ
=
_simulate_row_buffer
(
SIR_row_buffer
)
plt
.
figure
()
plt
.
step
(
times
(
σ
),
_get_values_row
(
σ
,
:
I
),
"ro--"
,
marker
=
"x"
,
where
=
"post"
,
linewidth
=
1.0
)
plt
.
savefig
(
get_module_path
()
*
"/tests/simulation/res_pics/sim_sir_row_buffer_bounded.
pn
g"
)
plt
.
savefig
(
get_module_path
()
*
"/tests/simulation/res_pics/sim_sir_row_buffer_bounded.
sv
g"
)
plt
.
close
()
return
true
...
...
tests/simulation/sim_sir_tauleap.jl
View file @
a94525a5
...
...
@@ -4,7 +4,7 @@ load_plots()
load_model
(
"SIR_tauleap"
)
σ
=
simulate
(
SIR_tauleap
)
MarkovProcesses
.
plot
(
σ
;
filename
=
get_module_path
()
*
"/tests/simulation/res_pics/sim_sir_tauleap.
pn
g"
)
MarkovProcesses
.
plot
(
σ
;
filename
=
get_module_path
()
*
"/tests/simulation/res_pics/sim_sir_tauleap.
sv
g"
)
return
true
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment