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

forgot a bunch of files related to the last commit

parent 43a3f23f
...@@ -15,6 +15,7 @@ ER.buffer_size = 100 ...@@ -15,6 +15,7 @@ ER.buffer_size = 100
ER.estim_min_states = 8000 ER.estim_min_states = 8000
bench1_pkg = @benchmark simulate(ER) bench1_pkg = @benchmark simulate(ER)
@btime simulate(ER)
@show minimum(bench1_pkg), mean(bench1_pkg), maximum(bench1_pkg) @show minimum(bench1_pkg), mean(bench1_pkg), maximum(bench1_pkg)
rs = @reaction_network begin rs = @reaction_network begin
...@@ -31,6 +32,7 @@ jprob = JumpProblem(rs, dprob, Direct()) ...@@ -31,6 +32,7 @@ jprob = JumpProblem(rs, dprob, Direct())
jsol = solve(jprob, SSAStepper()) jsol = solve(jprob, SSAStepper())
bench1_catalyst = @benchmark solve(jprob, SSAStepper()) bench1_catalyst = @benchmark solve(jprob, SSAStepper())
@btime solve(jprob, SSAStepper())
@show minimum(bench1_catalyst), mean(bench1_catalyst), maximum(bench1_catalyst) @show minimum(bench1_catalyst), mean(bench1_catalyst), maximum(bench1_catalyst)
str_latex_bench1 = " str_latex_bench1 = "
......
module MarkovProcesses module MarkovProcesses
## Imports
import Base: +, -, * import Base: +, -, *
import Base: copy, getfield, getindex, getproperty, lastindex import Base: copy, getfield, getindex, getproperty, lastindex
import Base: setindex!, setproperty!, fill!, copyto! import Base: setindex!, setproperty!, fill!, copyto!
import Distributed: @everywhere, @distributed
import Distributions: Distribution, Product, Uniform, Normal
import Dates import Dates
import Distributed: @everywhere, @distributed
import Distributions: Product, Uniform, Normal
import Distributions: Distribution, Univariate, Continuous, UnivariateDistribution,
MultivariateDistribution, product_distribution
import StaticArrays: SVector import StaticArrays: SVector
## Exports
export Distribution, Product, Uniform, Normal export Distribution, Product, Uniform, Normal
# Common types and constructors # Common types and constructors
......
import Distributions: Distribution, Univariate, Continuous, UnivariateDistribution,
MultivariateDistribution, product_distribution
abstract type Model end abstract type Model end
abstract type ContinuousTimeModel <: Model end abstract type ContinuousTimeModel <: Model end
abstract type AbstractTrajectory end abstract type AbstractTrajectory end
abstract type LHA end
abstract type Edge end
const VariableModel = Symbol const VariableModel = Symbol
const ParameterModel = Symbol const ParameterModel = Symbol
const Transition = Union{Symbol,Nothing} const Transition = Union{Symbol,Nothing}
...@@ -42,27 +43,21 @@ struct Trajectory <: AbstractTrajectory ...@@ -42,27 +43,21 @@ struct Trajectory <: AbstractTrajectory
transitions::Vector{Transition} transitions::Vector{Transition}
end end
#= function generate_code_lha_type_def(lha_name::Symbol, edge_type::Symbol)
struct Edge return quote
transitions::Union{Nothing,Vector{Symbol}} struct $(lha_name) <: LHA
check_constraints::Function transitions::Vector{Transition}
update_state!::Function locations::Vector{Location}
end Λ::Dict{Location,Function}
=# locations_init::Vector{Location}
abstract type Edge end locations_final::Vector{Location}
map_var_automaton_idx::Dict{VariableAutomaton,Int} # nvar keys : str_var => idx in values
struct LHA flow::Dict{Location,Vector{Float64}} # output of length nvar
name::String map_edges::Dict{Location, Dict{Location,Vector{$(edge_type)}}}
transitions::Vector{Transition} constants::Dict{Symbol,Float64}
locations::Vector{Location} map_var_model_idx::Dict{VariableModel,Int} # of dim d (of a model)
Λ::Dict{Location,Function} end
locations_init::Vector{Location} end
locations_final::Vector{Location}
map_var_automaton_idx::Dict{VariableAutomaton,Int} # nvar keys : str_var => idx in values
flow::Dict{Location,Vector{Float64}} # output of length nvar
map_edges::Dict{Location, Dict{Location,Vector{Edge}}}
constants::Dict{Symbol,Float64}
map_var_model_idx::Dict{VariableModel,Int} # of dim d (of a model)
end end
mutable struct StateLHA mutable struct StateLHA
...@@ -123,9 +118,9 @@ function generate_code_model_type_constructor(model_name::Symbol) ...@@ -123,9 +118,9 @@ function generate_code_model_type_constructor(model_name::Symbol)
end end
end end
LHA(A::LHA, map_var::Dict{VariableModel,Int}) = LHA(A.name, A.transitions, A.locations, A.Λ, LHA(A::LHA, map_var::Dict{VariableModel,Int}) =
A.locations_init, A.locations_final, A.map_var_automaton_idx, A.flow, getfield(Main, Symbol(typeof(A)))(A.transitions, A.locations, A.Λ, A.locations_init, A.locations_final,
A.map_edges, A.constants, map_var) A.map_var_automaton_idx, A.flow, A.map_edges, A.constants, map_var)
Base.:*(m::ContinuousTimeModel, A::LHA) = SynchronizedModel(m, A) Base.:*(m::ContinuousTimeModel, A::LHA) = SynchronizedModel(m, A)
Base.:*(A::LHA, m::ContinuousTimeModel) = SynchronizedModel(m, A) Base.:*(A::LHA, m::ContinuousTimeModel) = SynchronizedModel(m, A)
......
...@@ -145,7 +145,7 @@ macro network_model(expr_network,expr_name...) ...@@ -145,7 +145,7 @@ macro network_model(expr_network,expr_name...)
# Creation of names variables # Creation of names variables
model_name = isempty(expr_name) ? "Network" : expr_name[1] model_name = isempty(expr_name) ? "Network" : expr_name[1]
model_name = Symbol(replace(model_name, ' ' => '_') * "Model") model_name = Symbol(replace(model_name, ' ' => '_') * "Model")
id = Dates.format(Dates.now(), "YmHMs") id = MarkovProcesses.newid()
nbr_reactions = length(list_expr_reactions) nbr_reactions = length(list_expr_reactions)
basename_func = "$(model_name)_$(id)" basename_func = "$(model_name)_$(id)"
basename_func = replace(basename_func, '-'=>'_') basename_func = replace(basename_func, '-'=>'_')
......
...@@ -27,3 +27,5 @@ load_model(name_model::String) = Base.MainInclude.include("$(get_module_path())/ ...@@ -27,3 +27,5 @@ load_model(name_model::String) = Base.MainInclude.include("$(get_module_path())/
load_automaton(automaton::String) = Base.MainInclude.include("$(get_module_path())/automata/$(automaton).jl") load_automaton(automaton::String) = Base.MainInclude.include("$(get_module_path())/automata/$(automaton).jl")
load_plots() = Base.MainInclude.include(get_module_path() * "/core/plots.jl") load_plots() = Base.MainInclude.include(get_module_path() * "/core/plots.jl")
newid() = Dates.format(Dates.now(), "YmHMs")
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