Skip to content

chc.lqr

Stability tier: stable.

LQR / AKOR: the r_θ→0 closed-form optimum and Riccati cross-checks.

For the linear(-ised) known system this is the analytic control optimum the learned controller must approach (a correctness limit). Maxima (exact symbolic) is the authority; scipy is the float64 numeric, cross-checked against PARI high-precision and Octave (see validation/).

linearize_continuous(dyn, x, u)

Jacobians (A, B) = (∂f/∂x, ∂f/∂u) of the continuous vector field at (x, u).

linearize_discrete(dyn, x, u, dt)

Jacobians (A_d, B_d) of one RK4 step at (x, u).

continuous_lqr(a, b, q, r)

Solve the continuous ARE; return (P, K) with the optimal feedback u = -K x.

finite_horizon_dlqr(a, b, q, r, qf, horizon)

Backward Riccati recursion for the finite-horizon discrete LQ problem.

Returns time-varying gains gains of shape (H, m, n) (u_k = -gains[k] x_k) and the initial cost-to-go P_0 (optimal cost 0.5 x0ᵀ P_0 x0).

dlqr_feedback_controls(dyn, x0, gains, dt)

Simulate u_k = -gains[k] x_k and return the realised control sequence (H, m).

linearized_regret_certificate(dyn, dyn_hat, x_star, u_star, q, r, x0, dt)

Local certainty-equivalence suboptimality certificate for a (non)linear plant.

Linearises the true dyn and estimated dyn_hat at (x_star, u_star) and returns the LQ certainty-equivalence regret bound (chc.regret.certainty_equivalence_gap) for that linearisation -- a local certificate valid where model error dominates the plant's curvature. Exact on a linear plant; empirically tracks the nonlinear closed-loop suboptimality to ~1.1x in the small-model-error regime. Extends the LQ guarantee of chc.regret to nonlinear plants, locally.