Tune.Search.Program.Context (Tune v0.5.0)

Copy Markdown View Source

Internal operations and program data for one search strategy.

Shared candidate, limit, accounting, random, and result state belongs to Tune.Search.Study.

Summary

Types

t()

@type t() :: %Tune.Search.Program.Context{
  failure_score: term(),
  optimizer: term(),
  run_options: term(),
  scores: term(),
  selector: term(),
  study: term(),
  train: term(),
  validation: term()
}

Functions

best(ctx)

@spec best(t()) :: {:ok, Tune.Program.t(), t()} | {:error, Exception.t(), t()}

budget(context)

@spec budget(t()) :: non_neg_integer() | nil

consider(ctx, program, evaluation, metadata \\ %{})

@spec consider(t(), Tune.Program.t(), Tune.Evaluation.t() | nil, map()) ::
  {String.t(), t()}

evaluate(ctx, program, cases)

@spec evaluate(t(), Tune.Program.t(), [Tune.Case.t()]) :: {Tune.Evaluation.t(), t()}

evaluate_validation(ctx, program)

@spec evaluate_validation(t(), Tune.Program.t()) :: {Tune.Evaluation.t(), t()}

exhausted?(context)

@spec exhausted?(t()) :: boolean()

incumbent(context)

@spec incumbent(t()) :: Tune.Candidate.t() | nil

limit_error(reason \\ :budget_exhausted)

@spec limit_error(atom()) :: Exception.t()

max_model_calls(context)

@spec max_model_calls(t()) :: non_neg_integer() | nil

new(opts)

@spec new(keyword()) :: t()

note(ctx, key, value)

@spec note(t(), atom(), term()) :: t()

notes(context)

@spec notes(t()) :: map()

propose(ctx, predictor, input, role \\ :proposal)

@spec propose(t(), Tune.Predictor.t(), map(), atom()) ::
  {{:ok, map()} | {:error, term()}, t()}

random(ctx)

@spec random(t()) :: {float(), t()}

result(ctx, value, parameters, opts \\ [])

@spec result(t(), term(), map(), keyword()) :: Tune.Result.t()

run(ctx, program, input, role)

@spec run(t(), Tune.Program.t(), map(), atom()) ::
  {{:ok, Tune.Prediction.t()} | {:error, term()}, t()}

sample(ctx, list, count)

@spec sample(t(), list(), non_neg_integer()) :: {list(), t()}

score(ctx, tune_case, prediction)

@spec score(t(), Tune.Case.t(), Tune.Prediction.t()) ::
  {{:ok, %{score: number(), feedback: String.t() | nil}} | {:error, term()},
   t()}

seed(context)

@spec seed(t()) :: term()

shuffle(ctx, list)

@spec shuffle(t(), list()) :: {list(), t()}

stop(ctx, reason)

@spec stop(t(), atom()) :: t()

stop_reason(context)

@spec stop_reason(t()) :: atom() | nil

uniform(ctx, n)

@spec uniform(t(), pos_integer()) :: {non_neg_integer(), t()}