Changeset 2556


Ignore:
Timestamp:
Apr 26, 2019 12:05:31 PM (6 months ago)
Author:
forrest
Message:

make integer slacks continuous for heuristics

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcHeuristic.cpp

    r2543 r2556  
    578578    int options = clpSolver->getModelPtr()->moreSpecialOptions();
    579579    clpSolver->getModelPtr()->setMoreSpecialOptions(options | 64);
     580  }
     581  if (clpSolver) {
     582    // take out zero cost integers which will be integer anyway
     583    const double *rowLower = clpSolver->getRowLower();
     584    const double *rowUpper = clpSolver->getRowUpper();
     585    const double *objective = clpSolver->getObjCoefficients();
     586    int numberRows = clpSolver->getNumRows();
     587    const CoinPackedMatrix *matrixByRow = clpSolver->getMatrixByRow();
     588    const double *elementByRow = matrixByRow->getElements();
     589    const int *column = matrixByRow->getIndices();
     590    const CoinBigIndex *rowStart = matrixByRow->getVectorStarts();
     591    const int *rowLength = matrixByRow->getVectorLengths();
     592    const CoinPackedMatrix *matrixByColumn = clpSolver->getMatrixByCol();
     593    //const double * element = matrixByColumn->getElements();
     594    //const int *row = matrixByColumn->getIndices();
     595    //const CoinBigIndex *columnStart = matrixByColumn->getVectorStarts();
     596    const int *columnLength = matrixByColumn->getVectorLengths();
     597    for (int i = 0; i < numberRows; i++) {
     598      if (rowLower[i] != floor(rowLower[i]) ||
     599          rowUpper[i] != floor(rowUpper[i]))
     600        continue;
     601      int jColumn = -1;
     602      for (CoinBigIndex k = rowStart[i]; k < rowStart[i] + rowLength[i]; k++) {
     603        int iColumn = column[k];
     604        double value = elementByRow[k];
     605        if (!clpSolver->isInteger(iColumn) || floor(value) != value) {
     606          jColumn = -2;
     607          break;
     608        } else if (!objective[iColumn] && columnLength[iColumn] == 1) {
     609          jColumn = iColumn;
     610        }
     611      }
     612      if (jColumn>=0)
     613        clpSolver->setContinuous(jColumn);
     614    }
    580615  }
    581616#endif
     
    15051540                int i;
    15061541                for (i = 0; i < numberSOS; i++) {
     1542#ifndef NDEBUG
    15071543                  int type = setInfo[i].setType();
     1544#endif
    15081545                  int n = setInfo[i].numberEntries();
    15091546                  const int *which = setInfo[i].which();
Note: See TracChangeset for help on using the changeset viewer.