smac.intensification.intensification module

class smac.intensification.intensification.Intensifier(tae_runner: smac.tae.execute_ta_run.ExecuteTARun, stats: smac.stats.stats.Stats, traj_logger: smac.utils.io.traj_logging.TrajLogger, rng: numpy.random.mtrand.RandomState, instances: List[str], instance_specifics: Mapping[str, numpy.ndarray] = None, cutoff: int = None, deterministic: bool = False, run_obj_time: bool = True, always_race_against: ConfigSpace.configuration_space.Configuration = None, run_limit: int = 2147483647, use_ta_time_bound: bool = False, minR: int = 1, maxR: int = 2000, adaptive_capping_slackfactor: float = 1.2, min_chall: int = 2)[source]

Bases: smac.intensification.abstract_racer.AbstractRacer

Races challengers against an incumbent (a.k.a. SMAC’s intensification procedure).

Parameters
  • tae_runner (tae.executre_ta_run_*.ExecuteTARun* Object) – target algorithm run executor

  • stats (Stats) – stats object

  • traj_logger (TrajLogger) – TrajLogger object to log all new incumbents

  • rng (np.random.RandomState) –

  • instances (typing.List[str]) – list of all instance ids

  • instance_specifics (typing.Mapping[str,np.ndarray]) – mapping from instance name to instance specific string

  • cutoff (int) – runtime cutoff of TA runs

  • deterministic (bool) – whether the TA is deterministic or not

  • run_obj_time (bool) – whether the run objective is runtime or not (if true, apply adaptive capping)

  • always_race_against (Configuration) – if incumbent changes race this configuration always against new incumbent; can sometimes prevent over-tuning

  • use_ta_time_bound (bool,) – if true, trust time reported by the target algorithms instead of measuring the wallclock time for limiting the time of intensification

  • run_limit (int) – Maximum number of target algorithm runs per call to intensify.

  • maxR (int) – Maximum number of runs per config (summed over all calls to intensifiy).

  • minR (int) – Minimum number of run per config (summed over all calls to intensify).

  • adaptive_capping_slackfactor (float) – slack factor of adpative capping (factor * adpative cutoff)

  • min_chall (int) – minimal number of challengers to be considered (even if time_bound is exhausted earlier)

_add_inc_run(incumbent: ConfigSpace.configuration_space.Configuration, run_history: smac.runhistory.runhistory.RunHistory, log_traj: bool = True) → None[source]

Add new run for incumbent

Side effect: adds runs to <run_history>

Parameters
_generate_challengers(challengers: Optional[List[ConfigSpace.configuration_space.Configuration]], chooser: Optional[smac.optimizer.epm_configuration_chooser.EPMChooser]) → Iterator[Optional[ConfigSpace.configuration_space.Configuration]][source]

Retuns a sequence of challengers to use in intensification If challengers are not provided, then optimizer will be used to generate the challenger list

Parameters
Returns

A generator containing the next challengers to use

Return type

typing.Optional[typing.Generator[Configuration]]

_get_instances_to_run(challenger: ConfigSpace.configuration_space.Configuration, incumbent: ConfigSpace.configuration_space.Configuration, run_history: smac.runhistory.runhistory.RunHistory, N: int) → Tuple[List[smac.runhistory.runhistory.InstSeedBudgetKey], float][source]

Returns the minimum list of <instance, seed> pairs to run the challenger on before comparing it with the incumbent

Parameters
Returns

  • typing.List[InstSeedBudgetKey] – list of <instance, seed, budget> tuples to run

  • float – total (runtime) cost of running the incumbent on the instances (used for adaptive capping while racing)

_next_iteration() → None[source]

Updates tracking variables at the end of an intensification run

_race_challenger(challenger: ConfigSpace.configuration_space.Configuration, incumbent: ConfigSpace.configuration_space.Configuration, run_history: smac.runhistory.runhistory.RunHistory, log_traj: bool = True) → ConfigSpace.configuration_space.Configuration[source]

Aggressively race challenger against incumbent

Parameters
Returns

new_incumbent – Either challenger or incumbent

Return type

Configuration

eval_challenger(challenger: ConfigSpace.configuration_space.Configuration, incumbent: Optional[ConfigSpace.configuration_space.Configuration], run_history: smac.runhistory.runhistory.RunHistory, time_bound: float = 2147483647.0, log_traj: bool = True) → Tuple[ConfigSpace.configuration_space.Configuration, float][source]

Running intensification to determine the incumbent configuration. Side effect: adds runs to run_history

Implementation of Procedure 2 in Hutter et al. (2011).

Provide either challengers or optimizer and set the other to None. If both arguments are given, then the optimizer will be used.

Parameters
  • challenger (Configuration) – promising configurations

  • incumbent (typing.Optional[Configuration]) – best configuration so far, None in 1st run

  • run_history (smac.runhistory.runhistory.RunHistory) – stores all runs we ran so far

  • time_bound (float, optional (default=2 ** 31 - 1)) – time in [sec] available to perform intensify

  • log_traj (bool) – whether to log changes of incumbents in trajectory

Returns

  • incumbent (Configuration()) – current (maybe new) incumbent configuration

  • inc_perf (float) – empirical performance of incumbent configuration

get_next_challenger(challengers: Optional[List[ConfigSpace.configuration_space.Configuration]], chooser: Optional[smac.optimizer.epm_configuration_chooser.EPMChooser], run_history: Optional[smac.runhistory.runhistory.RunHistory] = None, repeat_configs: bool = True) → Tuple[Optional[ConfigSpace.configuration_space.Configuration], bool][source]

Selects which challenger to use based on the iteration stage and set the iteration parameters. First iteration will choose configurations from the chooser or input challengers, while the later iterations pick top configurations from the previously selected challengers in that iteration

Parameters
Returns

  • typing.Optional[Configuration] – next configuration to evaluate

  • bool – flag telling if the configuration is newly sampled or one currently being tracked

class smac.intensification.intensification.IntensifierStage(value)[source]

Bases: enum.Enum

Class to define different stages of intensifier

RUN_BASIS = 3
RUN_CHALLENGER = 2
RUN_FIRST_CONFIG = 0
RUN_INCUMBENT = 1