smac.main.base_smbo

Classes

BaseSMBO(scenario, stats, runner, ...[, ...])

Implementation that contains the main Bayesian optimization loop.

Interfaces

class smac.main.base_smbo.BaseSMBO(scenario, stats, runner, initial_design, runhistory, runhistory_encoder, intensifier, model, acquisition_maximizer, acquisition_function, random_design, overwrite=False)[source]

Bases: object

Implementation that contains the main Bayesian optimization loop.

Parameters:
  • scenario (Scenario) – The scenario object, holding all environmental information.

  • stats (Stats) – Stats object to collect statistics about SMAC.

  • runner (AbstractRunner) – The runner (containing the target function) is called internally to judge a trial’s performance.

  • initial_design (InitialDesign) – The sampled configurations from the initial design are evaluated before the Bayesian optimization loop starts.

  • runhistory (Runhistory) – The runhistory stores all trials.

  • runhistory_encoder (RunHistoryEncoder) – Based on the runhistory, the surrogate model is trained. However, the data first needs to be encoded, which is done by the runhistory encoder. For example, inactive hyperparameters need to be encoded or cost values can be log transformed.

  • intensifier (AbstractIntensifier) – The intensifier decides which trial (combination of configuration, seed, budget and instance) should be run next.

  • model (AbstractModel) – The surrogate model.

  • acquisition_maximizer (AbstractAcquisitionMaximizer) – The acquisition maximizer, deciding which configuration is most promising based on the surrogate model and acquisition function.

  • acquisition_function (AbstractAcquisitionFunction) – The acquisition function.

  • random_design (RandomDesign) – The random design is used in the acquisition maximier, deciding whether the next configuration should be drawn from the acquisition function or randomly.

  • overwrite (bool, defaults to False) – When True, overwrites the run results if a previous run is found that is inconsistent in the meta data with the current setup. If overwrite is set to False, the user is asked for the exact behaviour (overwrite completely, save old run, or use old results).

Warning

This model should only be initialized by a facade.

abstract ask()[source]

Asks the intensifier for the next trial.

Return type:

tuple[TrialInfoIntent, TrialInfo]

Returns:

  • intent (TrialInfoIntent) – Intent of the trials (wait/skip/run).

  • info (TrialInfo) – Information about the trial (config, instance, seed, budget).

abstract get_next_configurations(n=None)[source]

Chooses next candidate solution with Bayesian optimization. The suggested configurations depend on the surrogate model acquisition optimizer/function. This method is used by the intensifier.

Parameters:

n (int | None, defaults to None) – Number of configurations to return. If None, uses the number of challengers defined in the acquisition optimizer.

Returns:

configurations – Iterator over configurations from the acquisition optimizer.

Return type:

Iterator[Configuration]

property incumbent: ConfigSpace.configuration_space.Configuration | None

The best configuration so far.

Return type:

Optional[Configuration]

optimize()[source]

Runs the Bayesian optimization loop.

Returns:

incumbent – The best found configuration.

Return type:

Configuration

property runhistory: RunHistory

The run history, which is filled with all information during the optimization process.

Return type:

RunHistory

save()[source]

Saves the current stats and runhistory.

Return type:

None

property stats: Stats

The stats object, which is updated during the optimization and shows relevant information, e.g., how many trials have been finished and how the trajectory looks like.

Return type:

Stats

abstract tell(info, value, time_left=None, save=True)[source]

Adds the result of a trial to the runhistory and updates the intensifier. Also, the stats object is updated.

Parameters:
  • info (TrialInfo) – Describes the trial from which to process the results.

  • value (TrialValue) – Contains relevant information regarding the execution of a trial.

  • time_left (float | None, defaults to None) – How much time in seconds is left to perform intensification.

  • save (bool, optional to True) – Whether the runhistory should be saved.

Return type:

None

update_acquisition_function(acquisition_function)[source]

Updates acquisition function and assosiates the current model. Also, the acquisition optimizer is updated.

Return type:

None

update_model(model)[source]

Updates the model and updates the acquisition function.

Return type:

None

validate(config, *, instances=None, seed=None)[source]

Validates a configuration with different seeds than in the optimization process and on the highest budget (if budget type is real-valued).

Parameters:
  • config (Configuration) – Configuration to validate

  • instances (list[str] | None, defaults to None) – Which instances to validate. If None, all instances specified in the scenario are used. In case that the budget type is real-valued budget, this argument is ignored.

  • seed (int | None, defaults to None) – If None, the seed from the scenario is used.

Returns:

cost – The averaged cost of the configuration. In case of multi-fidelity, the cost of each objective is averaged.

Return type:

float | list[float]