Stabilize LQE covariance symmetry checks#1227
Open
marko1olo wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1174.
This makes the Riccati symmetry checks more robust and avoids false
QN must be a symmetric matrixerrors whenlqe()/dlqe()form the projected process covarianceG @ QN @ G.T.Details
issymmetric/ishermitianusing a small scale-aware tolerance.QNas a symmetric covariance matrix before projection.G @ QN @ G.T, which is mathematically symmetric but can pick up roundoff-level asymmetry.lqe(..., method="scipy")anddlqe(..., method="scipy").QNis still rejected instead of silently repaired.Local validation
care()anddare()rejectG @ QN @ G.TwithControlArgument: QN must be a symmetric matrix; the measured projected asymmetry was4.44e-16.python -m pytest -p no:cacheprovider control\tests\mateqn_test.py::TestMatrixEquations::test_symmetric_shape_check_tolerance -qpython -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 -qpython -m pytest -p no:cacheprovider control\tests\mateqn_test.py -q-> 11 passed, 13 skipped (slycotnot installed)python -m pytest -p no:cacheprovider control\tests\stochsys_test.py -q-> 29 passed, 2 skipped (slycotnot installed)python -m ruff check --no-cache control\mateqn.py control\stochsys.py control\tests\mateqn_test.py control\tests\stochsys_test.pyPYTHONPYCACHEPREFIX=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.pygit diff --cached --checkAI-assisted contribution disclosure: implementation prepared with OpenAI Codex and reviewed/tested locally before submission.