ENH: Add informative ValueError for LQMarkov DARE non-convergence when beta=1#831
ENH: Add informative ValueError for LQMarkov DARE non-convergence when beta=1#831HG-Cheng wants to merge 5 commits into
Conversation
|
Hello maintainers, I noticed the CI pipeline failed on the Looking closely at the logs, the failure is entirely isolated to Just leaving a note here for visibility. Looking forward to your review on the core changes! |
|
@HG-Cheng Thank you for the contribution! Do you know what is known to happen when beta > 1? (The current code does not prohibit |
|
@oyamad "Thanks for the review! |
|
@HG-Cheng Next question is: what is known to happen when beta = 1? For the instance in #508 (comment), it does not converge even with |
|
Hi @oyamad,Thanks for running that test! That actually makes perfect sense mathematically.If |
|
Hi @HG-Cheng — thanks so much for digging into this, and for the great back-and-forth with @oyamad in the thread! 🙌 The improved, context-aware message in There's one thing I think we should sort out before this is ready, though: the new construction-time guard is a bit too broad and would break valid uses of the plain The change adds this to both if beta >= 1.0:
raise ValueError("Discount factor beta cannot be greater than 1.")For
if (self.C != 0).any() and beta >= 1:
raise ValueError('beta must be strictly smaller than 1 if ' +
'T = None and C != 0.')So the new guard would make even The "β=1 diverges" reasoning holds specifically for the A possible path forward:
Two tiny nits in Thanks again for the contribution — this is close, and the diagnostic message is a real improvement! Let me know if anything's unclear. 😊 |
|
Thanks for the detailed feedback, @mmcky! I've updated the PR accordingly:
I also merged the latest upstream Thanks again! |
References
Addresses #508
Description
This PR improves the handling and diagnostics of
LQMarkovproblems aroundbeta = 1.Changes
beta = 1use cases in the plainLQclass.beta > 1when constructingLQMarkov.LQMarkov(beta=1)to reach the Riccati solver.max_iterandbeta == 1, raise a more informativeValueErrorexplaining that strict contraction is not guaranteed and that convergence may be very slow or fail to reach the requested tolerance.LQconstruction with the defaultbeta=1;LQMarkov(beta=1)construction;LQMarkov(beta>1);beta=1solver failure message.No changes are made to the Riccati iteration algorithm itself.
Validation
The changes were tested after merging the latest upstream
main:test_lqcontrol.py: 12 passedtest_matrix_eqn.py: 4 passedtest_lqnash.py: 2 passed