This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Description
It would be nice if we have an EarlyStopper that stops optimization if a func_val is lower (in the case of minimization) than a given threshold
I've implemented and tested it in a private repository
class ThresholdStopper(EarlyStopper):
"""
Stop the optimization if the best func_vals is lower than the given threshold
"""
def __init__(self, threshold: float) -> bool:
super(EarlyStopper, self).__init__()
self.threshold = threshold
def _criterion(self, result):
func_vals = np.sort(result.func_vals)
best = func_vals[0]
# True if best < threshold given by the user
return best <= self.threshold