gpridge.engine ============== .. py:module:: gpridge.engine .. autoapi-nested-parse:: Python side of the rgpot learning-engine C ABI. The surrogate's learn-on-the-fly policy lives in C++ behind ``libgpr_engine.so``: a two-sided variance gate in multiples of the model's own likelihood noise, a convergence certificate that forces a ground-truth call before a driver may claim convergence, and a split between acquiring a row and incorporating it. Reaching that through the same C ABI eOn loads means ASE and eOn run one policy rather than two implementations that drift apart. The host supplies the oracle as a callback, so the engine never owns a loop: anything that can hold a potential can hold this. Attributes ---------- .. autoapisummary:: gpridge.engine.ACQUIRE_VARIANCE gpridge.engine.ACQUIRE_CERTIFY gpridge.engine.ACQUIRE_BATCH gpridge.engine.ACQUIRE_REJECT Classes ------- .. autoapisummary:: gpridge.engine.ActiveGPEngine Module Contents --------------- .. py:data:: ACQUIRE_VARIANCE :value: 1 .. py:data:: ACQUIRE_CERTIFY :value: 2 .. py:data:: ACQUIRE_BATCH :value: 3 .. py:data:: ACQUIRE_REJECT :value: 4 .. py:class:: ActiveGPEngine(oracle, library=None, sigma_lo_factor=None, sigma_hi_factor=None, certify_below_force=None, refit_training_revisions=None) The learning surrogate, reached through its C ABI. :param oracle: ``oracle(positions, atomic_numbers, box) -> (energy, forces)`` with ``positions`` and ``forces`` shaped ``(N, 3)``. Raising is reported to the engine as a recoverable failure, which leaves the row unlearned rather than corrupting the model. :type oracle: :py:class:`callable` :param library: Path to ``libgpr_engine.so``. Defaults to ``GPR_ENGINE_LIBRARY``, then the copy a wheel installs inside the package, then the loader's search path. :type library: :py:class:`str`, *optional* :param sigma_lo_factor: The two-sided gate, in multiples of the model's own likelihood noise. Below the low factor the model answers; above the high one the geometry is not learned from. :type sigma_lo_factor: :py:class:`float`, *optional* :param sigma_hi_factor: The two-sided gate, in multiples of the model's own likelihood noise. Below the low factor the model answers; above the high one the geometry is not learned from. :type sigma_hi_factor: :py:class:`float`, *optional* :param certify_below_force: A predicted force magnitude under this (eV/Angstrom) forces a ground-truth call, so a driver that is about to declare convergence is checked against the oracle rather than trusted. Drivers stop on a force criterion, so leaving this unset lets a driver converge on an unbacked answer. :type certify_below_force: :py:class:`float`, *optional* :param refit_training_revisions: Refit cadence in training-set appends. :type refit_training_revisions: :py:class:`int`, *optional* .. rubric:: Notes Passing none of the four leaves the engine on its own defaults. .. py:attribute:: model_updates :value: 0 .. py:attribute:: acquisitions :value: 0 .. py:property:: model_state Surface epoch. Changes only when an incorporation moved the posterior, so host quasi-Newton history keys on it. .. py:method:: incorporate() Fit acquired observations and advance the model's surface epoch. Calls with no pending observations leave the epoch unchanged. .. py:method:: force(positions, atomic_numbers, box=None, *, incorporate=True) Energy, forces and predictive variance at one geometry. The engine answers from the posterior where it is resolved and calls the oracle where it is not; the caller cannot tell which happened except through ``acquisitions`` and the variance. The call ends an incorporation boundary by default. Pass ``incorporate=False`` for evaluations sharing one fixed posterior, then call :meth:`incorporate` at the host's update boundary. .. py:method:: close() Destroy the native engine handle. Safe to call more than once.