@@ -18,14 +18,13 @@ mutable struct CoevolveJumpAggregation{T, S, F1, F2, RNG, GR, PQ} <:
1818 pq:: PQ # priority queue of next time
1919 lrates:: F1 # vector of rate lower bound functions
2020 urates:: F1 # vector of rate upper bound functions
21- Ls :: F1 # vector of interval length functions
21+ rateintervals :: F1 # vector of interval length functions
2222end
2323
2424function CoevolveJumpAggregation (nj:: Int , njt:: T , et:: T , crs:: Vector{T} , sr:: Nothing ,
2525 maj:: S , rs:: F1 , affs!:: F2 , sps:: Tuple{Bool, Bool} ,
26- rng:: RNG ; u:: U ,
27- dep_graph = nothing ,
28- lrates, urates, Ls) where {T, S, F1, F2, RNG, U}
26+ rng:: RNG ; u:: U , dep_graph = nothing , lrates, urates,
27+ rateintervals) where {T, S, F1, F2, RNG, U}
2928 if dep_graph === nothing
3029 if (get_num_majumps (maj) == 0 ) || ! isempty (rs)
3130 error (" To use Coevolve a dependency graph between jumps must be supplied." )
@@ -47,30 +46,22 @@ function CoevolveJumpAggregation(nj::Int, njt::T, et::T, crs::Vector{T}, sr::Not
4746
4847 pq = MutableBinaryMinHeap {T} ()
4948 CoevolveJumpAggregation{T, S, F1, F2, RNG, typeof (dg),
50- typeof (pq)
51- }(nj, nj, njt,
52- et,
53- crs, sr, maj,
54- rs,
55- affs!, sps,
56- rng,
57- dg, pq,
58- lrates, urates, Ls)
49+ typeof (pq)}(nj, nj, njt, et, crs, sr, maj, rs, affs!, sps, rng,
50+ dg, pq, lrates, urates, rateintervals)
5951end
6052
6153# creating the JumpAggregation structure (tuple-based variable jumps)
6254function aggregate (aggregator:: Coevolve , u, p, t, end_time, constant_jumps,
63- ma_jumps, save_positions, rng;
64- dep_graph = nothing , variable_jumps = nothing ,
65- kwargs... )
55+ ma_jumps, save_positions, rng; dep_graph = nothing ,
56+ variable_jumps = nothing , kwargs... )
6657 AffectWrapper = FunctionWrappers. FunctionWrapper{Nothing, Tuple{Any}}
6758 RateWrapper = FunctionWrappers. FunctionWrapper{typeof (t),
6859 Tuple{typeof (u), typeof (p), typeof (t)}}
6960 affects! = Vector {AffectWrapper} ()
7061 rates = Vector {RateWrapper} ()
7162 lrates = Vector {RateWrapper} ()
7263 urates = Vector {RateWrapper} ()
73- Ls = Vector {RateWrapper} ()
64+ rateintervals = Vector {RateWrapper} ()
7465
7566 if (constant_jumps != = nothing ) && ! isempty (constant_jumps)
7667 append! (affects!,
@@ -86,7 +77,7 @@ function aggregate(aggregator::Coevolve, u, p, t, end_time, constant_jumps,
8677 append! (rates, [RateWrapper (j. rate) for j in variable_jumps])
8778 append! (lrates, [RateWrapper (j. lrate) for j in variable_jumps])
8879 append! (urates, [RateWrapper (j. urate) for j in variable_jumps])
89- append! (Ls , [RateWrapper (j. L ) for j in variable_jumps])
80+ append! (rateintervals , [RateWrapper (j. rateinterval ) for j in variable_jumps])
9081 end
9182
9283 num_jumps = get_num_majumps (ma_jumps) + length (urates)
@@ -96,9 +87,7 @@ function aggregate(aggregator::Coevolve, u, p, t, end_time, constant_jumps,
9687 next_jump_time = typemax (t)
9788 CoevolveJumpAggregation (next_jump, next_jump_time, end_time, cur_rates, sum_rate,
9889 ma_jumps, rates, affects!, save_positions, rng;
99- u = u,
100- dep_graph = dep_graph,
101- lrates = lrates, urates = urates, Ls = Ls)
90+ u, dep_graph, lrates, urates, rateintervals)
10291end
10392
10493# set up a new simulation and calculate the first jump / jump time
144133 @inbounds return p. urates[uidx](u, params, t)
145134end
146135
147- @inline function get_L (p:: CoevolveJumpAggregation , lidx, u, params, t)
148- @inbounds return p. Ls [lidx](u, params, t)
136+ @inline function get_rateinterval (p:: CoevolveJumpAggregation , lidx, u, params, t)
137+ @inbounds return p. rateintervals [lidx](u, params, t)
149138end
150139
151140@inline function get_lrate (p:: CoevolveJumpAggregation , lidx, u, params, t)
@@ -173,9 +162,9 @@ function next_time(p::CoevolveJumpAggregation{T}, u, params, t, i, tstop::T) whe
173162 _t = t + s
174163 if lidx > 0
175164 while t < tstop
176- L = get_L (p, lidx, u, params, t)
177- if s > L
178- t = t + L
165+ rateinterval = get_rateinterval (p, lidx, u, params, t)
166+ if s > rateinterval
167+ t = t + rateinterval
179168 urate = get_urate (p, uidx, u, params, t)
180169 s = urate == zero (t) ? typemax (t) : randexp (rng) / urate
181170 _t = t + s
0 commit comments