Skip to content

Add CmaEsRefinementSampler — CMA-ES with quasi-random refinement#359

Open
EliMunkey wants to merge 8 commits intooptuna:mainfrom
EliMunkey:add-cma-es-refinement-sampler
Open

Add CmaEsRefinementSampler — CMA-ES with quasi-random refinement#359
EliMunkey wants to merge 8 commits intooptuna:mainfrom
EliMunkey:add-cma-es-refinement-sampler

Conversation

@EliMunkey
Copy link

@EliMunkey EliMunkey commented Mar 13, 2026

Summary

A three-phase sampler combining Sobol QMC initialization, CMA-ES optimization, and quasi-random Gaussian refinement using Sobol-based perturbation vectors with exponential decay.

BBOB benchmark results (24 functions, 5D, 10 seeds, 200 trials):

Sampler Mean Normalized Regret vs Random
Random baseline 1.0000
Default TPE 0.2463 75% better
CMA-ES (tuned) 0.2004 80% better
CMA-ES + Refinement 0.1284 87% better

The refinement phase uses quasi-random Sobol sequences transformed via inverse CDF to generate Gaussian-distributed perturbation vectors. This provides more uniform directional coverage than pseudo-random Gaussian, systematically exploring directions that random sampling misses.

Minimal example

import optuna
import optunahub

def objective(trial):
    return sum(trial.suggest_float(f"x{i}", -5, 5) ** 2 for i in range(5))

module = optunahub.load_module("samplers/cma_es_refinement")
sampler = module.CmaEsRefinementSampler(seed=42)
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=200)
print(f"Best: {study.best_value:.6f}")

Full experiment logs (135 experiments): github.com/EliMunkey/autoresearch-optuna

TODO

  • Package added under package/
  • __init__.py exports the sampler class
  • README.md with description, API docs, and benchmarks
  • example.py with working demonstration
  • LICENSE file included
  • Unit tests added
  • Cross-validated on independent test functions (5D and 10D)

EliMunkey and others added 7 commits March 13, 2026 08:17
Three-phase sampler: Sobol QMC → CMA-ES → Gaussian refinement.
Achieves 0.1501 mean normalized regret on BBOB (25% better than
pure CMA-ES at 0.2004), discovered through 97 autoresearch experiments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document the BBOB evaluation protocol, function categories, and
metric definitions for reproducibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix midpoint calculation bug in refinement phase
- Add n_medium_refine_trials parameter for explicit control
- Remove unused IntersectionSearchSpace import
- Use proper TYPE_CHECKING imports for type hints
- Rewrite example.py with CMA-ES comparison on Rastrigin
- Consolidate README: single benchmark section, working code example,
  correct optuna_versions (4.7.0), remove broken link

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Test basic sampling, phase transitions, reproducibility, and
refinement proximity to the best point.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Run independent benchmark on 8 test functions at 5D and 10D against
  TPE(multivariate=True) and CMA-ES baselines. CMA-ES+Refine wins at
  both dimensions, with the advantage widening at 10D (0.17 vs 0.37).
- Add for_budget() classmethod for auto-scaling phases to any trial count.
- Add test_known_value and test_for_budget tests (6 total).
- Document known limitation on deceptive functions (Schwefel).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…line)

Replace pseudo-random Gaussian perturbation with Sobol-based quasi-random
Gaussian vectors in the refinement phase. The Sobol sequence provides more
uniform directional coverage in 5D, systematically exploring directions
that pseudo-random misses.

Key changes:
- Refinement uses scipy.stats.qmc.Sobol + inverse CDF for perturbation
- Replace 2-stage (medium/tight) with exponential decay sigma schedule
- sigma_start=0.13, decay_rate=0.11 (experimentally optimized)
- BBOB mean regret: 0.1284 (was 0.1501, -14.5%)
- Strongest gains on separable (-41%) and multimodal_global (-45%)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@EliMunkey EliMunkey changed the title Add CmaEsRefinementSampler — CMA-ES with multi-stage local refinement Add CmaEsRefinementSampler — CMA-ES with quasi-random refinement Mar 13, 2026
@y0z
Copy link
Member

y0z commented Mar 16, 2026

@not522, could you review this PR?

@y0z y0z added the new-package New packages label Mar 16, 2026
@not522
Copy link
Member

not522 commented Mar 16, 2026

Thank you for your PR!
Could you fix the CI? https://github.com/optuna/optunahub-registry/actions/runs/23073620859/job/67029413493

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@EliMunkey
Copy link
Author

Fixed the ruff lint/format failures in sampler.py (commit f804518):

  • I001: Added missing blank line before if TYPE_CHECKING block (import sorting)
  • Format: Collapsed multi-line function calls that fit within the line length limit

All ruff check and ruff format --check now pass cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-package New packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants