Skip to content

Commit

Permalink
Merge pull request #437 from isaacsas/make_switchvals_constants
Browse files Browse the repository at this point in the history
create variables for the various auto-alg thresholds
  • Loading branch information
isaacsas authored Aug 6, 2024
2 parents ede0b43 + 66cfe83 commit 07d8220
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/JumpProcesses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ import Base.Threads

const DEFAULT_RNG = Random.default_rng()

# thresholds for auto-alg below which the listed alg is used
# see select_aggregator for details
const USE_DIRECT_THRESHOLD = 20
const USE_RSSA_THRESHOLD = 100
const USE_SORTINGDIRECT_THRESHOLD = 200

include("jumps.jl")
include("massaction_rates.jl")
include("aggregators/aggregators.jl")
Expand Down
6 changes: 3 additions & 3 deletions src/aggregators/aggregators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,18 @@ function select_aggregator(jumps::JumpSet; vartojumps_map = nothing,
end

# if the number of jumps is small, return the Direct
num_jumps(jumps) < 20 && return Direct
num_jumps(jumps) < USE_DIRECT_THRESHOLD && return Direct

# if there are only massaction jumps, we can build the species-jumps dependency graphs
can_build_dgs = num_crjs(jumps) == 0 && num_vrjs(jumps) == 0
have_species_to_jumps_dgs = !isnothing(vartojumps_map) && !isnothing(jumptovars_map)

# if we have the species-jumps dgs or can build them, use a Rejection-based methods
if can_build_dgs || have_species_to_jumps_dgs
(num_jumps(jumps) < 100) && return RSSA
(num_jumps(jumps) < USE_RSSA_THRESHOLD) && return RSSA
return RSSACR
elseif !isnothing(dep_graph) # if only have a normal dg
(num_jumps(jumps) < 200) && return SortingDirect
(num_jumps(jumps) < USE_SORTINGDIRECT_THRESHOLD) && return SortingDirect
return DirectCR
else
return Direct
Expand Down

0 comments on commit 07d8220

Please sign in to comment.