smac.intensification.abstract_racer module

class smac.intensification.abstract_racer.AbstractRacer(stats: smac.stats.stats.Stats, traj_logger: smac.utils.io.traj_logging.TrajLogger, rng: numpy.random.mtrand.RandomState, instances: List[str], instance_specifics: Optional[Mapping[str, numpy.ndarray]] = None, cutoff: Optional[float] = None, deterministic: bool = False, run_obj_time: bool = True, minR: int = 1, maxR: int = 2000, adaptive_capping_slackfactor: float = 1.2, min_chall: int = 1)[source]

Bases: object

Base class for all racing methods

The “intensification” is designed to output a RunInfo object with enough information to run a given configuration (for example, the run info contains the instance/seed pair, as well as the associated resources).

A worker can execute this RunInfo object and produce a RunValue object with the execution results. Each intensifier process the RunValue object and updates it’s internal state in preparation for the next iteration.

Note: Do not use directly

Parameters
  • stats (Stats) – stats object

  • traj_logger (smac.utils.io.traj_logging.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 (float) – 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)

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

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

  • 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)

_adapt_cutoff(challenger: ConfigSpace.configuration_space.Configuration, run_history: smac.runhistory.runhistory.RunHistory, inc_sum_cost: float) → float[source]

Adaptive capping: Compute cutoff based on time so far used for incumbent and reduce cutoff for next run of challenger accordingly

!Only applicable if self.run_obj_time

!runs on incumbent should be superset of the runs performed for the

challenger

Parameters
Returns

cutoff – Adapted cutoff

Return type

float

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

Compare two configuration wrt the runhistory and return the one which performs better (or None if the decision is not safe)

Decision strategy to return x as being better than y:
  1. x has at least as many runs as y

  2. x performs better than y on the intersection of runs on x and y

Implicit assumption:

Challenger was evaluated on the same instance-seed pairs as incumbent

Parameters
Returns

Return type

None or better of the two configurations x,y

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

Retuns the next challenger to use in intensification If challenger is None, then optimizer will be used to generate the next challenger

Parameters
Returns

next challenger to use

Return type

Configuration

get_next_run(challengers: Optional[List[ConfigSpace.configuration_space.Configuration]], incumbent: ConfigSpace.configuration_space.Configuration, chooser: Optional[smac.optimizer.epm_configuration_chooser.EPMChooser], run_history: smac.runhistory.runhistory.RunHistory, repeat_configs: bool = True, num_workers: int = 1) → Tuple[smac.intensification.abstract_racer.RunInfoIntent, smac.runhistory.runhistory.RunInfo][source]

Abstract method for choosing the next challenger, to allow for different selections across intensifiers uses _next_challenger() by default

If no more challengers are available, the method should issue a SKIP via RunInfoIntent.SKIP, so that a new iteration can sample new configurations.

Parameters
Returns

  • run_info (RunInfo) – An object that encapsulates necessary information for a config run

  • intent (RunInfoIntent) – Indicator of how to consume the RunInfo object

process_results(run_info: smac.runhistory.runhistory.RunInfo, incumbent: Optional[ConfigSpace.configuration_space.Configuration], run_history: smac.runhistory.runhistory.RunHistory, time_bound: float, result: smac.runhistory.runhistory.RunValue, log_traj: bool = True) → Tuple[ConfigSpace.configuration_space.Configuration, float][source]

The intensifier stage will be updated based on the results/status of a configuration execution. Also, a incumbent will be determined.

Parameters
  • run_info (RunInfo) – A RunInfo containing the configuration that was evaluated

  • incumbent (typing.Optional[Configuration]) – Best configuration seen so far

  • run_history (RunHistory) – stores all runs we ran so far if False, an evaluated configuration will not be generated again

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

  • result (RunValue) – Contain the result (status and other methadata) of exercising a challenger/incumbent.

  • 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

class smac.intensification.abstract_racer.RunInfoIntent(value)[source]

Bases: enum.Enum

Class to define different requests on how to process the runinfo

Gives the flexibility to indicate whether a configuration should be skipped (SKIP) or if the SMBO should simple run a generated run_info.

RUN = 0
SKIP = 1
WAIT = 2