selector.generators.surrogates.ggapp_surrogate

This module contains functions for the GGA++ surrogate.

Classes

GGAppSurr(scenario[, seed, cost, logger])

Surrogate for GGA++.

class selector.generators.surrogates.ggapp_surrogate.GGAppSurr(scenario, seed=False, cost=[1, 1, 0, 0], logger=None)[source]

Bases: object

Surrogate for GGA++.

Note

Implementation based on the paper “Model-Based Genetic Algorithms for Algorithm Configuration, C. Ans{‘o}tegui et al. and using source code of the package costcla.

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

  • seed (int) – Random seed.

  • cost (list) – Cost matrix for cost-sensitive classification. Per default set to neutral to take no effect.

  • logger (logging.Logger) – Logger from main loop. Default is None, so no Debug infos.

expected_improvement(suggestions, _)[source]

Compute expected improvement via CPPL 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_costs(y)[source]

Generate cost matrix.

Parameters:

y (ndarray) – Configuration performances.

Returns:

costs: ndarray of mock cost matrices.

Return type:

ndarray

get_suggestions(scenario, n_samples, data, results, _, oversampling=10)[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.

  • data (list of selector.pool.Tournament) – Tournament history.

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

  • _ (list of str) – Instance set to run on in the next tournament.

  • oversampling (int) – Multiplier for generation via GGA graph crossover before filtering with GGApp model.

Returns:

Suggested configurations.

Return type:

list of selector.pool.Configuration

predict(confs, _=None)[source]

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

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

  • _ (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, r, ni)[source]

Compute probability of improvement.

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

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

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

Returns:

pi_output: Probabilities of improvement.

Return type:

ndarray

set_cat(c)[source]

Set Cat value to binary.

Parameters:

c (bool) – Any bool value.

Returns:

True will be 0, False will be 1.

Return type:

int

transfom_selector_scenario_for_ggapp(scenario)[source]

Transform scenario from Selector to suit GGAppSurr.

Parameters:

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

transform_values(conf)[source]

Transform configuration values in GGA++ format.

Parameters:

conf (selector.pool.Configurator or list of selector.pool.Configuration) – Configuration(s) to transform for GGAppSurr.

Returns:

Transformed configuration(s).

Return type:

selector.pool.Configurator or list of selector.pool.Configuration

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

Update GGA++ 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.