コールバック#

Layer 2: Compose

イベント#

saealib.Event

Base class for all callback events.

saealib.RunStartEvent

Fired once when the optimization run starts.

saealib.RunEndEvent

Fired once when the optimization run ends.

saealib.InitialEvaluationStartEvent

Fired after initial sampling, before initial archive evaluation.

saealib.InitialEvaluationEndEvent

Fired after initial archive evaluation, before archive sorting.

saealib.GenerationStartEvent

Fired at the beginning of each generation.

saealib.GenerationEndEvent

Fired at the end of each generation, before yielding the context.

saealib.SurrogateStartEvent

Fired before surrogate-based candidate scoring.

saealib.SurrogateEndEvent

Fired after surrogate-based candidate scoring.

saealib.AcquisitionStartEvent

Fired before acquisition scoring, inside AcquisitionStage.

saealib.AcquisitionEndEvent

Fired after acquisition scoring succeeds, inside AcquisitionStage.

saealib.PostCrossoverEvent

Fired after crossover and repair.

saealib.PostMutationEvent

Fired after mutation and repair.

saealib.PostAskEvent

Fired after the full ask step (post crossover and mutation).

saealib.PostSurrogateFitEvent

Fired after the surrogate model is fitted.

saealib.PostEvaluationEvent

Fired after true evaluation of selected candidates.

コールバックマネージャー#

saealib.CallbackManager

Manages event handlers.

組み込みハンドラー#

saealib.logging_generation(event)[ソース]#

Log the state at the start of each generation.

For single-objective problems, logs the best objective value determined by the comparator. For multi-objective problems, logs the size of the first Pareto front and the per-objective value ranges of that front.

パラメータ:

event (GenerationStartEvent) -- The generation-start event.

戻り値の型:

None

saealib.logging_generation_hv(reference_point)[ソース]#

Return a handler that logs the hypervolume per generation.

Computes the hypervolume of the first Pareto front in the archive with respect to the given reference point (minimization convention).

パラメータ:

reference_point (np.ndarray) -- Reference (nadir) point, shape (n_obj,). Each component should be strictly greater than the best achievable value per objective.

戻り値:

A handler compatible with CallbackManager.register.

戻り値の型:

Callable[[GenerationStartEvent], None]

サンプル

>>> optimizer.cbmanager.register(
...     GenerationStartEvent,
...     logging_generation_hv(np.array([1.1, 1.1]))
... )

チェックポイント保存#

saealib.CheckpointCallback

Callback that saves checkpoints at regular generation intervals.