Methods (API)

This page documents the method implementations exposed in iohblade.methods.

class iohblade.methods.EoH(llm: LLM, budget: int, name='EoH', **kwargs)

Bases: Method

get_config() → dict[str, Any]

The method’s configuration, logged with every run.

Returns:

A dictionary with the keys

  • name (str): the name of the method;

  • source (str): where the implementation comes from, for example github.com/vendor/repository@<commit_hash>;

  • config (dict): the arguments that configure the method.

Return type:

dict[str, Any]

to_dict()

Returns a dictionary representation of the method including all parameters.

Returns:

Dictionary representation of the method.

Return type:

dict

class iohblade.methods.FunSearch(llm: LLM, budget: int, name: str = 'FunSearch', num_islands: int = 10, programs_per_prompt: int = 2, samples_per_prompt: int = 4, reset_period: int | None = None, temperature_init: float = 0.1, temperature_period: int = 30000)

Bases: Method

FunSearch: island-based evolution with best-shot prompting.

The programs database holds num_islands islands. On each island, programs are clustered by score. A prompt shows programs_per_prompt programs of one island, sampled by a softmax over cluster scores and ordered from worst to best, and asks for an improved next version. The samples_per_prompt new programs are evaluated and added to that island. Every reset_period evaluations the weaker half of the islands is restarted from the best program of a stronger island.

Differences with the reference implementation:

  • a program is a complete solution (for example a class), not a single function in a fixed skeleton; the problem’s task and format prompts frame the versions;

  • the first program is sampled from the problem prompt (the reference starts from a hand-written template), and is added to every island;

  • islands are reset after a number of evaluations instead of a wall-clock period, so runs are reproducible with the experiment seed;

  • samples are drawn and evaluated one at a time (no parallel samplers).

Exactly budget solutions are evaluated. Failed evaluations count towards the budget but are not added to the database, and are never returned as the best solution unless no evaluation succeeded. Only single-objective (scalar) fitness is supported.

Parameters:
  • llm – The LLM used to generate programs.

  • budget – Number of evaluations.

  • name – Name of the method.

  • num_islands – Number of islands.

  • programs_per_prompt – Number of programs shown in a prompt (k).

  • samples_per_prompt – Number of programs sampled from each prompt.

  • reset_period – Evaluations between island resets. None uses budget // 5 (four resets per run); 0 disables resets. There is no reset after the last evaluation.

  • temperature_init – Initial temperature of the cluster sampling.

  • temperature_period – Period, in programs per island, of the linear decay of the cluster sampling temperature.

get_config() → dict[str, Any]

The method’s configuration, logged with every run.

Returns:

A dictionary with the keys

  • name (str): the name of the method;

  • source (str): where the implementation comes from, for example github.com/vendor/repository@<commit_hash>;

  • config (dict): the arguments that configure the method.

Return type:

dict[str, Any]

to_dict() → dict[str, Any]

Returns a dictionary representation of the method including all parameters.

Returns:

Dictionary representation of the method.

Return type:

dict

class iohblade.methods.LHNS_Method(llm: LLM, budget, method, cooling_rate: float = 0.1, table_size: int = 10, name='LHNS', minimisation=True)

Bases: Method

get_config() → dict[str, Any]

The method’s configuration, logged with every run.

Returns:

A dictionary with the keys

  • name (str): the name of the method;

  • source (str): where the implementation comes from, for example github.com/vendor/repository@<commit_hash>;

  • config (dict): the arguments that configure the method.

Return type:

dict[str, Any]

to_dict()

Returns a dictionary representation of the method including all parameters.

Returns:

Dictionary representation of the method.

Return type:

dict

class iohblade.methods.LLaMEA(llm: LLM, budget: int, name='LLaMEA', **kwargs)

Bases: Method

get_config() → dict[str, Any]

The method’s configuration, logged with every run.

Returns:

A dictionary with the keys

  • name (str): the name of the method;

  • source (str): where the implementation comes from, for example github.com/vendor/repository@<commit_hash>;

  • config (dict): the arguments that configure the method.

Return type:

dict[str, Any]

to_dict()

Returns a dictionary representation of the method including all parameters.

Returns:

Dictionary representation of the method.

Return type:

dict

property uses_hpo: bool

True when LLaMEA samples configuration spaces (HPO=True).

class iohblade.methods.MCTS_Method(llm: LLM, budget: int, lambda_0: float = 0.1, alpha: float = 0.5, maximisation: bool = True, max_children: int = 5, expansion_factor: int = 2)

Bases: Method

get_config() → dict[str, Any]

The method’s configuration, logged with every run.

Returns:

A dictionary with the keys

  • name (str): the name of the method;

  • source (str): where the implementation comes from, for example github.com/vendor/repository@<commit_hash>;

  • config (dict): the arguments that configure the method.

Return type:

dict[str, Any]

to_dict()

Returns a dictionary representation of the method including all parameters.

Returns:

Dictionary representation of the method.

Return type:

dict

class iohblade.methods.MoEH_Method(llm: LLM, budget: int, iterations: int, population_size: int, minimisation: bool, use_e2_operator: bool = True, use_m1_operator: bool = True, use_m2_operator: bool = True, name='MoEH')

Bases: Method

get_config() → dict[str, Any]

The method’s configuration, logged with every run.

Returns:

A dictionary with the keys

  • name (str): the name of the method;

  • source (str): where the implementation comes from, for example github.com/vendor/repository@<commit_hash>;

  • config (dict): the arguments that configure the method.

Return type:

dict[str, Any]

to_dict()

Returns a dictionary representation of the method including all parameters.

Returns:

Dictionary representation of the method.

Return type:

dict

class iohblade.methods.MutationType(value)

Bases: Enum

E2 = 'e2'
M1 = 'm1'
M2 = 'm2'
class iohblade.methods.RandomSearch(llm: LLM, budget, name='RandomSearch', **kwargs)

Bases: Method

get_config() → dict[str, Any]

The method’s configuration, logged with every run.

Returns:

A dictionary with the keys

  • name (str): the name of the method;

  • source (str): where the implementation comes from, for example github.com/vendor/repository@<commit_hash>;

  • config (dict): the arguments that configure the method.

Return type:

dict[str, Any]

to_dict()

Returns a dictionary representation of the method including all parameters.

Returns:

Dictionary representation of the method.

Return type:

dict

class iohblade.methods.ReEvo(llm: LLM, budget: int, name: str = 'ReEvo', **kwargs: Any)

Bases: Method

Wrapper for the ReEvo baseline.

ReEvo writes reflection files (problem_iter*_*.txt). They go to output_path if given; otherwise to a reevo folder in the run’s log directory when the problem has a logger, else to a temporary directory that is removed afterwards. (Never to the working directory.)

get_config() → dict[str, Any]

The method’s configuration, logged with every run.

Returns:

A dictionary with the keys

  • name (str): the name of the method;

  • source (str): where the implementation comes from, for example github.com/vendor/repository@<commit_hash>;

  • config (dict): the arguments that configure the method.

Return type:

dict[str, Any]

to_dict()

Returns a dictionary representation of the method including all parameters.

Returns:

Dictionary representation of the method.

Return type:

dict

class iohblade.methods.ShinkaEvolve(llm: LLM, budget: int, name: str = 'ShinkaEvolve', num_islands: int = 2, archive_size: int = 40, num_archive_inspirations: int = 1, num_top_k_inspirations: int = 1, elite_selection_ratio: float = 0.3, parent_selection: str = 'weighted', parent_selection_lambda: float = 10.0, exploitation_alpha: float = 1.0, num_beams: int = 5, migration_interval: int = 10, migration_rate: float = 0.0, patch_type_probs: dict[str, float] | None = None, max_patch_attempts: int = 1, max_patch_resamples: int = 3, use_text_feedback: bool = False, novelty_rejection: bool = False, novelty_threshold: float = 0.99, max_novelty_attempts: int = 3, novelty_judge: bool = True, embedding: str | Callable[[str], ndarray | list[float]] = 'ngram', meta_interval: int | None = None, meta_max_recommendations: int = 5, task_sys_msg: str | None = None, bandit_c: float = 1.0, bandit_epsilon: float = 0.2, bandit_decay: float = 0.95)

Bases: Method

ShinkaEvolve: sample-efficient program evolution.

Each generation evaluates exactly one program:

  1. LLM choice. When the LLM is a Multi_LLM (provider: multi), an asymmetric UCB bandit chooses one of its LLMs; the reward is a child’s improvement over its parent and the initial program.

  2. Parent and inspirations. An island is drawn uniformly; a parent is drawn from its archive programs (parent_selection), together with num_archive_inspirations + num_top_k_inspirations other programs that are shown in the prompt, worst first.

  3. Patch. A diff (SEARCH/REPLACE edits), a full rewrite (one of five prompt variants) or a crossover with an inspiration, drawn with patch_type_probs. On an island without a correct program, a failed program is fixed instead. A reply that cannot be applied is retried in the same conversation (max_patch_attempts), then with a new parent (max_patch_resamples).

  4. Novelty rejection (optional). A candidate whose code embedding is more similar than novelty_threshold to a program on the island is rejected, unless an LLM judge finds it meaningfully different; a new candidate is then proposed (max_novelty_attempts).

  5. Meta recommendations (optional). Every meta_interval evaluations the LLM summarises the new programs, updates its global insights and writes meta_max_recommendations recommendations; one of them is added to later diff and full-rewrite prompts.

The first program is sampled from the problem prompt and copied to every island; children stay on their parent’s island, and programs migrate between islands when migration_rate > 0.

Differences with ShinkaEvolve, which are needed for BLADE’s contracts:

  • Budget. ShinkaEvolve counts generations and loses a generation when no patch applies or all candidates are rejected as not novel. Here every generation ends with one evaluation: if no patch applies, the code of the last reply is evaluated (and fails if it has none); if every candidate is rejected, the last one is evaluated. Rejected candidates are not evaluated, but their LLM calls are logged.

  • Programs are complete solutions without EVOLVE-BLOCK markers; the problem’s task prompt is part of every prompt, and fitness is shown with the problem’s direction (problem.minimisation).

  • Embeddings default to a local character n-gram embedding instead of an embedding API; pass a function from code to a vector to use another. Novelty rejection and meta recommendations are off by default, as in ShinkaEvolve’s packaged defaults.

  • The bandit is the linear reward variant without API-cost awareness; there is no random temperature per query.

  • Proposals and evaluations run one at a time (no asynchronous jobs).

Failed evaluations never become the best solution unless no evaluation succeeded. Only single-objective (scalar) fitness is supported.

Parameters:
  • llm – The LLM, or a Multi_LLM to let the bandit choose LLMs.

  • budget – Number of evaluations.

  • name – Name of the method.

  • num_islands – Number of islands.

  • archive_size – Maximum number of programs in the archive.

  • num_archive_inspirations – Archive programs shown in a prompt.

  • num_top_k_inspirations – Best programs shown in a prompt.

  • elite_selection_ratio – Share of archive inspirations taken from the island’s best programs.

  • parent_selection – weighted (sigmoid of the score relative to the median, divided by 1 + number of children), power_law or beam_search.

  • parent_selection_lambda – Sharpness of the weighted selection.

  • exploitation_alpha – Exponent of the power-law selection.

  • num_beams – Children of a beam-search parent.

  • migration_interval – Generations between migrations.

  • migration_rate – Share of an island’s programs that migrate.

  • patch_type_probs – Probabilities of diff, full and cross patches.

  • max_patch_attempts – LLM replies per parent before resampling.

  • max_patch_resamples – Parents tried per generation.

  • use_text_feedback – Show the evaluation feedback in prompts.

  • novelty_rejection – Reject candidates that are too similar.

  • novelty_threshold – Cosine similarity above which a candidate is checked (or rejected without a judge).

  • max_novelty_attempts – Candidates per generation.

  • novelty_judge – Ask the LLM whether a similar candidate is novel.

  • embedding – "ngram" or a function from code to a vector.

  • meta_interval – Evaluations between meta recommendation updates (None: off).

  • meta_max_recommendations – Number of recommendations.

  • task_sys_msg – The system message (Shinka’s default if None).

  • bandit_c – Exploration coefficient of the bandit.

  • bandit_epsilon – Exploration probability of the bandit.

  • bandit_decay – Decay of the bandit statistics.

get_config() → dict[str, Any]

The method’s configuration, logged with every run.

Returns:

A dictionary with the keys

  • name (str): the name of the method;

  • source (str): where the implementation comes from, for example github.com/vendor/repository@<commit_hash>;

  • config (dict): the arguments that configure the method.

Return type:

dict[str, Any]

to_dict() → dict[str, Any]

Returns a dictionary representation of the method including all parameters.

Returns:

Dictionary representation of the method.

Return type:

dict

iohblade.methods.funsearch

alias of FunSearch

FunSearch

iohblade.methods.FunSearch implements FunSearch (Romera-Paredes et al., Nature 625, 2024). Its programs database follows the reference code and the LLM4AD port:

  • Islands and clusters. num_islands independent islands; on each island programs with the same score form a cluster.

  • Best-shot prompts. A prompt shows programs_per_prompt programs of one island as versions, worst first. They are drawn by a softmax over the cluster scores, with a temperature that starts at temperature_init and decays linearly over temperature_period programs; within a cluster, shorter programs are preferred. The LLM is asked for the next, improved version, and samples_per_prompt programs are sampled per prompt.

  • Island resets. Every reset_period evaluations (default budget // 5; 0 disables resets) the weaker half of the islands is restarted from the best program of a stronger island.

Differences with the reference implementation: a program is a complete solution (for example a class) rather than one function in a skeleton; the first program is sampled from the problem prompt; resets are counted in evaluations, not wall-clock time, so runs are reproducible; and samples are evaluated one at a time. Exactly budget solutions are evaluated. Failed evaluations are not added to the database. Only single-objective problems are supported.

methods:
  - type: funsearch
    llm: gpt
    budget: 200
    params: {num_islands: 10, programs_per_prompt: 2, samples_per_prompt: 4}

ShinkaEvolve

iohblade.methods.ShinkaEvolve implements ShinkaEvolve (Lange et al., arXiv:2509.19349), reimplemented after the reference code (version 0.0.8). The shinka package itself cannot be installed next to BLADE (it requires openai>=2 and google-genai>=2), and its budget counts generations rather than evaluations. Each generation:

  • chooses an LLM with an asymmetric UCB bandit when the LLM is a provider: multi LLM (the reward is a child’s improvement over its parent and the initial program);

  • samples a parent from an island’s archive programs (parent_selection: weighted by default, power_law or beam_search) and inspirations (num_archive_inspirations + num_top_k_inspirations), shown worst first;

  • patches the parent with a SEARCH/REPLACE diff, a full rewrite (one of five prompt variants) or a crossover (patch_type_probs, default 0.6/0.3/0.1); islands without a correct program fix a failed program;

  • optionally rejects candidates that are not novel (novelty_rejection): a code embedding more similar than novelty_threshold to a program on the island is rejected, unless the LLM judges it meaningfully different;

  • optionally adds one of the meta recommendations that the LLM writes every meta_interval evaluations from summaries of the new programs.

Differences with the reference implementation:

  • Budget. Exactly budget solutions are evaluated, one per generation. When no reply can be applied, the code of the last reply is evaluated; when every candidate is rejected as not novel, the last one is evaluated. Rejected candidates are not evaluated, but their LLM calls are logged.

  • Embeddings use a local character n-gram embedding by default (no embedding API, no extra cost); pass embedding= a function from code to a vector in Python to use another.

  • Programs are complete solutions without EVOLVE-BLOCK markers. Fitness is shown with the problem’s optimisation direction.

  • Bandit: the linear reward variant without API-cost awareness, and no random temperature per query.

  • No asynchronous jobs: proposals and evaluations run one at a time.

  • No files written: nothing is written to disk (ShinkaEvolve writes a SQLite database and a folder per generation).

Novelty rejection and meta recommendations are off by default, as in ShinkaEvolve’s packaged defaults; turning them on costs extra LLM calls (a judge call per similar candidate, and meta_interval + 2 calls per update). Only single-objective problems are supported.

llms:
  mix:
    provider: multi
    llms: [gpt, gemini]
methods:
  - type: shinka_evolve
    llm: mix
    budget: 100
    params:
      num_islands: 2
      novelty_rejection: true
      meta_interval: 10