Skip to content

Commit aac881e

Browse files
committed
Added a builder pattern
1 parent 15071b3 commit aac881e

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

src/context.jl

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,49 @@ step_likelihood_api(::Type) = false
2323
track_likelihood_api(::Type) = false
2424
enabled_api(::Type) = false
2525

26-
#=
27-
M = maybe soon. X = yes. ' ' = no.
28-
FTF-S is a first-to-fire version that stores more information.
29-
30-
STEP TRACK ENABLED
31-
NR M M X
32-
Direct X M X
33-
FR X X
34-
FR-T X X X
35-
FTF
36-
FTF-S X X
37-
FTF-ST X X X
38-
Petri X X
39-
Petri-T X X X
40-
=#
41-
42-
function make_sampler(
43-
;
26+
27+
struct SamplerBuilderGroup
28+
name::Symbol
29+
selector::Function
30+
frequency_tier::Int64
31+
constant::Bool
32+
sampler::Symbol
33+
end
34+
35+
struct SamplerBuilder{K,T}
36+
clock_type::K
37+
time_type::T
38+
step_likelihood::Bool
39+
trajectory_likelihood::Bool
40+
debug::Bool
41+
recording::Bool
42+
common_random::Bool
43+
group::Vector{SamplerBuilderGroup}
44+
end
45+
46+
function SamplerBuilder(::Type{K}, ::Type{T};
47+
step_likelihood=false,
48+
trajectory_likelihood=false,
49+
debug=false,
50+
recording=false,
51+
common_random=false,
52+
) where {K,T}
53+
SamplerBuilder{K,T}(K, T, step_likelihood, trajectory_likelihood, debug, recording, common_random)
54+
end
55+
56+
function add_group!(
57+
builder::SamplerBuilder,
58+
name::Symbol; # User-given name for this sampler.
59+
selector::Function, # Which clocks use this sampler.
60+
frequency_tier::Int64=1, # Higher number = more churn.
61+
constant::Bool=false, # Constant hazards, ie Exponential.
62+
sampler::Symbol=:any, # Ask for specific sampler.
4463
)
64+
push!(builder.group,
65+
SamplerBuilderGroup(
66+
name, selector, frequency_tier, constant, sampler
67+
)
68+
)
4569
end
4670

4771

0 commit comments

Comments
 (0)