Skip to content

Configuration sampler

RandomSearchSampler (StagedIterationConfigurationSampler)

Source code in blackboxopt/optimizers/staged/configuration_sampler.py
class RandomSearchSampler(StagedIterationConfigurationSampler):
    def __init__(self, search_space: ParameterSpace):
        self.search_space = search_space

    def sample_configuration(self) -> Tuple[dict, dict]:
        return self.search_space.sample(), {}

    def digest_evaluation(self, evaluation: Evaluation):
        """Random Search is stateless and does nothing with finished evaluations."""

digest_evaluation(self, evaluation)

Random Search is stateless and does nothing with finished evaluations.

Source code in blackboxopt/optimizers/staged/configuration_sampler.py
def digest_evaluation(self, evaluation: Evaluation):
    """Random Search is stateless and does nothing with finished evaluations."""

sample_configuration(self)

Pick the next configuration.

Returns:

Type Description
Tuple[dict, dict]

The configuration to be evaluated, Additional information that will be added to the optimizer_info dict.

Source code in blackboxopt/optimizers/staged/configuration_sampler.py
def sample_configuration(self) -> Tuple[dict, dict]:
    return self.search_space.sample(), {}

StagedIterationConfigurationSampler

Base class for sampling new configurations inside a StagedIterationOpitimzer.

Source code in blackboxopt/optimizers/staged/configuration_sampler.py
class StagedIterationConfigurationSampler:
    """Base class for sampling new configurations inside a StagedIterationOpitimzer."""

    @abc.abstractmethod
    def sample_configuration(self) -> Tuple[dict, dict]:
        """Pick the next configuration.

        Returns:
            The configuration to be evaluated,
            Additional information that will be added to the `optimizer_info` dict.
        """

    @abc.abstractmethod
    def digest_evaluation(self, evaluation: Evaluation):
        """Register the result of an evaluation."""

digest_evaluation(self, evaluation)

Register the result of an evaluation.

Source code in blackboxopt/optimizers/staged/configuration_sampler.py
@abc.abstractmethod
def digest_evaluation(self, evaluation: Evaluation):
    """Register the result of an evaluation."""

sample_configuration(self)

Pick the next configuration.

Returns:

Type Description
Tuple[dict, dict]

The configuration to be evaluated, Additional information that will be added to the optimizer_info dict.

Source code in blackboxopt/optimizers/staged/configuration_sampler.py
@abc.abstractmethod
def sample_configuration(self) -> Tuple[dict, dict]:
    """Pick the next configuration.

    Returns:
        The configuration to be evaluated,
        Additional information that will be added to the `optimizer_info` dict.
    """