Optimizer

The Optimizer class orchestrates the active learning loop by coordinating the acquisition function and search strategy. It selects the most promising candidates for evaluation by first obtaining a candidate pool from the search strategy, then scoring candidates using the acquisition function, and finally selecting the top-k candidates for oracle evaluation.

class alf_core.optimizer.optimizer.Optimizer(acquisition_fn, search_fn)[source]

Bases: object

Implements the ask/tell interface for active learning.

Coordinates search and acquisition functions to propose candidates and update the surrogate model iteratively.

ask(state)[source]

Propose the next batch of candidates to evaluate.

Uses the search function to generate a candidate pool, then the acquisition function to score and select the top candidates. In the first round, uses the training dataset if available.

Parameters:

state (State) – Current task state.

Returns:

  • The proposed candidates to evaluate

  • Updated state with ask_time metric

Return type:

tuple[list[Candidate], State]

get_metrics(state)[source]

Collect metrics from acquired candidates, surrogate, and search functions.

Parameters:

state (State) – Current task state.

Returns:

  • Metrics on acquired candidates (mean, max, min)

  • Surrogate training metrics (if available)

  • Search function metrics

Return type:

dict[str, float]

tell(state)[source]

Update the surrogate model with newly acquired data.

Trains the surrogate model on the updated training and validation datasets, then computes and updates metrics.

Parameters:

state (State) – Current task state with updated dataset.

Return type:

State

Returns:

Updated state with tell_time, training_history, and optimizer metrics.