From 80eb2e368dfc76eb3e7b2c6dd4151fff855f1cdb Mon Sep 17 00:00:00 2001 From: Mahmoud Bentriou <mahmoud.bentriou@centralesupelec.fr> Date: Thu, 10 Dec 2020 01:14:24 +0100 Subject: [PATCH] Fix about types of transition arrays --- core/common.jl | 13 +++++++------ models/ER.jl | 2 +- models/SIR.jl | 2 +- models/SIR_tauleap.jl | 2 +- models/_bench_perf_test/ER_col.jl | 2 +- models/_bench_perf_test/ER_col_buffer.jl | 2 +- models/_bench_perf_test/ER_row_buffer.jl | 2 +- models/_bench_perf_test/SIR_col.jl | 2 +- models/_bench_perf_test/SIR_col_buffer.jl | 2 +- models/_bench_perf_test/SIR_row_buffer.jl | 2 +- models/poisson.jl | 2 +- 11 files changed, 17 insertions(+), 16 deletions(-) diff --git a/core/common.jl b/core/common.jl index 56987bf..b3b129f 100644 --- a/core/common.jl +++ b/core/common.jl @@ -18,7 +18,7 @@ mutable struct ContinuousTimeModel <: Model map_var_idx::Dict{VariableModel,Int} # maps variable str to index in the state space _map_obs_var_idx::Dict{VariableModel,Int} # maps variable str to index in the observed state space map_param_idx::Dict{ParameterModel,Int} # maps parameter str to index in the parameter space - transitions::Vector{<:Transition} + transitions::Vector{Transition} p::Vector{Float64} x0::Vector{Int} t0::Float64 @@ -35,17 +35,17 @@ struct Trajectory <: AbstractTrajectory m::ContinuousTimeModel values::Vector{Vector{Int}} times::Vector{Float64} - transitions::Vector{<:Transition} + transitions::Vector{Transition} end struct Edge - transitions::Vector{<:Transition} + transitions::Vector{Transition} check_constraints::Function update_state!::Function end struct LHA - transitions::Vector{<:Transition} + transitions::Vector{Transition} locations::Vector{Location} Λ::Dict{Location,Function} locations_init::Vector{Location} @@ -74,7 +74,7 @@ struct SynchronizedTrajectory <: AbstractTrajectory sm::SynchronizedModel values::Vector{Vector{Int}} times::Vector{Float64} - transitions::Vector{<:Transition} + transitions::Vector{Transition} end struct ParametricModel @@ -86,12 +86,13 @@ end # Constructors function ContinuousTimeModel(dim_state::Int, dim_params::Int, map_var_idx::Dict{VariableModel,Int}, - map_param_idx::Dict{ParameterModel,Int}, transitions::Vector{<:Transition}, + map_param_idx::Dict{ParameterModel,Int}, transitions::Vector{<:Transition}, p::Vector{Float64}, x0::Vector{Int}, t0::Float64, f!::Function, isabsorbing::Function; g::Vector{VariableModel} = keys(map_var_idx), time_bound::Float64 = Inf, buffer_size::Int = 10, estim_min_states::Int = 50, name::String = "Unnamed") dim_obs_state = length(g) + transitions = convert(Vector{Transition}, transitions) _map_obs_var_idx = Dict() _g_idx = Vector{Int}(undef, dim_obs_state) for i = 1:dim_obs_state diff --git a/models/ER.jl b/models/ER.jl index f4d7312..b2d0d0c 100644 --- a/models/ER.jl +++ b/models/ER.jl @@ -9,7 +9,7 @@ l_tr_ER = [:R1,:R2,:R3] p_ER = [1.0, 1.0, 1.0] x0_ER = [100, 100, 0, 0] t0_ER = 0.0 -function ER_f!(xnplus1::Vector{Int}, l_t::Vector{Float64}, l_tr::Vector{<:Transition}, +function ER_f!(xnplus1::Vector{Int}, l_t::Vector{Float64}, l_tr::Vector{Transition}, xn::Vector{Int}, tn::Float64, p::Vector{Float64}) @inbounds a1 = p[1] * xn[1] * xn[2] @inbounds a2 = p[2] * xn[3] diff --git a/models/SIR.jl b/models/SIR.jl index 1b4e953..7161169 100644 --- a/models/SIR.jl +++ b/models/SIR.jl @@ -9,7 +9,7 @@ l_tr_SIR = [:R1,:R2] p_SIR = [0.0012, 0.05] x0_SIR = [95, 5, 0] t0_SIR = 0.0 -function SIR_f!(xnplus1::Vector{Int}, l_t::Vector{Float64}, l_tr::Vector{<:Transition}, +function SIR_f!(xnplus1::Vector{Int}, l_t::Vector{Float64}, l_tr::Vector{Transition}, xn::Vector{Int}, tn::Float64, p::Vector{Float64}) @inbounds a1 = p[1] * xn[1] * xn[2] @inbounds a2 = p[2] * xn[2] diff --git a/models/SIR_tauleap.jl b/models/SIR_tauleap.jl index 22dd799..40a07d0 100644 --- a/models/SIR_tauleap.jl +++ b/models/SIR_tauleap.jl @@ -10,7 +10,7 @@ l_tr_SIR_tauleap = [:U] p_SIR_tauleap = [0.0012, 0.05, 5.0] x0_SIR_tauleap = [95, 5, 0] t0_SIR_tauleap = 0.0 -function SIR_tauleap_f!(xnplus1::Vector{Int}, l_t::Vector{Float64}, l_tr::Vector{<:Transition}, +function SIR_tauleap_f!(xnplus1::Vector{Int}, l_t::Vector{Float64}, l_tr::Vector{Transition}, xn::Vector{Int}, tn::Float64, p::Vector{Float64}) tau = p[3] a1 = p[1] * xn[1] * xn[2] diff --git a/models/_bench_perf_test/ER_col.jl b/models/_bench_perf_test/ER_col.jl index 1354cd7..0cbc2d8 100644 --- a/models/_bench_perf_test/ER_col.jl +++ b/models/_bench_perf_test/ER_col.jl @@ -10,7 +10,7 @@ p = [1.0, 1.0, 1.0] x0 = [100, 100, 0, 0] t0 = 0.0 -function ER_col_f!(xnplus1::Vector{Int}, tnplus1::Vector{Float64}, tr::Vector{<:Transition}, +function ER_col_f!(xnplus1::Vector{Int}, tnplus1::Vector{Float64}, tr::Vector{Transition}, xn::AbstractVector{Int}, tn::Float64, p::Vector{Float64}) a1 = p[1] * xn[1] * xn[2] a2 = p[2] * xn[3] diff --git a/models/_bench_perf_test/ER_col_buffer.jl b/models/_bench_perf_test/ER_col_buffer.jl index b975fca..f826f03 100644 --- a/models/_bench_perf_test/ER_col_buffer.jl +++ b/models/_bench_perf_test/ER_col_buffer.jl @@ -9,7 +9,7 @@ l_tr = [:R1,:R2,:R3] p = [1.0, 1.0, 1.0] x0 = [100, 100, 0, 0] t0 = 0.0 -function ER_col_buffer_f!(mat_x::Matrix{Int}, l_t::Vector{Float64}, l_tr::Vector{<:Transition}, idx::Int, +function ER_col_buffer_f!(mat_x::Matrix{Int}, l_t::Vector{Float64}, l_tr::Vector{Transition}, idx::Int, xn::AbstractVector{Int}, tn::Float64, p::Vector{Float64}) a1 = p[1] * xn[1] * xn[2] a2 = p[2] * xn[3] diff --git a/models/_bench_perf_test/ER_row_buffer.jl b/models/_bench_perf_test/ER_row_buffer.jl index e8e66e2..395cbaa 100644 --- a/models/_bench_perf_test/ER_row_buffer.jl +++ b/models/_bench_perf_test/ER_row_buffer.jl @@ -9,7 +9,7 @@ l_tr = [:R1,:R2,:R3] p = [1.0, 1.0, 1.0] x0 = [100, 100, 0, 0] t0 = 0.0 -function ER_row_buffer_f!(mat_x::Matrix{Int}, l_t::Vector{Float64}, l_tr::Vector{<:Transition}, idx::Int, +function ER_row_buffer_f!(mat_x::Matrix{Int}, l_t::Vector{Float64}, l_tr::Vector{Transition}, idx::Int, xn::AbstractVector{Int}, tn::Float64, p::Vector{Float64}) a1 = p[1] * xn[1] * xn[2] a2 = p[2] * xn[3] diff --git a/models/_bench_perf_test/SIR_col.jl b/models/_bench_perf_test/SIR_col.jl index 8bf497f..3a26155 100644 --- a/models/_bench_perf_test/SIR_col.jl +++ b/models/_bench_perf_test/SIR_col.jl @@ -9,7 +9,7 @@ l_tr = [:R1,:R2] p = [0.0012, 0.05] x0 = [95, 5, 0] t0 = 0.0 -function SIR_col_f!(xnplus1::Vector{Int}, tnplus1::Vector{Float64}, tr::Vector{<:Transition}, +function SIR_col_f!(xnplus1::Vector{Int}, tnplus1::Vector{Float64}, tr::Vector{Transition}, xn::AbstractVector{Int}, tn::Float64, p::Vector{Float64}) a1 = p[1] * xn[1] * xn[2] a2 = p[2] * xn[2] diff --git a/models/_bench_perf_test/SIR_col_buffer.jl b/models/_bench_perf_test/SIR_col_buffer.jl index cecf5f0..599dd59 100644 --- a/models/_bench_perf_test/SIR_col_buffer.jl +++ b/models/_bench_perf_test/SIR_col_buffer.jl @@ -9,7 +9,7 @@ l_tr = [:R1,:R2] p = [0.0012, 0.05] x0 = [95, 5, 0] t0 = 0.0 -function SIR_col_buffer_f!(mat_x::Matrix{Int}, l_t::Vector{Float64}, l_tr::Vector{<:Transition}, idx::Int, +function SIR_col_buffer_f!(mat_x::Matrix{Int}, l_t::Vector{Float64}, l_tr::Vector{Transition}, idx::Int, xn::AbstractVector{Int}, tn::Float64, p::Vector{Float64}) a1 = p[1] * xn[1] * xn[2] a2 = p[2] * xn[2] diff --git a/models/_bench_perf_test/SIR_row_buffer.jl b/models/_bench_perf_test/SIR_row_buffer.jl index d8cae69..b6ba1cd 100644 --- a/models/_bench_perf_test/SIR_row_buffer.jl +++ b/models/_bench_perf_test/SIR_row_buffer.jl @@ -9,7 +9,7 @@ l_tr = [:R1,:R2] p = [0.0012, 0.05] x0 = [95, 5, 0] t0 = 0.0 -function SIR_row_buffer_f!(mat_x::Matrix{Int}, l_t::Vector{Float64}, l_tr::Vector{<:Transition}, idx::Int, +function SIR_row_buffer_f!(mat_x::Matrix{Int}, l_t::Vector{Float64}, l_tr::Vector{Transition}, idx::Int, xn::AbstractVector{Int}, tn::Float64, p::Vector{Float64}) a1 = p[1] * xn[1] * xn[2] a2 = p[2] * xn[2] diff --git a/models/poisson.jl b/models/poisson.jl index 0f107b2..c0133ae 100644 --- a/models/poisson.jl +++ b/models/poisson.jl @@ -10,7 +10,7 @@ l_tr_poisson = [:R] p_poisson = [5.0] x0_poisson = [0] t0_poisson = 0.0 -function poisson_f!(xnplus1::Vector{Int}, l_t::Vector{Float64}, l_tr::Vector{<:Transition}, +function poisson_f!(xnplus1::Vector{Int}, l_t::Vector{Float64}, l_tr::Vector{Transition}, xn::Vector{Int}, tn::Float64, p::Vector{Float64}) u1 = rand() -- GitLab