Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bentriou Mahmoud
MarkovProcesses.jl
Commits
e8d15bd4
Commit
e8d15bd4
authored
Feb 21, 2021
by
Bentriou Mahmoud
Browse files
forgot a bunch of files related to the last commit
parent
43a3f23f
Changes
5
Hide whitespace changes
Inline
Side-by-side
bench/pkg/catalyst.jl
View file @
e8d15bd4
...
...
@@ -15,6 +15,7 @@ ER.buffer_size = 100
ER
.
estim_min_states
=
8000
bench1_pkg
=
@benchmark
simulate
(
ER
)
@btime
simulate
(
ER
)
@show
minimum
(
bench1_pkg
),
mean
(
bench1_pkg
),
maximum
(
bench1_pkg
)
rs
=
@reaction_network
begin
...
...
@@ -31,6 +32,7 @@ jprob = JumpProblem(rs, dprob, Direct())
jsol
=
solve
(
jprob
,
SSAStepper
())
bench1_catalyst
=
@benchmark
solve
(
jprob
,
SSAStepper
())
@btime
solve
(
jprob
,
SSAStepper
())
@show
minimum
(
bench1_catalyst
),
mean
(
bench1_catalyst
),
maximum
(
bench1_catalyst
)
str_latex_bench1
=
"
...
...
core/MarkovProcesses.jl
View file @
e8d15bd4
module
MarkovProcesses
## Imports
import
Base
:
+
,
-
,
*
import
Base
:
copy
,
getfield
,
getindex
,
getproperty
,
lastindex
import
Base
:
setindex!
,
setproperty!
,
fill!
,
copyto!
import
Distributed
:
@everywhere
,
@distributed
import
Distributions
:
Distribution
,
Product
,
Uniform
,
Normal
import
Dates
import
Distributed
:
@everywhere
,
@distributed
import
Distributions
:
Product
,
Uniform
,
Normal
import
Distributions
:
Distribution
,
Univariate
,
Continuous
,
UnivariateDistribution
,
MultivariateDistribution
,
product_distribution
import
StaticArrays
:
SVector
## Exports
export
Distribution
,
Product
,
Uniform
,
Normal
# Common types and constructors
...
...
core/common.jl
View file @
e8d15bd4
import
Distributions
:
Distribution
,
Univariate
,
Continuous
,
UnivariateDistribution
,
MultivariateDistribution
,
product_distribution
abstract type
Model
end
abstract type
ContinuousTimeModel
<:
Model
end
abstract type
AbstractTrajectory
end
abstract type
LHA
end
abstract type
Edge
end
const
VariableModel
=
Symbol
const
ParameterModel
=
Symbol
const
Transition
=
Union
{
Symbol
,
Nothing
}
...
...
@@ -42,27 +43,21 @@ struct Trajectory <: AbstractTrajectory
transitions
::
Vector
{
Transition
}
end
#=
struct Edge
transitions::Union{Nothing,Vector{Symbol}}
check_constraints::Function
update_state!::Function
end
=#
abstract type
Edge
end
struct
LHA
name
::
String
transitions
::
Vector
{
Transition
}
locations
::
Vector
{
Location
}
Λ
::
Dict
{
Location
,
Function
}
locations_init
::
Vector
{
Location
}
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)
function
generate_code_lha_type_def
(
lha_name
::
Symbol
,
edge_type
::
Symbol
)
return
quote
struct
$
(
lha_name
)
<:
LHA
transitions
::
Vector
{
Transition
}
locations
::
Vector
{
Location
}
Λ
::
Dict
{
Location
,
Function
}
locations_init
::
Vector
{
Location
}
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_type
)}}}
constants
::
Dict
{
Symbol
,
Float64
}
map_var_model_idx
::
Dict
{
VariableModel
,
Int
}
# of dim d (of a model)
end
end
end
mutable struct
StateLHA
...
...
@@ -123,9 +118,9 @@ function generate_code_model_type_constructor(model_name::Symbol)
end
end
LHA
(
A
::
LHA
,
map_var
::
Dict
{
VariableModel
,
Int
})
=
LHA
(
A
.
name
,
A
.
transitions
,
A
.
locations
,
A
.
Λ
,
A
.
locations
_init
,
A
.
locations_
f
in
al
,
A
.
map_var_autom
aton
_idx
,
A
.
flow
,
A
.
map_edges
,
A
.
constants
,
map_var
)
LHA
(
A
::
LHA
,
map_var
::
Dict
{
VariableModel
,
Int
})
=
getfield
(
Main
,
Symbol
(
typeof
(
A
)))(
A
.
transitions
,
A
.
locations
,
A
.
Λ
,
A
.
locations_in
it
,
A
.
loc
at
i
on
s_final
,
A
.
map_var_automaton_idx
,
A
.
flow
,
A
.
map_edges
,
A
.
constants
,
map_var
)
Base
.:*
(
m
::
ContinuousTimeModel
,
A
::
LHA
)
=
SynchronizedModel
(
m
,
A
)
Base
.:*
(
A
::
LHA
,
m
::
ContinuousTimeModel
)
=
SynchronizedModel
(
m
,
A
)
...
...
core/network_model.jl
View file @
e8d15bd4
...
...
@@ -145,7 +145,7 @@ macro network_model(expr_network,expr_name...)
# Creation of names variables
model_name
=
isempty
(
expr_name
)
?
"Network"
:
expr_name
[
1
]
model_name
=
Symbol
(
replace
(
model_name
,
' '
=>
'_'
)
*
"Model"
)
id
=
Dates
.
format
(
Dates
.
now
(),
"YmHMs"
)
id
=
MarkovProcesses
.
newid
(
)
nbr_reactions
=
length
(
list_expr_reactions
)
basename_func
=
"
$(model_name)
_
$(id)
"
basename_func
=
replace
(
basename_func
,
'-'
=>
'_'
)
...
...
core/utils.jl
View file @
e8d15bd4
...
...
@@ -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_plots
()
=
Base
.
MainInclude
.
include
(
get_module_path
()
*
"/core/plots.jl"
)
newid
()
=
Dates
.
format
(
Dates
.
now
(),
"YmHMs"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment