Run a genetic algorithm to search for an optimal PK model structure within a predefined search space using nlmixr2-based model fitting and penalties.
ga.operator(
dat,
param_table = NULL,
search.space = c("ivbase", "oralbase"),
no.cores = NULL,
ga.control = gaControl(),
penalty.control = penaltyControl(),
precomputed_results_file = NULL,
foldername = NULL,
filename = "test",
seed = 1234,
.modEnv = NULL,
verbose = TRUE,
...
)An object of class "gaOperatorResult" containing:
Final Selected Code: data frame with the best binary encoding.
Final Selected Model Name: model identifier for the best encoding.
Model Run History: data frame of fitted models and fitness values.
Selection History: list of per-generation results.
A data frame containing pharmacokinetic data in standard nlmixr2 format, including "ID", "TIME", "EVID", and "DV", and may include additional columns.
Optional data frame of initial parameter estimates. If NULL,
the table is generated by auto_param_table().
Character, one of "ivbase" or "oralbase". Default is "ivbase".
Integer. Number of CPU cores to use. If NULL, uses
rxode2::getRxThreads().
A list of GA control parameters, generated by
gaControl(). Includes:
npop - number of individuals (chromosomes) per generation.
niter - maximum number of generations.
pcross - crossover probability.
pmut - per-bit mutation probability.
diff_tol - significance difference threshold used for ranking.
nls - frequency (in generations) of running local exhaustive search around the best current model.
A list of penalty control parameters defined by
penaltyControl(), specifying penalty values used for model diagnostics
during fitness evaluation.
Optional path to a CSV file of previously computed model results used for caching.
Character string specifying the folder name for storing
intermediate results. If NULL (default), tempdir()
is used for temporary storage. If specified, a cache directory
is created in the current working directory.
Optional character string used as a prefix for output files. Defaults to "test".
Integer. Random seed controlling the random sampling steps of the genetic algorithm operator for reproducible runs. Default is 1234.
Optional environment used to store run state and cached results. If NULL, a new environment is created.
Logical. If TRUE, print progress messages.
Additional arguments passed to mod.run().
Zhonghui Huang
The algorithm evolves a population of binary-encoded candidate models over multiple generations using tournament selection, crossover, mutation, and local search. Candidate encodings are validated and then evaluated by fitting models and applying user-defined penalties. The best individual is carried forward to the next generation.
mod.run, gaControl, penaltyControl, auto_param_table, spaceConfig, create.pop, validStringbinary, decodeBinary, parseName, rank_new, runlocal, ga.sel.tournament, ga.crossover, ga.mutation
# \donttest{
# Example usage with phenotype dataset
outs <- ga.operator(
dat = pheno_sd,
param_table = NULL,
search.space = "ivbase",
ga.control = gaControl(),
saem.control = nlmixr2est::saemControl(
seed = 1234,
nBurn = 200,
nEm = 300,
logLik = TRUE
)
)
print(outs)
# }
Run the code above in your browser using DataLab