poli.core.abstract_black_box.AbstractBlackBox

poli.core.abstract_black_box.AbstractBlackBox#

class poli.core.abstract_black_box.AbstractBlackBox(batch_size: Optional[int] = None, parallelize: bool = False, num_workers: Optional[int] = None, evaluation_budget: int = inf)#

Abstract base class for a black box optimization problem.

Parameters
  • batch_size (int, optional) – The batch size for evaluating the black box function. Default is None.

  • parallelize (bool, optional) – Flag indicating whether to evaluate the black box function in parallel. Default is False.

  • num_workers (int, optional) – The number of workers to use for parallel evaluation. Default is None, which uses half of the available CPU cores.

  • evaluation_budget (int, optional) – The maximum number of evaluations allowed for the black box function. Default is float(“inf”).

observer#

The observer object for recording observations during evaluation.

Type

AbstractObserver or None

observer_info#

The information given by the observer after initialization.

Type

object or None

parallelize#

Flag indicating whether to evaluate the black box function in parallel.

Type

bool

num_workers#

The number of workers to use for parallel evaluation.

Type

int

batch_size#

The batch size for evaluating the black box function.

Type

int or None

set_observer(observer)#

Set the observer object for recording observations during evaluation.

reset_evaluation_budget()#

Reset the evaluation budget by setting the number of evaluations made to 0.

__call__(x, context=None)#

Evaluate the black box function for the given input.

_black_box(x, context=None)#

Abstract method for evaluating the black box function.

terminate()#

Terminate the black box optimization problem.

__enter__()#

Enter the context manager.

__exit__(exc_type, exc_val, exc_tb)#

Exit the context manager.

__del__()#

Destructor for the black box optimization problem.

__neg__()#

Create a new black box with the objective function as the negative of the original one.

__init__(batch_size: Optional[int] = None, parallelize: bool = False, num_workers: Optional[int] = None, evaluation_budget: int = inf)#

Initialize the AbstractBlackBox object.

Parameters
  • batch_size (int, optional) – The batch size for parallel execution, by default None.

  • parallelize (bool, optional) – Flag indicating whether to parallelize the execution, by default False.

  • num_workers (int, optional) – The number of workers for parallel execution, by default we use half the available CPUs.

  • evaluation_budget (int, optional) – The maximum number of evaluations allowed for the black box function, by default float(“inf”).

Methods

__init__([batch_size, parallelize, ...])

Initialize the AbstractBlackBox object.

reset_evaluation_budget()

Resets the evaluation budget by setting the number of evaluations made to 0.

set_observer(observer)

Set the observer object for recording observations during evaluation.

terminate()

Terminate the black box optimization problem.