Learn R Programming

nlmixr2auto (version 1.0.0)

perturb_2bit: Apply 2-bit perturbation to escape local optimum

Description

Randomly flips two parameters ("2-bit change") in the current model string to generate a perturbed candidate.

Usage

perturb_2bit(prev_string, search.space, max.try = 1000)

Value

A list with two named numeric vectors:

original_neighbor

raw 2-bit flip (may be invalid)

validated_neighbor

validated and usable model code

Arguments

prev_string

A named numeric vector representing the current model.

search.space

Character, one of "ivbase" or "oralbase". Default is "ivbase".

max.try

Maximum number of attempts to generate a valid perturbed model.

Author

Zhonghui Huang

Details

The function returns both:

  • original_neighbor: the raw 2-bit flip before validation

  • validated_neighbor: the corrected version after validation

This allows downstream functions (e.g. detect_move()) to identify which parameters were intentionally changed (primary moves), while still using a valid model code for evaluation.

Examples

Run this code
prev <- c(no.cmpt = 2, eta.km = 0, eta.vc = 1,
          eta.vp = 0, eta.vp2 = 0, eta.q = 1,
          eta.q2 = 0, mm = 0, mcorr = 1, rv = 2)
perturb <- perturb_2bit(prev, search.space = "ivbase")
perturb$original_neighbor   # original 2-bit flip
perturb$validated_neighbor  # validated model

Run the code above in your browser using DataLab