# `Tune.Optimizers.Reflective`
[🔗](https://github.com/mikehostetler/tune/blob/v0.5.0/lib/tune/optimizers/reflective.ex#L1)

The reflective evolutionary search shared by GEPA and Optimize.Anything.

A component is one tunable text: a predictor instruction, or a declared
parameter value rendered as text. The search keeps a pool of candidates,
each fully evaluated on the validation set with per-row scores and
lineage. Each iteration either:

  * reflects: selects a parent from the per-row Pareto frontier (a
    candidate is sampled in proportion to the number of validation rows on
    which it has the best score), picks the parent's next component round
    robin, runs the parent on a training minibatch, sends the trajectories
    with their scores and metric feedback to the proposal role, and builds a
    child with the proposed text. The child is scored on the same
    minibatch and gets a full validation pass only if it beats the parent's
    minibatch total; or
  * merges: every `merge_every` iterations, finds two pool candidates with a
    common ancestor that changed different components, combines those
    changes into one child, and validates it.

Only complete, eligible validation results can become the incumbent; ties
keep the earlier candidate.

# `component`

```elixir
@type component() :: %{
  name: String.t(),
  get: (Tune.t() -&gt; String.t()),
  put: (Tune.t(), String.t() -&gt; {:ok, Tune.t()} | {:error, term()}),
  propose: (Tune.Search.Program.Context.t(), String.t(), String.t() -&gt;
              {String.t() | nil, Tune.Search.Program.Context.t()})
}
```

# `run`

```elixir
@spec run(map(), Tune.t(), [component()], Tune.Search.Program.Context.t()) ::
  {:ok, Tune.t(), Tune.Search.Program.Context.t()}
  | {:error, term(), Tune.Search.Program.Context.t()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
