Skip to content

Stabilize LQE covariance symmetry checks - #1227

Open
marko1olo wants to merge 1 commit into
python-control:mainfrom
marko1olo:fix-dlqe-symmetrize-process-covariance
Open

Stabilize LQE covariance symmetry checks#1227
marko1olo wants to merge 1 commit into
python-control:mainfrom
marko1olo:fix-dlqe-symmetrize-process-covariance

Conversation

@marko1olo

@marko1olo marko1olo commented Jun 7, 2026

Copy link
Copy Markdown

Summary

Fixes #1174.

This makes the Riccati symmetry checks more robust and avoids false QN must be a symmetric matrix errors when lqe() / dlqe() form the projected process covariance G @ QN @ G.T.

Details

  • Replace the local floating-point symmetry check with SciPy's issymmetric / ishermitian using a small scale-aware tolerance.
  • Validate user-supplied QN as a symmetric covariance matrix before projection.
  • Symmetrize only the projected covariance G @ QN @ G.T, which is mathematically symmetric but can pick up roundoff-level asymmetry.
  • Add deterministic regressions for both lqe(..., method="scipy") and dlqe(..., method="scipy").
  • Add a guard test showing clearly asymmetric user QN is still rejected instead of silently repaired.

Local validation

  • Red proof: using the regression matrices without the projected-covariance symmetrization makes care() and dare() reject G @ QN @ G.T with ControlArgument: QN must be a symmetric matrix; the measured projected asymmetry was 4.44e-16.
  • python -m pytest -p no:cacheprovider control\tests\mateqn_test.py::TestMatrixEquations::test_symmetric_shape_check_tolerance -q
  • python -m pytest -p no:cacheprovider control\tests\stochsys_test.py::test_lqe_symmetrizes_projected_process_covariance control\tests\stochsys_test.py::test_dlqe_symmetrizes_projected_process_covariance control\tests\stochsys_test.py::test_lqe_rejects_user_supplied_asymmetric_covariance -q
  • python -m pytest -p no:cacheprovider control\tests\mateqn_test.py -q -> 11 passed, 13 skipped (slycot not installed)
  • python -m pytest -p no:cacheprovider control\tests\stochsys_test.py -q -> 29 passed, 2 skipped (slycot not installed)
  • python -m ruff check --no-cache control\mateqn.py control\stochsys.py control\tests\mateqn_test.py control\tests\stochsys_test.py
  • PYTHONPYCACHEPREFIX=C:\tmp\pycache-python-control-1174 python -m compileall -q control\mateqn.py control\stochsys.py control\tests\mateqn_test.py control\tests\stochsys_test.py
  • git diff --cached --check

AI-assisted contribution disclosure: implementation prepared with OpenAI Codex and reviewed/tested locally before submission.


AI Disclosure: Codex (ChatGPT 5.5) was used during code navigation, initial drafting, and PR text preparation. All logic, code changes, and test cases have been manually reviewed, verified, and tested locally by the author in accordance with the NumPy AI Policy.

@murrayrm

murrayrm commented Aug 9, 2026

Copy link
Copy Markdown
Member

@marko1olo Please rebase off of main to trigger updated CI checks from PR #1243.

@coveralls

coveralls commented Aug 13, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 94.76% (+0.003%) from 94.757% — marko1olo:fix-dlqe-symmetrize-process-covariance into python-control:main

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.

better symmetry check test

3 participants