Skip to content

Commit 2ec5321

Browse files
committed
merge r2521 from trunk, but make synchronizeMatrix() private; see #113
1 parent f9289ea commit 2ec5321

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Clp/src/ClpModel.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,15 @@ void ClpModel::resize(int newNumberRows, int newNumberColumns)
13851385
maximumColumns_ = CoinMax(maximumColumns_, numberColumns_);
13861386
}
13871387
}
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+
}
13881397
// Deletes rows
13891398
void ClpModel::deleteRows(int number, const int *which)
13901399
{
@@ -1811,6 +1820,7 @@ void ClpModel::addRows(int number, const double *rowLower,
18111820
matrix_->appendMatrix(number, 0, rowStarts, columns, elements);
18121821
}
18131822
}
1823+
synchronizeMatrix();
18141824
}
18151825
// Add rows
18161826
void ClpModel::addRows(int number, const double *rowLower,
@@ -1843,6 +1853,7 @@ void ClpModel::addRows(int number, const double *rowLower,
18431853
delete[] newIndex;
18441854
delete[] newElements;
18451855
}
1856+
synchronizeMatrix();
18461857
}
18471858
#ifndef CLP_NO_VECTOR
18481859
void ClpModel::addRows(int number, const double *rowLower,
@@ -1896,6 +1907,7 @@ void ClpModel::addRows(int number, const double *rowLower,
18961907
if (lengthNames_) {
18971908
rowNames_.resize(numberRows_);
18981909
}
1910+
synchronizeMatrix();
18991911
}
19001912
#endif
19011913
#ifndef SLIM_CLP
@@ -2073,6 +2085,7 @@ int ClpModel::addRows(const CoinBuild &buildObject, bool tryPlusMinusOne, bool c
20732085
// make sure matrix correct size
20742086
matrix_->setDimensions(numberRows_, numberColumns_);
20752087
}
2088+
synchronizeMatrix();
20762089
return numberErrors;
20772090
}
20782091
#endif
@@ -2195,6 +2208,7 @@ int ClpModel::addRows(CoinModel &modelObject, bool tryPlusMinusOne, bool checkDu
21952208
<< numberErrors
21962209
<< CoinMessageEol;
21972210
}
2211+
synchronizeMatrix();
21982212
return numberErrors;
21992213
} else {
22002214
// not suitable for addRows
@@ -2286,6 +2300,7 @@ void ClpModel::addColumns(int number, const double *columnLower,
22862300
// Do even if elements NULL (to resize)
22872301
matrix_->appendMatrix(number, 1, columnStarts, rows, elements);
22882302
}
2303+
synchronizeMatrix();
22892304
}
22902305
// Add columns
22912306
void ClpModel::addColumns(int number, const double *columnLower,
@@ -2319,6 +2334,7 @@ void ClpModel::addColumns(int number, const double *columnLower,
23192334
delete[] newIndex;
23202335
delete[] newElements;
23212336
}
2337+
synchronizeMatrix();
23222338
}
23232339
#ifndef CLP_NO_VECTOR
23242340
void ClpModel::addColumns(int number, const double *columnLower,
@@ -2383,6 +2399,7 @@ void ClpModel::addColumns(int number, const double *columnLower,
23832399
if (lengthNames_) {
23842400
columnNames_.resize(numberColumns_);
23852401
}
2402+
synchronizeMatrix();
23862403
}
23872404
#endif
23882405
#ifndef SLIM_CLP
@@ -2517,6 +2534,7 @@ int ClpModel::addColumns(const CoinBuild &buildObject, bool tryPlusMinusOne, boo
25172534
delete[] lower;
25182535
delete[] upper;
25192536
}
2537+
synchronizeMatrix();
25202538
return 0;
25212539
}
25222540
#endif
@@ -2632,6 +2650,7 @@ int ClpModel::addColumns(CoinModel &modelObject, bool tryPlusMinusOne, bool chec
26322650
<< numberErrors
26332651
<< CoinMessageEol;
26342652
}
2653+
synchronizeMatrix();
26352654
return numberErrors;
26362655
} else {
26372656
// not suitable for addColumns

Clp/src/ClpModel.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ class ClpModel {
140140
bool isInteger(int index) const;
141141
/// Resizes rim part of model
142142
void resize(int newNumberRows, int newNumberColumns);
143+
private:
144+
/// Makes sure matrix dimensions are at least model dimensions
145+
void synchronizeMatrix();
146+
public:
143147
/// Deletes rows
144148
void deleteRows(int number, const int *which);
145149
/// Add one row

0 commit comments

Comments
 (0)