Skip to content
Snippets Groups Projects
Commit 6e91cd8e authored by Bentriou Mahmoud's avatar Bentriou Mahmoud
Browse files

New test for sir row bench + fix other test

parent 047eb00b
No related branches found
No related tags found
No related merge requests found
# File for benchmarking simulation and memory access of the package.
# Trajectories
_get_values_col(σ::AbstractTrajectory, var::String) =
σ.values[(σ.m)._map_obs_var_idx[var],:]
_get_values_row(σ::AbstractTrajectory, var::String) =
σ.values[:,(σ.m)._map_obs_var_idx[var]]
_get_state_col(σ::AbstractTrajectory, idx::Int) =
σ.values[:,idx]
_get_state_row(σ::AbstractTrajectory, idx::Int) =
σ.values[idx,:]
_get_value_col(σ::AbstractTrajectory, var::String, idx::Int) =
σ.values[(σ.m)._map_obs_var_idx[var],idx]
_get_value_row(σ::AbstractTrajectory, var::String, idx::Int) =
σ.values[idx,(σ.m)._map_obs_var_idx[var]]
# Model
function _simulate_col(m::ContinuousTimeModel)
# trajectory fields
......@@ -135,7 +148,7 @@ function _simulate_row_buffer(m::ContinuousTimeModel; buffer_size::Int = 5)
while i < buffer_size && !is_absorbing && (tn <= m.time_bound)
i += 1
m.f!(mat_x, l_t, l_tr, i, xn, tn, m.p)
xn = @view mat_x[:,i]
xn = @view mat_x[i,:]
tn = l_t[i]
is_absorbing = m.is_absorbing(m.p,xn)::Bool
end
......
......@@ -9,6 +9,7 @@ if !isdir(str_dir_pics) mkdir(str_dir_pics) end
@test include("simulation/sim_sir.jl")
@test include("simulation/sim_sir_bounded.jl")
@test include("simulation/sim_sir_col_buffer_bounded.jl")
@test include("simulation/sim_sir_row_buffer_bounded.jl")
@test include("simulation/sim_er.jl")
end
......@@ -8,7 +8,7 @@ SIR_col_buffer.time_bound = 100.0
σ = _simulate_col_buffer(SIR_col_buffer)
plt.figure()
plt.step(σ["times"], σ["I"], "ro--", marker="x", where="post", linewidth=1.0)
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.png")
plt.close()
......
using MarkovProcesses
include(get_module_path() * "/core/_tests_simulate.jl")
using PyPlot
load_model("_bench_perf_test/SIR_row_buffer")
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.png")
plt.close()
return true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment