Skip to content

Support reading SDPA files with multiple LP blocks - #25

Open
f-fr wants to merge 2 commits into
scipopt:mainfrom
f-fr:sdpa-multi-lp
Open

Support reading SDPA files with multiple LP blocks#25
f-fr wants to merge 2 commits into
scipopt:mainfrom
f-fr:sdpa-multi-lp

Conversation

@f-fr

@f-fr f-fr commented Aug 30, 2026

Copy link
Copy Markdown

Some SDPA files (generated by other tools) may contain multiple LP blocks, but SCIP-SDP only allows for a single LP block. Converting such instances by merging the multiple blocks into a single block is tedious, so this change modifies the reader such that multiple blocks are supported.

The basic changes are as follows:

  1. two new fields blockoffsets and newblockidx are added to the data struct, idxlinconsblock is removed
  2. blockoffsets[b] contains the offset of LP-block b. This equals the sum of the sizes of all preceding LP blocks. An element at (row, col) of block b is then interpreted as (row + blockoffsets[b], col + blockoffsets[b]) of the single (merged) LP block.
  3. newblockidx[b] contains the new block index of each SDP block b. This equals the old index minus the number of the preceding LP blocks (formerly the index shift was implemented w.r.t. the single LP block, now there may be several LP blocks). For an LP block newblockidx[b] == -1 (this is how LP blocks are recognized).

Frank Fischer added 2 commits August 30, 2026 14:24
Multiple LP blocks (indicated by negative block sizes) are supported
by the SDPA file format but not the reader. This change modifies the
reader such that multiple LP blocks are read as if they were a single
block: each element "v b i j x" is interpreted as
"v b (i + blockoffsets[b]) (j + blockoffsets[b]) x" where
"blockoffsets[b]" is the sum of the block sizes of all preceding LP
blocks. This effectively reads LP blocks (i.e. diagonal block) as
one single diagonal block.
@pfetsch pfetsch mentioned this pull request Aug 31, 2026
@pfetsch

pfetsch commented Aug 31, 2026

Copy link
Copy Markdown
Member

Thank you. This is great!

Since I cannot write to this pull request, I created a copy #26 . There I added two tests for block indices outside of the range (in order to make the unit test readererrors pass. Moreover, I streamlined the code just a bit (directly allocate the block indices). Can you please have a look there?

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.

2 participants