pdmlabs.optimization.base#

Abstract base class for all PdMLabs optimizer adapters.

Classes

BaseOptimizerAdapter()

Abstract base for optimizer adapters.

class pdmlabs.optimization.base.BaseOptimizerAdapter#

Bases: ABC

Abstract base for optimizer adapters.

Subclasses translate the PdMLabs native param space (dict of str -> list | rv_frozen) into their backend’s representation and expose a unified maximize / minimize API.

The raw objective function passed to adapters has the signature:

def optimization_objective(**params) -> float

Each adapter is responsible for wrapping it into whatever calling convention its backend requires (batch list, single config, etc.).

A single float is the whole contract: anything else a trial produces (its threshold, its fitted pipeline) travels back to the main process through pdmlabs.optimization.trial_sink.TrialSink, which the objective closure carries into the workers. Adapters neither see nor forward it, so they need no changes to support it.

abstract maximize(param_space: dict, objective_fn, n_iterations: int, n_jobs: int, initial_random: int, constraint_fn=None) dict#

Run optimization maximizing objective_fn over param_space.

Parameters:
  • param_space – PdMLabs native space β€” str -> list or rv_frozen.

  • objective_fn – Raw callable (**params) -> float (single config, single score). Adapters wrap this into whatever their backend expects.

  • n_iterations – Number of optimizer iterations / trials.

  • n_jobs – Degree of parallelism (adapter-specific meaning).

  • initial_random – Number of random warm-up evaluations (Mango only; ignored by SMAC).

  • constraint_fn – Optional constraint predicate on parameter dicts (Mango only).

Returns:

Keys: best_params (dict), best_objective (float), params_tried (list[dict]), objective_values (list[float]).

Return type:

dict

minimize(param_space: dict, objective_fn, n_iterations: int, n_jobs: int, initial_random: int, constraint_fn=None) dict#

Minimize by negating objective_fn and delegating to maximize.

supports_categorical: bool = True#