# `Nous.Eval.Optimizer.Parameter`
[🔗](https://github.com/nyo16/nous/blob/v0.17.1/lib/nous/eval/optimizer/parameter.ex#L1)

Defines optimizable parameters for agent configuration.

Parameters define the search space for optimization. Each parameter
specifies a name, type, and valid range of values.

## Parameter Types

- `:float` - Continuous floating point values
- `:integer` - Discrete integer values
- `:choice` - Categorical choices from a list
- `:bool` - Boolean true/false

## Examples

    # Temperature from 0.0 to 1.0 in steps of 0.1
    Parameter.float(:temperature, 0.0, 1.0, step: 0.1)

    # Max tokens from 100 to 2000 in steps of 100
    Parameter.integer(:max_tokens, 100, 2000, step: 100)

    # Model selection
    Parameter.choice(:model, [
      "lmstudio:ministral-3-14b",
      "lmstudio:qwen-7b",
      "openai:gpt-4"
    ])

    # Enable/disable a feature
    Parameter.bool(:use_cot)

## Conditional Parameters

Parameters can be conditional on other parameter values:

    Parameter.float(:top_p, 0.0, 1.0,
      condition: {:temperature, &(&1 > 0.5)}
    )

# `param_type`

```elixir
@type param_type() :: :float | :integer | :choice | :bool
```

# `t`

```elixir
@type t() :: %Nous.Eval.Optimizer.Parameter{
  choices: [term()] | nil,
  condition: {atom(), function()} | nil,
  default: term() | nil,
  log_scale: boolean(),
  max: number() | nil,
  min: number() | nil,
  name: atom(),
  step: number() | nil,
  type: param_type()
}
```

# `active?`

```elixir
@spec active?(t(), map()) :: boolean()
```

Check if a parameter is active given current config.

# `bool`

```elixir
@spec bool(
  atom(),
  keyword()
) :: t()
```

Create a boolean parameter.

## Options

  * `:default` - Default value (default: false)
  * `:condition` - Conditional on another parameter

## Examples

    Parameter.bool(:use_cot)
    Parameter.bool(:stream, default: true)

# `choice`

```elixir
@spec choice(atom(), [term()], keyword()) :: t()
```

Create a categorical choice parameter.

## Options

  * `:default` - Default value
  * `:condition` - Conditional on another parameter

## Examples

    Parameter.choice(:model, ["gpt-4", "gpt-3.5-turbo", "claude-3"])
    Parameter.choice(:strategy, [:greedy, :sampling, :beam_search])

# `float`

```elixir
@spec float(atom(), number(), number(), keyword()) :: t()
```

Create a float parameter.

## Options

  * `:step` - Step size for grid search (default: calculated)
  * `:default` - Default value
  * `:log_scale` - Use log scale for sampling
  * `:condition` - Conditional on another parameter

## Examples

    Parameter.float(:temperature, 0.0, 1.0)
    Parameter.float(:temperature, 0.0, 1.0, step: 0.1)
    Parameter.float(:learning_rate, 1.0e-5, 1.0e-2, log_scale: true)

# `from_map`

```elixir
@spec from_map(map()) :: {:ok, t()} | {:error, String.t()}
```

Build a parameter from a plain data map (e.g. decoded from YAML/JSON).

This is the safe alternative to evaluating an `.exs` parameter file: it
constructs parameters from pure data, never executing code. Keys may be
strings or atoms. The `:condition` feature (which needs a function) is NOT
supported here — declare conditional parameters in code if you need them.

## Expected shape

    %{"type" => "float", "name" => "temperature", "min" => 0.0, "max" => 1.0,
      "step" => 0.1}
    %{"type" => "integer", "name" => "max_tokens", "min" => 256, "max" => 2048,
      "step" => 256}
    %{"type" => "choice", "name" => "model", "choices" => ["gpt-4", "gpt-4o"]}
    %{"type" => "bool", "name" => "use_cot", "default" => true}

Returns `{:ok, t()}` or `{:error, reason}`.

# `integer`

```elixir
@spec integer(atom(), integer(), integer(), keyword()) :: t()
```

Create an integer parameter.

## Options

  * `:step` - Step size (default: 1)
  * `:default` - Default value
  * `:condition` - Conditional on another parameter

## Examples

    Parameter.integer(:max_tokens, 100, 4000)
    Parameter.integer(:max_tokens, 100, 4000, step: 100)

# `sample`

```elixir
@spec sample(t()) :: term()
```

Sample a random value from the parameter space.

# `values`

```elixir
@spec values(t()) :: [term()]
```

Get all possible values for a parameter (for grid search).

---

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