BlackBoxFuncList¶
- class BlackBoxFuncList¶
Bases:
object
Class handles multiple black-box objective functions for multi-objective optimization.
Methods
Initialize a black-box function list class.
Add a user-defined constraint to the black-box function class.
Append a black-box function class.
Handle redundancy of variables and consistent issuance of amplify.PolyArray for different black-box objective functions, and unify variables and constraints.
Attributes
Constraints associated with this black-box function list.
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:
- __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:
- __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 ofBlackBoxFuncList.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.
- add_constraint(
- constraint: Constraint | Constraints | list[Constraint | Constraints] | list[Constraint] | list[Constraints],
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.