Skip to content

blackboxopt.optimizers.random_search

RandomSearch

get_evaluation_specification(self)

[summary]

Exceptions:

Type Description
OptimizationComplete

Raised if the optimizer's max_steps are reached.

Returns:

Type Description
EvaluationSpecification

[description]

Source code in blackboxopt/optimizers/random_search.py
def get_evaluation_specification(self) -> EvaluationSpecification:
    """[summary]

    Raises:
        OptimizationComplete: Raised if the optimizer's `max_steps` are reached.

    Returns:
        [description]
    """
    if self.n_steps >= self.max_steps:
        raise OptimizationComplete()

    eval_spec = EvaluationSpecification(
        configuration=self.search_space.sample(),
        settings={},
        optimizer_info={"step": self.n_steps},
    )
    self.n_steps += 1

    return eval_spec

report_evaluation(self, evaluation) inherited

Report an evaluated evaluation specification.

NOTE: Not all optimizers support reporting results for evaluation specifications that were not proposed by the optimizer.

Parameters:

Name Type Description Default
evaluation Evaluation

An evaluated evaluation specification.

required
Source code in blackboxopt/optimizers/random_search.py
def report_evaluation(self, evaluation: Evaluation) -> None:
    raise_on_unknown_or_incomplete_objectives(
        known_objectives=self.objectives,
        reported_objectives=evaluation.objectives,
    )

    super().report_evaluation(evaluation)