Skip to content

Conversation

@ZedongPeng
Copy link
Collaborator

Fixes #13

The display_problem_details function previously did not support dense matrix format since it used matrix.data, which only exists in BCOO or BSCR.

@ZedongPeng ZedongPeng requested a review from Copilot May 14, 2025 21:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_matrix to cover dense‐matrix usage in the solver
  • Update display_problem_details to branch on sparse vs. dense inputs and use jnp.count_nonzero and 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_data contains 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., using jnp.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_details logs 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)

@ZedongPeng ZedongPeng merged commit 62a5dc0 into MIT-Lu-Lab:main May 14, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting Verbose=True in r2HPDHG initialization causes error in mpax.solver_log.display_problem_details

1 participant