> ## Documentation Index
> Fetch the complete documentation index at: https://doc.blueapi.ir/llms.txt
> Use this file to discover all available pages before exploring further.

# Selection Strategies for Evolutionary Search

> Specification for selection operators in EMEP, including tournament, truncation, elitism, and roulette with decision rationale and configuration.

Selection determines which candidates become parents for the next generation in the EMEP evolutionary loop. The choice of selector shapes convergence speed, diversity maintenance, and resistance to local optima. This page specifies four selection strategies and the decision logic for choosing among them.

## Selection Decision Tree

```mermaid theme={null}
flowchart TD
    START([START]) --> GOAL{Primary Goal?}
    GOAL -->|Fast Convergence| TOURN[Tournament Selection]
    GOAL -->|Steady Improvement| TRUNC[Truncation Selection]
    GOAL -->|Preserve Best| ELITE[Elitism]
    GOAL -->|Explore Widely| ROULET[Roulette Selection]
    TOURN --> PARAM1[Set Tournament Size]
    TRUNC --> PARAM2[Set Truncation Threshold]
    ELITE --> PARAM3[Set Elite Count]
    ROULET --> PARAM4[Set Fitness Scaling]
    PARAM1 --> OUTPUT[Return Selected Parents]
    PARAM2 --> OUTPUT
    PARAM3 --> OUTPUT
    PARAM4 --> OUTPUT
    OUTPUT --> END([END])
```

## Tournament Selection

Randomly samples K candidates from the population. The candidate with the highest fitness wins and becomes a parent. K is the tournament size.

* **K = 2**: weak selection pressure, high diversity
* **K = 5**: moderate pressure, balanced
* **K = 10+**: strong pressure, fast convergence risk

Tournament selection is the default in EMEP. It does not require fitness scaling and works with negative fitness values. It is robust to outliers because only relative ranking within the tournament matters.

**Rationale**: Tournament selection balances exploration and exploitation without global fitness normalization. It is the recommended starting point for most experiments.

## Truncation Selection

Ranks all candidates by fitness. The top T% are selected as parents. The remainder are discarded.

* **T = 50%**: moderate pressure
* **T = 25%**: strong pressure
* **T = 10%**: very strong pressure, high convergence risk

Truncation is deterministic and simple to implement. It can cause rapid loss of diversity if T is too small.

**Rationale**: Truncation is appropriate when evaluation is expensive and only high-quality candidates deserve further investment. Use with large populations to maintain diversity.

## Elitism

Unconditionally preserves the top E candidates into the next generation. Elitism is not a standalone selector but a modifier applied alongside any primary selection method.

* **E = 1**: guarantees the best candidate is never lost
* **E = 4**: default in EMEP, preserves a small elite archive within the population
* **E = population\_size**: degenerate case, no evolution

Elitism prevents regression between generations. It is always enabled in EMEP with a configurable count.

**Rationale**: Without elitism, a generation's best candidate can be lost to random mutation or crossover. Elitism ensures monotonic non-degradation of the population's maximum fitness.

## Roulette Selection (Fitness Proportionate)

Selects candidates with probability proportional to their fitness. Requires positive fitness values. If fitness can be negative, a scaling offset is applied.

```text theme={null}
P(select_i) = fitness_i / sum(fitness)
```

Roulette is sensitive to fitness scale. A single outlier with very high fitness can dominate selection, collapsing diversity.

**Rationale**: Roulette is included for completeness and comparison studies. It is not recommended as the primary selector in EMEP due to its sensitivity to fitness landscape shape.

## Selector Configuration

| Parameter   | Tournament            | Truncation            | Elitism                   | Roulette            |
| ----------- | --------------------- | --------------------- | ------------------------- | ------------------- |
| Key setting | tournament\_size      | truncation\_threshold | elite\_count              | fitness\_scaling    |
| Default     | 5                     | 0.5                   | 4                         | linear              |
| Range       | 2 to population\_size | 0.1 to 0.9            | 0 to population\_size / 4 | linear, sigma, rank |

## Combined Strategy

EMEP supports hybrid selection: tournament for primary parents, elitism for preservation, and occasional roulette injection to maintain diversity. The hybrid is configured as:

```json theme={null}
{
  "primary": "tournament",
  "tournament_size": 5,
  "elitism_count": 4,
  "diversity_injection": 0.1,
  "injection_selector": "roulette"
}
```

Diversity injection selects 10% of parents via roulette rather than tournament. This introduces low-fitness candidates that may carry useful genetic material.

<Info>
  Selection operates on fitness values computed from the Optimization Set only. The Validation Set and Hidden Test Set are not used during selection. This prevents information leakage into the evolutionary process.
</Info>
