Add the assume_PSD flag in calls to cvxpy.quad_form #543
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.
Resolves an issue where
ArpackNoConvergence
errors were being raised by CVXPY when trying to optimize large portfolios. This error is raised when CVXPY checks if the given matrix is Positive Semi-Definite, callingscipy.sparse.linalg.eigsh
to determine if the min eigenvalue is negative, which uses Arnoldi Iteration. However, CVXPY relies on SciPy's defaultmaxiter
argument foreigsh
which is simply the matrix's dimension multiplied by 10 which can fail to converge when checking larger matrices.Since the covariance matrices being sent to CVXPY are already checked/corrected for PSD in
fix_nonpositive_semidefinite
, we can use theassume_PSD
flag when callingcp.quad_form
to prevent these errors from being raised.