BlackBoxFuncList¶

class BlackBoxFuncList¶

Bases: object

Class handles multiple black-box objective functions for multi-objective optimization.

Methods

__init__

Initialize a black-box function list class.

add_constraint

Add a user-defined constraint to the black-box function class.

append

Append a black-box function class.

handle_duplicates

Handle redundancy of variables and consistent issuance of amplify.PolyArray for different black-box objective functions, and unify variables and constraints.

Attributes

constraints

Constraints associated with this black-box function list.

variable_names

Names of variables associated with this black-box function list.

__getattr__(name: str) BlackBoxFuncBase¶

Get a variable in var_dict.

Raises:

ValueError – If the specified object is not found.

Returns:

A black-box function class instance.

Return type:

BlackBoxFuncBase

__getitem__(i: int) BlackBoxFuncBase¶

Return the i-th black-box function class instance.

Parameters:

i (int) – Index of a black-box function class instance.

Returns:

The i-th black-box function class instance.

Return type:

BlackBoxFuncBase

__init__(objectives: list[BlackBoxFuncBase], unify_variables: bool = False) None¶

Initialize a black-box function list class.

Parameters:
  • objectives (list[BlackBoxFuncBase]) – A list of class instances of black-box functions to be considered in multi-objective optimization.

  • unify_variables (bool, optional) – Whether to unify variables and constraints of multiple objectives in BlackBoxFuncList.handle_duplicates). Note that if you are performing multi-objective optimizations and want to manually operate amplify.PolyArray for variables (e.g. for creating custom constraints), this has to be done AFTER the last execution of BlackBoxFuncList.handle_duplicates with unify_variables = True. Since this unification is expected to be executed in the initializers of the optimizers, such operation usually should be done after the instantiation of the relevant optimizers. Defaults to False.

__iter__() Iterator[BlackBoxFuncBase]¶

The list of black-box function class instances.

Yields:

Iterator[BlackBoxFuncBase] – A black-box function class instance.

__len__() int¶

Return a number of black-box function class instances.

add_constraint(
constraint: Constraint | Constraints | list[Constraint | Constraints] | list[Constraint] | list[Constraints],
) None¶

Add a user-defined constraint to the black-box function class.

Parameters:

constraint (constraint () – Constraint | Constraints | list[Constraint | Constraints] | list[Constraint] | list[Constraints]): User-defined constraints.

append(bb: BlackBoxFuncBase) None¶

Append a black-box function class.

Parameters:

bb (BlackBoxFuncBase) – A black-box function class instance.

handle_duplicates() None¶

Handle redundancy of variables and consistent issuance of amplify.PolyArray for different black-box objective functions, and unify variables and constraints. Expected to call this each time there is change in the objective functions to consider. The unification happens when unify_variables = True in BlackBoxFuncList.__init__.

__dict__ = mappingproxy({'__module__': 'amplify_bbopt.bb_func', '__doc__': 'Class handles multiple black-box objective functions for multi-objective optimization.', '__init__': <function BlackBoxFuncList.__init__>, 'handle_duplicates': <function BlackBoxFuncList.handle_duplicates>, '__getattr__': <function BlackBoxFuncList.__getattr__>, 'add_constraint': <function BlackBoxFuncList.add_constraint>, 'append': <function BlackBoxFuncList.append>, '__len__': <function BlackBoxFuncList.__len__>, '__getitem__': <function BlackBoxFuncList.__getitem__>, '__iter__': <function BlackBoxFuncList.__iter__>, 'constraints': <property object>, 'variable_names': <property object>, '__dict__': <attribute '__dict__' of 'BlackBoxFuncList' objects>, '__weakref__': <attribute '__weakref__' of 'BlackBoxFuncList' objects>, '__annotations__': {'_objectives': 'list[BlackBoxFuncBase]'}})¶
__weakref__¶

list of weak references to the object (if defined)

property constraints: Constraints¶

Constraints associated with this black-box function list.

property variable_names: list[str]¶

Names of variables associated with this black-box function list.