fix: the display_problem_details not support dense matrix error#22
Merged
ZedongPeng merged 1 commit intoMIT-Lu-Lab:mainfrom May 14, 2025
Merged
fix: the display_problem_details not support dense matrix error#22ZedongPeng merged 1 commit intoMIT-Lu-Lab:mainfrom
ZedongPeng merged 1 commit intoMIT-Lu-Lab:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates display_problem_details to correctly handle dense matrices and adds a test for solver behavior with dense constraint matrices.
- Add a new test
test_rapdhg_lp_with_jit_dense_matrixto cover dense‐matrix usage in the solver - Update
display_problem_detailsto branch on sparse vs. dense inputs and usejnp.count_nonzeroand value extraction for dense matrices
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/rapdhg_test.py | Added test_rapdhg_lp_with_jit_dense_matrix to run the solver with dense matrices |
| mpax/solver_log.py | Updated display_problem_details to support dense formats by checking instance type and using JAX operations |
Comments suppressed due to low confidence (2)
mpax/solver_log.py:213
- When handling dense matrices,
constraint_matrix_datacontains all elements (including zeros), so the computed min and avg statistics include zeros, which conflicts with the log header. To preserve 'nonzero' semantics, filter out zeros (e.g., usingjnp.nonzero(qp.constraint_matrix)) before computing these statistics.
jax_debug_log("Absolute value of nonzero constraint matrix elements:\n"
tests/rapdhg_test.py:78
- This new test runs the solver with dense matrices but doesn’t verify that
display_problem_detailslogs the correct statistics for dense inputs. Consider capturing the logger output or adding assertions on log content to ensure the display function behaves as expected.
result = solver.optimize(qp)
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.
Fixes #13
The
display_problem_detailsfunction previously did not support dense matrix format since it usedmatrix.data, which only exists inBCOOorBSCR.