Callbacks

Events

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

Callback Manager

saealib.CallbackManager

Manages event handlers.

Built-in Handlers

saealib.logging_generation(event)[source]

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.

Parameters:

event (GenerationStartEvent) – The generation-start event.

Return type:

None

saealib.logging_generation_hv(reference_point)[source]

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

Parameters:

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

Returns:

A handler compatible with CallbackManager.register.

Return type:

Callable[[GenerationStartEvent], None]

Examples

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