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

Copy link
Copy Markdown
Contributor

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.

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

1 participant