fides/minimize.py
def check_convergence(self, step: Step, fval: float,
                          grad: np.ndarray) -> None:
        """
        Check whether optimization has converged.

        :param step:
            update to optimization variables

        :param fval:
            updated objective function value

        :param grad:
            updated objective function gradient
        """
        converged = False

        fatol = self.get_option(Options.FATOL)
        frtol = self.get_option(Options.FRTOL)
        xtol = self.get_option(Options.XTOL)
        gatol = self.get_option(Options.GATOL)
        grtol = self.get_option(Options.GRTOL)
        gnorm = norm(grad)
        stepsx = step.ss + step.ss0
        nsx = norm(stepsx)

        if self.delta <= self.delta_iter and \
                np.abs(fval - self.fval) < fatol + frtol*np.abs(self.fval):
            self.exitflag = ExitFlag.FTOL
            self.logger.warning(
                'Stopping as function difference '
                f'{np.abs(self.fval - fval):.2E} was smaller than specified '
                f'tolerances (atol={fatol:.2E}, rtol={frtol:.2E})'
            )
            converged = True

        elif self.iteration > 1 and nsx < xtol:
            self.exitflag = ExitFlag.XTOL
            self.logger.warning(
                'Stopping as norm of step '
                f'{nsx} was smaller than specified '
                f'tolerance (tol={xtol:.2E})'
            )
            converged = True

        elif gnorm <= gatol:
            self.exitflag = ExitFlag.GTOL
            self.logger.warning(
                'Stopping as gradient norm satisfies absolute convergence '
                f'criteria: {gnorm:.2E} < {gatol:.2E}'
            )
            converged = True

        elif gnorm <= grtol * np.abs(self.fval):
            self.exitflag = ExitFlag.GTOL
            self.logger.warning(
                'Stopping as gradient norm satisfies relative convergence '
                f'criteria: {gnorm:.2E} < {grtol:.2E} * '
                f'{np.abs(self.fval):.2E}'
            )
            converged = True

        self.converged = converged

        Check whether optimization has converged.

        :param step:
            update to optimization variables

        :param fval:
            updated objective function value

        :param grad:
            updated objective function gradient
        
Check whether optimization has converged.
Check whether optimization has converged .
def check_convergence(self, step: Step, fval: float,
                          grad: np.ndarray) -> None:
        converged = False
        fatol = self.get_option(Options.FATOL)
        frtol = self.get_option(Options.FRTOL)
        xtol = self.get_option(Options.XTOL)
        gatol = self.get_option(Options.GATOL)
        grtol = self.get_option(Options.GRTOL)
        gnorm = norm(grad)
        stepsx = step.ss + step.ss0
        nsx = norm(stepsx)
        if self.delta <= self.delta_iter and \
                np.abs(fval - self.fval) < fatol + frtol*np.abs(self.fval):
            self.exitflag = ExitFlag.FTOL
            self.logger.warning(
                'Stopping as function difference '
                f'{np.abs(self.fval - fval):.2E} was smaller than specified '
                f'tolerances (atol={fatol:.2E}, rtol={frtol:.2E})'
            )
            converged = True
        elif self.iteration > 1 and nsx < xtol:
            self.exitflag = ExitFlag.XTOL
            self.logger.warning(
                'Stopping as norm of step '
                f'{nsx} was smaller than specified '
                f'tolerance (tol={xtol:.2E})'
            )
            converged = True
        elif gnorm <= gatol:
            self.exitflag = ExitFlag.GTOL
            self.logger.warning(
                'Stopping as gradient norm satisfies absolute convergence '
                f'criteria: {gnorm:.2E} < {gatol:.2E}'
            )
            converged = True
        elif gnorm <= grtol * np.abs(self.fval):
            self.exitflag = ExitFlag.GTOL
            self.logger.warning(
                'Stopping as gradient norm satisfies relative convergence '
                f'criteria: {gnorm:.2E} < {grtol:.2E} * '
                f'{np.abs(self.fval):.2E}'
            )
            converged = True
        self.converged = converged
def check_convergence ( self , step : Step , fval : float , grad : np . ndarray ) -> None : converged = False fatol = self . get_option ( Options . FATOL ) frtol = self . get_option ( Options . FRTOL ) xtol = self . get_option ( Options . XTOL ) gatol = self . get_option ( Options . GATOL ) grtol = self . get_option ( Options . GRTOL ) gnorm = norm ( grad ) stepsx = step . ss + step . ss0 nsx = norm ( stepsx ) if self . delta <= self . delta_iter and np . abs ( fval - self . fval ) < fatol + frtol * np . abs ( self . fval ) : self . exitflag = ExitFlag . FTOL self . logger . warning ( 'Stopping as function difference ' f'{np.abs(self.fval - fval):.2E} was smaller than specified ' f'tolerances (atol={fatol:.2E}, rtol={frtol:.2E})' ) converged = True elif self . iteration > 1 and nsx < xtol : self . exitflag = ExitFlag . XTOL self . logger . warning ( 'Stopping as norm of step ' f'{nsx} was smaller than specified ' f'tolerance (tol={xtol:.2E})' ) converged = True elif gnorm <= gatol : self . exitflag = ExitFlag . GTOL self . logger . warning ( 'Stopping as gradient norm satisfies absolute convergence ' f'criteria: {gnorm:.2E} < {gatol:.2E}' ) converged = True elif gnorm <= grtol * np . abs ( self . fval ) : self . exitflag = ExitFlag . GTOL self . logger . warning ( 'Stopping as gradient norm satisfies relative convergence ' f'criteria: {gnorm:.2E} < {grtol:.2E} * ' f'{np.abs(self.fval):.2E}' ) converged = True self . converged = converged
Check whether optimization has converged.
Check whether optimization has converged .
"""
        Check whether optimization has converged.

        :param step:
            update to optimization variables

        :param fval:
            updated objective function value

        :param grad:
            updated objective function gradient
        """
self
step
Step
update to optimization variables
update to optimization variables
fval
float
updated objective function value
updated objective function value
grad
np.ndarray
updated objective function gradient
updated objective function gradient