Table of Contents

Class XnesSampler

Namespace
OptunaSharp.Samplers
Assembly
OptunaSharp.dll

A sampler driving Exponential Natural Evolution Strategies (Wierstra et al. 2014): a full-covariance Gaussian factored as A = σ·B and adapted through the matrix exponential of a natural-gradient direction — the NES most closely related to CMA-ES's rank-µ update. It captures correlations between parameters that the diagonal SnesSampler cannot, at O(d²)–O(d³) cost per generation.

When to prefer alternatives. OptunaSharp already ships mature full-covariance adaptation (CmaEsSampler, VkdCmaSampler, LmCmaSampler); xNES is provided for completeness of the NES family. For most correlated continuous problems CmaEsSampler is the better-tuned choice, and SnesSampler is cheaper in high dimension.

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

Examples

var study = Optuna.CreateStudy(sampler: new XnesSampler(seed: 42));
study.Optimize(t =>
{
    double x = t.SuggestFloat("x", -5, 5);
    double y = t.SuggestFloat("y", -5, 5);
    return (x - 1) * (x - 1) + 100 * (y - x * x) * (y - x * x);   // Rosenbrock
}, nTrials: 600);

Constructors

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

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

public XnesSampler(int nStartupTrials = 1, BaseSampler? independentSampler = null, bool warnIndependentSampling = true, int? seed = null, double sigma = 0.3, double etaMu = 1, double? etaSigma = null, double? etaB = 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 xNES.

sigma double

Initial global step size σ in the transformed [0,1] space (default 0.3).

etaMu double

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

etaSigma double?

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

etaB double?

Transform learning rate η_B; null uses the Table 1 default (equal to η_σ).

popsize int?

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

Exceptions

ArgumentException

The initial step size σ 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