This function simulates the random evolution of an IBM.
Usage
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
)
Arguments
- model
Model resulting from a call to the function
mk_model
.- initial_population
Object of population class representing the initial population.
- events_bounds
Named vector of events bounds, with names corresponding to events names.
- parameters
List of model parameters.
- age_max
Maximum age of individuals in the population (
Inf
by default).- time
Final time (Numeric). Can be of length 1 or a vector of simulation discretized times.
- multithreading
Logical for multithread activation,
FALSE
by default. Should be only activated for IBM simulation with no interactions.- num_threads
(Optional) Number of threads used for multithreading. Set by default to the number of concurrent threads supported by the available hardware implementation.
- clean_step
(Optional) Optional parameter for improving simulation time. Time step for removing dead (or exited) individuals from the population. By default, equal to age_max.
- clean_ratio
(Optional) Optional parameter for improving simulation time. 0.1 by default.
- seed
(Optional) Random generator seed, random by default.
- verbose
(Optional) Activate verbose output, FALSE by default.
Value
List composed of
- arguments
Simulation inputs (initial population, parameters value, multithreading...)
- logs
Simulation logs (algorithm duration, accepted/rejected events...).
- population
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]
. Iftime
is a vector (time[1], ..., time[n]
),population
is a list ofn
objects of type population, each representing the state of the population at timetime[i]
, fori = 1,..., n
.
Examples
# \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)
# }