saealib.AccuracyBasedSurrogateSwitcher#

class saealib.AccuracyBasedSurrogateSwitcher[source]#

Bases: ABC, Generic[T]

Abstract base for accuracy-driven module and parameter switching.

Implementations return a replacement surrogate manager, optimization strategy, or numeric parameter based on the most recent accuracy snapshot. Call switch() inside an iterate() loop and apply the result:

switcher = StrategySwitcher(ps_strategy, ib_strategy)
for ctx in optimizer.iterate():
    optimizer.set_strategy(
        switcher.switch(optimizer.surrogate_manager.last_accuracy)
)

Methods

__init__

switch

Return the replacement value for the next step.

Method Details

AccuracyBasedSurrogateSwitcher.__init__()#
abstractmethod AccuracyBasedSurrogateSwitcher.switch(accuracy)[source]#

Return the replacement value for the next step.

Parameters:

accuracy (SurrogateAccuracy or None) – Most recent accuracy snapshot from surrogate_manager.last_accuracy. None on the first step or when no accuracy evaluator is configured.

Returns:

Replacement module or parameter value.

Return type:

T