-
Notifications
You must be signed in to change notification settings - Fork 199
fix(socp): canonicalize QC Q COO for rotated SOC detection #1439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yuwenchen95
wants to merge
11
commits into
NVIDIA:main
Choose a base branch
from
yuwenchen95:fix-qcqp-canonical-coo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7063060
fix(socp): canonicalize QC Q COO for rotated SOC detection (#1435)
yuwenchen95 5f0e06b
clarify require_symmetric_* for MPS symmetric-half input only, and tr…
yuwenchen95 9ff9b03
refactor(io): simplify QC COO canonicalization API and merge rules
yuwenchen95 b555adf
drop unused symmetric flag from canonicalize_quadratic_constraints
yuwenchen95 334bbb7
Move COO canonicalization into mps_parser; split QCMATRIX validation …
yuwenchen95 aa69c54
Add a python test to the problem in Issue 1435
yuwenchen95 3829701
Align the grpc data generation to the change of triplet form of quadr…
yuwenchen95 b9d16a3
Polish comment and tests
yuwenchen95 f15eac8
Replace the unordered_map-based QCMATRIX symmetry check and COO canon…
yuwenchen95 3912c48
Merge branch 'main' into fix-qcqp-canonical-coo
yuwenchen95 a516ff6
Update the guard of dimension for fast check of rotated socs and adju…
yuwenchen95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,7 +239,9 @@ class mps_data_model_t { | |
| * - row identity and type (from ROWS), | ||
| * - sparse linear coefficients (from COLUMNS), | ||
| * - RHS value (from RHS), | ||
| * - quadratic matrix Q in COO (SoA: row, col, value) from QCMATRIX — one triplet per nonzero. | ||
| * - quadratic matrix Q in canonical COO (SoA: row, col, value): one triplet per variable pair, | ||
| * sorted by (row, col). Off-diagonal cross terms store the full coefficient on x_i*x_j | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: do these need to be sorted?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We conduct sorting for efficient merging duplicates later. |
||
| * (e.g. -2*d for rotated SOC), not as symmetric halves. | ||
| */ | ||
| struct quadratic_constraint_t { | ||
| /** ROWS declaration index (among all constraint rows), not an index into the linear CSR. */ | ||
|
|
@@ -251,7 +253,7 @@ class mps_data_model_t { | |
| std::vector<f_t> linear_values{}; | ||
| std::vector<i_t> linear_indices{}; | ||
| f_t rhs_value{f_t(0)}; | ||
| /** Q nonzeros: parallel arrays, same length (COO / SoA). Sorted by (row, col) in append. */ | ||
|
|
||
| std::vector<i_t> rows{}; | ||
| std::vector<i_t> cols{}; | ||
| std::vector<f_t> vals{}; | ||
|
|
@@ -262,7 +264,8 @@ class mps_data_model_t { | |
| * @note All span inputs are host memory; the model copies this data. | ||
| * @param linear_values, linear_indices Same nnz; can be empty for a purely quadratic row (rare). | ||
| * @param vals, rows, cols COO triplets for Q; same length; may all be empty if Q is empty. | ||
| * Stored sorted by (row, col). | ||
| * Canonicalized on ingest to one triplet per variable pair (full x^T Q x coefficient), | ||
| * stored in upper-triangular (min row, max col) form. | ||
| * @param constraint_row_type MPS ROWS type: 'L' (<=) or 'G' (>=). Stored as given; 'G' rows are | ||
| * converted to '<=' form when building the SOCP for the barrier solver. Equality ('E') is | ||
| * not supported. | ||
|
|
@@ -385,4 +388,17 @@ class mps_data_model_t { | |
|
|
||
| }; // class mps_data_model_t | ||
|
|
||
| /** | ||
| * @brief Canonicalize each quadratic constraint's Q matrix. | ||
| * | ||
| * Merge duplicate COO entries and off-diagonal variable pairs, then store Q in | ||
| * upper-triangular form with one coefficient per variable pair (the full x^T Q x | ||
| * contribution for that pair). | ||
| * | ||
| * @param constraints Quadratic constraints whose rows, cols, and vals are updated. | ||
| */ | ||
| template <typename i_t, typename f_t> | ||
| void canonicalize_quadratic_constraints( | ||
| std::vector<typename mps_data_model_t<i_t, f_t>::quadratic_constraint_t>& constraints); | ||
|
|
||
| } // namespace cuopt::linear_programming::io | ||
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.