Table of Contents

Class RveaSampler

Namespace
OptunaSharp.Samplers
Assembly
OptunaSharp.dll

Multi-objective sampler using the RVEA algorithm (Cheng et al., 2016): a reference-vector-guided evolutionary algorithm for many-objective optimization. It reuses the whole NSGA-II genetic machinery (BaseGASampler, child generation, crossovers, mutations) and swaps the elite-selection strategy for angle-penalized-distance (APD) survival (OptunaSharp.Samplers.Rvea.RveaApdSurvival): each individual is associated with its nearest reference vector, and within every reference vector the survivor is the one whose distance to the ideal point is least after a generation-growing angle penalty — an explicit diversity→convergence shift that suits three-and-more-objective fronts. The reference vectors are periodically re-scaled to the current objective ranges.

Beyond-core. RVEA has no Optuna / OptunaHub counterpart; like SmsEmoaSampler it is validated by convergence and achieved hypervolume, not bit-matched to an upstream. The default operators are RVEA's classic SBXCrossover (η=30) + PolynomialMutation (η=20); mating uses the shared NSGA-II child generation, so only the survival differs from the NSGA-II family.

Generation horizon. The APD penalty grows with (generation / nMaxGenerations)^α and the reference vectors adapt every ceil(nMaxGenerations · adaptFreq) generations. Optuna is trial-budget-driven and does not expose a maximum generation to the sampler, so nMaxGenerations sets that schedule's horizon explicitly (the ratio is clamped to 1 beyond it).

Reference-vector count. The structured Das-Dennis lattice has a fixed size for each (objectives, partitions) pair, so — unless explicit reference points are supplied — the effective population size is set to the largest lattice size not exceeding the requested populationSize.

public class RveaSampler : BaseGASampler
Inheritance
RveaSampler
Inherited Members

Examples

var study = Optuna.CreateStudy(
    directions: new[] { StudyDirection.Minimize, StudyDirection.Minimize, StudyDirection.Minimize },
    sampler: new RveaSampler(populationSize: 91, seed: 0));
study.Optimize(t =>
{
    double x = t.SuggestFloat("x", 0, 1), y = t.SuggestFloat("y", 0, 1), z = t.SuggestFloat("z", 0, 1);
    return new[] { x, y, z };
}, nTrials: 900);

Constructors

RveaSampler(int, BaseMutation?, double?, BaseCrossover?, double, double, int?, double, double, int, double[,]?, int?, Func<Study, OrderedDict<string, BaseDistribution>, List<FrozenTrial>, OrderedDict<string, object?>>?, Action<Study, FrozenTrial, TrialState, IReadOnlyList<double>?>?)

Configures reference-vector survival, progress-dependent angular penalties, and reproduction.

public RveaSampler(int populationSize = 50, BaseMutation? mutation = null, double? mutationProb = null, BaseCrossover? crossover = null, double crossoverProb = 0.9, double swappingProb = 0.5, int? seed = null, double alpha = 2, double adaptFreq = 0.1, int nMaxGenerations = 100, double[,]? referencePoints = null, int? dividingParameter = null, Func<Study, OrderedDict<string, BaseDistribution>, List<FrozenTrial>, OrderedDict<string, object?>>? childGenerationStrategy = null, Action<Study, FrozenTrial, TrialState, IReadOnlyList<double>?>? afterTrialStrategy = null)

Parameters

populationSize int

Target number of reference vectors / generation size. When reference points are generated (the default), the effective count is the largest Das-Dennis lattice size not exceeding this (see the class remarks).

mutation BaseMutation

Mutation applied when creating child individuals; defaults to PolynomialMutation (η=20).

mutationProb double?

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

crossover BaseCrossover

Crossover applied when creating child individuals; defaults to SBXCrossover (η=30, RVEA's classic operator).

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 random number generator.

alpha double

The APD penalty exponent α (default 2.0).

adaptFreq double

Fraction of nMaxGenerations at which the reference vectors are re-scaled to the current objective ranges (default 0.1; 0 disables adaptation).

nMaxGenerations int

Generation horizon for the APD penalty schedule and the adaptation period (default 100).

referencePoints double[,]

Explicit reference vectors (a 2-D array with n_objectives columns). When null (default), Das-Dennis reference vectors are generated.

dividingParameter int?

Number of Das-Dennis divisions when generating the default reference vectors. When null (default), it is chosen so the lattice size is closest to (≤) populationSize.

childGenerationStrategy Func<Study, OrderedDict<string, BaseDistribution>, List<FrozenTrial>, OrderedDict<string, object>>

Experimental. Overrides child generation.

afterTrialStrategy Action<Study, FrozenTrial, TrialState, IReadOnlyList<double>>

Experimental. Overrides the after-trial procedure.

Exceptions

ValueError

Population size is too small, alpha is negative, adaptation frequency is outside [0, 1], or the maximum generation count is below one.

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.

Exceptions

Exception

A configured after-trial or constraint callback fails; its exception propagates.

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.

SelectParent(Study, int)

Select parent trials from the population for the given generation. Called once per generation; the result is cached in the study system attributes.

public override List<FrozenTrial> SelectParent(Study study, int generation)

Parameters

study Study

Study supplying trial history, objective directions, and storage.

generation int

Zero-based generation whose individuals or optimizer state are requested.

Returns

List<FrozenTrial>

The selected parent trials for the requested generation.