Source code for scm.glompo.generators.incumbent

import numpy as np

from .basegenerator import BaseGenerator
from ..common.namedtuples import Result
from ...plams.core.settings import Settings

__all__ = ("IncumbentGenerator",)


[docs]class IncumbentGenerator(BaseGenerator): """Starts a new optimizer at ``GloMPOManager.result['x']``. A random vector is generated if this is indeterminate. """ def __amssettings__(self, s: Settings) -> Settings: s.input.ams.Generator.Type = "Incumbent" return s def generate(self, manager: "GloMPOManager") -> np.ndarray: best: Result = manager.result bounds = np.array(manager.bounds) n_parms = manager.n_parms if best.x is None: return (bounds[:, 1] - bounds[:, 0]) * np.random.random(n_parms) + bounds[:, 0] return np.array(best.x)