smac.intensifier.intensifier

Classes

Intensifier(scenario[, min_config_calls, ...])

Races challengers against an incumbent.

Interfaces

class smac.intensifier.intensifier.Intensifier(scenario, min_config_calls=1, max_config_calls=2000, min_challenger=2, intensify_percentage=0.5, race_against=None, seed=None)[source]

Bases: AbstractIntensifier

Races challengers against an incumbent.

SMAC’s intensification procedure, in detail: Intensify(Θ_new, θ_inc, M, R, t_intensify, Π, c_hat) c_hat(θ, Π’) denotes the empirical cost of θ on the subset of instances Π’ ⊆ Π, based on the trials in R; max_config_calls is a parameter where: Θ_new: Sequence of parameter settings to evaluate, challengers in this class. θ_inc: incumbent parameter setting, incumbent in this class.

1 for i := 1, … , length(Θ_new) do 2 θ_new ← Θ_new[i]

STAGE -> RUN_INCUMBENT

3 if R contains less than max_config_calls trials with configuration θ_inc then 4 Π’ ← {π’∈ Π | R contains less than or equal number of trials using θ_inc and π’ 0 than using θ_inc and any other π’’∈ Π} 5 π ← instance sampled uniformly at random from Π’ 6 s ← seed, drawn uniformly at random 7 R ← ExecuteRun(R, θ_inc, π, s) 8 N ← 1

STAGE -> RUN_CHALLENGER

9 while true do 10 S_missing ← {instance, seed} pairs for which θ_inc was run before, but not θ_new 11 S_torun ← random subset of S_missing of size min(N, size(S_missing)) 12 foreach (π, s) ∈ S_torun do R ← ExecuteRun(R, θ_new, π, s) 13 S_missing ← S_missing \ S_torun 14 Π_common ← instances for which we previously ran both θ_inc and θ_new 15 if c_hat(θ_new, Π_common) > c_hat(θ_inc, Π_common) then break 16 else if S_missing = ∅ then θ_inc ← θ_new; break 17 else N ← 2 · N 18 if time spent in this call to this procedure exceeds t_intensify and i ≥ 2 then break 19 return [R, θ_inc]

Parameters:
  • scenario (Scenario) –

  • min_config_calls (int, defaults to 1) – Minimum number of trials per config (summed over all calls to intensify).

  • max_config_calls (int, defaults to 2000) – Maximum number of trials per config (summed over all calls to intensify).

  • min_challenger (int, defaults to 2) – Minimal number of challengers to be considered (even if time_bound is exhausted earlier).

  • intensify_percentage (float, defaults to 0.5) – How much percentage of the time should configurations be intensified (evaluated on higher budgets or more instances). This parameter is accessed in the SMBO class.

  • race_against (Configuration | None, defaults to none) – If incumbent changes, race this configuration always against new incumbent. Prevents sometimes over-tuning.

  • seed (int | None, defaults to none) –

get_next_challenger(challengers, get_next_configurations)[source]

This function returns the next challenger, that should be exercised though lines 8-17.

It does so by populating _configs_to_run, which is a pool of configuration from which the racer will sample. Each configuration within _configs_to_run, will be intensified on different instances/seed registered in self._to_run as stated in line 11.

A brand new configuration should only be sampled, after all self._to_run instance seed pairs are exhausted.

This method triggers a call to _next_iteration if there are no more configurations to run, for the current intensification loop. This marks the transition to Line 2, where a new configuration to intensify will be drawn from epm/initial challengers.

Parameters:
  • challengers (list[Configuration] | None, defaults to None) – Promising configurations.

  • get_next_configurations (Callable[[], Iterator[Configuration]] | None) – Function that generates next configurations to use for racing.

Return type:

tuple[Optional[Configuration], bool]

Returns:

  • configuration (Configuration | None) – The configuration of the selected challenger.

  • new_challenger (bool) – If the configuration is a new challenger.

get_next_trial(challengers, incumbent, get_next_configurations, runhistory, repeat_configs=True, n_workers=1)[source]

This procedure is in charge of generating a TrialInfo object to comply with lines 7 (in case stage is stage == RUN_INCUMBENT) or line 12 (In case of stage == RUN_CHALLENGER).

A TrialInfo object encapsulates the necessary information for a worker to execute the job, nevertheless, a challenger is not always available. This could happen because no more configurations are available or the new configuration to try was already executed.

To circumvent this, an intent is also returned:

  • intent == RUN: Run the TrialInfo object (Normal Execution).

  • intent == SKIP: Skip this iteration. No challenger is available. In particular because challenger is the same

    as incumbent

Parameters:
  • challengers (list[Configuration] | None) – Promising configurations.

  • incumbent (Configuration) – Incumbent configuration.

  • get_next_configurations (Callable[[], Iterator[Configuration]] | None, defaults to none) – Function that generates next configurations to use for racing.

  • runhistory (RunHistory) –

  • repeat_configs (bool, defaults to true) – If false, an evaluated configuration will not be generated again.

  • n_workers (int, optional, defaults to 1) – The maximum number of workers available.

Return type:

tuple[TrialInfoIntent, TrialInfo]

Returns:

  • TrialInfoIntent – Indicator of how to consume the TrialInfo object.

  • TrialInfo – An object that encapsulates necessary information of the trial.

get_target_function_budgets()[source]

Which budgets are used to call the target function.

Return type:

list[Optional[float]]

get_target_function_instances()[source]

Which instances are used to call the target function.

Return type:

list[Optional[str]]

get_target_function_seeds()[source]

Which seeds are used to call the target function.

Return type:

list[int]

property intensify_percentage: float

How much percentage of the time should configurations be intensified (evaluated on higher budgets or more instances). This parameter is accessed in the SMBO class.

Return type:

float

property meta: dict[str, Any]

Returns the meta data of the created object.

Return type:

dict[str, Any]

process_results(trial_info, trial_value, incumbent, runhistory, time_bound, log_trajectory=True)[source]

The intensifier stage will be updated based on the results/status of a configuration execution. During intensification, the following can happen:

  • Challenger raced against incumbent.

  • Also, during a challenger run, a capped exception can be triggered, where no racer post processing is needed.

  • A run on the incumbent for more confidence needs to be processed, IntensifierStage.PROCESS_INCUMBENT_RUN.

  • The first run results need to be processed (PROCESS_FIRST_CONFIG_RUN).

At the end of any run, checks are done to move to a new iteration.

Parameters:
  • trial_info (TrialInfo) –

  • trial_value (TrialValue) –

  • incumbent (Configuration | None) – Best configuration seen so far.

  • runhistory (RunHistory) –

  • time_bound (float) – Time [sec] available to perform intensify.

  • log_trajectory (bool) – Whether to log changes of incumbents in the trajectory.

Return type:

tuple[Configuration, float]

Returns:

  • incumbent (Configuration) – Current (maybe new) incumbent configuration.

  • incumbent_costs (float | list[float]) – Empirical cost(s) of the incumbent configuration.

property uses_budgets: bool

If the intensifier needs to make use of budgets.

Return type:

bool

property uses_instances: bool

If the intensifier needs to make use of instances.

Return type:

bool

property uses_seeds: bool

If the intensifier needs to make use of seeds.

Return type:

bool