cotengra.experimental.hyper_pe¶
Hyper optimization using parallel evolution with ranked sigma assignment.
Classes¶
A parallel evolution optimizer operating in raw |
|
Hyper-optimization using parallel evolution with ranked sigmas. |
Module Contents¶
- class cotengra.experimental.hyper_pe.HyperPESampler(space, seed=None, population_size=8, sigma_min=0.01, sigma_max=0.5, elite_migrate_prob=0.0, differential_prob=0.0, patience=None, exponential_param_power=None)¶
A parallel evolution optimizer operating in raw
[-1, 1]space.Multiple workers each maintain their own solution. Perturbation scales (sigmas) are distributed across an evenly spaced range and reassigned by rank after each generation: the best-scoring worker gets the lowest sigma (exploit) and the worst gets the highest (explore).
- 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 number of parallel workers. When
"auto"it is chosen based on the mapped parameter dimension.sigma_min (float, optional) – The smallest perturbation scale (assigned to the best worker).
sigma_max (float, optional) – The largest perturbation scale (assigned to the worst worker).
elite_migrate_prob (float, optional) – Probability each generation of copying the best worker’s solution to the worst worker’s slot.
differential_prob (float, optional) – Per-sample probability of using a differential perturbation (
x_best - x_rand) instead of Gaussian noise.patience (int or None, optional) – If a worker has not improved for this many generations, re-randomize its solution.
Noneor0disables.exponential_param_power (float, optional) – Passed through to the shared parameter mapping for
FLOAT_EXPparameters.
- rng¶
- params¶
- ndim¶
- population_size = 8¶
- sigma_min = 0.01¶
- sigma_max = 0.5¶
- elite_migrate_prob = 0.0¶
- differential_prob = 0.0¶
- patience = None¶
- _solutions¶
- _scores¶
- _stagnation = [0, 0, 0, 0, 0, 0, 0, 0]¶
- _sigmas¶
- _trial_counter = 0¶
- _generation = None¶
- _trial_map¶
- _make_sigmas()¶
Create geometrically spaced sigmas from sigma_min to sigma_max.
- _sample_candidate(worker_idx, noise=None)¶
Perturb a worker’s current solution with its assigned sigma.
- _sample_generation()¶
Start a new generation with one trial per worker.
- _extend_generation(worker_idx=None, noise=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 update workers if the generation is complete.
For each trial, if it scores better than (or equal to) its worker’s current best, the worker adopts the new solution. Then sigmas are reassigned by rank: best worker gets lowest sigma, worst gets highest.
- class cotengra.experimental.hyper_pe.PEOptLib¶
Bases:
cotengra.experimental.hyper.HyperOptLibHyper-optimization using parallel evolution with ranked sigmas.
- setup(methods, space, optimizer=None, population_size='auto', sigma_min=0.01, sigma_max=0.5, elite_migrate_prob=0.5, differential_prob=0.5, patience=8, method_exploration=1.0, method_temperature=1.0, exponential_param_power=None, seed=None, **kwargs)¶
Initialize PE 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 number of parallel workers for each method.
sigma_min (float, optional) – Smallest perturbation scale (for the best-ranked worker).
sigma_max (float, optional) – Largest perturbation scale (for the worst-ranked worker).
elite_migrate_prob (float, optional) – Probability of copying best solution to worst worker.
differential_prob (float, optional) – Per-sample probability of differential perturbation.
patience (int or None, optional) – Generations without improvement before restart.
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 PE.