Table of Contents

Class OpenAiEsSampler

Namespace
OptunaSharp.Samplers
Assembly
OptunaSharp.dll

A sampler driving OpenAI Evolution Strategies (Salimans et al. 2017): an isotropic Gaussian N(mean, σ²I) whose mean ascends the natural gradient estimated from a population of mirrored, rank-shaped perturbations, stepped with Adam. It is a robust, embarrassingly-parallel, gradient-free optimizer that complements the covariance model of CmaEsSampler and the diagonal NES of SnesSampler.

Convergence character. OpenAI-ES uses a single global σ. With the defaults σ is annealed only slowly (the estool recipe), so within a typical Optuna budget the search settles to a neighborhood of the optimum rather than to machine precision — the natural regime for noisy, high-dimensional objectives. When you need fine convergence on a smooth objective, prefer SnesSampler (per-coordinate adaptive σ) or CmaEsSampler.

Unsupported parameters. Categorical parameters and single-valued distributions are sampled by the independent sampler, as in CmaEsSampler. Dynamic search spaces fall back to independent sampling with a warning.

public sealed class OpenAiEsSampler : EvolutionStrategySampler
Inheritance
OpenAiEsSampler
Inherited Members

Examples

var study = Optuna.CreateStudy(sampler: new OpenAiEsSampler(seed: 42));
study.Optimize(t =>
{
    double s = 0;
    for (int i = 0; i < 8; i++) { double x = t.SuggestFloat($"x{i}", -5, 5); s += x * x; }
    return s;
}, nTrials: 600);

Constructors

OpenAiEsSampler(int, BaseSampler?, bool, int?, double, double, int?, bool, double, double, double, double, double, double, double, double)

Configures OpenAI-ES proposals and its independent startup and unsupported-parameter fallback.

public OpenAiEsSampler(int nStartupTrials = 1, BaseSampler? independentSampler = null, bool warnIndependentSampling = true, int? seed = null, double sigma = 0.1, double learningRate = 0.05, int? popsize = null, bool mirrored = true, double weightDecay = 0, double sigmaDecay = 0.999, double sigmaLimit = 0.01, double learningRateDecay = 1, double learningRateLimit = 0.001, double beta1 = 0.9, double beta2 = 0.999, double adamEpsilon = 1E-08)

Parameters

nStartupTrials int

Independent sampling is used until this many trials complete.

independentSampler BaseSampler

Sampler for parameters outside the relative search space (default RandomSampler).

warnIndependentSampling bool

Emit a warning when a parameter is sampled independently.

seed int?

Random seed for OpenAI-ES.

sigma double

Initial isotropic perturbation scale σ in the transformed [0,1] space (default 0.1).

learningRate double

Adam base step size α applied to the estimated mean-gradient (default 0.05).

popsize int?

Population size per generation (default max(8, 4 + ⌊3 ln d⌋), rounded to even when mirrored).

mirrored bool

Use antithetic sampling (pairs ε, −ε); reduces variance, requires an even population (default true).

weightDecay double

L2 pull on candidates toward the origin. Off by default: in the transformed [0,1] box the origin is a corner, so a nonzero value biases the search toward that corner.

sigmaDecay double

Per-generation multiplicative σ decay; 1.0 keeps σ fixed as in the paper (default 0.999).

sigmaLimit double

Lower floor below which σ stops decaying (default 0.01).

learningRateDecay double

Per-generation learning-rate decay; 1.0 keeps it fixed (default 1.0, suited to short budgets).

learningRateLimit double

Lower floor below which the learning rate stops decaying (default 0.001).

beta1 double

Adam first-moment decay coefficient (default 0.9).

beta2 double

Adam second-moment decay coefficient (default 0.999).

adamEpsilon double

Adam numerical-stability term (default 1e-8).

Properties

AttrPrefix

The system-attr key prefix distinguishing this sampler's stored state (e.g. "openaies:").

protected override string AttrPrefix { get; }

Property Value

string

SamplerLogger

The logger namespace for this sampler (e.g. "optuna.samplers.openai_es").

protected override Logger SamplerLogger { get; }

Property Value

Logger