rtac.ac_functionalities.ranking.cppl

Implements the CPPL class for RTAC.

Classes

CPPL(scenario, pool[, contender_dict])

CPPL Bandit and AC functions.

class rtac.ac_functionalities.ranking.cppl.CPPL(scenario: Namespace, pool: dict, contender_dict: dict | None = None)[source]

Bases: object

CPPL Bandit and AC functions.

Note

Implementation based on the paper: “Pool-based realtime algorithm configuration: A preselection bandit approach”

Parameters:
  • scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.

  • pool (dict) – Pool of configurations.

  • contender_dict (dict) – Dictionary containing Configurations that ran in last tournament.

asses_configurations() None[source]

Comparatively asses which Configurations are to be replaced from the pool based on skills and confidence computed by CPPL model.

Return type:

None

assess_children(transformed_configs: ndarray, nd: int) list[int][source]

Compute the skill and confidence values for newly generated Configurations based on feature matrix computed for the set of newly generated configurations and return the indices of nd best of them.

Parameters:
  • transformed_configs (np.ndarray) – transformed values of generated Configurations

  • nd (int) – Number of configurations to be replaced in the pool.

Returns:

List of indices of the nd best Configurations from all newly generated Configurations.

Return type:

list[int]

compute_array_dimension(nc_pca_f: int, nc_pca_p: int) int[source]

Compute the correct dimension of np.ndarrays used in bandit.

Parameters:
  • nc_pca_f (int) – Dimension of PCA for problem instance features.

  • nc_pca_p (int) – Dimension of PCA for Configuration values.

Returns:

Dimension of np.ndarrays used in bandit.

Return type:

int

context_specific_feature_matrix() None[source]

Compute the context-specific feature matrix.

Return type:

None

crossover(parents: list[rtac.ac_functionalities.rtac_data.Configuration], nr_children: int) list[rtac.ac_functionalities.rtac_data.Configuration][source]

Perform genetic crossover on the provided Configurations to generate offspring, with small probability of randomly generated Configurations nr_children of times.

Parameters:
  • parents (list[Configuration]) – The Configurations to be used for genetic crossover.

  • nr_children (int) – Number of how many offspring to generate.

Returns:

List of generated Configurations.

Return type:

list[Configuration]

discard_configs() int[source]

Assess the quality of the Configurations in the pool and decide which ones to replace.

Returns:

Number of Configurations to be replaced.

Return type:

int

generate_configs(nr_discarded: int) dict[str, rtac.ac_functionalities.rtac_data.Configuration] | None[source]

Perform genetic crossover on the provided Configurations to generate offspring, with small probability of randomly generated Configurations on each available core. Asses generated Configurations with CPPL model. Ensure no duplicates are inserted into the pool (possible due to CPPL model preferring configuration values). Aim at providing nr_discarding Configurations (if number is not reduced by omitting duplicates).

Parameters:

nr_discarded (int) – Number of how many new Configurations to generate.

Returns:

Dict of generated Configurations or None.

Return type:

dict[str, Configuration] or None

gradient() ndarray[source]

Computes gradient learnt from results.

Returns:

Gradient learnt from all previous results.

Return type:

np.ndarray

hessian() ndarray[source]

Computes Hessian matrix expressing confidence in skills.

Returns:

Hessian matrix expressing confidence in skills.

Return type:

np.ndarray

init_onehot_encoder() None[source]

Initialize OneHotEncoder to be used on categorical Configuration values.

Return type:

None

init_param_scaler(config_space: Namespace) None[source]

Initialize MinMaxScaler to be used on Configuration values.

Parameters:

config_space (argparse.Namespace) – Namespace containing all settings for the RTAC.

Return type:

None

insert_in_pool(configs)[source]
joinFeatureMap(x, y, mode) ndarray[source]

Joining Configuration values and problem instance features.

Parameters:
  • x (np.ndarray) – Configuration values.

  • y (np.ndarray) – Problem instance features.

  • mode (str) – Mode of combining Configuration values and instance features.

Returns:

Combined Configuration values and problem instance features.

Return type:

np.ndarray

manage_pool() None[source]

Deciding if Configurations need to be replaced and generating new ones if necessary.

Return type:

None

pre_train(feature_path: str) None[source]

Pretrain StandardScaler to be used on problem instance features.

Parameters:

feature_path (str) – Path to the CSV file containing the features.

Return type:

None

process_results() None[source]

Processing results of the last tournament. :rtype: None

record_bandit() None[source]

Records bandit state to later log it.

Return type:

None

select_contenders() None[source]

Select Configurations to run in next tournament and save them in self.contender_dict.

Return type:

None

skill_and_confidence() None[source]

Compute the skill and confidence values for Configurations in pool based on current feature matrix and save the indices of nr_cores best of them to self.S_t.

Return type:

None

split_param_types(config_space: Namespace) None[source]

Split parameter space by categorical and everything else.

Parameters:

config_space (argparse.Namespace) – Namespace containing all settings for the RTAC.

Return type:

None

transform_conf(conf: Configuration) ndarray[source]

Transorm Configuration values with MinMaxScaler and OneHotEncoder.

Parameters:

conf (Configuration) – Configuration to be transformed.

Returns:

Transformed Configuration values.

Return type:

np.ndarray

update_data() None[source]

Update data used in bandit computations by tournament results.

Return type:

None