# `Imp.Optimizer`
[🔗](https://github.com/deepfates/imp/blob/v0.18.1/lib/imp/optimizer.ex#L39)

Canonical execution contract for program and training optimizers.

Optimizer modules declare what they produce and which dataset splits they
consume. `run/3` dispatches only through this behaviour; callback arity is
never used to infer argument meaning. Operational safety failures remain
raised across this boundary instead of becoming generic optimizer errors.

# `capabilities`

```elixir
@type capabilities() :: %{
  kind: kind(),
  datasets: %{required(atom()) =&gt; requirement()},
  result:
    :program
    | :training_result
    | :constructed_program
    | {:workflow_result, module()}
}
```

# `kind`

```elixir
@type kind() :: :program | :training | :constructor | :workflow
```

# `requirement`

```elixir
@type requirement() :: :required | :optional | :unsupported
```

# `run`

```elixir
@callback run(struct(), program :: term(), keyword()) :: {:ok, term()} | {:error, term()}
```

# `validate_invocation_options`
*optional* 

```elixir
@callback validate_invocation_options(keyword()) :: :ok | {:error, term()}
```

# `validate_invocation_options`
*optional* 

```elixir
@callback validate_invocation_options(struct(), keyword()) :: :ok | {:error, term()}
```

# `capabilities`

```elixir
@spec capabilities(struct()) :: {:ok, capabilities()} | {:error, term()}
```

Returns validated capability metadata for an optimizer value.

# `run`

```elixir
@spec run(struct(), term(), keyword()) :: {:ok, term()} | {:error, term()}
```

Runs an optimizer through its declared behaviour.

# `run`

```elixir
@spec run(struct(), term(), keyword(), kind() | :any) ::
  {:ok, term()} | {:error, term()}
```

# `run_with_datasets`

```elixir
@spec run_with_datasets(struct(), term(), map(), [kind()] | :any) ::
  {:ok, capabilities(), term()} | {:error, term()}
```

Runs an optimizer once against the named datasets available to a composed workflow.

---

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