Commit ec345f72 authored by Bentriou Mahmoud's avatar Bentriou Mahmoud
Browse files

Small fix in tests

parent 886e9d98
......@@ -10,8 +10,8 @@ set_time_bound!(SIR, 200.0)
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(σ, tml_obs, y_obs, :I) == σ.state_lha_end[:d]
@show test, euclidean_distance(σ, tml_obs, y_obs, :I), σ.state_lha_end[:d]
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
......@@ -28,41 +28,43 @@ for exp in l_exp
continue
end
val_exp = dict_exp[exp]
x1, x2, t1, t2 = val_exp[1], val_exp[2], val_exp[3], val_exp[4]
A_F = create_automaton_F(model, x1, x2, t1, t2, :P)
l_k3 = 0:10:100
nb_param = length(l_k3)
l_dist_cosmos = zeros(nb_param)
l_dist_pkg = zeros(nb_param)
for i in 1:nb_param
# Cosmos estimation
k3 = l_k3[i]
command = `Cosmos $(absolute_path * "models/" * str_model * ".gspn")
$(absolute_path * "distance_F/dist_F_" * str_model * ".lha") --njob $(nworkers())
--const k_3=$(k3),x1=$x1,x2=$x2,t1=$t1,t2=$t2
--level $(level) --width $(width)
--verbose 0`
#run(command)
run(pipeline(command, stderr=devnull))
dict_values = cosmos_get_values("Result_dist_F_$(str_model).res")
l_dist_cosmos[i] = dict_values["Estimated value"][1]
nb_sim = dict_values["Total paths"][1]
nb_accepted = dict_values["Accepted paths"][1]
nb_sim = convert(Int, nb_sim)
# MarkovProcesses estimation
set_param!(ER, :k3, convert(Float64, k3))
sync_ER = ER*A_F
l_dist_pkg[i], nb_accepts_pkg = distribute_mean_value_lha(sync_ER, :d, nb_sim; with_accepts = true)
#@info "About accepts" nb_sim nb_accepted nb_accepts_pkg
test = isapprox(l_dist_cosmos[i], l_dist_pkg[i]; atol = width*1.01) || 
(l_dist_cosmos[i] == 9997999 && l_dist_pkg[i] == Inf)
test2 = nb_accepts_pkg == (nb_sim / nb_accepted)
global test_all = test_all && test && test2
if !test
@show l_dist_pkg[i], l_dist_cosmos[i]
@show exp
@show k3
@show nb_sim
let test, test2, nb_sim, sync_ER, k3, x1, x2, t1, t2, A_F
x1, x2, t1, t2 = val_exp[1], val_exp[2], val_exp[3], val_exp[4]
A_F = create_automaton_F(model, x1, x2, t1, t2, :P)
# Cosmos estimation
k3 = l_k3[i]
command = `Cosmos $(absolute_path * "models/" * str_model * ".gspn")
$(absolute_path * "distance_F/dist_F_" * str_model * ".lha") --njob $(nworkers())
--const k_3=$(k3),x1=$x1,x2=$x2,t1=$t1,t2=$t2
--level $(level) --width $(width)
--verbose 0`
#run(command)
run(pipeline(command, stderr=devnull))
dict_values = cosmos_get_values("Result_dist_F_$(str_model).res")
l_dist_cosmos[i] = dict_values["Estimated value"][1]
nb_sim = dict_values["Total paths"][1]
nb_accepted = dict_values["Accepted paths"][1]
nb_sim = convert(Int, nb_sim)
# MarkovProcesses estimation
set_param!(ER, :k3, convert(Float64, k3))
sync_ER = ER*A_F
l_dist_pkg[i], nb_accepts_pkg = distribute_mean_value_lha(sync_ER, :d, nb_sim; with_accepts = true)
#@info "About accepts" nb_sim nb_accepted nb_accepts_pkg
test = isapprox(l_dist_cosmos[i], l_dist_pkg[i]; atol = width*1.01) || 
(l_dist_cosmos[i] == 9997999 && l_dist_pkg[i] == Inf)
test2 = nb_accepts_pkg == (nb_sim / nb_accepted)
global test_all = test_all && test && test2
if !test
@show l_dist_pkg[i], l_dist_cosmos[i]
@show exp
@show k3
@show nb_sim
end
end
end
@info exp l_dist_pkg l_dist_cosmos
......
......@@ -29,32 +29,34 @@ mat_full_k1 = zeros(nb_k1,nb_k2)
mat_full_k2 = zeros(nb_k1,nb_k2)
for i = 1:nb_k1
for j = 1:nb_k2
# Cosmos estimation
k1 = l_k1[i]
k2 = l_k2[j]
command = `Cosmos $(absolute_path * "models/" * str_model * ".gspn")
$(absolute_path * "distance_G/dist_G_" * str_model * ".lha") --njob $(nworkers())
--const k_1=$(k1),k_2=$(k2),x1=$x1,x2=$x2,t1=$t1,t2=$t2
--level $(level) --width $(width)
--verbose 0`
run(pipeline(command, stderr=devnull))
dict_values = cosmos_get_values("Result_dist_G_$(str_model).res")
mat_dist_cosmos[i,j] = dict_values["Estimated value"][1]
nb_sim = dict_values["Total paths"][1]
nb_accepted = dict_values["Accepted paths"][1]
nb_sim = convert(Int, nb_sim)
# MarkovProcesses estimation
set_param!(ER, :k1, convert(Float64, k1))
set_param!(ER, :k2, convert(Float64, k2))
sync_ER = ER*A_G
mat_dist_pkg[i,j], nb_accepts_pkg = distribute_mean_value_lha(sync_ER, :d, nb_sim; with_accepts = true)
#@info "About accepts" nb_sim nb_accepted nb_accepts_pkg
test = isapprox(mat_dist_cosmos[i,j], mat_dist_pkg[i,j]; atol = width*1.01)
test2 = nb_accepts_pkg == (nb_sim / nb_accepted)
if !test
@info "Distances too different" (k1,k2) mat_dist_pkg[i,j] mat_dist_cosmos[i,j]
let test, test2, nb_sim, sync_ER, k1, k2
# Cosmos estimation
k1 = l_k1[i]
k2 = l_k2[j]
command = `Cosmos $(absolute_path * "models/" * str_model * ".gspn")
$(absolute_path * "distance_G/dist_G_" * str_model * ".lha") --njob $(nworkers())
--const k_1=$(k1),k_2=$(k2),x1=$x1,x2=$x2,t1=$t1,t2=$t2
--level $(level) --width $(width)
--verbose 0`
run(pipeline(command, stderr=devnull))
dict_values = cosmos_get_values("Result_dist_G_$(str_model).res")
mat_dist_cosmos[i,j] = dict_values["Estimated value"][1]
nb_sim = dict_values["Total paths"][1]
nb_accepted = dict_values["Accepted paths"][1]
nb_sim = convert(Int, nb_sim)
# MarkovProcesses estimation
set_param!(ER, :k1, convert(Float64, k1))
set_param!(ER, :k2, convert(Float64, k2))
sync_ER = ER*A_G
mat_dist_pkg[i,j], nb_accepts_pkg = distribute_mean_value_lha(sync_ER, :d, nb_sim; with_accepts = true)
#@info "About accepts" nb_sim nb_accepted nb_accepts_pkg
test = isapprox(mat_dist_cosmos[i,j], mat_dist_pkg[i,j]; atol = width*1.01)
test2 = nb_accepts_pkg == (nb_sim / nb_accepted)
if !test
@info "Distances too different" (k1,k2) mat_dist_pkg[i,j] mat_dist_cosmos[i,j]
end
global test_all = test_all && test && test2
end
global test_all = test_all && test && test2
end
end
......
......@@ -32,38 +32,40 @@ mat_full_k1 = zeros(nb_k1,nb_k2)
mat_full_k2 = zeros(nb_k1,nb_k2)
for i = 1:nb_k1
for j = 1:nb_k2
# Cosmos estimation
k1 = l_k1[i]
k2 = l_k2[j]
command = `Cosmos $(absolute_path * "models/" * str_model * ".gspn")
$(absolute_path * "distance_G_F/dist_G_F_" * str_model * ".lha") --njob $(nworkers())
--const k_1=$(k1),k_2=$(k2),x1=$x1,x2=$x2,t1=$t1,t2=$t2
--level $(level) --width $(width)
--verbose 0`
run(pipeline(command, stderr=devnull))
dict_values = cosmos_get_values("Result_dist_G_F_$(str_model).res")
mat_dist_cosmos[i,j] = dict_values["Estimated value"][1]
mat_dist_prime_cosmos[i,j] = dict_values["Estimated value"][2]
nb_sim = dict_values["Total paths"][1]
nb_accepted = dict_values["Accepted paths"][1]
nb_sim = convert(Int, nb_sim)
# MarkovProcesses estimation
set_param!(ER, :k1, convert(Float64, k1))
set_param!(ER, :k2, convert(Float64, k2))
sync_ER = ER*A_G_F
mat_dist_pkg[i,j], mat_dist_prime_pkg[i,j], nb_accepts_pkg = distribute_mean_value_lha(sync_ER, [:d,:dprime], nb_sim; with_accepts = true)
#@info "Computed distances" mat_dist_pkg[i,j] mat_dist_prime_pkg[i,j] mat_dist_cosmos[i,j] mat_dist_prime_cosmos[i,j]
#@info "About accepts" nb_sim nb_accepted nb_accepts_pkg
test = (isapprox(mat_dist_cosmos[i,j], mat_dist_pkg[i,j]; atol = width*1.01)) || 
(mat_dist_cosmos[i,j] == 9997999 && mat_dist_pkg[i,j] == Inf)
test2 = nb_accepts_pkg == (nb_sim / nb_accepted)
if !test
@info "Distances too different" (k1,k2) mat_dist_pkg[i,j] mat_dist_prime_pkg[i,j] mat_dist_cosmos[i,j] mat_dist_prime_cosmos[i,j]
let test, test2, nb_sim, sync_ER, k1, k2
# Cosmos estimation
k1 = l_k1[i]
k2 = l_k2[j]
command = `Cosmos $(absolute_path * "models/" * str_model * ".gspn")
$(absolute_path * "distance_G_F/dist_G_F_" * str_model * ".lha") --njob $(nworkers())
--const k_1=$(k1),k_2=$(k2),x1=$x1,x2=$x2,t1=$t1,t2=$t2
--level $(level) --width $(width)
--verbose 0`
run(pipeline(command, stderr=devnull))
dict_values = cosmos_get_values("Result_dist_G_F_$(str_model).res")
mat_dist_cosmos[i,j] = dict_values["Estimated value"][1]
mat_dist_prime_cosmos[i,j] = dict_values["Estimated value"][2]
nb_sim = dict_values["Total paths"][1]
nb_accepted = dict_values["Accepted paths"][1]
nb_sim = convert(Int, nb_sim)
# MarkovProcesses estimation
set_param!(ER, :k1, convert(Float64, k1))
set_param!(ER, :k2, convert(Float64, k2))
sync_ER = ER*A_G_F
mat_dist_pkg[i,j], mat_dist_prime_pkg[i,j], nb_accepts_pkg = distribute_mean_value_lha(sync_ER, [:d,:dprime], nb_sim; with_accepts = true)
#@info "Computed distances" mat_dist_pkg[i,j] mat_dist_prime_pkg[i,j] mat_dist_cosmos[i,j] mat_dist_prime_cosmos[i,j]
#@info "About accepts" nb_sim nb_accepted nb_accepts_pkg
test = (isapprox(mat_dist_cosmos[i,j], mat_dist_pkg[i,j]; atol = width*1.01)) || 
(mat_dist_cosmos[i,j] == 9997999 && mat_dist_pkg[i,j] == Inf)
test2 = nb_accepts_pkg == (nb_sim / nb_accepted)
if !test
@info "Distances too different" (k1,k2) mat_dist_pkg[i,j] mat_dist_prime_pkg[i,j] mat_dist_cosmos[i,j] mat_dist_prime_cosmos[i,j]
end
if !test2
@info "Different proportion of accepted trajectories" nb_sim nb_accepted nb_accepts_pkg
end
global test_all = test_all && test && test2
end
if !test2
@info "Different proportion of accepted trajectories" nb_sim nb_accepted nb_accepts_pkg
end
global test_all = test_all && test && test2
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment