Skip to content

Commit

Permalink
check matrix orientation - convert to col-ordered
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxies committed Sep 3, 2024
1 parent f5135aa commit fd58e7b
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/MibSModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,8 @@ MibSModel::loadProblemData(const CoinPackedMatrix& matrix,
int problemType(MibSPar_->entry(MibSParams::bilevelProblemType));

int i(0), j(0), k(0), start(0), end(0), beg(0);


bool matType = matrix.isColOrdered(); // YX: check input matrix orientation
int inputNumRows = matrix.getNumRows(); // YX: to diff from #eqConstrs
int numCols = matrix.getNumCols();

Expand All @@ -1097,6 +1098,13 @@ MibSModel::loadProblemData(const CoinPackedMatrix& matrix,
CoinPackedMatrix rowMatrix;
CoinPackedMatrix *newMatrix = NULL;
CoinPackedMatrix *matrix1 = NULL; // YX: w/ appended equality constrs

// YX: need col mat to start; cp to matrix1 if row-ordered
if(!matType){
matrix1 = new CoinPackedMatrix();
matrix1->copyOf(matrix);
matrix1->reverseOrdering();
}

// --- prepare for equality constraints (if any) ---

Expand Down Expand Up @@ -1155,12 +1163,17 @@ MibSModel::loadProblemData(const CoinPackedMatrix& matrix,

// YX: add rows to the problem matrix and link pointers to vectors
if(numRows > inputNumRows){
matrix1 = new CoinPackedMatrix();
matrix1->copyOf(matrix);
if(!matrix1){
matrix1 = new CoinPackedMatrix();
matrix1->copyOf(matrix);
}
matrix1->reverseOrdering();

rowMatrix = matrix;
rowMatrix.reverseOrdering();
// YX: switch if matrix was col ordered
if(matType){
rowMatrix.reverseOrdering();
}
const double * matElements = rowMatrix.getElements();
const int * matIndices = rowMatrix.getIndices();
const int * matStarts = rowMatrix.getVectorStarts();
Expand Down

0 comments on commit fd58e7b

Please sign in to comment.