@@ -1104,7 +1104,8 @@ MibSModel::loadProblemData(const CoinPackedMatrix& matrix,
1104
1104
int problemType (MibSPar_->entry (MibSParams::bilevelProblemType));
1105
1105
1106
1106
int i (0 ), j (0 ), k (0 ), start (0 ), end (0 ), beg (0 );
1107
-
1107
+
1108
+ bool matType = matrix.isColOrdered (); // YX: check input matrix orientation
1108
1109
int inputNumRows = matrix.getNumRows (); // YX: to diff from #eqConstrs
1109
1110
int numCols = matrix.getNumCols ();
1110
1111
@@ -1118,6 +1119,13 @@ MibSModel::loadProblemData(const CoinPackedMatrix& matrix,
1118
1119
CoinPackedMatrix rowMatrix;
1119
1120
CoinPackedMatrix *newMatrix = NULL ;
1120
1121
CoinPackedMatrix *matrix1 = NULL ; // YX: w/ appended equality constrs
1122
+
1123
+ // YX: need col mat to start; cp to matrix1 if row-ordered
1124
+ if (!matType){
1125
+ matrix1 = new CoinPackedMatrix ();
1126
+ matrix1->copyOf (matrix);
1127
+ matrix1->reverseOrdering ();
1128
+ }
1121
1129
1122
1130
// --- prepare for equality constraints (if any) ---
1123
1131
@@ -1176,12 +1184,17 @@ MibSModel::loadProblemData(const CoinPackedMatrix& matrix,
1176
1184
1177
1185
// YX: add rows to the problem matrix and link pointers to vectors
1178
1186
if (numRows > inputNumRows){
1179
- matrix1 = new CoinPackedMatrix ();
1180
- matrix1->copyOf (matrix);
1187
+ if (!matrix1){
1188
+ matrix1 = new CoinPackedMatrix ();
1189
+ matrix1->copyOf (matrix);
1190
+ }
1181
1191
matrix1->reverseOrdering ();
1182
1192
1183
1193
rowMatrix = matrix;
1184
- rowMatrix.reverseOrdering ();
1194
+ // YX: switch if matrix was col ordered
1195
+ if (matType){
1196
+ rowMatrix.reverseOrdering ();
1197
+ }
1185
1198
const double * matElements = rowMatrix.getElements ();
1186
1199
const int * matIndices = rowMatrix.getIndices ();
1187
1200
const int * matStarts = rowMatrix.getVectorStarts ();
0 commit comments