Table of Contents

Class SnesSampler

Namespace
OptunaSharp.Samplers
Assembly
OptunaSharp.dll

A sampler driving Separable Natural Evolution Strategies (Wierstra et al. 2014): a diagonal Gaussian with a per-coordinate mean and scale, adapted by natural-gradient steps. Because σ is adapted per coordinate, SNES converges to high precision without the fixed-σ floor of OpenAiEsSampler, while costing only O(d) per sample — the practical NES for higher-dimensional continuous hyperparameter spaces where full-covariance CmaEsSampler becomes expensive. The price is an assumption of (approximate) coordinate independence.

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 SnesSampler : EvolutionStrategySampler
Inheritance
SnesSampler
Inherited Members

Examples

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

Constructors

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

Configures SNES proposals and its independent startup and unsupported-parameter fallback.

public SnesSampler(int nStartupTrials = 1, BaseSampler? independentSampler = null, bool warnIndependentSampling = true, int? seed = null, double sigma = 0.3, double etaMu = 1, double? etaSigma = null, int? popsize = null)

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 SNES.

sigma double

Initial per-coordinate scale σ in the transformed [0,1] space (default 0.3).

etaMu double

Mean learning rate η_μ (Table 1 default 1.0).

etaSigma double?

Scale learning rate η_σ; null uses the Table 1 default (3 + ln d)/(5√d).

popsize int?

Population size λ per generation; null uses the Table 1 default 4 + ⌊3 ln d⌋.

Exceptions

ArgumentException

The initial scale σ is not strictly positive.

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