smac.facade.smac_ac_facade¶
- class smac.facade.smac_ac_facade.SMAC4AC(scenario: smac.scenario.scenario.Scenario, tae_runner: Optional[Union[Type[smac.tae.base.BaseRunner], Callable]] = None, tae_runner_kwargs: Optional[Dict] = None, runhistory: Optional[Union[Type[smac.runhistory.runhistory.RunHistory], smac.runhistory.runhistory.RunHistory]] = None, runhistory_kwargs: Optional[Dict] = None, intensifier: Optional[Type[smac.intensification.abstract_racer.AbstractRacer]] = None, intensifier_kwargs: Optional[Dict] = None, acquisition_function: Optional[Type[smac.optimizer.acquisition.AbstractAcquisitionFunction]] = None, acquisition_function_kwargs: Optional[Dict] = None, integrate_acquisition_function: bool = False, acquisition_function_optimizer: Optional[Type[smac.optimizer.ei_optimization.AcquisitionFunctionMaximizer]] = None, acquisition_function_optimizer_kwargs: Optional[Dict] = None, model: Optional[Type[smac.epm.base_epm.AbstractEPM]] = None, model_kwargs: Optional[Dict] = None, runhistory2epm: Optional[Type[smac.runhistory.runhistory2epm.AbstractRunHistory2EPM]] = None, runhistory2epm_kwargs: Optional[Dict] = None, multi_objective_algorithm: Optional[Type[smac.optimizer.multi_objective.abstract_multi_objective_algorithm.AbstractMultiObjectiveAlgorithm]] = None, multi_objective_kwargs: Optional[Dict] = None, initial_design: Optional[Type[smac.initial_design.initial_design.InitialDesign]] = None, initial_design_kwargs: Optional[Dict] = None, initial_configurations: Optional[List[ConfigSpace.configuration_space.Configuration]] = None, stats: Optional[smac.stats.stats.Stats] = None, restore_incumbent: Optional[ConfigSpace.configuration_space.Configuration] = None, rng: Optional[Union[int, numpy.random.mtrand.RandomState]] = None, smbo_class: Optional[Type[smac.optimizer.smbo.SMBO]] = None, run_id: Optional[int] = None, random_configuration_chooser: Optional[Type[smac.optimizer.random_configuration_chooser.RandomConfigurationChooser]] = None, random_configuration_chooser_kwargs: Optional[Dict] = None, dask_client: Optional[distributed.client.Client] = None, n_jobs: Optional[int] = 1)¶
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 byExecuteTAFuncDict
. If not set, it will be initialized with theExecuteTARunOld
.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 useEI
orLogEI
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).
acquisition_function_optimizer (AcquisitionFunctionMaximizer) – Object that implements the
AcquisitionFunctionMaximizer
. Will usesmac.optimizer.ei_optimization.InterleavedLocalAndRandomSearch
if not set.acquisition_function_optimizer_kwargs (Optional[dict]) – Arguments passed to constructor of ~acquisition_function_optimizer
model (AbstractEPM) – 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 orRunHistory2EPM4LogCost
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.
run_id (int (optional)) – Run ID will be used as subfolder for output_dir. If no
run_id
is given, a randomrun_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
isNone
. Will be ignored ifdask_client
is notNone
. IfNone
, this value will be set to 1, if-1
, this will be set to the number of cpu cores.
- logger¶
- runhistory¶
List with information about previous runs
- Type
- trajectory¶
List of all incumbents
- Type
list
- get_runhistory() smac.runhistory.runhistory.RunHistory ¶
- Returns the runhistory (i.e., all evaluated configurations and
the results).
- Returns
Runhistory
- Return type
- get_tae_runner() smac.tae.base.BaseRunner ¶
Returns target algorithm evaluator (TAE) object which can run the target algorithm given a configuration
- Returns
TAE
- Return type
- get_trajectory() List[smac.utils.io.traj_logging.TrajEntry] ¶
Returns the trajectory (i.e., all incumbent configurations over time).
- Returns
Trajectory
- Return type
List of
TrajEntry
- optimize() ConfigSpace.configuration_space.Configuration ¶
Optimizes the algorithm provided in scenario (given in constructor)
- Returns
incumbent – Best found configuration
- Return type
Configuration
- register_callback(callback: Callable) None ¶
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 fromsmac.callbacks
they implement.- Parameters
Callable (callback -) –
- Returns
- Return type
None
- validate(config_mode: Union[List[ConfigSpace.configuration_space.Configuration], numpy.ndarray, str] = 'inc', instance_mode: Union[List[str], 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
backend (string) – what backend to be used by joblib
- Returns
runhistory – runhistory containing all specified runs
- Return type