@@ -1385,6 +1385,15 @@ void ClpModel::resize(int newNumberRows, int newNumberColumns)
1385
1385
maximumColumns_ = CoinMax (maximumColumns_, numberColumns_);
1386
1386
}
1387
1387
}
1388
+ // Makes sure matrix dimensions are at least model dimensions
1389
+ void ClpModel::synchronizeMatrix ()
1390
+ {
1391
+ if (matrix_) {
1392
+ int numberRows = CoinMax (numberRows_,matrix_->getNumRows ());
1393
+ int numberColumns = CoinMax (numberColumns_,matrix_->getNumCols ());
1394
+ matrix_->setDimensions (numberRows,numberColumns);
1395
+ }
1396
+ }
1388
1397
// Deletes rows
1389
1398
void ClpModel::deleteRows (int number, const int *which)
1390
1399
{
@@ -1811,6 +1820,7 @@ void ClpModel::addRows(int number, const double *rowLower,
1811
1820
matrix_->appendMatrix (number, 0 , rowStarts, columns, elements);
1812
1821
}
1813
1822
}
1823
+ synchronizeMatrix ();
1814
1824
}
1815
1825
// Add rows
1816
1826
void ClpModel::addRows (int number, const double *rowLower,
@@ -1843,6 +1853,7 @@ void ClpModel::addRows(int number, const double *rowLower,
1843
1853
delete[] newIndex;
1844
1854
delete[] newElements;
1845
1855
}
1856
+ synchronizeMatrix ();
1846
1857
}
1847
1858
#ifndef CLP_NO_VECTOR
1848
1859
void ClpModel::addRows (int number, const double *rowLower,
@@ -1896,6 +1907,7 @@ void ClpModel::addRows(int number, const double *rowLower,
1896
1907
if (lengthNames_) {
1897
1908
rowNames_.resize (numberRows_);
1898
1909
}
1910
+ synchronizeMatrix ();
1899
1911
}
1900
1912
#endif
1901
1913
#ifndef SLIM_CLP
@@ -2073,6 +2085,7 @@ int ClpModel::addRows(const CoinBuild &buildObject, bool tryPlusMinusOne, bool c
2073
2085
// make sure matrix correct size
2074
2086
matrix_->setDimensions (numberRows_, numberColumns_);
2075
2087
}
2088
+ synchronizeMatrix ();
2076
2089
return numberErrors;
2077
2090
}
2078
2091
#endif
@@ -2195,6 +2208,7 @@ int ClpModel::addRows(CoinModel &modelObject, bool tryPlusMinusOne, bool checkDu
2195
2208
<< numberErrors
2196
2209
<< CoinMessageEol;
2197
2210
}
2211
+ synchronizeMatrix ();
2198
2212
return numberErrors;
2199
2213
} else {
2200
2214
// not suitable for addRows
@@ -2286,6 +2300,7 @@ void ClpModel::addColumns(int number, const double *columnLower,
2286
2300
// Do even if elements NULL (to resize)
2287
2301
matrix_->appendMatrix (number, 1 , columnStarts, rows, elements);
2288
2302
}
2303
+ synchronizeMatrix ();
2289
2304
}
2290
2305
// Add columns
2291
2306
void ClpModel::addColumns (int number, const double *columnLower,
@@ -2319,6 +2334,7 @@ void ClpModel::addColumns(int number, const double *columnLower,
2319
2334
delete[] newIndex;
2320
2335
delete[] newElements;
2321
2336
}
2337
+ synchronizeMatrix ();
2322
2338
}
2323
2339
#ifndef CLP_NO_VECTOR
2324
2340
void ClpModel::addColumns (int number, const double *columnLower,
@@ -2383,6 +2399,7 @@ void ClpModel::addColumns(int number, const double *columnLower,
2383
2399
if (lengthNames_) {
2384
2400
columnNames_.resize (numberColumns_);
2385
2401
}
2402
+ synchronizeMatrix ();
2386
2403
}
2387
2404
#endif
2388
2405
#ifndef SLIM_CLP
@@ -2517,6 +2534,7 @@ int ClpModel::addColumns(const CoinBuild &buildObject, bool tryPlusMinusOne, boo
2517
2534
delete[] lower;
2518
2535
delete[] upper;
2519
2536
}
2537
+ synchronizeMatrix ();
2520
2538
return 0 ;
2521
2539
}
2522
2540
#endif
@@ -2632,6 +2650,7 @@ int ClpModel::addColumns(CoinModel &modelObject, bool tryPlusMinusOne, bool chec
2632
2650
<< numberErrors
2633
2651
<< CoinMessageEol;
2634
2652
}
2653
+ synchronizeMatrix ();
2635
2654
return numberErrors;
2636
2655
} else {
2637
2656
// not suitable for addColumns
0 commit comments