Table of Contents

Class AgeMoea2Sampler

Namespace
OptunaSharp.Samplers
Assembly
OptunaSharp.dll

Multi-objective sampler using AGE-MOEA-2 (Layer 2 of the AGE-MOEA-2 port). The Optuna-idiomatic face of the algorithm — an ask/tell BaseGASampler that reconstructs the population from completed trials exactly like NSGAIISampler, but replaces NSGA-II's rank + crowding-distance elite selection with AGE-MOEA-2's geometry-based environmental selection (AgeMoea2ElitePopulationSelectionStrategy over OptunaSharp.Samplers.AgeMoea.AgeMoea2Survival). Children are generated with SBX + polynomial mutation over Optuna's transformed search space, so the sampler works across Optuna's full parameter space (float / int / categorical). For conditional (branch-defined) parameters use NSGAIIICptSampler (NSGA-III-CPT); this sampler has no such extension.

AGE-MOEA-2 (Panichella, GECCO 2022, doi:10.1145/3512290.3528732) is absent from Optuna core, so — like LM-CMA and JANUS — this is a beyond-core sampler. Scope of the parity guarantee: the byte-perfect, pymoo-faithful AGE-MOEA-2 lives in Layer 1 (OptunaSharp.Samplers.AgeMoea.AgeMoea2Optimizer, generation-by-generation bit-exact vs pymoo.minimize). This Layer-2 sampler is validated behaviorally: it uses Optuna's operators (a different RNG stream than pymoo's), so it is not pymoo-bit-exact — it brings AGE-MOEA-2's survival to Optuna's define-by-run workflow. Unconstrained multi-objective.

public class AgeMoea2Sampler : BaseGASampler
Inheritance
AgeMoea2Sampler
Derived
Inherited Members

Constructors

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

Configures AGE-MOEA-2 survival and the genetic operators used to produce each generation.

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

Parameters

populationSize int

Number of individuals (trials) per generation. Must be >= 2.

mutation BaseMutation

Mutation applied when creating children. Null selects PolynomialMutation with eta = 20, AGE-MOEA-2's default mutation.

mutationProb double?

Per-parameter mutation probability. null ⇒ 1 / len(params).

crossover BaseCrossover

Crossover applied when creating children. Defaults to SBXCrossover (eta = 15).

crossoverProb double

Probability that a crossover occurs.

swappingProb double

Probability of swapping each parameter during crossover.

seed int?

Seed for the random number generator.

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.

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.