saealib.SurrogateManager#
- class saealib.SurrogateManager[source]#
Bases:
ABCAbstract base class for surrogate managers.
A SurrogateManager is narrowed to training and prediction management It coordinates
TrainingSetconstruction, model fitting, and prediction, and returns aSurrogatePredictionfor callers.- last_accuracy#
Accuracy metrics computed after the most recent
fit()call.Noneuntil the first fit or when no evaluator is configured.- Type:
SurrogateAccuracy or None
Methods
Return the surrogate-manager contract. |
|
Pre-fit the surrogate on the archive. |
|
End-of-generation hook; override to update internal state. |
|
Predict candidate solutions using the surrogate model. |
|
Return a copy of this manager with |
Method Details
- SurrogateManager.__init__()#
- SurrogateManager.fit(archive, ctx=None)[source]#
Pre-fit the surrogate on the archive.
Call once before a sequence of
predict(..., refit=False)calls when the archive does not change between calls (e.g. the surrogate-only inner loop ofGenerationBasedStrategy). The default implementation is a no-op; override in managers that maintain a fitted surrogate model.- Parameters:
archive (Archive) – Archive of evaluated solutions used for surrogate training.
ctx (OptimizationState or None, optional) – Current optimization context.
- Return type:
None
- SurrogateManager.on_generation_end(gen, archive, ctx=None)[source]#
End-of-generation hook; override to update internal state.
- Parameters:
gen (int)
archive (Archive)
ctx (OptimizationState | None)
- Return type:
None
- abstractmethod SurrogateManager.predict(candidates_x, archive, ctx=None, *, refit=True)[source]#
Predict candidate solutions using the surrogate model.
- Parameters:
candidates_x (np.ndarray) – Candidate design variable matrix. shape: (n_candidates, dim)
archive (Archive) – Archive of evaluated solutions used for surrogate training.
ctx (OptimizationState or None, optional) – Current optimization context. Passed to
TrainingSet.buildfor strategies that require comparator or population access.refit (bool, optional) – If
True(default), fit the surrogate before predicting. PassFalseafter an explicitfit()call to skip redundant re-fitting when the archive has not changed.
- Returns:
One batched prediction covering every row of
candidates_x. Acquisition scoring is not performed here — pass the result to anAcquisitionFunction.- Return type: