smac.optimizer.smbo module

class smac.optimizer.smbo.SMBO(scenario: smac.scenario.scenario.Scenario, stats: smac.stats.stats.Stats, initial_design: smac.initial_design.initial_design.InitialDesign, runhistory: smac.runhistory.runhistory.RunHistory, runhistory2epm: smac.runhistory.runhistory2epm.AbstractRunHistory2EPM, intensifier: smac.intensification.abstract_racer.AbstractRacer, num_run: int, model: smac.epm.rf_with_instances.RandomForestWithInstances, acq_optimizer: smac.optimizer.ei_optimization.AcquisitionFunctionMaximizer, acquisition_func: smac.optimizer.acquisition.AbstractAcquisitionFunction, rng: numpy.random.mtrand.RandomState, tae_runner: smac.tae.base.BaseRunner, restore_incumbent: Optional[ConfigSpace.configuration_space.Configuration] = None, random_configuration_chooser: smac.optimizer.random_configuration_chooser.RandomConfigurationChooser = <smac.optimizer.random_configuration_chooser.ChooserNoCoolDown object>, predict_x_best: bool = True, min_samples_model: int = 1)

Bases: object

Interface that contains the main Bayesian optimization loop

logger
incumbent
scenario
config_space
stats
initial_design
runhistory
intensifier
num_run
rng
initial_design_configs
epm_chooser
tae_runner
_get_timebound_for_intensification(time_spent: float, update: bool) float

Calculate time left for intensify from the time spent on choosing challengers using the fraction of time intended for intensification (which is specified in scenario.intensification_percentage).

Parameters
  • time_spent (float) –

  • update (bool) – Only used to check in the unit tests how this function was called

Returns

time_left

Return type

float

_incorporate_run_results(run_info: smac.runhistory.runhistory.RunInfo, result: smac.runhistory.runhistory.RunValue, time_left: float) None

The SMBO submits a config-run-request via a RunInfo object. When that config run is completed, a RunValue, which contains all the relevant information obtained after running a job, is returned. This method incorporates the status of that run into the stats/runhistory objects so that other consumers can advance with their task.

Additionally, it checks for a new incumbent via the intensifier process results, which also has the side effect of moving the intensifier to a new state

Parameters
  • run_info (RunInfo) – Describes the run (config) from which to process the results

  • result (RunValue) – Contains relevant information regarding the execution of a config

  • time_left (float) – time in [sec] available to perform intensify

run() ConfigSpace.configuration_space.Configuration

Runs the Bayesian optimization loop

Returns

incumbent – The best found configuration

Return type

np.array(1, H)

save() None

Saves the current stats and runhistory.

start() None

Starts the Bayesian Optimization loop. Detects whether the optimization is restored from a previous state.

validate(config_mode: Union[str, List[ConfigSpace.configuration_space.Configuration]] = 'inc', instance_mode: Union[str, List[str]] = 'train+test', repetitions: int = 1, use_epm: bool = False, n_jobs: int = - 1, backend: str = 'threading') smac.runhistory.runhistory.RunHistory

Create validator-object and run validation, using scenario-information, runhistory from smbo and tae_runner from intensify

Parameters
  • config_mode (str or list<Configuration>) – string or directly a list of Configuration str from [def, inc, def+inc, wallclock_time, cpu_time, all] time evaluates at cpu- or wallclock-timesteps of: [max_time/2^0, max_time/2^1, max_time/2^3, …, default] with max_time being the highest recorded time

  • instance_mode (string) – what instances to use for validation, from [train, test, train+test]

  • repetitions (int) – number of repetitions in nondeterministic algorithms (in deterministic will be fixed to 1)

  • use_epm (bool) – whether to use an EPM instead of evaluating all runs with the TAE

  • n_jobs (int) – number of parallel processes used by joblib

Returns

runhistory – runhistory containing all specified runs

Return type

RunHistory