
Takes a model object and runs it with various threads values
Source:R/test-threads.R
test_threads.RdTakes a model object and runs it with various threads values
Arguments
- .mod
bbi_model object to copy/test.
- .threads
Integer vector of threads values to test.
- .bbi_args
a named list.
- .cap_iterations
Maximum number of iterations for NONMEM to run in test models. Will update
MAXEVAL,NITER, andNBURN, whichever is relevant for each estimation method. The best number for this is model-dependent. Typically, something between 10 and 100 is good, depending on how long each iteration takes. You want something that will run for 3-5 minutes total. You can set this argument toNULLto run with the same settings as the original model. Any option set to0will not be overwritten.- ...
args passed through to submit_models()
Details
Unfortunately, there is no easy way to know how many threads are ideal for a given NONMEM model. It is dependent on many factors, including model complexity and the structure of the input data. Typically, the best way to find the ideal number of threads for a given model is to test it empirically. This function is intended to help the user do this.
The function will create copies of your model, cap the number of evaluation iterations, and then
run these copies with the specified number of threads. The check_run_times() helper can then
be used to easily see how long each test model ran for, giving you a good sense of what the ideal
number of threads might be.
Examples
if (FALSE) { # \dontrun{
mod <- read_model(file.path(MODEL_DIR, 1))
mods <- test_threads(.mod = mod, .threads = c(2, 4), .cap_iterations = 10,
.mode = "local")
check_run_times(mods, .wait = TRUE, .time_limit = 100)
check_run_times(mods, .wait = FALSE, .return_times = "all")
delete_models(.mods = mods)
# Dry Run:
mods <- test_threads(.mod = mod, .threads = c(2, 4), .cap_iterations = 10,
.mode = "local", .dry_run = TRUE)
delete_models(.mods = mods)
} # }