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.intensification.Intensifier, aggregate_func: <built-in function callable>, num_run: int, model: smac.epm.rf_with_instances.RandomForestWithInstances, acq_optimizer: smac.optimizer.ei_optimization.AcquisitionFunctionMaximizer, acquisition_func: smac.optimizer.acquisition.AbstractAcquisitionFunction, rng: mtrand.RandomState, restore_incumbent: ConfigSpace.configuration_space.Configuration = None)[source]

Bases: object

Interface that contains the main Bayesian optimization loop

logger
incumbent
scenario
config_space
stats
initial_design
runhistory
rh2EPM
intensifier
aggregate_func
num_run
model
acq_optimizer
acquisition_func
rng

Interface that contains the main Bayesian optimization loop

Parameters:
  • scenario (smac.scenario.scenario.Scenario) – Scenario object
  • stats (Stats) – statistics object with configuration budgets
  • initial_design (InitialDesign) – initial sampling design
  • runhistory (RunHistory) – runhistory with all runs so far
  • runhistory2epm (AbstractRunHistory2EPM) – Object that implements the AbstractRunHistory2EPM to convert runhistory data into EPM data
  • intensifier (Intensifier) – intensification of new challengers against incumbent configuration (probably with some kind of racing on the instances)
  • aggregate_func (callable) –
    how to aggregate the runs in the runhistory to get the performance of a
    configuration
  • num_run (int) – id of this run (used for pSMAC)
  • model (RandomForestWithInstances) – empirical performance model (right now, we support only RandomForestWithInstances)
  • acq_optimizer (AcquisitionFunctionMaximizer) – Optimizer of acquisition function.
  • acquisition_function (AcquisitionFunction) – Object that implements the AbstractAcquisitionFunction (i.e., infill criterion for acq_optimizer)
  • restore_incumbent (Configuration) – incumbent to be used from the start. ONLY used to restore states.
  • rng (np.random.RandomState) – Random number generator
choose_next(X: numpy.ndarray, Y: numpy.ndarray, incumbent_value: float = None)[source]

Choose next candidate solution with Bayesian optimization. The suggested configurations depend on the argument acq_optimizer to the SMBO class.

Parameters:
  • X ((N, D) numpy array) – Each row contains a configuration and one set of instance features.
  • Y ((N, O) numpy array) – The function values for each configuration instance pair.
  • incumbent_value (float) – Cost value of incumbent configuration (required for acquisition function); if not given, it will be inferred from runhistory; if not given and runhistory is empty, it will raise a ValueError
Returns:

Return type:

Iterable

run()[source]

Runs the Bayesian optimization loop

Returns:incumbent – The best found configuration
Return type:np.array(1, H)
start()[source]

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

validate(config_mode='inc', instance_mode='train+test', repetitions=1, use_epm=False, n_jobs=-1, backend='threading')[source]

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