Source code for scm.glompo.exitconditions.maxtotalfunctioncalls

from .baseexitcondition import BaseExitCondition
from ...plams.core.settings import Settings

__all__ = ("MaxTotalFunctionCalls",)


[docs]class MaxTotalFunctionCalls(BaseExitCondition): """Returns ``True`` after ``fmax`` function evaluations have been executed across all managed optimizers.""" def __init__(self, fmax: int): super().__init__() self.fmax = fmax def __amssettings__(self, s: Settings) -> Settings: s.input.ams.ExitCondition.Type = "MaxTotalFunctionCalls" s.input.ams.ExitCondition.MaxTotalFunctionCalls = self.fmax return s def __call__(self, manager: "GloMPOManager") -> bool: self.last_result = manager.f_counter >= self.fmax return self.last_result