Randomly flips two parameters ("2-bit change") in the current model string to generate a perturbed candidate.
Value
A list with two named numeric vectors:
- original_neighbor
raw 2-bit flip (may be invalid)
- validated_neighbor
validated and usable model code
Details
The function returns both:
original_neighbor: the raw 2-bit flip before validationvalidated_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
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
#> no.cmpt eta.km eta.vc eta.vp eta.vp2 eta.q eta.q2 mm mcorr rv
#> 3 0 1 0 0 1 1 0 1 2
perturb$validated_neighbor # validated model
#> no.cmpt eta.km eta.vc eta.vp eta.vp2 eta.q eta.q2 mm mcorr rv
#> 3 0 1 0 0 1 1 0 1 2