saealib.SurrogateManager#

class saealib.SurrogateManager[ソース]#

ベースクラス: ABC

Abstract base class for surrogate managers.

A SurrogateManager is narrowed to training and prediction management It coordinates TrainingSet construction, model fitting, and prediction, and returns a SurrogatePrediction for callers.

last_accuracy#

Accuracy metrics computed after the most recent fit() call. None until the first fit or when no evaluator is configured.

Type:

SurrogateAccuracy or None

Methods

__init__

contract

Return the surrogate-manager contract.

fit

Pre-fit the surrogate on the archive.

on_generation_end

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

predict

Predict candidate solutions using the surrogate model.

with_on_generation_end

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

Method Details

SurrogateManager.__init__()#
SurrogateManager.contract()[ソース]#

Return the surrogate-manager contract.

戻り値の型:

ComponentContract

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

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 of GenerationBasedStrategy). The default implementation is a no-op; override in managers that maintain a fitted surrogate model.

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

  • ctx (OptimizationState or None, optional) -- Current optimization context.

戻り値の型:

None

SurrogateManager.on_generation_end(gen, archive, ctx=None)[ソース]#

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

パラメータ:
  • gen (int)

  • archive (Archive)

  • ctx (OptimizationState | None)

戻り値の型:

None

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

Predict candidate solutions using the surrogate model.

パラメータ:
  • 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.build for strategies that require comparator or population access.

  • refit (bool, optional) -- If True (default), fit the surrogate before predicting. Pass False after an explicit fit() call to skip redundant re-fitting when the archive has not changed.

戻り値:

One batched prediction covering every row of candidates_x. Acquisition scoring is not performed here — pass the result to an AcquisitionFunction.

戻り値の型:

SurrogatePrediction

SurrogateManager.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