Skip to content

Document and test LQR state-input cross terms - #1099

Open
dongxuelian2 wants to merge 1 commit into
JuliaControl:masterfrom
dongxuelian2:codex/lqr-cross-term
Open

dongxuelian2 wants to merge 1 commit into
JuliaControl:masterfrom
dongxuelian2:codex/lqr-cross-term

Conversation

@dongxuelian2

Copy link
Copy Markdown
Contributor

Closes #1098.

lqr(..., Q, R, N) already passes the cross term to MatrixEquations.arec / ared as their positional S argument. Make this existing interface explicit for both matrix and state-space inputs, document the cost and dimensions, and give executable continuous/discrete examples. The positional API and solver implementation are unchanged.

Document the completion-of-squares relation F = R \ N', Abar = A - B*F, Qbar = Q - N*F, K = Kbar + F, together with the different continuous/discrete gain formulas and the standard LQR assumptions.

Add regression tests for generalized CARE/DARE residuals, analytic scalar solutions, completion of squares, closed-loop stability, complex data, Float32, vector inputs, structured/view/static/sparse cross terms, dimension errors, semidefinite transformed costs, zero N, input immutability, solver keyword forwarding, and extra=Val(true) outputs.

Validation on Windows x64:

  • Julia 1.10.12 with MatrixEquations 1.5.0 / MatrixPencils 1.8.3: all 166 focused checks pass.
  • Julia 1.13.2 with MatrixEquations 2.7.0: all 166 focused checks and the new docstring doctest pass.
  • 216 additional real/complex numerical systems pass independent generalized Riccati, completion-of-squares, closed-loop Lyapunov, and discrete accumulated-cost checks (1,408 assertions).
  • Julia 1.10.12, GROUP=ControlSystems / Pkg.test(): all 1,156 tests pass.
  • Julia 1.13.2, Pkg.test("ControlSystemsBase"): full suite passes (7,384 passed, 6 expected broken).

The Julia 1.10.12 Base run hits an existing allocation ceiling in test_freqresp.jl:69 (about 123.5 kB allocated versus a 68.0 kB limit). The same test fails on unmodified upstream 3035fbdf with the same dependencies and test settings; its other 414 frequency-response checks pass. This PR leaves that unrelated test unchanged.

@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.29%. Comparing base (3035fbd) to head (60def61).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1099   +/-   ##
=======================================
  Coverage   92.29%   92.29%           
=======================================
  Files          42       42           
  Lines        6177     6177           
=======================================
  Hits         5701     5701           
  Misses        476      476           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cross-term argument to LQR function

1 participant