Source code for scm.glompo.exitconditions.targetfunctionvalue

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

__all__ = ("TargetFunctionValue",)


[docs]class TargetFunctionValue(BaseExitCondition): """Returns ``f_best <= target + atol``, where ``f_best`` is the best value seen thus far by the manager.""" def __init__(self, target: float, atol: float = 1e-6): super().__init__() self.target = target self.atol = atol def __amssettings__(self, s: Settings) -> Settings: s.input.ams.ExitCondition.Type = "TargetFunctionValue" s.input.ams.ExitCondition.TargetFunctionValue = self.target return s def __call__(self, manager: "GloMPOManager") -> bool: if manager.result.fx is not None: self.last_result = manager.result.fx <= self.target + self.atol else: self.last_result = False return self.last_result