orderCrossover<
T>(first,second,cut): readonly [readonlyT[], readonlyT[]]
Defined in: packages/evolution/src/permutation.ts:35
Cross two permutations with an inclusive order-crossover cut.
Both parents must have equal length and contain the same unique values under Set SameValueZero equality. Each
child keeps one parent’s cut segment and fills the other positions in the opposite parent’s cyclic order. Runs in
O(n) expected time and O(n) auxiliary space, returns new readonly arrays, and never mutates either parent.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”readonly T[]
second
Section titled “second”readonly T[]
readonly [number, number]
Returns
Section titled “Returns”readonly [readonly T[], readonly T[]]
Throws
Section titled “Throws”With code INVALID_PERMUTATION when a parent is not an array,
DUPLICATE_ELEMENT when either parent repeats a value, UNEQUAL_PARENT_DOMAIN when parent domains differ, or
INVALID_CUT when the cut is not an ascending safe-integer pair inside both parents.