smac.facade.smac_ac_facade

Classes

SMAC4AC(scenario[, tae_runner, ...])

Facade to use SMAC default mode for Algorithm configuration.

class smac.facade.smac_ac_facade.SMAC4AC(scenario, tae_runner=None, tae_runner_kwargs=None, runhistory=None, runhistory_kwargs=None, intensifier=None, intensifier_kwargs=None, acquisition_function=None, acquisition_function_kwargs=None, integrate_acquisition_function=False, user_priors=False, user_prior_kwargs=None, acquisition_function_optimizer=None, acquisition_function_optimizer_kwargs=None, model=None, model_kwargs=None, runhistory2epm=None, runhistory2epm_kwargs=None, multi_objective_algorithm=None, multi_objective_kwargs=None, initial_design=None, initial_design_kwargs=None, initial_configurations=None, stats=None, restore_incumbent=None, rng=None, smbo_class=None, smbo_kwargs=None, run_id=None, random_configuration_chooser=None, random_configuration_chooser_kwargs=None, dask_client=None, n_jobs=1)[source]

Bases: object

Facade to use SMAC default mode for Algorithm configuration.

Parameters
  • scenario (Scenario) – Scenario object

  • tae_runner (BaseRunner or callable) – Callable or implementation of BaseRunner. In case a callable is passed it will be wrapped by ExecuteTAFuncDict. If not set, it will be initialized with the ExecuteTARunOld.

  • tae_runner_kwargs (Optional[Dict]) – arguments passed to constructor of ‘~tae_runner’

  • runhistory (RunHistory) – runhistory to store all algorithm runs

  • runhistory_kwargs (Optional[Dict]) – arguments passed to constructor of runhistory. We strongly advise against changing the aggregation function, since it will break some code assumptions

  • intensifier (AbstractRacer) – intensification object or class to issue a racing to decide the current incumbent. Default: class Intensifier

  • intensifier_kwargs (Optional[Dict]) – arguments passed to the constructor of ‘~intensifier’

  • acquisition_function (~smac.optimizer.acquisition.AbstractAcquisitionFunction) – Class or object that implements the AbstractAcquisitionFunction. Will use EI or LogEI if not set. ~acquisition_function_kwargs is passed to the class constructor.

  • acquisition_function_kwargs (Optional[Dict]) – dictionary to pass specific arguments to ~acquisition_function

  • integrate_acquisition_function (bool, default=False) – Whether to integrate the acquisition function. Works only with models which can sample their hyperparameters (i.e. GaussianProcessMCMC).

  • user_priors (bool, default=False) – Whether to make use of user priors in the optimization procedure, using PriorAcquisitionFunction.

  • user_prior_kwargs (Optional[Dict]) – Dictionary to pass specific arguments to optimization with prior, e.g. prior confidence parameter, and the floor value for the prior (lowest possible value the prior can take).

  • acquisition_function_optimizer (AcquisitionFunctionMaximizer) – Object that implements the AcquisitionFunctionMaximizer. Will use smac.optimizer.ei_optimization.InterleavedLocalAndRandomSearch if not set.

  • acquisition_function_optimizer_kwargs (Optional[dict]) – Arguments passed to constructor of ~acquisition_function_optimizer

  • model (BaseEPM) – Model that implements train() and predict(). Will use a RandomForestWithInstances if not set.

  • model_kwargs (Optional[dict]) – Arguments passed to constructor of ~model

  • runhistory2epm (RunHistory2EMP) – Object that implements the AbstractRunHistory2EPM. If None, will use RunHistory2EPM4Cost if objective is cost or RunHistory2EPM4LogCost if objective is runtime.

  • runhistory2epm_kwargs (Optional[dict]) – Arguments passed to the constructor of ~runhistory2epm

  • multi_objective_algorithm (Optional[Type["AbstractMultiObjectiveAlgorithm"]]) – Class that implements multi objective logic. If None, will use: smac.optimizer.multi_objective.aggregation_strategy.MeanAggregationStrategy Multi objective only becomes active if the objective specified in ~scenario.run_obj is a List[str] with at least two entries.

  • multi_objective_kwargs (Optional[Dict]) – Arguments passed to ~multi_objective_algorithm.

  • initial_design (InitialDesign) – initial sampling design

  • initial_design_kwargs (Optional[dict]) – arguments passed to constructor of ~initial_design

  • initial_configurations (List[Configuration]) – list of initial configurations for initial design – cannot be used together with initial_design

  • stats (Stats) – optional stats object

  • rng (np.random.RandomState) – Random number generator

  • restore_incumbent (Configuration) – incumbent used if restoring to previous state

  • smbo_class (SMBO) – Class implementing the SMBO interface which will be used to instantiate the optimizer class.

  • smbo_kwargs (~ Optional[Dict]) – Arguments passed to the constructor of ‘~smbo’

  • run_id (int (optional)) – Run ID will be used as subfolder for output_dir. If no run_id is given, a random run_id will be chosen.

  • random_configuration_chooser (RandomConfigurationChooser) – How often to choose a random configuration during the intensification procedure.

  • random_configuration_chooser_kwargs (Optional[dict]) – arguments of constructor for ~random_configuration_chooser

  • dask_client (dask.distributed.Client) – User-created dask client, can be used to start a dask cluster and then attach SMAC to it.

  • n_jobs (int, optional) – Number of jobs. If > 1 or -1, this creates a dask client if dask_client is None. Will be ignored if dask_client is not None. If None, this value will be set to 1, if -1, this will be set to the number of cpu cores.

logger
stats
Type

Stats

solver
Type

SMBO

runhistory

List with information about previous runs

Type

RunHistory

trajectory

List of all incumbents

Type

list

get_runhistory()[source]

Returns the runhistory (i.e., all evaluated configurations and the results).

Returns

Runhistory

Return type

smac.runhistory.runhistory.RunHistory

get_tae_runner()[source]

Returns target algorithm evaluator (TAE) object which can run the target algorithm given a configuration.

Returns

TAE

Return type

smac.tae.base.BaseRunner

get_trajectory()[source]

Returns the trajectory (i.e., all incumbent configurations over time).

Returns

Trajectory

Return type

List of TrajEntry

optimize()[source]

Optimizes the algorithm provided in scenario (given in constructor)

Returns

incumbent – Best found configuration

Return type

Configuration

register_callback(callback)[source]

Register a callback function.

Callbacks must implement a class in smac.callbacks and be instantiated objects. They will automatically be registered within SMAC based on which callback class from smac.callbacks they implement.

Parameters

Callable (callback -) –

Return type

None

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

  • backend (string) – what backend to be used by joblib

Returns

runhistory – runhistory containing all specified runs

Return type

RunHistory