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

performance improvement of euclidean distance automaton

parent ec345f72
No related branches found
No related tags found
No related merge requests found
......@@ -55,11 +55,14 @@ function create_euclidean_distance_automaton(m::ContinuousTimeModel, timeline::A
# l1 => l1
# Defined below
@everywhere $(func_name(:cc, :l1, :l1, 1))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
getfield(S, :values)[$(idx_var_t)] >= $(timeline)[convert(Int, getfield(S, :values)[$(idx_var_idx)])]
(tml = $(Tuple(timeline));
tml_idx = tml[convert(Int, getfield(S, :values)[$(idx_var_idx)])];
getfield(S, :values)[$(idx_var_t)] >= tml_idx)
@everywhere $(func_name(:us, :l1, :l1, 1))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
(setindex!(getfield(S, :values), getfield(S, :values)[$(idx_var_d)] +
(getfield(S, :values)[$(idx_var_n)] - $(observations)[convert(Int, getfield(S, :values)[$(idx_var_idx)])])^2,
$(idx_var_d));
(y_obs = $(Tuple(observations));
y_obs_idx = y_obs[convert(Int, getfield(S, :values)[$(idx_var_idx)])];
setindex!(getfield(S, :values), getfield(S, :values)[$(idx_var_d)] + (getfield(S, :values)[$(idx_var_n)] - y_obs_idx)^2,
$(idx_var_d));
setindex!(getfield(S, :values), getfield(S, :values)[$(idx_var_idx)] + 1.0, $(idx_var_idx)))
@everywhere $(func_name(:cc, :l1, :l1, 2))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) = true
......
......@@ -11,7 +11,6 @@ y_obs = vectorize(simulate(SIR), :I, tml_obs)
sync_SIR = SIR * create_euclidean_distance_automaton(SIR, tml_obs, y_obs, :I)
σ = simulate(sync_SIR)
test = euclidean_distance(σ, :I, tml_obs, y_obs) == σ.state_lha_end[:d]
@show test, euclidean_distance(σ, :I, tml_obs, y_obs), σ.state_lha_end[:d]
return test
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