BlackBoxFuncBase¶

class BlackBoxFuncBase¶

Bases: ABC, Generic[_Param]

Base class for black-box functions.

Methods

__init__

Initialize the Variables class.

evaluate

Evaluates the black-box function with the given input values.

Attributes

flattened_variables_dict

Returns the flattened variables dictionary.

mapping

Returns the mapping from argument names to variable names or lists of variable names.

name

Returns the name of the black-box function.

variables

Returns the variables of the black-box function.

class Variables¶

Bases: object

A class to hold variables considered in the black-box function.

__getattr__(name: str) Variable | list[Variable]¶
__init__(
flattened_variables_dict: dict[str, Variable],
mapping: dict[str, str | list[str]],
) None¶

Initialize the Variables class.

Parameters:
  • flattened_variables_dict (dict[str, Variable]) – A dictionary mapping variable names to their corresponding variable objects.

  • mapping (dict[str, str | list[str]]) – A dictionary mapping argument names to variable names or lists of variable names.

Raises:
  • ValueError – If the flattened_variables_dict is empty.

  • ValueError – If the mapping is empty.

__len__() int¶
__dict__ = mappingproxy({'__module__': 'amplify_bbopt.blackbox', '__doc__': 'A class to hold variables considered in the black-box function.', '__init__': <function BlackBoxFuncBase.Variables.__init__>, '__getattr__': <function BlackBoxFuncBase.Variables.__getattr__>, '__len__': <function BlackBoxFuncBase.Variables.__len__>, '__dict__': <attribute '__dict__' of 'Variables' objects>, '__weakref__': <attribute '__weakref__' of 'Variables' objects>, '__annotations__': {}})¶
__weakref__¶

list of weak references to the object (if defined)

abstract __call__(*args: ~typing.~_Param, **kwargs: ~typing.~_Param) float¶

Call self as a function.

classmethod __class_getitem__(params)¶
__init__() None¶

Initialize the Variables class.

classmethod __init_subclass__(*args, **kwargs)¶

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

evaluate(values: dict[str, float]) float¶

Evaluates the black-box function with the given input values.

Parameters:

values (dict[str, float]) – A dictionary mapping variable names to their corresponding input values.

Returns:

The output of the black-box function.

Return type:

float

__abstractmethods__ = frozenset({'__call__'})¶
__dict__ = mappingproxy({'__module__': 'amplify_bbopt.blackbox', '__doc__': 'Base class for black-box functions.', 'Variables': <class 'amplify_bbopt.blackbox.BlackBoxFuncBase.Variables'>, '__init__': <function BlackBoxFuncBase.__init__>, 'mapping': <property object>, 'name': <property object>, 'flattened_variables_dict': <property object>, 'variables': <property object>, 'evaluate': <function BlackBoxFuncBase.evaluate>, '__call__': <function BlackBoxFuncBase.__call__>, '__orig_bases__': (<class 'abc.ABC'>, typing.Generic[~_Param]), '__dict__': <attribute '__dict__' of 'BlackBoxFuncBase' objects>, '__weakref__': <attribute '__weakref__' of 'BlackBoxFuncBase' objects>, '__parameters__': (~_Param,), '__abstractmethods__': frozenset({'__call__'}), '_abc_impl': <_abc._abc_data object>, '__annotations__': {'_flattened_variables_dict': 'dict[str, Variable]', '_mapping': 'dict[str, str | list[str]]', '_name': 'str', '_variables': 'BlackBoxFuncBase.Variables | None'}})¶
__orig_bases__ = (<class 'abc.ABC'>, typing.Generic[~_Param])¶
__parameters__ = (~_Param,)¶
__slots__ = ()¶
__weakref__¶

list of weak references to the object (if defined)

property flattened_variables_dict: dict[str, Variable]¶

Returns the flattened variables dictionary.

property mapping: dict[str, str | list[str]]¶

Returns the mapping from argument names to variable names or lists of variable names.

property name: str¶

Returns the name of the black-box function.

property variables: Variables¶

Returns the variables of the black-box function.