saealib.GlobalSurrogateManager#

class saealib.GlobalSurrogateManager(surrogate, training_set=None, accuracy_evaluator=None)[source]#

Bases: SurrogateManager

Surrogate manager that fits once on the full archive.

Fits the surrogate on all archived solutions, then predicts and scores all candidates in a single batch. Suitable when global approximation quality is sufficient.

Parameters:
  • surrogate (Surrogate) – Surrogate model instance.

  • training_set (TrainingSet or None) – Strategy object for building training data. Defaults to ArchiveObjectiveSet().

  • accuracy_evaluator (AccuracyEvaluator or None) – If provided, fit() computes accuracy metrics after each fit and stores them in last_accuracy.

Methods

__init__

contract

Return the global-manager contract.

fit

Fit the surrogate on the full archive.

on_generation_end

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

predict

Fit on full archive, then predict all candidates at once.

with_on_generation_end

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

Method Details

GlobalSurrogateManager.__init__(surrogate, training_set=None, accuracy_evaluator=None)[source]#
Parameters:
GlobalSurrogateManager.contract()[source]#

Return the global-manager contract.

Return type:

ComponentContract

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

Fit the surrogate on the full archive.

If an accuracy_evaluator was supplied at construction, accuracy metrics are computed immediately after fitting and stored in last_accuracy.

Parameters:
  • archive (Archive)

  • ctx (OptimizationState | None)

Return type:

None

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

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

Fit on full archive, then predict all candidates at once.

Parameters:
  • candidates_x (np.ndarray)

  • archive (Archive)

  • ctx (OptimizationState | None)

  • refit (bool)

Return type:

SurrogatePrediction

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