Skip to content

Helpers

smac.acquisition.maximizer.helpers #

ChallengerList #

ChallengerList(
    configspace: ConfigurationSpace,
    challenger_callback: Callable,
    random_design: (
        AbstractRandomDesign | None
    ) = ProbabilityRandomDesign(
        seed=0, probability=0.08447232371720552
    ),
)

Bases: Iterator

Helper class to interleave random configurations in a list of challengers.

Provides an iterator which returns a random configuration in each second iteration. Reduces time necessary to generate a list of new challengers as one does not need to sample several hundreds of random configurations in each iteration which are never looked at.

Parameters#

configspace : ConfigurationSpace challenger_callback : Callable Callback function which returns a list of challengers (without interleaved random configurations), must a be a python closure. random_design : AbstractRandomDesign | None, defaults to ModulusRandomDesign(modulus=2.0) Which random design should be used.

Source code in smac/acquisition/maximizer/helpers.py
def __init__(
    self,
    configspace: ConfigurationSpace,
    challenger_callback: Callable,
    random_design: AbstractRandomDesign | None = ProbabilityRandomDesign(seed=0, probability=0.08447232371720552),
):
    self._challengers_callback = challenger_callback
    self._challengers: list[Configuration] | None = None
    self._configspace = configspace
    self._index = 0
    self._iteration = 1  # 1-based to prevent from starting with a random configuration
    self._random_design = random_design