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
nStartupTrialsintIndependent sampling is used until this many trials complete.
independentSamplerBaseSamplerSampler for parameters outside the relative search space (default RandomSampler).
warnIndependentSamplingboolEmit a warning when a parameter is sampled independently.
seedint?Random seed for xNES.
sigmadoubleInitial global step size σ in the transformed
[0,1]space (default 0.3).etaMudoubleMean learning rate η_µ (Table 1 default 1.0).
etaSigmadouble?Step-size learning rate η_σ;
nulluses the Table 1 default(9 + 3 ln d)/(5 d √d).etaBdouble?Transform learning rate η_B;
nulluses the Table 1 default (equal to η_σ).popsizeint?Population size λ per generation;
nulluses the Table 1 default4 + ⌊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
SamplerLogger
The logger namespace for this sampler (e.g. "optuna.samplers.openai_es").
protected override Logger SamplerLogger { get; }