# rankSelection

> **rankSelection**(`random`, `scores`, `selectionSize`, `objective`): readonly `number`\[]

Defined in: [packages/evolution/src/selection.ts:143](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/evolution/src/selection.ts#L143)

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.

## Parameters

### random

[`RandomSource`](/reference/knotkit/prng/type-aliases/randomsource/)

### scores

readonly `number`\[]

### selectionSize

`number`

### objective

[`Objective`](/reference/knotkit/evolution/type-aliases/objective/)

## Returns

readonly `number`\[]

## 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, or `INVALID_OBJECTIVE` for an unsupported objective.

## Throws

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