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

EarlyStopper callback given a threshold #999

@GuillaumeSimo

Description

@GuillaumeSimo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions