saealib.PairwiseSurrogateManager#

class saealib.PairwiseSurrogateManager(surrogate, training_set=None, n_ref=10)[ソース]#

ベースクラス: SurrogateManager

Surrogate manager for pairwise comparison surrogates.

predict() pairs each candidate with reference points sampled once per call from the archive and averages the predicted win probability over all pairs, returning the result as a "win_rate" prediction channel. Pair with WinRateAcquisition This manager performs the full reference-sampling + pair-construction + predict_proba() + per-candidate win-rate-aggregation sequence itself, rather than the usual "manager predicts, then acquisition scores" split -- the (candidate, reference) pairs are not known until this manager's own reference-sampling logic runs, and AcquisitionFunction deliberately has no Surrogate/SurrogateManager access to construct and predict on them itself.

The surrogate must be a ComparisonSurrogate that implements predict_proba().

パラメータ:
  • surrogate (ComparisonSurrogate) -- Pairwise comparison surrogate (e.g. SklearnRFCClassificationSurrogate).

  • training_set (TrainingSet or None) -- Training data builder. Defaults to PairwiseComparisonSet(). ctx is required when using PairwiseComparisonSet.

  • n_ref (int) -- Number of archive points sampled, once per predict() call, as the shared reference set every candidate in that call is compared against. When the archive has fewer than n_ref points all are used.

Methods

__init__

contract

Return the pairwise-manager contract.

fit

Fit the surrogate on pairwise comparison training data.

on_generation_end

End-of-generation hook; override to update internal state.

predict

Predict per-candidate mean win rate against archive reference points.

with_on_generation_end

Return a copy of this manager with fn appended to the hook.

Method Details

PairwiseSurrogateManager.__init__(surrogate, training_set=None, n_ref=10)[ソース]#
パラメータ:
PairwiseSurrogateManager.contract()[ソース]#

Return the pairwise-manager contract.

戻り値の型:

ComponentContract

PairwiseSurrogateManager.fit(archive, ctx=None)[ソース]#

Fit the surrogate on pairwise comparison training data.

パラメータ:
  • archive (Archive) -- Archive of evaluated solutions.

  • ctx (OptimizationState or None) -- Required when the training set is PairwiseComparisonSet (provides the comparator and rng).

戻り値の型:

None

PairwiseSurrogateManager.on_generation_end(gen, archive, ctx=None)#

End-of-generation hook; override to update internal state.

パラメータ:
  • gen (int)

  • archive (Archive)

  • ctx (OptimizationState | None)

戻り値の型:

None

PairwiseSurrogateManager.predict(candidates_x, archive, ctx=None, *, refit=True)[ソース]#

Predict per-candidate mean win rate against archive reference points.

Draws a reference subset from the archive exactly once per call (not once per candidate) -- this RNG-consumption timing is a once per candidate batch.

パラメータ:
  • candidates_x (np.ndarray) -- Candidate design variable matrix. shape: (n_candidates, dim)

  • archive (Archive) -- Archive of evaluated solutions.

  • ctx (OptimizationState or None) -- Optimization context. Required when refit=True and the training set is PairwiseComparisonSet, and to supply ctx.rng for reference sampling (falls back to a fresh unseeded generator when ctx is None).

  • refit (bool) -- If True (default), fit the surrogate before predicting.

戻り値:

A single "win_rate" channel, deliberately not named "objective": naming it "objective" would make predicted objective. value shape: (n_candidates, 1).

戻り値の型:

SurrogatePrediction

PairwiseSurrogateManager.with_on_generation_end(fn)#

Return a copy of this manager with fn appended to the hook.

パラメータ:

fn (callable) -- fn(gen, archive, ctx) -> None

戻り値:

Shallow copy with the hook registered.

戻り値の型:

SurrogateManager