Table of Contents

Class SmsEmoaSampler

Namespace
OptunaSharp.Samplers
Assembly
OptunaSharp.dll

Multi-objective sampler using the SMS-EMOA algorithm (Beume, Naujoks & Emmerich, 2007): a steady-state (μ+1) evolutionary algorithm whose survival operator removes the individual with the least hypervolume contribution in its worst nondomination front. Where NSGA-II breaks ties within a front by crowding distance, SMS-EMOA breaks them by the S-metric (dominated hypervolume) — so it steers directly toward a high-hypervolume Pareto approximation.

Beyond-core. SMS-EMOA has no Optuna / OptunaHub counterpart; like LmCmaSampler it is validated by convergence and achieved hypervolume, not bit-matched to an upstream. The crossover/mutation are the shared NSGA-II operators (SBXCrossover + PolynomialMutation by default), so behavior on the variation side matches the NSGA-II family; only the survival rule differs.

In-memory state. The μ-survivor population is reconstructed incrementally and held in memory for the study's duration, so a SMS-EMOA study does not resume its population across process boundaries (same concession as JanusSampler). Categorical and single-value distributions are handled by the independent sampler.

public class SmsEmoaSampler : BaseSampler
Inheritance
SmsEmoaSampler
Derived
Inherited Members

Examples

var study = Optuna.CreateStudy(
    directions: new[] { StudyDirection.Minimize, StudyDirection.Minimize },
    sampler: new SmsEmoaSampler(populationSize: 40, seed: 0));
study.Optimize(t =>
{
    double x = t.SuggestFloat("x", 0, 1), y = t.SuggestFloat("y", 0, 1);
    return new[] { x, (1 - Math.Sqrt(x)) + y };
}, nTrials: 400);

Constructors

SmsEmoaSampler(int, BaseMutation?, double?, BaseCrossover?, double, double, int?, double)

Configures steady-state hypervolume survival and the operators used to produce offspring.

public SmsEmoaSampler(int populationSize = 50, BaseMutation? mutation = null, double? mutationProb = null, BaseCrossover? crossover = null, double crossoverProb = 0.9, double swappingProb = 0.5, int? seed = null, double hvReferenceEps = 10)

Parameters

populationSize int

Number of individuals μ kept in the population.

mutation BaseMutation

Mutation applied to child individuals; defaults to PolynomialMutation. If a parameter selected for mutation has no mutation object it is instead resampled independently.

mutationProb double?

Probability of mutating each parameter. If null, 1 / len(params) is used.

crossover BaseCrossover

Crossover applied to child individuals; defaults to SBXCrossover (SMS-EMOA's classic SBX). UniformCrossover is always applied to categorical parameters.

crossoverProb double

Probability that a crossover occurs when creating a new individual.

swappingProb double

Probability of swapping each parameter of the parents during crossover.

seed int?

Seed for the random number generator.

hvReferenceEps double

Reference-point offset for the survival hypervolume: ref = 1 + eps in the population-normalized objective space (pymoo default 10).

Exceptions

ValueError

Population size is below two or the crossover parent count, or a configured reproduction probability is invalid.

Methods

AfterTrial(Study, FrozenTrial, TrialState, IReadOnlyList<double>?)

Trial post-processing: called after the objective function returns and right before the trial is finished and its state is stored.

public override void AfterTrial(Study study, FrozenTrial trial, TrialState state, IReadOnlyList<double>? values)

Parameters

study Study

Study that owns the trial being finished.

trial FrozenTrial

Trial snapshot before its terminal state is written to storage.

state TrialState

Terminal state being recorded: complete, pruned, or failed.

values IReadOnlyList<double>

Resulting trial values in objective order; non-null for a successful trial.

BeforeTrial(Study, FrozenTrial)

Trial pre-processing: called during trial initialization, just before the InferRelativeSearchSpace(Study, FrozenTrial) call.

public override void BeforeTrial(Study study, FrozenTrial trial)

Parameters

study Study

Study that owns the newly initialized trial.

trial FrozenTrial

New trial snapshot available before search-space inference.

InferRelativeSearchSpace(Study, FrozenTrial)

Infer the search space that will be used by relative sampling in the target trial.

This method is called right before SampleRelative(Study, FrozenTrial, OrderedDict<string, BaseDistribution>), and the search space returned by this method is passed to it. The parameters not contained in the search space will be sampled by using SampleIndependent(Study, FrozenTrial, string, BaseDistribution).

public override OrderedDict<string, BaseDistribution> InferRelativeSearchSpace(Study study, FrozenTrial trial)

Parameters

study Study

Study supplying trial history, directions, and storage.

trial FrozenTrial

Current trial snapshot; copy it before modifying its contents.

Returns

OrderedDict<string, BaseDistribution>

Parameter distributions eligible for joint sampling, in sampler-defined order.

ReseedRng()

Reseed sampler's random number generator.

Parallel optimization calls this hook before a worker's sequential trial loop. Concrete samplers refresh their random streams so workers do not deliberately reuse a seeded sequence. OptunaSharp workers share the study's sampler instance; this hook does not clone it or make concurrent sampling reproducible.

public override void ReseedRng()

SampleIndependent(Study, FrozenTrial, string, BaseDistribution)

Sample a parameter for a given distribution.

This method is called only for the parameters not contained in the search space returned by SampleRelative(Study, FrozenTrial, OrderedDict<string, BaseDistribution>). This method is suitable for sampling algorithms that do not use relationship between parameters such as random sampling and TPE.

public override object? SampleIndependent(Study study, FrozenTrial trial, string paramName, BaseDistribution paramDistribution)

Parameters

study Study

Study supplying trial history, directions, and storage.

trial FrozenTrial

Current trial snapshot; copy it before modifying its contents.

paramName string

Name of the parameter being suggested.

paramDistribution BaseDistribution

Distribution defining the parameter's domain and scale.

Returns

object

A value in the distribution's external representation, including null categorical choices.

SampleRelative(Study, FrozenTrial, OrderedDict<string, BaseDistribution>)

Sample parameters in a given search space.

The trial invokes this method lazily when it first needs relative parameters and caches the result for its remaining suggestions. This method is suitable for sampling algorithms that use relationship between parameters such as Gaussian Process and CMA-ES.

public override OrderedDict<string, object?> SampleRelative(Study study, FrozenTrial trial, OrderedDict<string, BaseDistribution> searchSpace)

Parameters

study Study

Study supplying trial history, directions, and storage.

trial FrozenTrial

Current trial snapshot; copy it before modifying its contents.

searchSpace OrderedDict<string, BaseDistribution>

Distributions returned by InferRelativeSearchSpace(Study, FrozenTrial).

Returns

OrderedDict<string, object>

Jointly sampled external parameter values; omitted parameters use independent sampling.