OptimizerBase¶
- class OptimizerBase¶
Bases:
ABC
Base class for black-box optimizer.
Methods
Initialize OptimizerBase.
Return the optimization history.
A method to execute optimization.
Set the current best solution and corresponding objective function value.
Update the weight for the objective function.
Attributes
Objective function value corresponding to the current best solution (optimaized input).
Current best solution (optimized input).
Current training dataset (both input and output of an individual objective function).
The number of current optimization cycle.
A number of the samples in initial data.
Objective function class instance.
The latest weight for the objective function.
- __init__(
- data: DataList,
- objective: BlackBoxFuncBase,
- objective_weight: float | Callable[[Any], float] = 1.0,
Initialize OptimizerBase.
- Parameters:
data (DataList) – Initial training dataset.
objective (BlackBoxFuncBase) – Objective (black-box) function class instance created with
blackbox
decorator.objective_weight (float | Callable[[int, Any], float], optional) – A weight imposed on the objective function in amplify.Model. If a Callable object is passed, a weight is the return value of the object with the used optimizer instance as an argument at each optimization cycle. Generally, weight is only useful in case of multi-objective optimization using
MultiObjectiveOptimizer
. Defaults to 1.
- fetch_history() History ¶
Return the optimization history.
- Returns:
The optimization history.
- Return type:
- set_best(best_solution_dict: FlatSolutionDict | None = None) None ¶
Set the current best solution and corresponding objective function value.
- Parameters:
best_solution_dict (FlatSolutionDict | None, optional) – A solution dictionary. This may contains solution values from other objective functions in case of multiple-objective optimization. In this case, ‘best’ means the variable value vector relevant to an individual objective function, that is a subset of the entire solution which achieve the best of multiple-objectives combined. Therefore, the set best here may not be the same as the best in OptimizerBase.data. If None is specified, search the best from OptimizerBase.data. Defaults to None.
- update_objective_weight(optimizer: Any) None ¶
Update the weight for the objective function.
The weight is determined according to the weight function passed to
OptimizerBase.__init__
(OptimizerBase.objective_weight
is callable). In case ofOptimizerBase.objective_weight
being float, the weight is constant over optimization cycles. Expected to be executed at the beginning of each optmization cycle.- Parameters:
optimizer (Any) – An optimizer to be passed to the callable
OptimizerBase.objective_weight
.
- __abstractmethods__ = frozenset({'optimize'})¶
- __dict__ = mappingproxy({'__module__': 'amplify_bbopt.optimizer', '__doc__': 'Base class for black-box optimizer.', '__init__': <function OptimizerBase.__init__>, 'num_initial_data': <property object>, 'objective': <property object>, 'i_cycle': <property object>, 'objective_weight': <property object>, 'update_objective_weight': <function OptimizerBase.update_objective_weight>, 'best_objective': <property object>, 'best_solution': <property object>, 'set_best': <function OptimizerBase.set_best>, 'data': <property object>, 'fetch_history': <function OptimizerBase.fetch_history>, 'optimize': <function OptimizerBase.optimize>, '__dict__': <attribute '__dict__' of 'OptimizerBase' objects>, '__weakref__': <attribute '__weakref__' of 'OptimizerBase' objects>, '__abstractmethods__': frozenset({'optimize'}), '_abc_impl': <_abc._abc_data object>, '__annotations__': {'_objective_weight': 'float | None', '_best_objective': 'int | float | None'}})¶
- __slots__ = ()¶
- __weakref__¶
list of weak references to the object (if defined)
- property best_objective: int | float¶
Objective function value corresponding to the current best solution (optimaized input).
- property best_solution: StructuredSolutionDict¶
Current best solution (optimized input).
- property data: DataList¶
Current training dataset (both input and output of an individual objective function).
- property objective: BlackBoxFuncBase¶
Objective function class instance.