(
        self, potential_best_value: float, best_parameters: ParameterType
    )
return False
Check if the optimization process should be stopped.
Check if the optimization process should be stopped.
Check if the optimization process should be stopped .
def should_stop(
        self, potential_best_value: float, best_parameters: ParameterType
    ) -> bool:
        """Check if the optimization process should be stopped."""
        is_improving = True
        if self.current_best_value is not None:
            if self.minimize:
                is_improving = (
                    potential_best_value + self.epsilon < self.current_best_value
                )
            else:
                is_improving = (
                    potential_best_value - self.epsilon > self.current_best_value
                )

        if is_improving:
            self.current_epochs_without_improvement = 0
            self.current_best_value = potential_best_value
            log.info(
                f"New best value: {potential_best_value}, best parameters: {best_parameters}"
            )

            return False
        else:
            self.current_epochs_without_improvement += 1

        if (
            self.current_epochs_without_improvement
            >= self.max_epochs_without_improvement
        ):
            log.info(
                f"Early stopping, best known value {self.current_best_value}"
                f" did not improve for {self.current_epochs_without_improvement} epochs"
            )
            return True
        return False
def should_stop ( self , potential_best_value : float , best_parameters : ParameterType ) -> bool : is_improving = True if self . current_best_value is not None : if self . minimize : is_improving = ( potential_best_value + self . epsilon < self . current_best_value ) else : is_improving = ( potential_best_value - self . epsilon > self . current_best_value ) if is_improving : self . current_epochs_without_improvement = 0 self . current_best_value = potential_best_value log . info ( f"New best value: {potential_best_value}, best parameters: {best_parameters}" ) return False else : self . current_epochs_without_improvement += 1 if ( self . current_epochs_without_improvement >= self . max_epochs_without_improvement ) : log . info ( f"Early stopping, best known value {self.current_best_value}" f" did not improve for {self.current_epochs_without_improvement} epochs" ) return True return False