mlos_bench.optimizers.MockOptimizer

class mlos_bench.optimizers.MockOptimizer(tunables: TunableGroups, config: dict, global_config: dict | None = None, service: Service | None = None)

Mock optimizer to test the Environment API.

Attributes:
config_space

Get the tunable parameters of the optimizer as a ConfigurationSpace.

current_iteration

The current number of iterations (suggestions) registered.

max_suggestions

The maximum number of iterations (suggestions) to run.

name

The name of the optimizer.

seed

The random seed for the optimizer.

start_with_defaults

Return True if the optimizer should start with the default values.

supports_preload

Return True if the optimizer supports pre-loading the data from previous experiments.

targets

A dictionary of {target: direction} of optimization targets.

tunable_params

Get the tunable parameters of the optimizer as TunableGroups.

Methods

bulk_register(configs, scores[, status])

Pre-load the optimizer with the bulk data from previous experiments.

get_best_observation()

Get the best observation so far.

not_converged()

Return True if not converged, False otherwise.

register(tunables, status[, score])

Register the observation for the given configuration.

suggest()

Generate the next (random) suggestion.

__init__(tunables: TunableGroups, config: dict, global_config: dict | None = None, service: Service | None = None)

Create a new optimizer for the given configuration space defined by the tunables.

Parameters:
tunablesTunableGroups

The tunables to optimize.

configdict

Free-format key/value pairs of configuration parameters to pass to the optimizer.

global_configOptional[dict]
serviceOptional[Service]
bulk_register(configs: Sequence[dict], scores: Sequence[Dict[str, int | float | str | None] | None], status: Sequence[Status] | None = None) bool

Pre-load the optimizer with the bulk data from previous experiments.

Parameters:
configsSequence[dict]

Records of tunable values from other experiments.

scoresSequence[Optional[Dict[str, TunableValue]]]

Benchmark results from experiments that correspond to configs.

statusOptional[Sequence[Status]]

Status of the experiments that correspond to configs.

Returns:
is_not_emptybool

True if there is data to register, false otherwise.

suggest() TunableGroups

Generate the next (random) suggestion.