Utils

exception iohblade.utils.NoCodeException

Bases: Exception

Could not extract generated code.

exception iohblade.utils.OverBudgetException

Bases: Exception

The algorithm tried to do more evaluations than allowed.

exception iohblade.utils.ThresholdReachedException

Bases: Exception

The algorithm reached the lower threshold.

exception iohblade.utils.TimeoutException

Bases: Exception

Custom exception for handling timeouts.

class iohblade.utils.aoc_logger(budget, lower=1e-08, upper=100000000.0, scale_log=True, stop_on_threshold=False, *args, **kwargs)

Bases: AbstractLogger

aoc_logger class implementing the logging module for ioh.

reset(self: ioh.iohcpp.logger.Logger) None

Reset the state of the logger

iohblade.utils.bootstrap_ci(diff, n_boot=10000, alpha=0.05, rng=None)

Compute a bootstrap confidence interval for a mean difference.

Args:

diff: Array of paired differences. n_boot: Number of bootstrap samples. alpha: Significance level (two-sided). rng: Random seed or numpy Generator.

Returns:

tuple[float, float]: Lower and upper confidence bounds.

class iohblade.utils.budget_logger(budget, *args, **kwargs)

Bases: AbstractLogger

budget_logger class implementing the logging module for ioh.

reset(self: ioh.iohcpp.logger.Logger) None

Reset the state of the logger

iohblade.utils.class_info(code_string: str) Tuple[str | None, str | None]

Return (class_name, docstring_or_None).

iohblade.utils.cliffs_delta(a, b)

Compute Cliff’s delta effect size for two samples.

Args:

a: Sample A values. b: Sample B values.

Returns:

float: Cliff’s delta in [-1, 1].

iohblade.utils.code_compare(code1, code2)
iohblade.utils.compare_auc(logger: any, method_a: str, method_b: str, budget: int = 100, metric: str = 'fitness', test: str = 'wilcoxon', n_boot: int = 10000, alpha: float = 0.05, rng: int = 0)

Compare convergence AUCs between two methods.

Args:

logger: Experiment logger containing evaluation data. method_a: Name of the first method. method_b: Name of the second method. budget: Maximum evaluation budget for AUC integration. metric: Column name for the fitness metric to integrate. test: Statistical test to use (“wilcoxon” or “ttest”). n_boot: Number of bootstrap samples for confidence intervals. alpha: Significance level (two-sided). rng: Random seed for bootstrapping.

Returns:

pd.DataFrame: Per-problem summary of AUC comparisons.

iohblade.utils.convert_to_serializable(data)
iohblade.utils.correct_aoc(ioh_function, logger, budget)

Correct aoc values in case a run stopped before the budget was exhausted

Args:

ioh_function: The function in its final state (before resetting!) logger: The logger in its final state, so we can ensure the settings for aoc calculation match budget: The intended maximum budget

Returns:

float: The normalized aoc of the run, corrected for stopped runs

iohblade.utils.first_class_name(code_string: str) str | None
iohblade.utils.is_jsonable(x)
iohblade.utils.paired_cohens_d(a, b)

Compute Cohen’s d for paired samples.

Args:

a: Sample A values. b: Sample B values.

Returns:

float: Paired-sample Cohen’s d.

iohblade.utils.sanitize(o)

Helper for sanitizing json data.