Online Per-Mode Leaky-Integrator Gain & Leak Autotuner
Joint per-mode (gain, leak) autotuner via Parseval Multi-Res PSD, faint-star adaptive memory, and ringing guard.
Overview & Role
Subscribes asynchronously to aol<N>_modevalOL_buff (and optional aol<N>_modevalWFS_buff, aol<N>_og_smooth/aol<N>_mWFSfact, aol<N>_mlimitcntfrac, and dynpsol H_diag/H_mimo FITS .kernel) in standalone C (cacao-fpsexec-modalopt). Builds a Parseval-exact unclamped 2-band Multi-Resolution PSD (decimated sub-Hz ring with exact sinc^2 boxcar inversion + explicit DC line + Hann Welch high-frequency PSD) and minimizes J_m(g, a) = sum P_OL * (|ETF|^2 + lam_dm * |CTF|^2) via shared BLAS SGEMM subject to Argument-Principle Nyquist stability and max|ETF| <= ms_max.
Decouples fast buffer-flip cadence (~0.25-0.5 s) from faint-star statistical memory using cumulative 1/k warmup into per-mode SNR-adaptive EWMA memory (tau_fast=3 s to tau_faint=15 s), dual regime-change flush (low-order power and HF noise floor), variance-aware James-Stein radial Empirical-Bayes pooling, and a statistically gated lag-d/lag-1 WFS ringing guard that backs off gain and freezes PSD updates on ringing slices. Publishes shadow aol<N>_mopt_* streams and opt-in live aol<N>_mgainfact / aol<N>_mmultfact paired with [0, 2.0] / [0, 1.0] safety clamps in modalfilter.c.
Compute Units / Entry Points: cacao-fpsexec-modaloptmodalfilter (mgain/mmult safety clamp)
Verified Highlights:
- -29.8% WFE vs static integrator in live SHM test (0.69 ms solve); real cacaosim replay: Stg1 a_lo=0.996, Stg2 a_mid=0.852 (1.5 ms solve)
- Faint-star adaptive memory stretches tau_C = 12 s vs tau_A = 2 s; dual change detector flushes on flux drop; 2.2x OG jump bounded by lag-d guard
Option Variants (CODE/OPT)
| Option Code | Behavior & Usage | Main Flags |
|---|---|---|
MOPT/SHAD | Shadow monitoring mode (default `.apply_gain=OFF`, `.apply_mult=OFF`) publishing `aol<N>_mopt_{gain,mult,snr,taumem,ring}` without touching loop. | — |
MOPT/LIVE | Live joint `(gain, leak)` publisher writing `aol<N>_mgainfact` & `aol<N>_mmultfact` (`.apply_gain=ON`, `.apply_mult=ON`, auto loopgain/mult). | — |
MOPT/FAINT | Faint-star SNR-adaptive memory (`tau_fast..tau_faint`, `1/k` warmup), James-Stein radial EB pooling (`.eb_enable`), and dual change-detector flush. | — |
MOPT/KERN | Exact discrete `dynpsol` `H_diag`/`H_mimo` FITS `.kernel` plant model with Argument-Principle stability & lag-d WFS ringing guard (`.ring_enable`). | — |
Dependencies & Calibration Chain
CLI Flags, Environment Variables & FPS Parameters
| Layer | Option (Links to Reference) | Default | Description |
|---|---|---|---|
| CACAO_* Env | CACAO_LOOPGAIN | 0.35 / 0.35 / 0.20 | Closed-loop modal integrator gain (stage 1 / 2 / 3) |
| CACAO_* Env | CACAO_LOOPMULT | 0.98 / 0.98 / 0.99 | Closed-loop leaky integrator multiplier (stage 1 / 2 / 3) |
| CACAO_* Env | CACAO_TBUFF_SIZE | 256 | Modal telemetry ring-buffer depth [frames] |
| CACAO_* Env | CACAO_DYNPSOL_KERNEL | (unset) | Dynamic PSOL impulse kernel FITS path (H_mimo / H_diag) for modalfilter |
| CACAO_* Env | CACAO_PSOL_WFSFACT | 1.0 | Pseudo open-loop (PSOL) WFS residual scaling factor |
| CACAO_* Env | CACAO_LATENCYSOFTWFR | 1.65 | Effective software + hardware loop latency [WFS frames] |
Implementation, Tests & Related Reports
Source Files
- cacao:
AOloopControl/modalopt.c - cacao:
AOloopControl/modalfilter.c
Verification Tests
test_16_modalopt.py