Source code for scm.glompo.exitconditions.maxoptimizersstopped
from .baseexitcondition import BaseExitCondition
from ...plams.core.settings import Settings
__all__ = ("MaxOptimizersStopped",)
[docs]class MaxOptimizersStopped(BaseExitCondition):
"""Returns ``True`` after ``max_stops`` optimizers have been shutdown by the manager."""
def __init__(self, max_stops: int):
super().__init__()
self.max_stops = max_stops
def __amssettings__(self, s: Settings) -> Settings:
s.input.ams.ExitCondition.Type = "MaxOptimizersStopped"
s.input.ams.ExitCondition.MaxOptimizersStopped = self.max_stops
return s
def __call__(self, manager: "GloMPOManager") -> bool:
self.last_result = len(manager.stopped_opts) >= self.max_stops
return self.last_result