Skip to content

FIX: raise instead of returning non-finite values when the Riccati iteration overflows - #990

Open
mayuriphad wants to merge 1 commit into
QuantEcon:mainfrom
mayuriphad:fix/riccati-nonfinite-raises
Open

mayuriphad wants to merge 1 commit into
QuantEcon:mainfrom
mayuriphad:fix/riccati-nonfinite-raises

Conversation

@mayuriphad

Copy link
Copy Markdown

Fixes #986

solve_discrete_riccati_system loops while error > tolerance. When the iterates overflow, error becomes nan, and nan > tolerance is False. The loop then exits as if it had converged and returns non-finite Ps. Callers such as LQMarkov.stationary_values fail later with SciPy's array must not contain infs or NaNs, and the solver's own failure message (with the beta >= 1 stabilizability hint) is never raised. The doubling solver solve_discrete_riccati, used by LQ and Kalman, exits the same way.

Both loops now raise the existing fail_msg as soon as the error is not finite. The check adds no arithmetic, so runs that converge are unchanged.

Tests:

  • Added test_solve_discrete_riccati_system_overflow_raises and test_solve_discrete_riccati_overflow_raises, both using the unstabilizable system x' = 2x, B = 0 from the issue. Both fail on main (no ValueError) and pass with this change.
  • test_matrix_eqn, test_lqcontrol, test_ricatti, test_kalman, test_robustlq and test_lqnash: 47 passed.

Note: #984 changes the update inside the system solver's loop but not its exit condition. The new check sits just after the error sum, so any conflict between the two PRs should be trivial.

…eration overflows (QuantEcon#986)

Signed-off-by: mayuriphad <mayuriphad656@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 18:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @mayuriphad!

QuantEcon welcomes AI-assisted contributions under its Code of AI Use. Every pull request carries one Assisted-by: line, and this one does not yet, so two quick things, please:

  1. Add one line to the description above: Assisted-by: <tool> (<model>) if AI tools meaningfully contributed (for example Assisted-by: Claude Code (Claude Fable 5.1)), or Assisted-by: none if they did not.
  2. Reply here to confirm that a human chose the task, read the result, and will answer review on it.

This comment is posted on every external pull request that arrives without the line, so it is not a flag on yours. Nothing is blocked; a maintainer reads the reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author-response Waiting on author response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: solve_discrete_riccati_system returns NaN instead of raising when the iteration overflows

3 participants