Utils

exception iohblade.utils.ComponentNotFoundError(kind, key, suggestions=None, known=None)

Bases: KeyError

No component is registered under the requested key.

exception iohblade.utils.ComponentUnavailableError(kind, key, target, cause, install_hint='')

Bases: ImportError

A registered component cannot be imported (e.g. missing dependency).

exception iohblade.utils.HarnessError

Bases: BaseException

The problem’s own evaluation code failed repeatedly.

Raised by iohblade.problem.Problem.__call__() when the evaluation keeps failing before any LLM-generated code has run (for example an import error in a custom problem, a missing dependency in the evaluation environment or a bug in evaluate). Such failures cannot be fixed by the LLM, so the run is aborted instead of spending the remaining budget.

It derives from BaseException (like KeyboardInterrupt) so the broad except Exception blocks in search methods do not swallow it; iohblade.experiment.Experiment records it as a failed run.

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) → 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.

Parameters:
  • diff – Array of paired differences.

  • n_boot – Number of bootstrap samples.

  • alpha – Significance level (two-sided).

  • rng – Random seed or numpy Generator.

Returns:

Lower and upper confidence bounds.

Return type:

tuple[float, float]

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

Bases: AbstractLogger

budget_logger class implementing the logging module for ioh.

reset(self) → 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.

Parameters:
  • a – Sample A values.

  • b – Sample B values.

Returns:

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

Return type:

float

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, minimisation: bool | None = None)

Compare convergence AUCs between two methods.

The AUC is the area under each run’s best-so-far curve over evaluations 1..budget (the last best value is carried forward when a run stopped early). Failed evaluations never improve the curve; before a run’s first valid evaluation the curve takes the worst valid value seen on that problem. With minimisation a lower AUC is better.

Parameters:
  • 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.

  • minimisation – Optimisation direction; by default as logged for each problem (logger.get_minimisation), else maximisation.

Returns:

Per-problem summary of AUC comparisons, including the minimisation direction used.

Return type:

pd.DataFrame

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

Parameters:
  • 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:

The normalized aoc of the run, corrected for stopped runs

Return type:

float

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.

Parameters:
  • a – Sample A values.

  • b – Sample B values.

Returns:

Paired-sample Cohen’s d.

Return type:

float

iohblade.utils.sanitize(o)

Helper for sanitizing json data.