chc.research.koopman¶
Stability tier: research.
Koopman dynamics + LQR: lift a nonlinear system to a global-linear one, then control it.
The Koopman idea: in a lifted feature space phi(x) the dynamics are approximately linear,
phi(x') ~ A phi(x) + B u. Fit A, B from transitions by least squares (EDMD); the nonlinear
system becomes linear, so control is a fast discrete LQR in the lifted space, not a
gradient-descent MPC. The LQR is exact for the linear surrogate, not for the plant: through a
nonlinear dictionary the input of even a control-affine plant can enter the lift with a
state-dependent gain, so a linear lift is misspecified there in general, and LQR or MPC on it
carries no closed-loop guarantee for the plant (Strässer et al. 2026, Annual Reviews in Control
61). This mirrors the CHC hybrid philosophy (a structured global model plus a correction); the
modern, Residual-Koopman-MPC-lineage control backend. The dictionary is polynomial in the state
less its centre, the midpoint of the states the fit read, and ends in a constant; the first
state_dim features are the centred state, so decoding is a slice and the centre added back.
KoopmanModel
dataclass
¶
Koopman model phi(x') ~ A phi(x) + B u fit by least squares on a polynomial lift.
ridge is the Tikhonov term on each coefficient, in units of its column's mean square, so
the fit reads the same in any units of the state and the action. Added as a constant, it
outweighed an action logged in millionths of its units and set B near zero.
form="bilinear" fits phi(x') ~ A phi(x) + B u + sum_j u_j H_j phi(x). In continuous
time a control-affine plant moves each feature of the lift by the action times a function of
the state, which the bilinear form carries (Strässer et al., Annual Reviews in Control 61,
2026). A fit reads one step, and there that property does not hold: a degree-k feature at
the next state, (f(x) + g(x) u)^k, holds u^2 to u^k, which neither form spans. On
x' = a x + b u with an action of unit variance, the x^2 feature's closure residual is
sqrt(1 - a^4) under the linear form and 1 - a^2 under the bilinear one
(validation/koopman_discrete_closure.mac), though both predict the next state exactly. In
one step the bilinear form carries the action's products with the lift, so it closes the state
of a plant bilinear in the state and the action, as x' = A x + b u + c x1 u, where the
linear form cannot. The default form="linear" fits as before, bit for bit.
fit reports closure_residuals: for each feature of the lift, the root mean square of
its one-step error on transitions held out of the fit, over the feature's spread about its
mean at the next state. The transitions are cut into five contiguous blocks, each predicted
by a model fit on the other four; the model kept is fit on all of them. A lift whose span the
dynamics map into itself reads 0 on noise-free data (ResDMD's residual, Colbrook and
Townsend, on the whole dictionary); one whose span they leave reads the share of each feature's
variation it does not predict. The ratio is read feature by feature, so it reads the same in
any units of the state and the action. Over the feature's root mean square instead, a level far
from zero would pass for prediction: a state read 273.15 higher, as in kelvin, takes the
degree-one lift of x' = 2x - x^3 + u/10 from 0.71, refused, to 0.0024, accepted. A feature
the log never moves has no spread, and is read over its root mean square. The first
state_dim residuals are the state's, which koopman_lqr_gain reads; the others say
which features the lift does not carry.
The lift is of the state less its centre, the midpoint of the logged states, and it holds a
constant. Without them a level was read as dynamics: the monomials of x + c span a
different space for every c, and none held the constant that an affine map of the state
needs. At degree 3 the same plant logged at levels 0, 1, 5 and 273.15 was refused, accepted,
refused and refused, and controllers accepted on a level diverged on the plant. Centred, the
model and its verdict read the same at every level, and with the constant the span of a
degree-d lift is every polynomial of degree d, which no shift of the state leaves.
koopman_lqr_gain(model, q_state, r, *, x_target=None, max_residual=0.5)
¶
Infinite-horizon discrete-LQR gain in the lifted space (state cost via the decode slice).
The gain is the lifted model's, and it is refused where the lift does not close on the state:
where a state's held-out closure residual, among the first state_dim of
closure_residuals, exceeds max_residual, or was not read. The default of 0.5 refuses a
lift that predicts less than three quarters of some state's variance on transitions it was not
fit on. The other features' residuals are not read: in one step a lift of degree 2 or more
does not close even on an exactly linear plant, whose next state it predicts exactly (see
KoopmanModel), and the controller lifts the measured state afresh at every step, so
the loop it closes moves by the state's one-step prediction. A feature that does not close
still enters the gain, which is solved on the whole lifted model: on a nonlinear plant the
gain is that model's LQR, not the plant's, and koopman_controller checks the loop the
controller closes. A bilinear model's channel depends on the state: its gain is the LQR of the
model linearised at x_target, which it then requires. A linear model's gain does not depend
on x_target.
The lift's constant moves with no action and costs nothing, so the LQR is solved on the other features and the constant's column of the gain is zero: the controller reads the lift's difference from the target's, where the constant cancels.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
before the model is fit. |
ValueError
|
where the lift does not close on the state, or a bilinear model is given no
|
koopman_controller(model, gain, x_target)
¶
Feedback law u = -G (phi(x) - phi(x_target)) regulating the system to x_target.
The law lifts the measured state afresh at every step, so the loop it closes is the model's
prediction re-lifted, not the lifted model, whose own loop the LQR makes stable whatever the
lift. Near the target that loop moves a deviation by J = [(A - B_t G) dphi/dx], the state's
rows, B_t the model's channel at the target; the law is refused where J's spectral
radius is not below 1, since then the loop leaves the target even in the model.
Raises:
| Type | Description |
|---|---|
ValueError
|
where the model's closed loop is not stable at |