Skip to content

Commit 23251da

Browse files
Remove unrelated formatting changes
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent f0e4c3a commit 23251da

8 files changed

Lines changed: 323 additions & 513 deletions

File tree

src/JumpProcesses.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ import SymbolicIndexingInterface as SII
3636

3737
# Import additional types and functions from DiffEqBase and SciMLBase
3838
using DiffEqBase: DiffEqBase, CallbackSet, ContinuousCallback, DAEFunction,
39-
DDEFunction, DiscreteProblem, ODEFunction, ODEProblem,
40-
ODESolution, ReturnCode, SDEFunction, SDEProblem, add_tstop!,
41-
deleteat!, isinplace, remake, savevalues!, step!,
42-
derivative_discontinuity!
39+
DDEFunction, DiscreteProblem, ODEFunction, ODEProblem,
40+
ODESolution, ReturnCode, SDEFunction, SDEProblem, add_tstop!,
41+
deleteat!, isinplace, remake, savevalues!, step!,
42+
derivative_discontinuity!
4343
using SciMLBase: SciMLBase, DEIntegrator
4444

4545
abstract type AbstractJump end
4646
abstract type AbstractMassActionJump <: AbstractJump end
4747
abstract type AbstractAggregatorAlgorithm end
4848
abstract type AbstractJumpAggregator end
4949
abstract type AbstractSSAIntegrator{Alg, IIP, U, T} <:
50-
DEIntegrator{Alg, IIP, U, T} end
50+
DEIntegrator{Alg, IIP, U, T} end
5151

5252
const DEFAULT_RNG = Random.default_rng()
5353

@@ -156,7 +156,7 @@ export init, solve, solve!
156156
include("SSA_stepper.jl")
157157
export SSAStepper
158158

159-
# leaping:
159+
# leaping:
160160
include("simple_regular_solve.jl")
161161
export SimpleTauLeaping, SimpleExplicitTauLeaping, EnsembleGPUKernel
162162

src/aggregators/aggregators.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,8 @@ algorithm with optimal binning, Journal of Chemical Physics 143, 074108
172172
"""
173173
struct DirectCRDirect <: AbstractAggregatorAlgorithm end
174174

175-
const JUMP_AGGREGATORS = (
176-
Direct(), DirectFW(), DirectCR(), SortingDirect(), RSSA(), FRM(),
177-
FRMFW(), NRM(), RSSACR(), RDirect(), Coevolve(), CCNRM(),
178-
)
175+
const JUMP_AGGREGATORS = (Direct(), DirectFW(), DirectCR(), SortingDirect(), RSSA(), FRM(),
176+
FRMFW(), NRM(), RSSACR(), RDirect(), Coevolve(), CCNRM())
179177

180178
# For JumpProblem construction without an aggregator
181179
struct NullAggregator <: AbstractAggregatorAlgorithm end
@@ -257,11 +255,9 @@ is_spatial(aggregator::NSM) = true
257255
is_spatial(aggregator::DirectCRDirect) = true
258256

259257
# return the fastest aggregator out of the available ones
260-
function select_aggregator(
261-
jumps::JumpSet; vartojumps_map = nothing,
258+
function select_aggregator(jumps::JumpSet; vartojumps_map = nothing,
262259
jumptovars_map = nothing, dep_graph = nothing, spatial_system = nothing,
263-
hopping_constants = nothing
264-
)
260+
hopping_constants = nothing)
265261

266262
# detect if a spatial SSA should be used
267263
!isnothing(spatial_system) && !isnothing(hopping_constants) && return DirectCRDirect

src/aggregators/bracketing.jl

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# bracketing intervals for RSSA-based aggregators
2+
# see: "On the rejection-based algorithm for simulation and analysis of
3+
# large-scale reaction networks", Thanh et al, J. Chem. Phys., 2015
4+
# note, expects the type of the bracketing variables [ulow,uhigh] to be the
5+
# same as the fluct_rate and ushift.
16
"""
27
BracketData(fluctrate, threshold, Δu)
38
BracketData{T1, T2}()
@@ -31,9 +36,9 @@ bd.fluctrate == 0.1
3136
```
3237
"""
3338
struct BracketData{T1, T2}
34-
fluctrate::T1
35-
threshold::T2
36-
Δu::T2
39+
fluctrate::T1 # interval should be [1-fluctrate,1+fluctrate] * u
40+
threshold::T2 # for u below threshold interval is:
41+
Δu::T2 # [max(u-Δu,0),u+Δu]
3742
end
3843

3944
# # suggested defaults
@@ -53,7 +58,7 @@ BracketData{T1, T2}() where {T1, T2} = BracketData(T1(0.1), T2(25), T2(4))
5358
@inline getΔu(bd::BracketData{T1, T2}, i) where {T1, T2 <: Number} = bd.Δu
5459

5560
@inline function delta_bracket(u::Integer, δ)
56-
return (trunc(typeof(u), (one(δ) - δ) * u), trunc(typeof(u), (one(δ) + δ) * u))
61+
(trunc(typeof(u), (one(δ) - δ) * u), trunc(typeof(u), (one(δ) + δ) * u))
5762
end
5863

5964
@inline delta_bracket(u, δ) = ((one(δ) - δ) * u), ((one(δ) + δ) * u)
@@ -75,7 +80,7 @@ end
7580

7681
# Get propensity brackets of massaction jump k.
7782
@inline function get_majump_brackets(ulow, uhigh, k, majumps)
78-
return evalrxrate(ulow, k, majumps), evalrxrate(uhigh, k, majumps)
83+
evalrxrate(ulow, k, majumps), evalrxrate(uhigh, k, majumps)
7984
end
8085

8186
# for constant rate jumps we must check the ordering of the bracket values
@@ -95,10 +100,8 @@ get brackets for the rate of reaction rx by first checking if the reaction is a
95100
if rx <= num_majumps
96101
return get_majump_brackets(p.ulow, p.uhigh, rx, ma_jumps)
97102
else
98-
@inbounds return get_cjump_brackets(
99-
p.ulow, p.uhigh, p.rates[rx - num_majumps],
100-
params, t
101-
)
103+
@inbounds return get_cjump_brackets(p.ulow, p.uhigh, p.rates[rx - num_majumps],
104+
params, t)
102105
end
103106
end
104107

@@ -108,7 +111,7 @@ end
108111
@inbounds for (i, uval) in enumerate(u)
109112
ulow[i], uhigh[i] = get_spec_brackets(p.bracket_data, i, uval)
110113
end
111-
return nothing
114+
nothing
112115
end
113116

114117
@inline function update_u_brackets!(p::AbstractSSAJumpAggregator, u::SVector)
@@ -117,12 +120,12 @@ end
117120
p.ulow = setindex(p.ulow, ulow, i)
118121
p.uhigh = setindex(p.uhigh, uhigh, i)
119122
end
120-
return nothing
123+
nothing
121124
end
122125

123126
# For ExtendedJumpArray, only iterate over the species portion (u.u), not the jump tracking portion
124127
@inline function update_u_brackets!(p::AbstractSSAJumpAggregator, u::ExtendedJumpArray)
125-
return update_u_brackets!(p, u.u)
128+
update_u_brackets!(p, u.u)
126129
end
127130

128131
# Set up bracketing. The aggregator must have fields
@@ -151,5 +154,5 @@ function set_bracketing!(p::AbstractSSAJumpAggregator, u, params, t)
151154
end
152155
p.sum_rate = sum_rate
153156

154-
return nothing
157+
nothing
155158
end

0 commit comments

Comments
 (0)