Skip to content

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

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

Select source indices through independent tournaments.

Candidates are distinct inside one tournament, but the same source index may win multiple tournaments. Tied scores retain the first sampled index, which is the lowest source index because sampleIndices is canonical. Inputs are not mutated. The result is a new array and randomness is consumed separately for every tournament.

RandomSource

readonly number[]

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, INVALID_TOURNAMENT_SIZE for a size outside 1..scores.length, or INVALID_OBJECTIVE for an unsupported objective.

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