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

# dspy_rs::optimizer

> Automatic prompt optimization.

<Note>
  Generated from rustdoc JSON at `dspy-rs v0.7.3` (commit `f7d67a6`). Do not edit by hand; regenerate with `python3 docs/scripts/gen_api.py` (see the script header for the rustdoc commands). Item links lead to full signatures and method docs on docs.rs.
</Note>

Automatic prompt optimization.

## Re-exports

| Item                                                                                                   | Description                            |
| ------------------------------------------------------------------------------------------------------ | -------------------------------------- |
| `bootstrap::*`                                                                                         | Glob re-export.                        |
| `copro::*`                                                                                             | Glob re-export.                        |
| `engine::*`                                                                                            | Glob re-export.                        |
| `gepa::*`                                                                                              | Glob re-export.                        |
| [`LeafInfo`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/target/struct.LeafInfo.html)             | Re-export of `target::LeafInfo`.       |
| `mipro::*`                                                                                             | Glob re-export.                        |
| [`OptimizeTarget`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/target/struct.OptimizeTarget.html) | Re-export of `target::OptimizeTarget`. |
| [`ProgramMetric`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/target/trait.ProgramMetric.html)    | Re-export of `target::ProgramMetric`.  |
| `simba::*`                                                                                             | Glob re-export.                        |
| `structural::*`                                                                                        | Glob re-export.                        |

## Modules

| Item                                                                                   | Description                                                                                                                   |
| -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| [`bootstrap`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/bootstrap/index.html)   | BootstrapFewShot: the minimal end-to-end exercise of the optimizer contract (vision §5.                                       |
| [`copro`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/copro/index.html)           |                                                                                                                               |
| [`engine`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/index.html)         | The shared evaluation engine (vision §5.4): every optimizer is a thin strategy over this core.                                |
| [`gepa`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/gepa/index.html)             |                                                                                                                               |
| [`mipro`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/mipro/index.html)           |                                                                                                                               |
| [`simba`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/simba/index.html)           | SIMBA: Stochastic Introspective Mini-Batch Ascent (vision §4.3) — the cheap agentic default.                                  |
| [`structural`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/structural/index.html) | Structural: LM-guided hill-climbing over the graph-edit calculus (RFC 0004 §6) — the sixth strategy over the shared `Engine`. |
| [`target`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/target/index.html)         | What an optimizer optimizes: `OptimizeTarget`, the lane-erased pair of (thing under optimization, evaluation harness).        |

## Structs

| Item                                                                                              | Description                                                                                                                     |
| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| [`OptimizerCommon`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/struct.OptimizerCommon.html) | The engine/RNG knobs shared by every optimizer builder: evaluation concurrency, budget caps, cache salt, and the sampling seed. |

## Enums

| Item                                                                          | Description                                                                                                    |
| ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [`Report`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/enum.Report.html) | What an optimization run produced. Strategy-specific payloads for the optimizers that report more than "done". |

## Traits

| Item                                                                                 | Description                                 |
| ------------------------------------------------------------------------------------ | ------------------------------------------- |
| [`Optimizer`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/trait.Optimizer.html) | A tuning strategy over the shared `Engine`. |

## `optimizer::bootstrap`

BootstrapFewShot: the minimal end-to-end exercise of the optimizer contract (vision §5.

### Structs

| Item                                                                                                                        | Description                                                      |
| --------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`BootstrapFewShot`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/bootstrap/struct.BootstrapFewShot.html)               | Few-shot demo bootstrapper — the simplest complete optimizer.    |
| [`BootstrapFewShotBuilder`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/bootstrap/struct.BootstrapFewShotBuilder.html) | Use builder syntax to set the inputs and finish with `build()`). |
| [`BootstrapReport`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/bootstrap/struct.BootstrapReport.html)                 | What a `BootstrapFewShot` run did.                               |

## `optimizer::copro`

### Structs

| Item                                                                                              | Description                                                      |
| ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`COPRO`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/copro/struct.COPRO.html)               | Breadth-first instruction optimizer.                             |
| [`COPROBuilder`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/copro/struct.COPROBuilder.html) | Use builder syntax to set the inputs and finish with `build()`). |

## `optimizer::engine`

The shared evaluation engine (vision §5.4): every optimizer is a thin strategy over this core.

### Structs

| Item                                                                                                       | Description                                                                                                                |
| ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| [`Budget`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.Budget.html)                     | Hard caps on evaluation spend. `None` = unlimited.                                                                         |
| [`Candidate`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.Candidate.html)               | A candidate is *data*: name-keyed per-leaf overlays plus a stable content hash (`Candidate::stable_hash`).                 |
| [`CandidateEval`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.CandidateEval.html)       | A candidate's results over one evaluation batch, in request order.                                                         |
| [`CandidateSlot`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.CandidateSlot.html)       | One leaf's slice of a `Candidate`: which optimizable values to inject.                                                     |
| [`Engine`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.Engine.html)                     | The shared evaluation core (vision §5.4).                                                                                  |
| [`EngineConfig`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.EngineConfig.html)         | Engine tuning knobs.                                                                                                       |
| [`ParetoStatistics`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.ParetoStatistics.html) | Snapshot of the Pareto frontier at a point in the search.                                                                  |
| [`ParetoView`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.ParetoView.html)             | Dominance snapshot computed from a `ScoreMatrix`: which candidates win (or tie, within tolerance) on at least one example. |
| [`RolloutCache`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.RolloutCache.html)         | In-memory rollout cache: `(baseline, candidate, example, salt)` → `Eval`.                                                  |
| [`RolloutOutcome`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.RolloutOutcome.html)     | One evaluated (or cache-served) rollout.                                                                                   |
| [`ScoreMatrix`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.ScoreMatrix.html)           | Per-instance score matrix: candidates × examples.                                                                          |
| [`Spend`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/struct.Spend.html)                       | What the engine has consumed so far. Reported to strategies.                                                               |

### Enums

| Item                                                                                                     | Description                         |
| -------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| [`BatchEvalOutcome`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/enum.BatchEvalOutcome.html) | Result of `Engine::evaluate_many`.  |
| [`EvalOutcome`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/enum.EvalOutcome.html)           | Result of `Engine::evaluate`.       |
| [`GateOutcome`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/engine/enum.GateOutcome.html)           | Result of `Engine::evaluate_gated`. |

## `optimizer::gepa`

### Structs

| Item                                                                                                                         | Description                                                                |
| ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| [`GEPA`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/gepa/struct.GEPA.html)                                             | Genetic-Pareto instruction optimizer with feedback-driven evolution.       |
| [`GEPABuilder`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/gepa/struct.GEPABuilder.html)                               | Use builder syntax to set the inputs and finish with `build()`).           |
| [`GEPACandidate`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/gepa/struct.GEPACandidate.html)                           | A single instruction candidate tracked through GEPA's evolutionary search. |
| [`GEPAResult`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/gepa/struct.GEPAResult.html)                                 | Full report from a `GEPA` optimization run.                                |
| [`ReflectOnInstructionOutput`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/gepa/struct.ReflectOnInstructionOutput.html) |                                                                            |

## `optimizer::mipro`

### Structs

| Item                                                                                                  | Description                                                                    |
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| [`MIPROv2`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/mipro/struct.MIPROv2.html)               | Trace-guided instruction and demo optimizer.                                   |
| [`MIPROv2Builder`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/mipro/struct.MIPROv2Builder.html) | Use builder syntax to set the inputs and finish with `build()`).               |
| [`PromptingTips`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/mipro/struct.PromptingTips.html)   | Library of general prompting best practices used to seed candidate generation. |

## `optimizer::simba`

SIMBA: Stochastic Introspective Mini-Batch Ascent (vision §4.3) — the cheap agentic default.

### Structs

| Item                                                                                                                      | Description                                                               |
| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [`IntrospectRolloutsOutput`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/simba/struct.IntrospectRolloutsOutput.html) |                                                                           |
| [`SIMBA`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/simba/struct.SIMBA.html)                                       | Minibatch introspective ascent — the cheap agentic default (vision §4.3). |
| [`SIMBABuilder`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/simba/struct.SIMBABuilder.html)                         | Use builder syntax to set the inputs and finish with `build()`).          |
| [`SimbaReport`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/simba/struct.SimbaReport.html)                           | What a `SIMBA` run did.                                                   |
| [`SimbaStep`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/simba/struct.SimbaStep.html)                               | What one SIMBA step did.                                                  |

### Enums

| Item                                                                                      | Description                                 |
| ----------------------------------------------------------------------------------------- | ------------------------------------------- |
| [`SimbaMove`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/simba/enum.SimbaMove.html) | Which of SIMBA's two moves a step proposed. |

## `optimizer::structural`

Structural: LM-guided hill-climbing over the graph-edit calculus (RFC 0004 §6) — the sixth strategy over the shared `Engine`.

### Structs

| Item                                                                                                             | Description                                                                                                  |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| [`ChooseEditOutput`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/structural/struct.ChooseEditOutput.html)   |                                                                                                              |
| [`Structural`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/structural/struct.Structural.html)               | Structural optimizer over the graph-edit calculus (RFC 0004 §6).                                             |
| [`StructuralBuilder`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/structural/struct.StructuralBuilder.html) | Use builder syntax to set the inputs and finish with `build()`).                                             |
| [`StructuralReport`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/structural/struct.StructuralReport.html)   | What a `Structural` run did. The winner is returned, not installed: bake it (\`report.program.bake(\&report. |
| [`StructuralStep`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/structural/struct.StructuralStep.html)       | What one Structural generation did.                                                                          |

## `optimizer::target`

What an optimizer optimizes: `OptimizeTarget`, the lane-erased pair of (thing under optimization, evaluation harness).

### Structs

| Item                                                                                                   | Description                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| [`LeafInfo`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/target/struct.LeafInfo.html)             | The read surface strategies build candidates from: one optimizable leaf's name, current values, and field contract.                         |
| [`OptimizeTarget`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/target/struct.OptimizeTarget.html) | The thing an `Optimizer` optimizes: a module or a program, packaged with its example set and metric. See the module docs for the two lanes. |

### Traits

| Item                                                                                                | Description                                                                                                                                                                  |
| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`ProgramMetric`](https://docs.rs/dspy-rs/latest/dspy_rs/optimizer/target/trait.ProgramMetric.html) | How a program-lane strategy tells the engine what "good" means: score one interpreter output (`JsonMap` of the program's output signature fields) against a labeled example. |
