saealib.PairwiseSurrogateManager#
- class saealib.PairwiseSurrogateManager(surrogate, training_set=None, n_ref=10)[source]#
Bases:
SurrogateManagerSurrogate 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 withWinRateAcquisitionThis 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, andAcquisitionFunctiondeliberately has noSurrogate/SurrogateManageraccess to construct and predict on them itself.The surrogate must be a
ComparisonSurrogatethat implementspredict_proba().- Parameters:
surrogate (ComparisonSurrogate) – Pairwise comparison surrogate (e.g.
SklearnRFCClassificationSurrogate).training_set (TrainingSet or None) – Training data builder. Defaults to
PairwiseComparisonSet().ctxis required when usingPairwiseComparisonSet.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 thann_refpoints all are used.
Methods
Return the pairwise-manager contract. |
|
Fit the surrogate on pairwise comparison training data. |
|
End-of-generation hook; override to update internal state. |
|
Predict per-candidate mean win rate against archive reference points. |
|
Return a copy of this manager with |
Method Details
- PairwiseSurrogateManager.__init__(surrogate, training_set=None, n_ref=10)[source]#
- Parameters:
surrogate (ComparisonSurrogate)
training_set (TrainingSet | None)
n_ref (int)
- 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=Trueand the training set isPairwiseComparisonSet, and to supplyctx.rngfor reference sampling (falls back to a fresh unseeded generator whenctxisNone).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.valueshape:(n_candidates, 1).- Return type:
- PairwiseSurrogateManager.with_on_generation_end(fn)#
Return a copy of this manager with
fnappended to the hook.- Parameters:
fn (callable) –
fn(gen, archive, ctx) -> None- Returns:
Shallow copy with the hook registered.
- Return type: