Closed flongford closed 4 years ago
Since #340, the only dependency that WeightedOptimizerEngine
has on SciPyOptimizerEngine
is via use of the _scipy_optimize
method in _weighted_optimize
.
We would need to invoke the super().optimize
method here (or equivalent) for this to be independent of the parent class. However, the if there are any extra functionalities in _scipy_optimize
that are missing from BaseOptimizerEngine
, then we will also need to ensure these are present in the base class.
We can explore ways to make the
WeightedOptimizerEngine
class not rely on inheriting fromScipyOptmizerEgine
, and rather be a mixin-type object that can sit on top of anyBaseOptimizerEngine
implementation.The mixin will need to:
- [ ] Overwrite the objective function to include weights on each KPI value returned
- [ ] Overload the
optimize
method to iterate through each combination of weights returned by the space sampler, calling thesuper().optimize
method in turn.
Would the goal be something like,
class MyOptimizerEngine(ScipyOptimizerEngine, WeightedOptimizerEngine): pass
where you don't have to implement any methods in MyOptimizerEngine - it just inherits from its bases (ScipyOptimizerEngine and WeightedOptimizerEngine).
In that case those bases should be unrelated: only one inherits from BaseOptimizerEngine and provides the optimize(). The other provides some other interface that optimize calls on. And then you can mix-and-match OptimizerEngine (weighted/etc) and optimizer (scipy/nevergrad).
Does that make sense?
Would the goal be something like,
class MyOptimizerEngine(ScipyOptimizerEngine, WeightedOptimizerEngine): pass
where you don't have to implement any methods in MyOptimizerEngine - it just inherits from its bases (ScipyOptimizerEngine and WeightedOptimizerEngine).
Yes, that would be the idea - or a namespace equivalent:
class WeightedOptimizerEngine(ScipyOptimizerEngine, WeightedOptimizerMixin):
pass
In that case those bases should be unrelated: only one inherits from BaseOptimizerEngine and provides the optimize(). The other provides some other interface that optimize calls on. And then you can mix-and-match OptimizerEngine (weighted/etc) and optimizer (scipy/nevergrad).
Does that make sense?
Perfect sense (hopefully it's also not too difficult to implement!).
We can explore ways to make the
WeightedOptimizerEngine
class not rely on inheriting fromScipyOptmizerEgine
, and rather be a mixin-type object that can sit on top of anyBaseOptimizerEngine
implementation.The mixin will need to:
optimize
method to iterate through each combination of weights returned by the space sampler, calling thesuper().optimize
method in turn.