GLE Colored-Noise Langevin¶
GLE-Langevin replaces the white-noise Langevin move with a generalized Langevin equation thermostat. An optimal-sampling drift matrix fitted once from the characteristic frequency flattens the noise spectrum. The same fitted matrix accelerates every gradient-capable driver.
Reference
The BAB propagator, stationary reseed per epoch, matrix_exp + ldl_sqrt construction of the drift, and the reduction to the canonical form appear in src/methods/gle_langevin.rs and the corresponding eindir GleThermostat / optimal_sampling_drift code. The “one drift serves all gradient drivers” claim is a direct consequence of the algebra (the GLE object occupies exactly the Move slot).
Prerequisites¶
Gradient of the objective required. Bounds.
pip install anneal
Step 1: Define obj + grad¶
import numpy as np
from anneal import gle_langevin
def rastrigin(x):
return 10.0 * len(x) + np.sum(x*x - 10.0 * np.cos(2.0 * np.pi * x))
def grad_rastrigin(x):
return 2.0 * x + 20.0 * np.pi * np.sin(2.0 * np.pi * x)
low = np.full(5, -5.0)
high = np.full(5, 5.0)
Step 2: Call gle_langevin (the exposed driver)¶
res = gle_langevin(rastrigin, grad_rastrigin, low, high,
max_fevals=4000, seed=11,
omega0=0.2, dt=0.2, n_epochs=40)
print("GLE best pos:", res["best_pos"])
print("GLE best val:", res["best_val"])
print("GLE evals:", res["n_evals"])
Expected on this separable ill-conditioned problem: the colored-noise version reaches lower values in the same budget than plain white-noise Langevin would, because the single fitted drift matrix equalizes efficiency across a decade of frequencies.
Step 3: The thermostat inside (what the algebra buys)¶
eindirbuilds theoptimal_sampling_driftmatrix A for the chosenomega0.The GLE move kernel (B-A-B splitting + exact matrix exponential; the propagator from the GLE literature) occupies the Move slot.
The same A works for any inner sampler that supplies a gradient (HMC variants, plain Langevin, custom methods).
No per-preset GLE code exists; the factoring guarantees it.
Stationary reseed per epoch keeps the auxiliary momenta consistent with the invariant measure even when the outer temperature schedule changes.
Why this works¶
White-noise Langevin critically damps only one frequency.
Real objectives have spectra spanning orders of magnitude (the classic “ill-conditioned” case).
The GLE drift matrix is the exact continuous-time solution that makes the integrated autocorrelation time flat from omega0 to ~100*=omega0=.
Because Move is the only slot that knows the proposal shape, swapping the white-noise proposal for the GLE proposal gives gradient drivers the same thermostat path.
See gle-mechanics (T4) for the matrix construction and the canonical-form derivation.