Skip to content

auto_math_ema_and_integral_control_1

github-actions[bot] edited this page Jul 20, 2026 · 2 revisions

Snippet from Math-EMA-and-Integral-Control.md

from compitum.control import SRMFController

# SRMFController is a deprecated alias for LyapunovController -- it is
# literally `class SRMFController(LyapunovController): pass`, with the
# IDENTICAL constructor signature and update() method (no separate
# alpha/gamma/rho/beta/kappa/r_min/r_max parameterization exists).
#
# Real constructor: (kappa: float = 0.1, r0: float = 1.0,
#                     integral_gain: float = 0.005)
#
# Real update signature: update(d_star: float, grad_norm: float)
#   -> Tuple[float, Dict[str, float]]
# It does NOT take a bare `d_t` and does NOT return a bare float.
ctrl = SRMFController()

print("d_star | grad_norm | eta_cap | trust_radius | drift_ema | drift_integral")
print("-------|-----------|---------|--------------|-----------|---------------")
for d_star in [0.2, 0.3, 0.1, 0.25, 0.22, 0.28, 0.15]:
    grad_norm = 1.0
    eta_cap, status = ctrl.update(d_star, grad_norm)
    print(
        f" {d_star:.2f}  |   {grad_norm:.2f}    | {eta_cap:.4f}  |    "
        f"{status['trust_radius']:.4f}    |  {status['drift_ema']:.4f}   |"
        f"     {status['drift_integral']:.4f}"
    )

Clone this wiki locally