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

Speed up performance for LHA core files.

Change of signatures of unit functions update_state!, check_constraints
of the automata edges. Use getfield instead of getproperty.

Now the execution of statistical estimation of the distance G is of the
order of Cosmos !
parent 979b7d4f
......@@ -15,7 +15,7 @@ function create_automaton_F(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
#S.n <=> S.values[A.map_var_automaton_idx[:n]]
#P <=> xn[map_var_model_idx[constants[str_O]] with str_O = :P. On stock str_O dans constants
# P = get_value(A, x, sym_obs)
# P = get_value(S, x, sym_obs)
## Map of automaton variables
map_var_automaton_idx = Dict{VariableAutomaton,Int}(:n => 1, :d => 2, :isabs => 3)
......@@ -35,89 +35,89 @@ function create_automaton_F(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
# l0 loc : we construct the edges of the form l0 => (..)
# "cc" as check_constraints
tuple = (:l0, :l1)
cc_aut_F_l0l1_1(A::LHA, S::StateLHA) = true
us_aut_F_l0l1_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_F_l0l1_1(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) = true
us_aut_F_l0l1_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l1;
S[:n] = get_value(A, x, sym_obs);
S[:n] = get_value(S, x, sym_obs);
S[:d] = Inf;
S[:isabs] = m.isabsorbing(m.p,x))
S[:isabs] = getfield(m, :isabsorbing)(getfield(m, :p),x))
edge1 = Edge([nothing], cc_aut_F_l0l1_1, us_aut_F_l0l1_1!)
map_edges[:l0][:l1] = [edge1]
# l1 loc : we construct the edges of the form l1 => (..)
tuple = (:l1, :l2)
cc_aut_F_l1l2_1(A::LHA, S::StateLHA) =
S.time >= A.constants[:t1] &&
(A.constants[:x1] <= S[:n] <= A.constants[:x2])
us_aut_F_l1l2_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_F_l1l2_1(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
getfield(S, :time) >= constants[:t1] &&
(constants[:x1] <= S[:n] <= constants[:x2])
us_aut_F_l1l2_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2;
S[:d] = 0)
edge1 = Edge([nothing], cc_aut_F_l1l2_1, us_aut_F_l1l2_1!)
cc_aut_F_l1l2_4(A::LHA, S::StateLHA) =
S.time >= A.constants[:t1] &&
cc_aut_F_l1l2_4(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
getfield(S, :time) >= constants[:t1] &&
S[:d] == 0
us_aut_F_l1l2_4!(A::LHA, S::StateLHA, x::Vector{Int}) =
us_aut_F_l1l2_4!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2)
edge4 = Edge([nothing], cc_aut_F_l1l2_4, us_aut_F_l1l2_4!)
cc_aut_F_l1l2_2(A::LHA, S::StateLHA) =
(S.time >= A.constants[:t2]) &&
(S[:n] < A.constants[:x1] || S[:n] > A.constants[:x2])
us_aut_F_l1l2_2!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_F_l1l2_2(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(getfield(S, :time) >= constants[:t2]) &&
(S[:n] < constants[:x1] || S[:n] > constants[:x2])
us_aut_F_l1l2_2!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2;
S[:d] = min(abs(S[:n] - A.constants[:x1]), abs(S[:n] - A.constants[:x2])))
S[:d] = min(abs(S[:n] - constants[:x1]), abs(S[:n] - constants[:x2])))
edge2 = Edge([nothing], cc_aut_F_l1l2_2, us_aut_F_l1l2_2!)
cc_aut_F_l1l2_3(A::LHA, S::StateLHA) =
istrue(S[:isabs]) && S.time <= A.constants[:t2]
us_aut_F_l1l2_3!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_F_l1l2_3(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
istrue(S[:isabs]) && getfield(S, :time) <= constants[:t2]
us_aut_F_l1l2_3!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2)
edge3 = Edge([nothing], cc_aut_F_l1l2_3, us_aut_F_l1l2_3!)
map_edges[:l1][:l2] = [edge1, edge2, edge3, edge4]
tuple = (:l1, :l3)
cc_aut_F_l1l3_1(A::LHA, S::StateLHA) =
(A.constants[:x1] <= S[:n] <= A.constants[:x2])
us_aut_F_l1l3_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_F_l1l3_1(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(constants[:x1] <= S[:n] <= constants[:x2])
us_aut_F_l1l3_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3;
S[:d] = 0;)
edge1 = Edge([nothing], cc_aut_F_l1l3_1, us_aut_F_l1l3_1!)
cc_aut_F_l1l3_2(A::LHA, S::StateLHA) =
(S[:n] < A.constants[:x1] || S[:n] > A.constants[:x2]) &&
(S.time <= A.constants[:t1])
us_aut_F_l1l3_2!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_F_l1l3_2(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S[:n] < constants[:x1] || S[:n] > constants[:x2]) &&
(getfield(S, :time) <= constants[:t1])
us_aut_F_l1l3_2!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3;
S[:d] = min(sqrt((S.time - A.constants[:t1])^2 + (S[:n] - A.constants[:x2])^2),
sqrt((S.time - A.constants[:t1])^2 + (S[:n] - A.constants[:x1])^2)))
S[:d] = min(sqrt((getfield(S, :time) - constants[:t1])^2 + (S[:n] - constants[:x2])^2),
sqrt((getfield(S, :time) - constants[:t1])^2 + (S[:n] - constants[:x1])^2)))
edge2 = Edge([nothing], cc_aut_F_l1l3_2, us_aut_F_l1l3_2!)
cc_aut_F_l1l3_3(A::LHA, S::StateLHA) =
(S[:n] < A.constants[:x1] || S[:n] > A.constants[:x2]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2])
us_aut_F_l1l3_3!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_F_l1l3_3(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S[:n] < constants[:x1] || S[:n] > constants[:x2]) &&
(constants[:t1] <= getfield(S, :time) <= constants[:t2])
us_aut_F_l1l3_3!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3;
S[:d] = min(S[:d], min(abs(S[:n] - A.constants[:x1]), abs(S[:n] - A.constants[:x2]))))
S[:d] = min(S[:d], min(abs(S[:n] - constants[:x1]), abs(S[:n] - constants[:x2]))))
edge3 = Edge([nothing], cc_aut_F_l1l3_3, us_aut_F_l1l3_3!)
map_edges[:l1][:l3] = [edge1, edge2, edge3]
# l3 loc
tuple = (:l3, :l1)
cc_aut_F_l3l1_1(A::LHA, S::StateLHA) = true
us_aut_F_l3l1_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_F_l3l1_1(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) = true
us_aut_F_l3l1_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l1;
S[:n] = get_value(A, x, sym_obs);
S[:isabs] = m.isabsorbing(m.p,x))
S[:n] = get_value(S, x, sym_obs);
S[:isabs] = getfield(m, :isabsorbing)(getfield(m, :p),x))
edge1 = Edge([:ALL], cc_aut_F_l3l1_1, us_aut_F_l3l1_1!)
map_edges[:l3][:l1] = [edge1]
tuple = (:l3, :l2)
cc_aut_F_l3l2_1(A::LHA, S::StateLHA) =
(S.time >= A.constants[:t2])
us_aut_F_l3l2_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_F_l3l2_1(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(getfield(S, :time) >= constants[:t2])
us_aut_F_l3l2_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2)
edge1 = Edge([nothing], cc_aut_F_l3l2_1, us_aut_F_l3l2_1!)
map_edges[:l3][:l2] = [edge1]
......
......@@ -34,51 +34,51 @@ function create_automaton_G(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
# l0 loc
tuple = (:l0, :l1)
cc_aut_G_l0l1_1(A::LHA, S::StateLHA) = true
us_aut_G_l0l1_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_G_l0l1_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) = true
us_aut_G_l0l1_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l1;
S[:d] = 0;
S[:n] = get_value(A, x, sym_obs);
S[:n] = get_value(S, x, sym_obs);
S[:in] = true;
S[:isabs] = m.isabsorbing(m.p,x))
S[:isabs] = getfield(m, :isabsorbing)(getfield(m, :p),x))
edge1 = Edge([nothing], cc_aut_G_l0l1_1, us_aut_G_l0l1_1!)
map_edges[:l0][:l1] = [edge1]
# l1 loc
tuple = (:l1, :l3)
cc_aut_G_l1l3_1(A::LHA, S::StateLHA) =
S.time <= A.constants[:t1] &&
S[:n] < A.constants[:x1] || S[:n] > A.constants[:x2]
us_aut_G_l1l3_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_G_l1l3_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
getfield(S, :time) <= constants[:t1] &&
S[:n] < constants[:x1] || S[:n] > constants[:x2]
us_aut_G_l1l3_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3;
S[:d] = min(abs(A.constants[:x1] - S[:n]), abs(A.constants[:x2] - S[:n]));
S[:d] = min(abs(constants[:x1] - S[:n]), abs(constants[:x2] - S[:n]));
S[:in] = false)
edge1 = Edge([nothing], cc_aut_G_l1l3_1, us_aut_G_l1l3_1!)
cc_aut_G_l1l3_3(A::LHA, S::StateLHA) =
cc_aut_G_l1l3_3(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
!istrue(S[:in]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2]) &&
(A.constants[:x1] <= S[:n] <= A.constants[:x2])
us_aut_G_l1l3_3!(A::LHA, S::StateLHA, x::Vector{Int}) =
(constants[:t1] <= getfield(S, :time) <= constants[:t2]) &&
(constants[:x1] <= S[:n] <= constants[:x2])
us_aut_G_l1l3_3!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3;
S[:d] = S[:d] * (S.time - A.constants[:t1]);
S[:d] = S[:d] * (getfield(S, :time) - constants[:t1]);
S[:tprime] = 0.0)
edge3 = Edge([nothing], cc_aut_G_l1l3_3, us_aut_G_l1l3_3!)
cc_aut_G_l1l3_2(A::LHA, S::StateLHA) =
(S.time <= A.constants[:t1]) &&
(A.constants[:x1] <= S[:n] <= A.constants[:x2])
us_aut_G_l1l3_2!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_G_l1l3_2(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
(getfield(S, :time) <= constants[:t1]) &&
(constants[:x1] <= S[:n] <= constants[:x2])
us_aut_G_l1l3_2!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3;
S[:d] = 0;
S[:in] = false)
edge2 = Edge([nothing], cc_aut_G_l1l3_2, us_aut_G_l1l3_2!)
cc_aut_G_l1l3_4(A::LHA, S::StateLHA) =
cc_aut_G_l1l3_4(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
istrue(S[:in]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2]) &&
(A.constants[:x1] <= S[:n] <= A.constants[:x2])
us_aut_G_l1l3_4!(A::LHA, S::StateLHA, x::Vector{Int}) =
(constants[:t1] <= getfield(S, :time) <= constants[:t2]) &&
(constants[:x1] <= S[:n] <= constants[:x2])
us_aut_G_l1l3_4!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3;
S[:tprime] = 0.0)
edge4 = Edge([nothing], cc_aut_G_l1l3_4, us_aut_G_l1l3_4!)
......@@ -86,80 +86,80 @@ function create_automaton_G(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
map_edges[:l1][:l3] = [edge1, edge2, edge3, edge4]
tuple = (:l1, :l4)
cc_aut_G_l1l4_1(A::LHA, S::StateLHA) =
cc_aut_G_l1l4_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
!istrue(S[:in]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2]) &&
(S[:n] < A.constants[:x1] || S[:n] > A.constants[:x2])
us_aut_G_l1l4_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
(constants[:t1] <= getfield(S, :time) <= constants[:t2]) &&
(S[:n] < constants[:x1] || S[:n] > constants[:x2])
us_aut_G_l1l4_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l4;
S[:d] += S[:d] * (S.time - A.constants[:t1]))
S[:d] += S[:d] * (getfield(S, :time) - constants[:t1]))
edge1 = Edge([nothing], cc_aut_G_l1l4_1, us_aut_G_l1l4_1!)
cc_aut_G_l1l4_2(A::LHA, S::StateLHA) =
cc_aut_G_l1l4_2(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
istrue(S[:in]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2]) &&
(S[:n] < A.constants[:x1] || S[:n] > A.constants[:x2])
us_aut_G_l1l4_2!(A::LHA, S::StateLHA, x::Vector{Int}) =
(constants[:t1] <= getfield(S, :time) <= constants[:t2]) &&
(S[:n] < constants[:x1] || S[:n] > constants[:x2])
us_aut_G_l1l4_2!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l4)
edge2 = Edge([nothing], cc_aut_G_l1l4_2, us_aut_G_l1l4_2!)
map_edges[:l1][:l4] = [edge1, edge2]
tuple = (:l1, :l2)
cc_aut_G_l1l2_1(A::LHA, S::StateLHA) =
cc_aut_G_l1l2_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
istrue(S[:in]) &&
S.time >= A.constants[:t2]
us_aut_G_l1l2_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
getfield(S, :time) >= constants[:t2]
us_aut_G_l1l2_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2)
edge1 = Edge([nothing], cc_aut_G_l1l2_1, us_aut_G_l1l2_1!)
cc_aut_G_l1l2_2(A::LHA, S::StateLHA) =
cc_aut_G_l1l2_2(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
!istrue(S[:in]) &&
S.time >= A.constants[:t2]
us_aut_G_l1l2_2!(A::LHA, S::StateLHA, x::Vector{Int}) =
getfield(S, :time) >= constants[:t2]
us_aut_G_l1l2_2!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2;
S[:d] = S[:d] * (A.constants[:t2] - A.constants[:t1]))
S[:d] = S[:d] * (constants[:t2] - constants[:t1]))
edge2 = Edge([nothing], cc_aut_G_l1l2_2, us_aut_G_l1l2_2!)
cc_aut_G_l1l2_3(A::LHA, S::StateLHA) =
cc_aut_G_l1l2_3(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
istrue(S[:isabs]) &&
S.time <= A.constants[:t1]
us_aut_G_l1l2_3!(A::LHA, S::StateLHA, x::Vector{Int}) =
getfield(S, :time) <= constants[:t1]
us_aut_G_l1l2_3!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2;
S[:d] = (A.constants[:t2] - A.constants[:t1]) *
min(abs(A.constants[:x1] - S[:n]), abs(A.constants[:x2] - S[:n])))
S[:d] = (constants[:t2] - constants[:t1]) *
min(abs(constants[:x1] - S[:n]), abs(constants[:x2] - S[:n])))
edge3 = Edge([nothing], cc_aut_G_l1l2_3, us_aut_G_l1l2_3!)
cc_aut_G_l1l2_4(A::LHA, S::StateLHA) =
cc_aut_G_l1l2_4(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
istrue(S[:isabs]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2])
us_aut_G_l1l2_4!(A::LHA, S::StateLHA, x::Vector{Int}) =
(constants[:t1] <= getfield(S, :time) <= constants[:t2])
us_aut_G_l1l2_4!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2;
S[:d] += (A.constants[:t2] - S.time) *
min(abs(A.constants[:x1] - S[:n]), abs(A.constants[:x2] - S[:n])))
S[:d] += (constants[:t2] - getfield(S, :time)) *
min(abs(constants[:x1] - S[:n]), abs(constants[:x2] - S[:n])))
edge4 = Edge([nothing], cc_aut_G_l1l2_4, us_aut_G_l1l2_4!)
map_edges[:l1][:l2] = [edge1, edge2, edge3, edge4]
# l3 loc
tuple = (:l3, :l1)
cc_aut_G_l3l1_1(A::LHA, S::StateLHA) = true
us_aut_G_l3l1_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_G_l3l1_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) = true
us_aut_G_l3l1_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l1;
S[:n] = get_value(A, x, sym_obs);
S[:isabs] = m.isabsorbing(m.p,x))
S[:n] = get_value(S, x, sym_obs);
S[:isabs] = getfield(m, :isabsorbing)(getfield(m, :p),x))
edge1 = Edge([:ALL], cc_aut_G_l3l1_1, us_aut_G_l3l1_1!)
map_edges[:l3][:l1] = [edge1]
tuple = (:l3, :l2)
cc_aut_G_l3l2_2(A::LHA, S::StateLHA) =
cc_aut_G_l3l2_2(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
istrue(S[:in]) &&
S.time >= A.constants[:t2]
us_aut_G_l3l2_2!(A::LHA, S::StateLHA, x::Vector{Int}) =
getfield(S, :time) >= constants[:t2]
us_aut_G_l3l2_2!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2;
S[:d] = S[:d] * (A.constants[:t2] - A.constants[:t1]))
S[:d] = S[:d] * (constants[:t2] - constants[:t1]))
edge2 = Edge([nothing], cc_aut_G_l3l2_2, us_aut_G_l3l2_2!)
cc_aut_G_l3l2_1(A::LHA, S::StateLHA) =
cc_aut_G_l3l2_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
!istrue(S[:in]) &&
S.time >= A.constants[:t2]
us_aut_G_l3l2_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
getfield(S, :time) >= constants[:t2]
us_aut_G_l3l2_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2)
edge1 = Edge([nothing], cc_aut_G_l3l2_1, us_aut_G_l3l2_1!)
......@@ -167,24 +167,24 @@ function create_automaton_G(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
# l4 loc
tuple = (:l4, :l1)
cc_aut_G_l4l1_1(A::LHA, S::StateLHA) = true
us_aut_G_l4l1_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_G_l4l1_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) = true
us_aut_G_l4l1_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l1;
S[:d] += S[:tprime] * min(abs(A.constants[:x1] - S[:n]), abs(A.constants[:x2] - S[:n]));
S[:d] += S[:tprime] * min(abs(constants[:x1] - S[:n]), abs(constants[:x2] - S[:n]));
S[:tprime] = 0.0;
S[:n] = get_value(A, x, sym_obs);
S[:n] = get_value(S, x, sym_obs);
S[:in] = true;
S[:isabs] = m.isabsorbing(m.p,x))
S[:isabs] = getfield(m, :isabsorbing)(getfield(m, :p),x))
edge1 = Edge([:ALL], cc_aut_G_l4l1_1, us_aut_G_l4l1_1!)
map_edges[:l4][:l1] = [edge1]
tuple = (:l4, :l2)
cc_aut_G_l4l2_1(A::LHA, S::StateLHA) =
(S.time >= A.constants[:t2])
us_aut_G_l4l2_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_G_l4l2_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
(getfield(S, :time) >= constants[:t2])
us_aut_G_l4l2_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2;
S[:d] += S[:tprime] * min(abs(A.constants[:x1] - S[:n]), abs(A.constants[:x2] - S[:n]));
S[:d] += S[:tprime] * min(abs(constants[:x1] - S[:n]), abs(constants[:x2] - S[:n]));
S[:tprime] = 0.0)
edge1 = Edge([nothing], cc_aut_G_l4l2_1, us_aut_G_l4l2_1!)
......
......@@ -45,51 +45,51 @@ function create_automaton_G_and_F(m::ContinuousTimeModel, x1::Float64, x2::Float
# l0G loc
tuple = (:l0G, :l1G)
cc_aut_G_l0Gl1G_1(A::LHA, S::StateLHA) = true
us_aut_G_l0Gl1G_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_G_l0Gl1G_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) = true
us_aut_G_l0Gl1G_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l1G;
S[:d] = 0;
S[:n] = get_value(A, x, sym_obs_G);
S[:n] = get_value(S, x, sym_obs_G);
S[:in] = true;
S[:isabs] = m.isabsorbing(m.p,x))
S[:isabs] = getfield(m, :isabsorbing)(getfield(m, :p),x))
edge1 = Edge([nothing], cc_aut_G_l0Gl1G_1, us_aut_G_l0Gl1G_1!)
map_edges[:l0G][:l1G] = [edge1]
# l1G loc
tuple = (:l1G, :l3G)
cc_aut_G_l1Gl3G_1(A::LHA, S::StateLHA) =
S.time <= A.constants[:t1] &&
S[:n] < A.constants[:x1] || S[:n] > A.constants[:x2]
us_aut_G_l1Gl3G_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_G_l1Gl3G_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
getfield(S, :time) <= constants[:t1] &&
S[:n] < constants[:x1] || S[:n] > constants[:x2]
us_aut_G_l1Gl3G_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3G;
S[:d] = min(abs(A.constants[:x1] - S[:n]), abs(A.constants[:x2] - S[:n]));
S[:d] = min(abs(constants[:x1] - S[:n]), abs(constants[:x2] - S[:n]));
S[:in] = false)
edge1 = Edge([nothing], cc_aut_G_l1Gl3G_1, us_aut_G_l1Gl3G_1!)
cc_aut_G_l1Gl3G_3(A::LHA, S::StateLHA) =
cc_aut_G_l1Gl3G_3(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
!istrue(S[:in]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2]) &&
(A.constants[:x1] <= S[:n] <= A.constants[:x2])
us_aut_G_l1Gl3G_3!(A::LHA, S::StateLHA, x::Vector{Int}) =
(constants[:t1] <= getfield(S, :time) <= constants[:t2]) &&
(constants[:x1] <= S[:n] <= constants[:x2])
us_aut_G_l1Gl3G_3!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3G;
S[:d] = S[:d] * (S.time - A.constants[:t1]);
S[:d] = S[:d] * (getfield(S, :time) - constants[:t1]);
S[:tprime] = 0.0)
edge3 = Edge([nothing], cc_aut_G_l1Gl3G_3, us_aut_G_l1Gl3G_3!)
cc_aut_G_l1Gl3G_2(A::LHA, S::StateLHA) =
(S.time <= A.constants[:t1]) &&
(A.constants[:x1] <= S[:n] <= A.constants[:x2])
us_aut_G_l1Gl3G_2!(A::LHA, S::StateLHA, x::Vector{Int}) =
cc_aut_G_l1Gl3G_2(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
(getfield(S, :time) <= constants[:t1]) &&
(constants[:x1] <= S[:n] <= constants[:x2])
us_aut_G_l1Gl3G_2!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3G;
S[:d] = 0;
S[:in] = false)
edge2 = Edge([nothing], cc_aut_G_l1Gl3G_2, us_aut_G_l1Gl3G_2!)
cc_aut_G_l1Gl3G_4(A::LHA, S::StateLHA) =
cc_aut_G_l1Gl3G_4(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
istrue(S[:in]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2]) &&
(A.constants[:x1] <= S[:n] <= A.constants[:x2])
us_aut_G_l1Gl3G_4!(A::LHA, S::StateLHA, x::Vector{Int}) =
(constants[:t1] <= getfield(S, :time) <= constants[:t2]) &&
(constants[:x1] <= S[:n] <= constants[:x2])
us_aut_G_l1Gl3G_4!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l3G;
S[:tprime] = 0.0)
edge4 = Edge([nothing], cc_aut_G_l1Gl3G_4, us_aut_G_l1Gl3G_4!)
......@@ -97,81 +97,81 @@ function create_automaton_G_and_F(m::ContinuousTimeModel, x1::Float64, x2::Float
map_edges[:l1G][:l3G] = [edge1, edge2, edge3, edge4]
tuple = (:l1G, :l4G)
cc_aut_G_l1Gl4G_1(A::LHA, S::StateLHA) =
cc_aut_G_l1Gl4G_1(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
!istrue(S[:in]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2]) &&
(S[:n] < A.constants[:x1] || S[:n] > A.constants[:x2])
us_aut_G_l1Gl4G_1!(A::LHA, S::StateLHA, x::Vector{Int}) =
(constants[:t1] <= getfield(S, :time) <= constants[:t2]) &&
(S[:n] < constants[:x1] || S[:n] > constants[:x2])
us_aut_G_l1Gl4G_1!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l4G;
S[:d] += S[:d] * (S.time - A.constants[:t1]))
S[:d] += S[:d] * (getfield(S, :time) - constants[:t1]))
edge1 = Edge([nothing], cc_aut_G_l1Gl4G_1, us_aut_G_l1Gl4G_1!)
cc_aut_G_l1Gl4G_2(A::LHA, S::StateLHA) =
cc_aut_G_l1Gl4G_2(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
istrue(S[:in]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2]) &&
(S[:n] < A.constants[:x1] || S[:n] > A.constants[:x2])
us_aut_G_l1Gl4G_2!(A::LHA, S::StateLHA, x::Vector{Int}) =
(constants[:t1] <= getfield(S, :time) <= constants[:t2]) &&
(S[:n] < constants[:x1] || S[:n] > constants[:x2])
us_aut_G_l1Gl4G_2!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l4G)
edge2 = Edge([nothing], cc_aut_G_l1Gl4G_2, us_aut_G_l1Gl4G_2!)
map_edges[:l1G][:l4G] = [edge1, edge2]
tuple = (:l1G, :l2G)
cc_aut_G_l1Gl2G_3(A::LHA, S::StateLHA) =
cc_aut_G_l1Gl2G_3(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
istrue(S[:isabs]) &&
S.time <= A.constants[:t1]
us_aut_G_l1Gl2G_3!(A::LHA, S::StateLHA, x::Vector{Int}) =
getfield(S, :time) <= constants[:t1]
us_aut_G_l1Gl2G_3!(S::StateLHA, constants::Dict{Symbol,Float64}, x::Vector{Int}) =
(S.loc = :l2G;
S[:d] = (A.constants[:t2] - A.constants[:t1]) *
min(abs(A.constants[:x1] - S[:n]), abs(A.constants[:x2] - S[:n])))
S[:d] = (constants[:t2] - constants[:t1]) *
min(abs(constants[:x1] - S[:n]), abs(constants[:x2] - S[:n])))
edge3 = Edge([nothing], cc_aut_G_l1Gl2G_3, us_aut_G_l1Gl2G_3!)
cc_aut_G_l1Gl2G_4(A::LHA, S::StateLHA) =
cc_aut_G_l1Gl2G_4(S::StateLHA, constants::Dict{Symbol,Float64}, xn::Vector{Int}) =
istrue(S[:isabs]) &&
(A.constants[:t1] <= S.time <= A.constants[:t2])
us_aut_G_l1Gl2G_4!(A::