From 8e2f3b49dbac352975b9bd846da5c5679a109764 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Tue, 23 Jul 2024 16:53:58 +0100 Subject: [PATCH] clean preprocessed model a bit more --- src/CglPreProcess/CglPreProcess.cpp | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/CglPreProcess/CglPreProcess.cpp b/src/CglPreProcess/CglPreProcess.cpp index 82ea633e..e59f6ae3 100644 --- a/src/CglPreProcess/CglPreProcess.cpp +++ b/src/CglPreProcess/CglPreProcess.cpp @@ -4317,6 +4317,61 @@ CglPreProcess::preProcessNonDefault(OsiSolverInterface &model, for ( int i=0 ; (igetNumCols()) ; i++ ) returnModel->setColName( i, model.getColName( originalColumns()[i] ) ); } + // clean model + if (returnModel) { + int numberRows = returnModel->getNumRows(); + int numberColumns = returnModel->getNumCols(); + CoinPackedMatrix matrixByRow(*returnModel->getMutableMatrixByRow()); + // clean rhs + double *elementByRow = matrixByRow.getMutableElements(); + const int *column = matrixByRow.getIndices(); + const CoinBigIndex *rowStart = matrixByRow.getVectorStarts(); + const int *rowLength = matrixByRow.getVectorLengths(); + + const double *rowLower = returnModel->getRowLower(); + const double *rowUpper = returnModel->getRowUpper(); + for (int iRow=0;iRowisInteger(column[j])) { + allInteger = false; + break; + } + double value = fabs(elementByRow[j]); + if (value-floor(value+0.5)>1.0e-13) { + allInteger = false; + break; + } + } + if (allInteger) { + double lower = rowLower[iRow]; + double upper = rowUpper[iRow]; + double lowerNew = lower; + double upperNew = upper; + if (lower>-1.0e15&&lower!=floor(lower+0.5)) { + if (fabs(lower-floor(lower+0.5))<1.0e-13) { + lowerNew = floor(lower+0.5); + } + } + if (upper<1.0e15&&upper!=floor(upper+0.5)) { + if (fabs(upper-floor(upper+0.5))<1.0e-13) { + upperNew = floor(upper+0.5); + } + } + if (lowerNew<=upperNew) { + if (lowerNew!=lower) + returnModel->setRowLower(iRow,lowerNew); + if (upperNew!=upper) + returnModel->setRowUpper(iRow,upperNew); + } else { + printf("LOOKS infeas\n"); + } + } + } + } + // end clean model delete [] scBound; return returnModel; }