selector.generators.surrogates.smac_surrogate

This module contains functions for the SMAC surrogate.

Classes

SmacSurr(scenario[, seed, pca_dim])

Surrogate from SMAC.

class selector.generators.surrogates.smac_surrogate.SmacSurr(scenario, seed=False, pca_dim=8)[source]

Bases: object

Surrogate from SMAC.

Note

Implementation is using source code of the package smac.

Parameters:
  • scenario (selector.scenario.Scenario) – AC scenario.

  • seed (int) – Random seed.

  • pca_dim (int) – PCA dimension for SMAC surrogates instance feature PCA.

expected_improvement(suggestions, _)[source]

Compute expected improvement via SMAC model.

Parameters:
  • suggestions (list of selector.pool.Configuration) – Suggested configurations.

  • _ (list of str) – List of next instances to be run.

Returns:

ei: Expected improvements.

Return type:

ndarray

get_suggestions(scenario, n_samples, *args)[source]

Suggest configurations to run next based on the next instance set to run on.

Parameters:
  • scenario (selector.scenario.Scenario) – AC scenario.

  • n_samples (int) – Number of configurations to return.

  • *args (Any) – Catches unneeded arguments due to the implementation of other surrogates.

Returns:

Suggested configurations.

Return type:

list of selector.pool.Configuration

pca_inst_feat_file(train_insts, feature_file, insts, pca_feats)[source]

Generate instance feature file with PCA features.

Parameters:
  • train_insts (str) – Name of instance file.

  • feature_file (str) – path to file with problem instance features.

  • insts (list of str) – Complete training instance set.

  • pca_feats (ndarray) – Problem instance features.

Returns:

  • ndarray, Instance features after PCA.

  • list, Instance names.

Return type:

tuple

predict(confs, inst)[source]

Predict performance/quality of configurations with GGA++ EPM.

Parameters:
  • confs (list of selector.pool.Configuration) – Suggested configurations.

  • inst (list) – List of next instances to run the tournament on.

Returns:

  • ndarray, Mean of predicted performance/quality.

  • ndarray, Variance of predicted performance/quality.

Return type:

tuple

probability_improvement(suggestions, results, i)[source]

Compute probability of improvement.

Parameters:
  • suggestions (list of selector.pool.Configuration) – Suggested configurations.

  • results (dict) – Performances of the configuration on the instance set of the tournament.

  • i (list) – List of next instances to run the tournament on.

Returns:

probimp: Probabilities of improvement.

Return type:

ndarray

transfom_selector_scenario_for_smac(scenario)[source]

Transform scenario to SMAC formulation.

Parameters:

scenario (selector.scenario.Scenario) – AC scenario.

Returns:

  • s : smac.scenario, AC scenario in SMAC format.

  • config_space : smac.configspace.ConfigurationSpace, Parameter space definition in SMAC format.

  • types : list, Parameter types.

  • bounds : list of float, Parameter bounds.

Return type:

tuple

transform_for_epm(confs, pred=False)[source]

Transform configuration to suit SMAC epm.

Parameters:
  • confs (list selector.pool.Configuration) – Configurations to be transformed.

  • pred (bool) – True if prepared for prediction.

Returns:

Transformed configurations.

Return type:

ndarray

transform_values(conf, pred=False)[source]

Transform configuration values in SMAC format.

Parameters:
  • conf (selector.pool.Configuration) – Configuration to be transformed.

  • pred (bool) – True if configuration is prepared for prediction.

Returns:

Transformed configuration values.

Return type:

dict

update(history, configs, results, terminations, ac_runtime=None)[source]

Update SMAC epm.

Parameters:
  • history (list of selector.pool.Tournament) – Tournament history.

  • configs (list of selector.pool.Configuration) – Configurations that participated in the tournament.

  • results (dict) – Results of the tournament.

  • terminations (dict) – Information about terminations of runs that occurred.

  • ac_runtime (int) – Total AC runtime in seconds so far.