Validates model parameter strings from genetic algorithms.
Details
The input string is a binary chromosome (0/1). The function:
Decodes the binary chromosome to a categorical parameter vector using
decodeBinary.Applies model constraints in categorical space by calling
validStringcat.Encodes the corrected categorical vector back to binary using
encodeBinary.
This design keeps all correction rules in validStringcat and
makes the GA version a thin wrapper around the categorical validator.
See also
validStringcat for categorical validation used by ACO/TS.
decodeBinary and encodeBinary for encoding
conversions.
Examples
# Example 1: ivbase, 1 compartment disables peripheral terms.
# Bits 1-2 encode no.cmpt; here 00 maps to 1.
invalid_iv <- c(0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1)
validStringbinary(invalid_iv, "ivbase")
#> [1] 0 1 0 1 0 0 0 0 0 1 0 1
# Example 2: oralbase, mm = 0 forces eta.km to 0.
# Bits 12-13 encode rv for oralbase.
invalid_oral <- c(1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1)
validStringbinary(invalid_oral, "oralbase")
#> [1] 1 0 0 1 0 0 0 0 1 0 0 0 1
# Example 3: custom, mcorr is cleared when there are not enough IIV terms.
simple_config <- list(
route = "bolus",
params = c("eta.vc", "mcorr", "rv"),
param_dependencies = list(),
fixed_params = list(no.cmpt = 1, eta.cl = 1, allometric_scaling = 1)
)
# custom encoding: eta.vc (1 bit), mcorr (1 bit), rv (2 bits)
invalid_custom <- c(0, 1, 1, 1) # eta.vc=0, mcorr=1, rv=4
validStringbinary(invalid_custom, "custom", custom_config = simple_config)
#> [1] 0 0 1 1