smac.main.smbo

Classes

SMBO(scenario, runner, runhistory, intensifier)

Implementation that contains the main Bayesian optimization loop.

Interfaces

class smac.main.smbo.SMBO(scenario, runner, runhistory, intensifier, overwrite=False)[source]

Bases: object

Implementation that contains the main Bayesian optimization loop.

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

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

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

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

  • 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 be initialized by a facade only.

ask()[source]

Asks the intensifier for the next trial.

Returns:

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

Return type:

TrialInfo

property budget_exhausted: bool

Checks whether the the remaining walltime, cputime or trials was exceeded.

exists(filename)[source]

Checks if the files associated with the run already exist. Checks all files that are created by the optimizer.

Parameters:

filename (str | Path) – The name of the folder of the SMAC run.

Return type:

bool

property intensifier: AbstractIntensifier

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

load()[source]

Loads the optimizer, intensifier, and runhistory from the output directory specified in the scenario.

Return type:

None

optimize()[source]

Runs the Bayesian optimization loop.

Returns:

incumbent – The best found configuration.

Return type:

Configuration

print_stats()[source]

Prints all statistics.

Return type:

None

property remaining_cputime: float

Subtracts the target function running budget with the used time.

property remaining_trials: int

Subtract the target function runs in the scenario with the used ta runs.

property remaining_walltime: float

Subtracts the runtime configuration budget with the used wallclock time.

reset()[source]

Resets the internal variables of the optimizer, intensifier, and runhistory.

Return type:

None

property runhistory: RunHistory

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

save()[source]

Saves the current stats, runhistory, and intensifier.

Return type:

None

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

Adds the result of a trial to the runhistory and updates the stats object.

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

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

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

Return type:

None

update_acquisition_function(acquisition_function)[source]

Updates the acquisition function including the associated model and the acquisition optimizer.

Return type:

None

update_model(model)[source]

Updates the model and updates the acquisition function.

Return type:

None

property used_target_function_walltime: float

Returns how much walltime the target function spend so far.

property used_walltime: float

Returns used wallclock time.

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

Validates a configuration on other seeds than the ones used 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]