saealib.PairwiseSurrogateManager#

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

Bases: 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().

Parameters:
  • 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)[source]#
Parameters:
PairwiseSurrogateManager.contract()[source]#

Return the pairwise-manager contract.

Return type:

ComponentContract

PairwiseSurrogateManager.fit(archive, ctx=None)[source]#

Fit the surrogate on pairwise comparison training data.

Parameters:
  • archive (Archive) – Archive of evaluated solutions.

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

Return type:

None

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

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

Parameters:
  • gen (int)

  • archive (Archive)

  • ctx (OptimizationState | None)

Return type:

None

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

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.

Parameters:
  • 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.

Returns:

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

Return type:

SurrogatePrediction

PairwiseSurrogateManager.with_on_generation_end(fn)#

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

Parameters:

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

Returns:

Shallow copy with the hook registered.

Return type:

SurrogateManager