Skip to content

rankSelection(random, scores, selectionSize, objective): readonly number[]

Defined in: packages/evolution/src/selection.ts:143

Select source indices with replacement from exponential competition-rank weights.

Each result consumes one weighted-choice draw. Scores are validated and ranked once, remain unmodified, and the returned indices refer to the original score order.

RandomSource

readonly number[]

number

Objective

readonly number[]

With code EMPTY_POPULATION for no scores, INVALID_SCORE for a non-finite score, INVALID_SELECTION_SIZE for a negative or unsafe selection size, or INVALID_OBJECTIVE for an unsupported objective.

With code INVALID_SOURCE_VALUE when the random source returns a value outside [0, 1).