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

Automaton ABC with volatile_simulate + some doc on model.jl

parent f4c41acb
No related branches found
No related tags found
No related merge requests found
......@@ -5,8 +5,8 @@ function _init_abc_automaton!(mat_p_old::Matrix{Float64}, vec_dist::Vector{Float
for i = eachindex(vec_dist)
draw!(vec_p, pm)
mat_p_old[:,i] = vec_p
σ = simulate(pm, vec_p)
vec_dist[i] = σ.S[str_var_aut]
S = volatile_simulate(pm, vec_p)
vec_dist[i] = S[str_var_aut]
end
end
......@@ -88,8 +88,8 @@ function _update_param!(mat_p::Matrix{Float64}, vec_dist::Vector{Float64},
if !insupport(pm, vec_p_prime)
continue
end
σ = simulate(pm, vec_p_prime)
dist_sim = σ.S[str_var_aut]
S = volatile_simulate(pm, vec_p_prime)
dist_sim = S[str_var_aut]
nbr_sim += 1
end
......
......@@ -245,7 +245,13 @@ function simulate(product::SynchronizedModel; p::Union{Nothing,AbstractVector{Fl
end
return SynchronizedTrajectory(Sn, product, values, times, transitions)
end
"""
`volatile_simulate(sm::SynchronizedModel; p, verbose)`
Simulates a model synchronized with an automaton but does not store the values of the simulation
in order to improve performance.
It returns the last state of the simulation `S::StateLHA` not a trajectory `σ::SynchronizedTrajectory`.
"""
function volatile_simulate(product::SynchronizedModel;
p::Union{Nothing,AbstractVector{Float64}} = nothing, verbose::Bool = false)
m = product.m
......@@ -311,6 +317,20 @@ function simulate(pm::ParametricModel, p_prior::AbstractVector{Float64})
return simulate(pm.m; p = full_p)
end
"""
`volatile_simulate(pm::ParametricModel, p_prior::AbstractVector{Float64})
A volatile version of `simulate(pm::ParametricModel, p_prior::AbstractVector{Float64})`.
The model in pm should be of type SynchronizedModel (`typeof(pm.m) <: SynchronizedModel`).
It returns `S::StateLHA`, not a trajectory.
"""
function volatile_simulate(pm::ParametricModel, p_prior::AbstractVector{Float64})
@assert typeof(pm.m) <: SynchronizedModel
full_p = copy(get_proba_model(pm).p)
full_p[pm._param_idx] = p_prior
return volatile_simulate(pm.m; p = full_p)
end
"""
`distribute_mean_value_lha(sm::SynchronizedModel, str_var::String, nbr_stim::Int)`
......
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