| crossover_fixknots | R Documentation |
m) with Feasibility-First RestartsProduces a child chromosome from two fixed-m parents (same number of
knots) by alternately sampling candidate knot locations from the parents and
enforcing the spacing constraint diff(child) > minDist. If a conflict
is encountered, the routine restarts the construction up to a small cap.
crossover_fixknots(mom, dad, prange = NULL, minDist, lmax, N)
mom, dad |
Integer vectors encoding parent chromosomes:
first entry |
prange |
Unused placeholder (kept for compatibility with other GA
operators). Default |
minDist |
Integer; minimum spacing between adjacent knots in the child. |
lmax |
Integer; chromosome length (number of rows in the population matrix). |
N |
Integer; series length. Used to place the sentinel |
Let mom and dad be chromosomes of the form
c(m, tau_1, ..., tau_m, ...). This operator:
Initializes an empty child of size m.
Picks the first knot at random from mom or dad.
For each subsequent position i=2,\dots,m, considers the
pair (mom[i], dad[i]) and chooses the first value that
maintains the spacing constraint relative to the previously chosen
knot (> minDist); if both work, one is chosen at random.
If no feasible choice exists at some step, the construction restarts
from the first position (up to a small cap governed internally by
up_tol).
The result is written back as a full-length chromosome with the sentinel
N+1 in position m+2, and zeros elsewhere.
An integer vector of length lmax encoding the child chromosome:
c(m, child_knots, N+1, 0, 0, ...).
crossover_fixknots, mutation_fixknots, selectTau_uniform_exact, Popinitial_fixknots, gareg_knots
N <- 120
lmax <- 30
minDist <- 5
m <- 3
mom <- c(m, c(20, 50, 90), rep(0, lmax - 1 - m))
mom[m + 2] <- N + 1
dad <- c(m, c(18, 55, 85), rep(0, lmax - 1 - m))
dad[m + 2] <- N + 1
child <- crossover_fixknots(mom, dad, minDist = minDist, lmax = lmax, N = N)
child
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.