Skip to content

Commit

Permalink
merge r2521 from trunk, but make synchronizeMatrix() private; see coi…
Browse files Browse the repository at this point in the history
  • Loading branch information
svigerske committed Feb 3, 2020
1 parent f9289ea commit 2ec5321
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Clp/src/ClpModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,15 @@ void ClpModel::resize(int newNumberRows, int newNumberColumns)
maximumColumns_ = CoinMax(maximumColumns_, numberColumns_);
}
}
// Makes sure matrix dimensions are at least model dimensions
void ClpModel::synchronizeMatrix()
{
if (matrix_) {
int numberRows = CoinMax(numberRows_,matrix_->getNumRows());
int numberColumns = CoinMax(numberColumns_,matrix_->getNumCols());
matrix_->setDimensions(numberRows,numberColumns);
}
}
// Deletes rows
void ClpModel::deleteRows(int number, const int *which)
{
Expand Down Expand Up @@ -1811,6 +1820,7 @@ void ClpModel::addRows(int number, const double *rowLower,
matrix_->appendMatrix(number, 0, rowStarts, columns, elements);
}
}
synchronizeMatrix();
}
// Add rows
void ClpModel::addRows(int number, const double *rowLower,
Expand Down Expand Up @@ -1843,6 +1853,7 @@ void ClpModel::addRows(int number, const double *rowLower,
delete[] newIndex;
delete[] newElements;
}
synchronizeMatrix();
}
#ifndef CLP_NO_VECTOR
void ClpModel::addRows(int number, const double *rowLower,
Expand Down Expand Up @@ -1896,6 +1907,7 @@ void ClpModel::addRows(int number, const double *rowLower,
if (lengthNames_) {
rowNames_.resize(numberRows_);
}
synchronizeMatrix();
}
#endif
#ifndef SLIM_CLP
Expand Down Expand Up @@ -2073,6 +2085,7 @@ int ClpModel::addRows(const CoinBuild &buildObject, bool tryPlusMinusOne, bool c
// make sure matrix correct size
matrix_->setDimensions(numberRows_, numberColumns_);
}
synchronizeMatrix();
return numberErrors;
}
#endif
Expand Down Expand Up @@ -2195,6 +2208,7 @@ int ClpModel::addRows(CoinModel &modelObject, bool tryPlusMinusOne, bool checkDu
<< numberErrors
<< CoinMessageEol;
}
synchronizeMatrix();
return numberErrors;
} else {
// not suitable for addRows
Expand Down Expand Up @@ -2286,6 +2300,7 @@ void ClpModel::addColumns(int number, const double *columnLower,
// Do even if elements NULL (to resize)
matrix_->appendMatrix(number, 1, columnStarts, rows, elements);
}
synchronizeMatrix();
}
// Add columns
void ClpModel::addColumns(int number, const double *columnLower,
Expand Down Expand Up @@ -2319,6 +2334,7 @@ void ClpModel::addColumns(int number, const double *columnLower,
delete[] newIndex;
delete[] newElements;
}
synchronizeMatrix();
}
#ifndef CLP_NO_VECTOR
void ClpModel::addColumns(int number, const double *columnLower,
Expand Down Expand Up @@ -2383,6 +2399,7 @@ void ClpModel::addColumns(int number, const double *columnLower,
if (lengthNames_) {
columnNames_.resize(numberColumns_);
}
synchronizeMatrix();
}
#endif
#ifndef SLIM_CLP
Expand Down Expand Up @@ -2517,6 +2534,7 @@ int ClpModel::addColumns(const CoinBuild &buildObject, bool tryPlusMinusOne, boo
delete[] lower;
delete[] upper;
}
synchronizeMatrix();
return 0;
}
#endif
Expand Down Expand Up @@ -2632,6 +2650,7 @@ int ClpModel::addColumns(CoinModel &modelObject, bool tryPlusMinusOne, bool chec
<< numberErrors
<< CoinMessageEol;
}
synchronizeMatrix();
return numberErrors;
} else {
// not suitable for addColumns
Expand Down
4 changes: 4 additions & 0 deletions Clp/src/ClpModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ class ClpModel {
bool isInteger(int index) const;
/// Resizes rim part of model
void resize(int newNumberRows, int newNumberColumns);
private:
/// Makes sure matrix dimensions are at least model dimensions
void synchronizeMatrix();
public:
/// Deletes rows
void deleteRows(int number, const int *which);
/// Add one row
Expand Down

0 comments on commit 2ec5321

Please sign in to comment.