tournamentSelection(
random,scores,selectionSize,tournamentSize,objective): readonlynumber[]
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.
Parameters
Section titled “Parameters”random
Section titled “random”scores
Section titled “scores”readonly number[]
selectionSize
Section titled “selectionSize”number
tournamentSize
Section titled “tournamentSize”number
objective
Section titled “objective”Returns
Section titled “Returns”readonly number[]
Throws
Section titled “Throws”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.
Throws
Section titled “Throws”With code INVALID_SOURCE_VALUE when the random source returns a value outside
[0, 1).