Description Usage Arguments Value Examples
View source: R/compile_reactions.R
By precompiling the reactions, you can run multiple SSA simulations repeatedly without having to recompile the reactions every time.
1 2 3 4 5 6 7 8 | compile_reactions(
reactions,
state_ids,
params,
buffer_ids = NULL,
hardcode_params = FALSE,
fun_by = 10000L
)
|
reactions |
'reaction' A list of multiple |
state_ids |
|
params |
|
buffer_ids |
|
hardcode_params |
|
fun_by |
|
A list of objects solely to be used by ssa()
.
x[["state_change"]]
: A sparse matrix of reaction effects.
x[["reaction_ids"]]
: The names of the reactions.
x[["buffer_ids"]]
: A set of buffer variables found in the propensity functions.
x[["buffer_size"]]
: The minimum size of the buffer required.
x[["function_pointers"]]
: A list of compiled propensity functions.
x[["hardcode_params"]]
: Whether the parameters were hard coded into the source code.'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | initial_state <- c(prey = 1000, predators = 1000)
params <- c(c1 = 10, c2 = 0.01, c3 = 10)
reactions <- list(
# propensity function effects name for reaction
reaction(~c1 * prey, c(prey = +1), "prey_up"),
reaction(~c2 * prey * predators, c(prey = -1, predators = +1), "predation"),
reaction(~c3 * predators, c(predators = -1), "pred_down")
)
compiled_reactions <- compile_reactions(
reactions = reactions,
state_ids = names(initial_state),
params = params
)
out <-
ssa(
initial_state = initial_state,
reactions = compiled_reactions,
params = params,
method = ssa_exact(),
final_time = 5,
census_interval = .001,
verbose = TRUE
)
plot_ssa(out)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.