cotengra.experimental.hyper_de

Hyper optimization using a pure Python differential evolution strategy.

Classes

HyperDESampler

A lightweight differential evolution optimizer operating in raw

DEOptLib

Hyper-optimization using differential evolution.

Module Contents

class cotengra.experimental.hyper_de.HyperDESampler(space, seed=None, population_size='auto', mutation=0.8, crossover=0.7, mutation_decay=1.0, mutation_min=0.1, mutation_max=1.5, exponential_param_power=None)

A lightweight differential evolution optimizer operating in raw [-1, 1] parameter space.

Each generation maintains a population of candidate vectors. New trial vectors are created using DE/rand/1/bin mutation and binomial crossover, then kept only if they improve on their parent.

Parameters:
  • space (dict[str, dict]) – The search space for a single contraction method.

  • seed (None or int, optional) – Random seed.

  • population_size (int or "auto", optional) – The population size. When "auto" it is chosen based on the mapped parameter dimension.

  • mutation (float, optional) – The differential weight (F) applied to the difference vector.

  • crossover (float, optional) – The crossover probability (CR) for binomial crossover.

  • mutation_decay (float, optional) – Multiplicative decay applied to mutation after each completed generation.

  • mutation_min (float, optional) – Lower bound for mutation.

  • mutation_max (float, optional) – Upper bound for mutation.

  • exponential_param_power (float, optional) – Passed through to the shared parameter mapping for FLOAT_EXP parameters.

rng
params
ndim
population_size = 'auto'
mutation = 0.8
crossover = 0.7
mutation_decay = 1.0
mutation_min = 0.1
mutation_max = 1.5
_population
_scores
_trial_counter = 0
_target_index = 0
_generation = None
_trial_map
_mutate(target_idx)

Create a trial vector via DE/rand/1/bin.

_sample_generation()

Prepare trial vectors for all population members.

_extend_generation(target_idx=None)

Append one more trial to the current generation.

ask()

Return the next candidate from the current generation.

If all prepared candidates have been issued, grow the generation by one more sample.

tell(trial_number, score)

Record a completed trial and perform selection if the generation is complete.

For each trial vector, if it scores better than (or equal to) its target parent, it replaces the parent in the population.

class cotengra.experimental.hyper_de.DEOptLib

Bases: cotengra.experimental.hyper.HyperOptLib

Hyper-optimization using differential evolution.

setup(methods, space, optimizer=None, population_size='auto', mutation=0.8, crossover=0.7, mutation_decay=1.0, mutation_min=0.1, mutation_max=1.5, method_exploration=1.0, method_temperature=1.0, exponential_param_power=None, seed=None, **kwargs)

Initialize DE optimizers for each contraction method.

Parameters:
  • methods (list[str]) – The contraction methods to optimize over.

  • space (dict[str, dict[str, dict]]) – The per-method hyperparameter search space.

  • optimizer (HyperOptimizer, optional) – The parent optimizer. Used to size the initial population large enough for parallel pre-dispatch.

  • population_size (int or "auto", optional) – The population size for each method-specific DE sampler.

  • mutation (float, optional) – Differential weight (F).

  • crossover (float, optional) – Crossover probability (CR).

  • mutation_decay (float, optional) – Parameters controlling mutation scale over generations.

  • mutation_min (float, optional) – Parameters controlling mutation scale over generations.

  • mutation_max (float, optional) – Parameters controlling mutation scale over generations.

  • method_exploration (float, optional) – Exploration strength for the LCB-based method chooser.

  • method_temperature (float, optional) – Noise temperature for the LCB-based method chooser.

  • exponential_param_power (float, optional) – Passed to the shared parameter mapping for FLOAT_EXP.

  • seed (None or int, optional) – Random seed.

get_setting()

Choose a contraction method, then request its next setting.

report_result(setting, trial, score)

Report a completed trial back to the method chooser and DE.