This function simulates the random evolution of an IBM.
popsim(
model,
initial_population,
events_bounds,
parameters = NULL,
age_max = Inf,
time,
multithreading = FALSE,
num_threads = NULL,
clean_step = NULL,
clean_ratio = 0.1,
seed = NULL,
verbose = FALSE
)
Model resulting from a call to the function mk_model
.
Object of population class representing the initial population.
Named vector of events bounds, with names corresponding to events names.
List of model parameters.
Maximum age of individuals in the population (Inf
by default).
Final time (Numeric). Can be of length 1 or a vector of simulation discretized times.
Logical for multithread activation, FALSE
by default. Should be only activated for IBM simulation with no interactions.
(Optional) Number of threads used for multithreading. Set by default to the number of concurrent threads supported by the available hardware implementation.
(Optional) Optional parameter for improving simulation time. Time step for removing dead (or exited) individuals from the population. By default, equal to age_max.
(Optional) Optional parameter for improving simulation time. 0.1 by default.
(Optional) Random generator seed, random by default.
(Optional) Activate verbose output, FALSE by default.
List composed of
Simulation inputs (initial population, parameters value, multithreading...)
Simulation logs (algorithm duration, accepted/rejected events...).
If time
is of length 1, population is an object of type population containing of all individuals who lived in the population in the time interval [0,time]
. If time
is a vector (time[1], ..., time[n]
), population
is a list of n
objects of type population, each representing the state of the population at time time[i]
, for i = 1,..., n
.
# \donttest{
init_size <- 100000
pop_df <- data.frame(birth = rep(0, init_size), death = NA)
pop <- population(pop_df)
birth = mk_event_poisson(type = 'birth', intensity = 'lambda')
death = mk_event_poisson(type = 'death', intensity = 'mu')
params = list('lambda' = 100, 'mu' = 100)
birth_death <- mk_model(events = list(birth, death),
parameters = params)
sim_out <- popsim(model = birth_death,
initial_population = pop,
events_bounds = c('birth' = params$lambda, 'death' = params$mu),
parameters = params,
time = 10)
# }