read_random_state_trajectory.jl 1.33 KB
Newer Older
Bentriou Mahmoud's avatar
Bentriou Mahmoud committed
1
2
3
4
5
6
7
8
9
10

using BenchmarkTools
using pygmalion
using MarkovProcesses

println("Pygmalion:")

str_m = "enzymatic_reaction"
str_d = "abc_er"
pygmalion.load_model(str_m)
11
12
l_var = ["E", "S", "ES", "P"]
str_oml = "E,S,ES,P,R,time"
Bentriou Mahmoud's avatar
Bentriou Mahmoud committed
13
14
15
16
17
18
19
20
21
22
23
ll_om = split(str_oml, ",")
x0 = State(95.0, 95.0, 0.0, 0.0, 0.0, 0.0)
p_true = Parameters(1.0, 1.0, 1.0)
u = Control(10.0)
tml = 1:400
g_all = create_observation_function([ObserverModel(str_oml, tml)]) 
so = pygmalion.simulate(f, g_all, x0, u, p_true; on = nothing, full_timeline = true)
function random_trajectory_value_pyg(so::SystemObservation)
    n_states = get_number_of_observations(so, "P")
    return to_vec(so, "P", rand(1:n_states))
end
24
25
26
27
function random_trajectory_state_pyg(so::SystemObservation)
    n_states = get_number_of_observations(so, "P")
    return to_vec(so, so.oml, rand(1:n_states))
end
Bentriou Mahmoud's avatar
Bentriou Mahmoud committed
28
29
30
31
32
33
34
35
36
37
38
# Bench
@timev random_trajectory_value_pyg(so)
b1_pyg = @benchmark random_trajectory_value_pyg($so)
@show minimum(b1_pyg), mean(b1_pyg), maximum(b1_pyg)

println("MarkovProcesses:")

MarkovProcesses.load_model("ER")
ER.time_bound = 10.0
σ = MarkovProcesses.simulate(ER)
function random_trajectory_value(σ::AbstractTrajectory)
39
    n_states = length_states(σ)
Bentriou Mahmoud's avatar
Bentriou Mahmoud committed
40
41
42
43
44
45
46
    return σ["P"][rand(1:n_states)]
end
# Bench
@timev random_trajectory_value(σ) 
b1 = @benchmark random_trajectory_value($σ)
@show minimum(b1), mean(b1), maximum(b1)