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 3 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 |
References
Fixes #508
Description
This PR addresses the cryptic
ValueError: Convergence failedissue when instantiatingLQMarkovwith a discount factorbeta = 1.0.Mathematical Context:
When
beta = 1.0, the Bellman operator for the discrete algebraic Riccati equation (DARE) loses its strict contraction mapping property. Consequently, the value function iteration transitions from exponential convergence to extremely slow, sublinear convergence.The Fix:
Instead of modifying the initial
Ps = np.eye(n)(which is necessary to ensure convergence to the stabilizing positive definite solution rather than a pseudo-solution), this PR implements a graceful degradation strategy.When
beta == 1.0and convergence fails withinmax_iter, the code now raises a highly informative context-awareValueError. It explains the mathematical limitation (loss of strict contraction) and explicitly guides the user to significantly increasemax_iter, saving hours of debugging time for future users.All existing unit tests in
test_lqcontrol.pycontinue to pass smoothly.