Commit 282b4f27 authored by Bentriou Mahmoud's avatar Bentriou Mahmoud
Browse files

small fix g automaton

parent 4221647a
......@@ -175,11 +175,19 @@ function create_automaton_G(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
# l4 => l2
@everywhere $(func_name(:cc, :l4, :l2, 1))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
(getfield(S, :time) >= $t2 || istrue(getfield(S, :values)[$(idx_var_isabs)]))
(istrue(getfield(S, :values)[$(idx_var_isabs)]))
@everywhere $(func_name(:us, :l4, :l2, 1))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
(setfield!(S, :loc, Symbol("l2"));
setindex!(getfield(S, :values), getfield(S, :values)[$(idx_var_d)] + ($t2 - getfield(S, :time)) * min(abs($x1 - getfield(S, :values)[$(idx_var_n)]), abs($x2 - getfield(S, :values)[$(idx_var_n)])), $(idx_var_d));
setindex!(getfield(S, :values), 0.0, $(idx_var_tprime)))
@everywhere $(func_name(:cc, :l4, :l2, 2))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
(getfield(S, :time) >= $t2)
@everywhere $(func_name(:us, :l4, :l2, 2))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
(setfield!(S, :loc, Symbol("l2"));
setindex!(getfield(S, :values), getfield(S, :values)[$(idx_var_d)] + getfield(S, :values)[$(idx_var_tprime)] * min(abs($x1 - getfield(S, :values)[$(idx_var_n)]), abs($x2 - getfield(S, :values)[$(idx_var_n)])), $(idx_var_d));
setindex!(getfield(S, :values), 0.0, $(idx_var_tprime)))
end
eval(meta_elementary_functions)
......@@ -227,7 +235,8 @@ function create_automaton_G(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
# l4 => l2
edge1 = Edge([nothing], getfield(Main, func_name(:cc, :l4, :l2, 1)), getfield(Main, func_name(:us, :l4, :l2, 1)))
map_edges[:l4][:l2] = [edge1]
edge2 = Edge([nothing], getfield(Main, func_name(:cc, :l4, :l2, 2)), getfield(Main, func_name(:us, :l4, :l2, 2)))
map_edges[:l4][:l2] = [edge1,edge2]
## Constants
constants = Dict{Symbol,Float64}(:x1 => x1, :x2 => x2, :t1 => t1, :t2 => t2)
......
......@@ -191,11 +191,18 @@ function create_automaton_G_and_F(m::ContinuousTimeModel, x1::Float64, x2::Float
# l4G => l2G
@everywhere $(func_name(:cc, :l4G, :l2G, 1))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
(getfield(S, :time) >= $t2 || istrue(getfield(S, :values)[$(idx_var_isabs)]))
(istrue(getfield(S, :values)[$(idx_var_isabs)]))
@everywhere $(func_name(:us, :l4G, :l2G, 1))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
(setfield!(S, :loc, Symbol("l2G"));
setindex!(getfield(S, :values), getfield(S, :values)[$(idx_var_d)] + ($t2 - getfield(S, :time)) * min(abs($x1 - getfield(S, :values)[$(idx_var_n)]), abs($x2 - getfield(S, :values)[$(idx_var_n)])), $(idx_var_d));)
@everywhere $(func_name(:cc, :l4G, :l2G, 2))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
(getfield(S, :time) >= $t2)
@everywhere $(func_name(:us, :l4G, :l2G, 2))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
(setfield!(S, :loc, Symbol("l2G"));
setindex!(getfield(S, :values), getfield(S, :values)[$(idx_var_d)] + getfield(S, :values)[$(idx_var_tprime)] * min(abs($x1 - getfield(S, :values)[$(idx_var_n)]), abs($x2 - getfield(S, :values)[$(idx_var_n)])), $(idx_var_d));)
# Connection between the two automata: l2G => l1F
@everywhere $(func_name(:cc, :l2G, :l1F, 1))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) = true
@everywhere $(func_name(:us, :l2G, :l1F, 1))(S::StateLHA, x::Vector{Int}, p::Vector{Float64}) =
......@@ -316,7 +323,8 @@ function create_automaton_G_and_F(m::ContinuousTimeModel, x1::Float64, x2::Float
# l4G => l2G
edge1 = Edge([nothing], getfield(Main, func_name(:cc, :l4G, :l2G, 1)), getfield(Main, func_name(:us, :l4G, :l2G, 1)))
map_edges[:l4G][:l2G] = [edge1]
edge2 = Edge([nothing], getfield(Main, func_name(:cc, :l4G, :l2G, 2)), getfield(Main, func_name(:us, :l4G, :l2G, 2)))
map_edges[:l4G][:l2G] = [edge1,edge2]
# l2G loc
# l2G => l1F : Transition from autF to autG
......
......@@ -58,6 +58,6 @@ Edges={
((l4,l1), ALL, t>=0, {d=d+tprime*min(((n-x1)^2)^0.5,((n-x2)^2)^0.5),tprime=0,n=E,in=1,test_abs=k_1*(E*S)+(k_2+k_3)*ES});
((l4,l2), #, t>=t2, {d=d+tprime*min(((n-x1)^2)^0.5,((n-x2)^2)^0.5)});
((l4,l2), #, test_abs=0, {d=d+tprime*min(((n-x1)^2)^0.5,((n-x2)^2)^0.5)});
((l4,l2), #, test_abs=0, {d=d+(t2-t)*min(((n-x1)^2)^0.5,((n-x2)^2)^0.5)});
};
......@@ -58,7 +58,7 @@ Edges={
((l4G,l1G), ALL, t>=0, {d=d+tprime*min(((n-x1)^2)^0.5,((n-x2)^2)^0.5),tprime=0,n=E,in=1,test_abs=k_1*(E*S)+(k_2+k_3)*ES});
((l4G,l2G), #, t>=t2, {d=d+tprime*min(((n-x1)^2)^0.5,((n-x2)^2)^0.5)});
((l4G,l2G), #, test_abs=0, {d=d+tprime*min(((n-x1)^2)^0.5,((n-x2)^2)^0.5)});
((l4G,l2G), #, test_abs=0, {d=d+(t2-t)*min(((n-x1)^2)^0.5,((n-x2)^2)^0.5)});
% From G to F automaton
((l2G,l1F), #, t>=0, {n=P,test_abs=k_1*(E*S)+(k_2+k_3)*ES,dprime=9997999});
......
Supports Markdown
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